notro-loader 0.0.1 → 0.0.2

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.
@@ -1,837 +1,837 @@
1
- import { z } from "zod";
2
-
3
- const emojiRequestSchema = z.string();
4
- const timeZoneRequestSchema = z.string();
5
-
6
- const idRequestSchema = z.string();
7
-
8
- const personUserObjectResponseSchema = z.object({
9
- type: z.literal("person"),
10
- person: z.object({
11
- email: z.string().optional(),
12
- }),
13
- name: z.string().nullable(),
14
- avatar_url: z.string().nullable(),
15
- id: idRequestSchema,
16
- object: z.literal("user"),
17
- });
18
-
19
- const emptyObjectSchema = z.record(z.never());
20
-
21
- const partialUserObjectResponseSchema = z.object({
22
- id: idRequestSchema,
23
- object: z.literal("user"),
24
- });
25
-
26
- const botUserObjectResponseSchema = z.object({
27
- type: z.literal("bot"),
28
- bot: z.union([
29
- emptyObjectSchema,
30
- z.object({
31
- owner: z.union([
32
- z.object({
33
- type: z.literal("user"),
34
- user: z.union([
35
- z.object({
36
- type: z.literal("person"),
37
- person: z.object({
38
- email: z.string(),
39
- }),
40
- name: z.string().nullable(),
41
- avatar_url: z.string().nullable(),
42
- id: idRequestSchema,
43
- object: z.literal("user"),
44
- }),
45
- partialUserObjectResponseSchema,
46
- ]),
47
- }),
48
- z.object({
49
- type: z.literal("workspace"),
50
- workspace: z.literal(true),
51
- }),
52
- ]),
53
- workspace_name: z.string().nullable(),
54
- }),
55
- ]),
56
- name: z.string().nullable(),
57
- avatar_url: z.string().nullable(),
58
- id: idRequestSchema,
59
- object: z.literal("user"),
60
- });
61
-
62
- const userObjectResponseSchema = z.union([
63
- personUserObjectResponseSchema,
64
- botUserObjectResponseSchema,
65
- ]);
66
-
67
- const selectColorSchema = z.union([
68
- z.literal("default"),
69
- z.literal("gray"),
70
- z.literal("brown"),
71
- z.literal("orange"),
72
- z.literal("yellow"),
73
- z.literal("green"),
74
- z.literal("blue"),
75
- z.literal("purple"),
76
- z.literal("pink"),
77
- z.literal("red"),
78
- ]);
79
-
80
- const partialSelectResponseSchema = z.object({
81
- id: z.string(),
82
- name: z.string(),
83
- color: selectColorSchema,
84
- });
85
-
86
- const dateResponseSchema = z.object({
87
- start: z.string(),
88
- end: z.string().nullable(),
89
- time_zone: timeZoneRequestSchema.nullable(),
90
- });
91
-
92
- const stringRequestSchema = z.string();
93
-
94
- const textRequestSchema = z.string();
95
-
96
- const stringFormulaPropertyResponseSchema = z.object({
97
- type: z.literal("string"),
98
- string: z.string().nullable(),
99
- });
100
-
101
- const dateFormulaPropertyResponseSchema = z.object({
102
- type: z.literal("date"),
103
- date: dateResponseSchema.nullable(),
104
- });
105
-
106
- const numberFormulaPropertyResponseSchema = z.object({
107
- type: z.literal("number"),
108
- number: z.number().nullable(),
109
- });
110
-
111
- const booleanFormulaPropertyResponseSchema = z.object({
112
- type: z.literal("boolean"),
113
- boolean: z.boolean().nullable(),
114
- });
115
-
116
- const formulaPropertyResponseSchema = z.union([
117
- stringFormulaPropertyResponseSchema,
118
- dateFormulaPropertyResponseSchema,
119
- numberFormulaPropertyResponseSchema,
120
- booleanFormulaPropertyResponseSchema,
121
- ]);
122
-
123
- const verificationPropertyUnverifiedResponseSchema = z.object({
124
- state: z.literal("unverified"),
125
- date: z.null(),
126
- verified_by: z.null(),
127
- });
128
-
129
- const verificationPropertyResponseSchema = z.object({
130
- state: z.union([z.literal("verified"), z.literal("expired")]),
131
- date: dateResponseSchema.nullable(),
132
- verified_by: z
133
- .union([
134
- z.object({
135
- id: idRequestSchema,
136
- }),
137
- z.object({
138
- person: z.object({
139
- email: z.string().optional(),
140
- }),
141
- id: idRequestSchema,
142
- type: z.literal("person").optional(),
143
- name: z.string().optional().nullable(),
144
- avatar_url: z.string().optional().nullable(),
145
- object: z.literal("user").optional(),
146
- }),
147
- z.object({
148
- bot: z.union([
149
- emptyObjectSchema,
150
- z.object({
151
- owner: z.union([
152
- z.object({
153
- type: z.literal("user"),
154
- user: z.union([
155
- z.object({
156
- type: z.literal("person"),
157
- person: z.object({
158
- email: z.string(),
159
- }),
160
- name: z.string().nullable(),
161
- avatar_url: z.string().nullable(),
162
- id: idRequestSchema,
163
- object: z.literal("user"),
164
- }),
165
- partialUserObjectResponseSchema,
166
- ]),
167
- }),
168
- z.object({
169
- type: z.literal("workspace"),
170
- workspace: z.literal(true),
171
- }),
172
- ]),
173
- workspace_name: z.string().nullable(),
174
- }),
175
- ]),
176
- id: idRequestSchema,
177
- type: z.literal("bot").optional(),
178
- name: z.string().optional().nullable(),
179
- avatar_url: z.string().optional().nullable(),
180
- object: z.literal("user").optional(),
181
- }),
182
- ])
183
- .nullable(),
184
- });
185
-
186
- const annotationResponseSchema = z.object({
187
- bold: z.boolean(),
188
- italic: z.boolean(),
189
- strikethrough: z.boolean(),
190
- underline: z.boolean(),
191
- code: z.boolean(),
192
- color: z.union([
193
- z.literal("default"),
194
- z.literal("gray"),
195
- z.literal("brown"),
196
- z.literal("orange"),
197
- z.literal("yellow"),
198
- z.literal("green"),
199
- z.literal("blue"),
200
- z.literal("purple"),
201
- z.literal("pink"),
202
- z.literal("red"),
203
- z.literal("default_background"),
204
- z.literal("gray_background"),
205
- z.literal("brown_background"),
206
- z.literal("orange_background"),
207
- z.literal("yellow_background"),
208
- z.literal("green_background"),
209
- z.literal("blue_background"),
210
- z.literal("purple_background"),
211
- z.literal("pink_background"),
212
- z.literal("red_background"),
213
- ]),
214
- });
215
-
216
- const textRichTextItemResponseSchema = z.object({
217
- type: z.literal("text"),
218
- text: z.object({
219
- content: z.string(),
220
- link: z
221
- .object({
222
- url: textRequestSchema,
223
- })
224
- .nullable(),
225
- }),
226
- annotations: annotationResponseSchema,
227
- plain_text: z.string(),
228
- href: z.string().nullable(),
229
- });
230
-
231
- const linkPreviewMentionResponseSchema = z.object({
232
- url: textRequestSchema,
233
- });
234
-
235
- const linkMentionResponseSchema = z.object({
236
- href: z.string(),
237
- });
238
-
239
- const templateMentionDateTemplateMentionResponseSchema = z.object({
240
- type: z.literal("template_mention_date"),
241
- template_mention_date: z.union([z.literal("today"), z.literal("now")]),
242
- });
243
-
244
- const templateMentionUserTemplateMentionResponseSchema = z.object({
245
- type: z.literal("template_mention_user"),
246
- template_mention_user: z.literal("me"),
247
- });
248
-
249
- const templateMentionResponseSchema = z.union([
250
- templateMentionDateTemplateMentionResponseSchema,
251
- templateMentionUserTemplateMentionResponseSchema,
252
- ]);
253
-
254
- const customEmojiResponseSchema = z.object({
255
- id: idRequestSchema,
256
- name: z.string(),
257
- url: z.string(),
258
- });
259
-
260
- const mentionRichTextItemResponseSchema = z.object({
261
- type: z.literal("mention"),
262
- mention: z.union([
263
- z.object({
264
- type: z.literal("user"),
265
- user: z.union([
266
- partialUserObjectResponseSchema,
267
- userObjectResponseSchema,
268
- ]),
269
- }),
270
- z.object({
271
- type: z.literal("date"),
272
- date: dateResponseSchema,
273
- }),
274
- z.object({
275
- type: z.literal("link_preview"),
276
- link_preview: linkPreviewMentionResponseSchema,
277
- }),
278
- z.object({
279
- type: z.literal("link_mention"),
280
- link_mention: linkMentionResponseSchema,
281
- }),
282
- z.object({
283
- type: z.literal("template_mention"),
284
- template_mention: templateMentionResponseSchema,
285
- }),
286
- z.object({
287
- type: z.literal("page"),
288
- page: z.object({
289
- id: idRequestSchema,
290
- }),
291
- }),
292
- z.object({
293
- type: z.literal("database"),
294
- database: z.object({
295
- id: idRequestSchema,
296
- }),
297
- }),
298
- z.object({
299
- type: z.literal("custom_emoji"),
300
- custom_emoji: customEmojiResponseSchema,
301
- }),
302
- ]),
303
- annotations: annotationResponseSchema,
304
- plain_text: z.string(),
305
- href: z.string().nullable(),
306
- });
307
-
308
- const equationRichTextItemResponseSchema = z.object({
309
- type: z.literal("equation"),
310
- equation: z.object({
311
- expression: textRequestSchema,
312
- }),
313
- annotations: annotationResponseSchema,
314
- plain_text: z.string(),
315
- href: z.string().nullable(),
316
- });
317
-
318
- const richTextItemResponseSchema = z.union([
319
- textRichTextItemResponseSchema,
320
- mentionRichTextItemResponseSchema,
321
- equationRichTextItemResponseSchema,
322
- ]);
323
-
324
- const rollupFunctionSchema = z.union([
325
- z.literal("count"),
326
- z.literal("count_values"),
327
- z.literal("empty"),
328
- z.literal("not_empty"),
329
- z.literal("unique"),
330
- z.literal("show_unique"),
331
- z.literal("percent_empty"),
332
- z.literal("percent_not_empty"),
333
- z.literal("sum"),
334
- z.literal("average"),
335
- z.literal("median"),
336
- z.literal("min"),
337
- z.literal("max"),
338
- z.literal("range"),
339
- z.literal("earliest_date"),
340
- z.literal("latest_date"),
341
- z.literal("date_range"),
342
- z.literal("checked"),
343
- z.literal("unchecked"),
344
- z.literal("percent_checked"),
345
- z.literal("percent_unchecked"),
346
- z.literal("count_per_group"),
347
- z.literal("percent_per_group"),
348
- z.literal("show_original"),
349
- ]);
350
-
351
- export const numberPropertyPageObjectResponseSchema = z.object({
352
- type: z.literal("number"),
353
- number: z.number().nullable(),
354
- id: z.string(),
355
- });
356
-
357
- export const urlPropertyPageObjectResponseSchema = z.object({
358
- type: z.literal("url"),
359
- url: z.string().nullable(),
360
- id: z.string(),
361
- });
362
-
363
- export const selectPropertyPageObjectResponseSchema = z.object({
364
- type: z.literal("select"),
365
- select: partialSelectResponseSchema.nullable(),
366
- id: z.string(),
367
- });
368
-
369
- export const multiSelectPropertyPageObjectResponseSchema = z.object({
370
- type: z.literal("multi_select"),
371
- multi_select: z.array(partialSelectResponseSchema),
372
- id: z.string(),
373
- });
374
-
375
- export const statusPropertyPageObjectResponseSchema = z.object({
376
- type: z.literal("status"),
377
- status: partialSelectResponseSchema.nullable(),
378
- id: z.string(),
379
- });
380
-
381
- export const datePropertyPageObjectResponseSchema = z.object({
382
- type: z.literal("date"),
383
- date: dateResponseSchema.nullable(),
384
- id: z.string(),
385
- });
386
-
387
- export const emailPropertyPageObjectResponseSchema = z.object({
388
- type: z.literal("email"),
389
- email: z.string().nullable(),
390
- id: z.string(),
391
- });
392
-
393
- export const phoneNumberPropertyPageObjectResponseSchema = z.object({
394
- type: z.literal("phone_number"),
395
- phone_number: z.string().nullable(),
396
- id: z.string(),
397
- });
398
-
399
- export const checkboxPropertyPageObjectResponseSchema = z.object({
400
- type: z.literal("checkbox"),
401
- checkbox: z.boolean(),
402
- id: z.string(),
403
- });
404
-
405
- export const filesPropertyPageObjectResponseSchema = z.object({
406
- type: z.literal("files"),
407
- files: z.array(
408
- z.union([
409
- z.object({
410
- file: z.object({
411
- url: z.string(),
412
- expiry_time: z.string(),
413
- }),
414
- name: stringRequestSchema,
415
- type: z.literal("file").optional(),
416
- }),
417
- z.object({
418
- external: z.object({
419
- url: textRequestSchema,
420
- }),
421
- name: stringRequestSchema,
422
- type: z.literal("external").optional(),
423
- }),
424
- ]),
425
- ),
426
- id: z.string(),
427
- });
428
-
429
- export const createdByPropertyPageObjectResponseSchema = z.object({
430
- type: z.literal("created_by"),
431
- created_by: z.union([
432
- partialUserObjectResponseSchema,
433
- userObjectResponseSchema,
434
- ]),
435
- id: z.string(),
436
- });
437
-
438
- export const createdTimePropertyPageObjectResponseSchema = z.object({
439
- type: z.literal("created_time"),
440
- created_time: z.string(),
441
- id: z.string(),
442
- });
443
-
444
- export const lastEditedByPropertyPageObjectResponseSchema = z.object({
445
- type: z.literal("last_edited_by"),
446
- last_edited_by: z.union([
447
- partialUserObjectResponseSchema,
448
- userObjectResponseSchema,
449
- ]),
450
- id: z.string(),
451
- });
452
-
453
- export const lastEditedTimePropertyPageObjectResponseSchema = z.object({
454
- type: z.literal("last_edited_time"),
455
- last_edited_time: z.string(),
456
- id: z.string(),
457
- });
458
-
459
- export const formulaPropertyPageObjectResponseSchema = z.object({
460
- type: z.literal("formula"),
461
- formula: formulaPropertyResponseSchema,
462
- id: z.string(),
463
- });
464
-
465
- export const buttonPropertyPageObjectResponseSchema = z.object({
466
- type: z.literal("button"),
467
- button: z.record(z.never()),
468
- id: z.string(),
469
- });
470
-
471
- export const uniqueIdPropertyPageObjectResponseSchema = z.object({
472
- type: z.literal("unique_id"),
473
- unique_id: z.object({
474
- prefix: z.string().nullable(),
475
- number: z.number().nullable(),
476
- }),
477
- id: z.string(),
478
- });
479
-
480
- export const verificationPropertyPageObjectResponseSchema = z.object({
481
- type: z.literal("verification"),
482
- verification: z
483
- .union([
484
- verificationPropertyUnverifiedResponseSchema,
485
- verificationPropertyResponseSchema,
486
- ])
487
- .nullable(),
488
- id: z.string(),
489
- });
490
-
491
- export const titlePropertyPageObjectResponseSchema = z.object({
492
- type: z.literal("title"),
493
- title: z.array(textRichTextItemResponseSchema),
494
- id: z.string(),
495
- });
496
-
497
- export const richTextPropertyPageObjectResponseSchema = z.object({
498
- type: z.literal("rich_text"),
499
- rich_text: z.array(textRichTextItemResponseSchema),
500
- id: z.string(),
501
- });
502
-
503
- export const peoplePropertyPageObjectResponseSchema = z.object({
504
- type: z.literal("people"),
505
- people: z.array(
506
- z.union([partialUserObjectResponseSchema, userObjectResponseSchema]),
507
- ),
508
- id: z.string(),
509
- });
510
-
511
- export const relationPropertyPageObjectResponseSchema = z.object({
512
- type: z.literal("relation"),
513
- relation: z.array(
514
- z.object({
515
- id: z.string(),
516
- }),
517
- ),
518
- id: z.string(),
519
- });
520
-
521
- export const rollupPropertyPageObjectResponseSchema = z.object({
522
- type: z.literal("rollup"),
523
- rollup: z.union([
524
- z.object({
525
- type: z.literal("number"),
526
- number: z.number().nullable(),
527
- function: rollupFunctionSchema,
528
- }),
529
- z.object({
530
- type: z.literal("date"),
531
- date: dateResponseSchema.nullable(),
532
- function: rollupFunctionSchema,
533
- }),
534
- z.object({
535
- type: z.literal("array"),
536
- array: z.array(
537
- z.union([
538
- z.object({
539
- type: z.literal("number"),
540
- number: z.number().nullable(),
541
- }),
542
- z.object({
543
- type: z.literal("url"),
544
- url: z.string().nullable(),
545
- }),
546
- z.object({
547
- type: z.literal("select"),
548
- select: partialSelectResponseSchema.nullable(),
549
- }),
550
- z.object({
551
- type: z.literal("multi_select"),
552
- multi_select: z.array(partialSelectResponseSchema),
553
- }),
554
- z.object({
555
- type: z.literal("status"),
556
- status: partialSelectResponseSchema.nullable(),
557
- }),
558
- z.object({
559
- type: z.literal("date"),
560
- date: dateResponseSchema.nullable(),
561
- }),
562
- z.object({
563
- type: z.literal("email"),
564
- email: z.string().nullable(),
565
- }),
566
- z.object({
567
- type: z.literal("phone_number"),
568
- phone_number: z.string().nullable(),
569
- }),
570
- z.object({
571
- type: z.literal("checkbox"),
572
- checkbox: z.boolean(),
573
- }),
574
- z.object({
575
- type: z.literal("files"),
576
- files: z.array(
577
- z.union([
578
- z.object({
579
- file: z.object({
580
- url: z.string(),
581
- expiry_time: z.string(),
582
- }),
583
- name: stringRequestSchema,
584
- type: z.literal("file").optional(),
585
- }),
586
- z.object({
587
- external: z.object({
588
- url: textRequestSchema,
589
- }),
590
- name: stringRequestSchema,
591
- type: z.literal("external").optional(),
592
- }),
593
- ]),
594
- ),
595
- }),
596
- z.object({
597
- type: z.literal("created_by"),
598
- created_by: z.union([
599
- partialUserObjectResponseSchema,
600
- userObjectResponseSchema,
601
- ]),
602
- }),
603
- z.object({
604
- type: z.literal("created_time"),
605
- created_time: z.string(),
606
- }),
607
- z.object({
608
- type: z.literal("last_edited_by"),
609
- last_edited_by: z.union([
610
- partialUserObjectResponseSchema,
611
- userObjectResponseSchema,
612
- ]),
613
- }),
614
- z.object({
615
- type: z.literal("last_edited_time"),
616
- last_edited_time: z.string(),
617
- }),
618
- z.object({
619
- type: z.literal("formula"),
620
- formula: formulaPropertyResponseSchema,
621
- }),
622
- z.object({
623
- type: z.literal("button"),
624
- button: z.record(z.never()),
625
- }),
626
- z.object({
627
- type: z.literal("unique_id"),
628
- unique_id: z.object({
629
- prefix: z.string().nullable(),
630
- number: z.number().nullable(),
631
- }),
632
- }),
633
- z.object({
634
- type: z.literal("verification"),
635
- verification: z
636
- .union([
637
- verificationPropertyUnverifiedResponseSchema,
638
- verificationPropertyResponseSchema,
639
- ])
640
- .nullable(),
641
- }),
642
- z.object({
643
- type: z.literal("title"),
644
- title: z.array(richTextItemResponseSchema),
645
- }),
646
- z.object({
647
- type: z.literal("rich_text"),
648
- rich_text: z.array(richTextItemResponseSchema),
649
- }),
650
- z.object({
651
- type: z.literal("people"),
652
- people: z.array(
653
- z.union([
654
- partialUserObjectResponseSchema,
655
- userObjectResponseSchema,
656
- ]),
657
- ),
658
- }),
659
- z.object({
660
- type: z.literal("relation"),
661
- relation: z.array(
662
- z.object({
663
- id: z.string(),
664
- }),
665
- ),
666
- }),
667
- ]),
668
- ),
669
- function: rollupFunctionSchema,
670
- }),
671
- ]),
672
- id: z.string(),
673
- });
674
-
675
- export const propertyPageObjectResponseSchema = z.union([
676
- numberPropertyPageObjectResponseSchema,
677
- urlPropertyPageObjectResponseSchema,
678
- selectPropertyPageObjectResponseSchema,
679
- multiSelectPropertyPageObjectResponseSchema,
680
- statusPropertyPageObjectResponseSchema,
681
- datePropertyPageObjectResponseSchema,
682
- emailPropertyPageObjectResponseSchema,
683
- phoneNumberPropertyPageObjectResponseSchema,
684
- checkboxPropertyPageObjectResponseSchema,
685
- filesPropertyPageObjectResponseSchema,
686
- createdByPropertyPageObjectResponseSchema,
687
- createdTimePropertyPageObjectResponseSchema,
688
- lastEditedByPropertyPageObjectResponseSchema,
689
- lastEditedTimePropertyPageObjectResponseSchema,
690
- formulaPropertyPageObjectResponseSchema,
691
- buttonPropertyPageObjectResponseSchema,
692
- uniqueIdPropertyPageObjectResponseSchema,
693
- verificationPropertyPageObjectResponseSchema,
694
- titlePropertyPageObjectResponseSchema,
695
- richTextPropertyPageObjectResponseSchema,
696
- peoplePropertyPageObjectResponseSchema,
697
- relationPropertyPageObjectResponseSchema,
698
- rollupPropertyPageObjectResponseSchema,
699
- ]);
700
-
701
- export const pageObjectResponseSchema = z.object({
702
- parent: z.union([
703
- z.object({
704
- type: z.literal("database_id"),
705
- database_id: z.string(),
706
- }),
707
- z.object({
708
- type: z.literal("page_id"),
709
- page_id: z.string(),
710
- }),
711
- z.object({
712
- type: z.literal("block_id"),
713
- block_id: z.string(),
714
- }),
715
- z.object({
716
- type: z.literal("workspace"),
717
- workspace: z.literal(true),
718
- }),
719
- z.object({
720
- type: z.literal("data_source_id"),
721
- data_source_id: z.string(),
722
- }),
723
- ]),
724
- properties: z.record(propertyPageObjectResponseSchema),
725
- icon: z
726
- .union([
727
- z.object({
728
- type: z.literal("emoji"),
729
- emoji: emojiRequestSchema,
730
- }),
731
- z.object({
732
- type: z.literal("external"),
733
- external: z.object({
734
- url: textRequestSchema,
735
- }),
736
- }),
737
- z.object({
738
- type: z.literal("file"),
739
- file: z.object({
740
- url: z.string(),
741
- expiry_time: z.string(),
742
- }),
743
- }),
744
- z.object({
745
- type: z.literal("custom_emoji"),
746
- custom_emoji: customEmojiResponseSchema,
747
- }),
748
- ])
749
- .nullable(),
750
- cover: z
751
- .union([
752
- z.object({
753
- type: z.literal("external"),
754
- external: z.object({
755
- url: textRequestSchema,
756
- }),
757
- }),
758
- z.object({
759
- type: z.literal("file"),
760
- file: z.object({
761
- url: z.string(),
762
- expiry_time: z.string(),
763
- }),
764
- }),
765
- ])
766
- .nullable(),
767
- created_by: partialUserObjectResponseSchema,
768
- last_edited_by: partialUserObjectResponseSchema,
769
- object: z.literal("page"),
770
- id: z.string(),
771
- created_time: z.string(),
772
- last_edited_time: z.string(),
773
- archived: z.boolean().optional().default(false),
774
- in_trash: z.boolean().optional().default(false),
775
- url: z.string(),
776
- public_url: z.string().nullable(),
777
- });
778
-
779
- export type PropertyPageObjectResponseType = z.infer<
780
- typeof propertyPageObjectResponseSchema
781
- >;
782
- export type PageObjectResponseType = z.infer<typeof pageObjectResponseSchema>;
783
-
784
- export const pageWithMarkdownSchema = pageObjectResponseSchema.extend({
785
- markdown: z.string(),
786
- truncated: z.boolean().default(false),
787
- });
788
- export type PageWithMarkdownType = z.infer<typeof pageWithMarkdownSchema>;
789
-
790
- /**
791
- * Shorthand aliases for Notion property schemas.
792
- *
793
- * Instead of importing each schema by its full name, you can use this object
794
- * to define your content collection schema more concisely.
795
- *
796
- * @example
797
- * ```ts
798
- * // Before
799
- * import { titlePropertyPageObjectResponseSchema, richTextPropertyPageObjectResponseSchema } from "notro";
800
- * properties: z.object({
801
- * Name: titlePropertyPageObjectResponseSchema,
802
- * Description: richTextPropertyPageObjectResponseSchema,
803
- * })
804
- *
805
- * // After
806
- * import { notroProperties } from "notro";
807
- * properties: z.object({
808
- * Name: notroProperties.title,
809
- * Description: notroProperties.richText,
810
- * })
811
- * ```
812
- */
813
- export const notroProperties = {
814
- title: titlePropertyPageObjectResponseSchema,
815
- richText: richTextPropertyPageObjectResponseSchema,
816
- number: numberPropertyPageObjectResponseSchema,
817
- select: selectPropertyPageObjectResponseSchema,
818
- multiSelect: multiSelectPropertyPageObjectResponseSchema,
819
- status: statusPropertyPageObjectResponseSchema,
820
- date: datePropertyPageObjectResponseSchema,
821
- checkbox: checkboxPropertyPageObjectResponseSchema,
822
- url: urlPropertyPageObjectResponseSchema,
823
- email: emailPropertyPageObjectResponseSchema,
824
- phoneNumber: phoneNumberPropertyPageObjectResponseSchema,
825
- files: filesPropertyPageObjectResponseSchema,
826
- people: peoplePropertyPageObjectResponseSchema,
827
- relation: relationPropertyPageObjectResponseSchema,
828
- rollup: rollupPropertyPageObjectResponseSchema,
829
- formula: formulaPropertyPageObjectResponseSchema,
830
- button: buttonPropertyPageObjectResponseSchema,
831
- uniqueId: uniqueIdPropertyPageObjectResponseSchema,
832
- verification: verificationPropertyPageObjectResponseSchema,
833
- createdBy: createdByPropertyPageObjectResponseSchema,
834
- createdTime: createdTimePropertyPageObjectResponseSchema,
835
- lastEditedBy: lastEditedByPropertyPageObjectResponseSchema,
836
- lastEditedTime: lastEditedTimePropertyPageObjectResponseSchema,
837
- } as const;
1
+ import { z } from "zod";
2
+
3
+ const emojiRequestSchema = z.string();
4
+ const timeZoneRequestSchema = z.string();
5
+
6
+ const idRequestSchema = z.string();
7
+
8
+ const personUserObjectResponseSchema = z.object({
9
+ type: z.literal("person"),
10
+ person: z.object({
11
+ email: z.string().optional(),
12
+ }),
13
+ name: z.string().nullable(),
14
+ avatar_url: z.string().nullable(),
15
+ id: idRequestSchema,
16
+ object: z.literal("user"),
17
+ });
18
+
19
+ const emptyObjectSchema = z.record(z.never());
20
+
21
+ const partialUserObjectResponseSchema = z.object({
22
+ id: idRequestSchema,
23
+ object: z.literal("user"),
24
+ });
25
+
26
+ const botUserObjectResponseSchema = z.object({
27
+ type: z.literal("bot"),
28
+ bot: z.union([
29
+ emptyObjectSchema,
30
+ z.object({
31
+ owner: z.union([
32
+ z.object({
33
+ type: z.literal("user"),
34
+ user: z.union([
35
+ z.object({
36
+ type: z.literal("person"),
37
+ person: z.object({
38
+ email: z.string(),
39
+ }),
40
+ name: z.string().nullable(),
41
+ avatar_url: z.string().nullable(),
42
+ id: idRequestSchema,
43
+ object: z.literal("user"),
44
+ }),
45
+ partialUserObjectResponseSchema,
46
+ ]),
47
+ }),
48
+ z.object({
49
+ type: z.literal("workspace"),
50
+ workspace: z.literal(true),
51
+ }),
52
+ ]),
53
+ workspace_name: z.string().nullable(),
54
+ }),
55
+ ]),
56
+ name: z.string().nullable(),
57
+ avatar_url: z.string().nullable(),
58
+ id: idRequestSchema,
59
+ object: z.literal("user"),
60
+ });
61
+
62
+ const userObjectResponseSchema = z.union([
63
+ personUserObjectResponseSchema,
64
+ botUserObjectResponseSchema,
65
+ ]);
66
+
67
+ const selectColorSchema = z.union([
68
+ z.literal("default"),
69
+ z.literal("gray"),
70
+ z.literal("brown"),
71
+ z.literal("orange"),
72
+ z.literal("yellow"),
73
+ z.literal("green"),
74
+ z.literal("blue"),
75
+ z.literal("purple"),
76
+ z.literal("pink"),
77
+ z.literal("red"),
78
+ ]);
79
+
80
+ const partialSelectResponseSchema = z.object({
81
+ id: z.string(),
82
+ name: z.string(),
83
+ color: selectColorSchema,
84
+ });
85
+
86
+ const dateResponseSchema = z.object({
87
+ start: z.string(),
88
+ end: z.string().nullable(),
89
+ time_zone: timeZoneRequestSchema.nullable(),
90
+ });
91
+
92
+ const stringRequestSchema = z.string();
93
+
94
+ const textRequestSchema = z.string();
95
+
96
+ const stringFormulaPropertyResponseSchema = z.object({
97
+ type: z.literal("string"),
98
+ string: z.string().nullable(),
99
+ });
100
+
101
+ const dateFormulaPropertyResponseSchema = z.object({
102
+ type: z.literal("date"),
103
+ date: dateResponseSchema.nullable(),
104
+ });
105
+
106
+ const numberFormulaPropertyResponseSchema = z.object({
107
+ type: z.literal("number"),
108
+ number: z.number().nullable(),
109
+ });
110
+
111
+ const booleanFormulaPropertyResponseSchema = z.object({
112
+ type: z.literal("boolean"),
113
+ boolean: z.boolean().nullable(),
114
+ });
115
+
116
+ const formulaPropertyResponseSchema = z.union([
117
+ stringFormulaPropertyResponseSchema,
118
+ dateFormulaPropertyResponseSchema,
119
+ numberFormulaPropertyResponseSchema,
120
+ booleanFormulaPropertyResponseSchema,
121
+ ]);
122
+
123
+ const verificationPropertyUnverifiedResponseSchema = z.object({
124
+ state: z.literal("unverified"),
125
+ date: z.null(),
126
+ verified_by: z.null(),
127
+ });
128
+
129
+ const verificationPropertyResponseSchema = z.object({
130
+ state: z.union([z.literal("verified"), z.literal("expired")]),
131
+ date: dateResponseSchema.nullable(),
132
+ verified_by: z
133
+ .union([
134
+ z.object({
135
+ id: idRequestSchema,
136
+ }),
137
+ z.object({
138
+ person: z.object({
139
+ email: z.string().optional(),
140
+ }),
141
+ id: idRequestSchema,
142
+ type: z.literal("person").optional(),
143
+ name: z.string().optional().nullable(),
144
+ avatar_url: z.string().optional().nullable(),
145
+ object: z.literal("user").optional(),
146
+ }),
147
+ z.object({
148
+ bot: z.union([
149
+ emptyObjectSchema,
150
+ z.object({
151
+ owner: z.union([
152
+ z.object({
153
+ type: z.literal("user"),
154
+ user: z.union([
155
+ z.object({
156
+ type: z.literal("person"),
157
+ person: z.object({
158
+ email: z.string(),
159
+ }),
160
+ name: z.string().nullable(),
161
+ avatar_url: z.string().nullable(),
162
+ id: idRequestSchema,
163
+ object: z.literal("user"),
164
+ }),
165
+ partialUserObjectResponseSchema,
166
+ ]),
167
+ }),
168
+ z.object({
169
+ type: z.literal("workspace"),
170
+ workspace: z.literal(true),
171
+ }),
172
+ ]),
173
+ workspace_name: z.string().nullable(),
174
+ }),
175
+ ]),
176
+ id: idRequestSchema,
177
+ type: z.literal("bot").optional(),
178
+ name: z.string().optional().nullable(),
179
+ avatar_url: z.string().optional().nullable(),
180
+ object: z.literal("user").optional(),
181
+ }),
182
+ ])
183
+ .nullable(),
184
+ });
185
+
186
+ const annotationResponseSchema = z.object({
187
+ bold: z.boolean(),
188
+ italic: z.boolean(),
189
+ strikethrough: z.boolean(),
190
+ underline: z.boolean(),
191
+ code: z.boolean(),
192
+ color: z.union([
193
+ z.literal("default"),
194
+ z.literal("gray"),
195
+ z.literal("brown"),
196
+ z.literal("orange"),
197
+ z.literal("yellow"),
198
+ z.literal("green"),
199
+ z.literal("blue"),
200
+ z.literal("purple"),
201
+ z.literal("pink"),
202
+ z.literal("red"),
203
+ z.literal("default_background"),
204
+ z.literal("gray_background"),
205
+ z.literal("brown_background"),
206
+ z.literal("orange_background"),
207
+ z.literal("yellow_background"),
208
+ z.literal("green_background"),
209
+ z.literal("blue_background"),
210
+ z.literal("purple_background"),
211
+ z.literal("pink_background"),
212
+ z.literal("red_background"),
213
+ ]),
214
+ });
215
+
216
+ const textRichTextItemResponseSchema = z.object({
217
+ type: z.literal("text"),
218
+ text: z.object({
219
+ content: z.string(),
220
+ link: z
221
+ .object({
222
+ url: textRequestSchema,
223
+ })
224
+ .nullable(),
225
+ }),
226
+ annotations: annotationResponseSchema,
227
+ plain_text: z.string(),
228
+ href: z.string().nullable(),
229
+ });
230
+
231
+ const linkPreviewMentionResponseSchema = z.object({
232
+ url: textRequestSchema,
233
+ });
234
+
235
+ const linkMentionResponseSchema = z.object({
236
+ href: z.string(),
237
+ });
238
+
239
+ const templateMentionDateTemplateMentionResponseSchema = z.object({
240
+ type: z.literal("template_mention_date"),
241
+ template_mention_date: z.union([z.literal("today"), z.literal("now")]),
242
+ });
243
+
244
+ const templateMentionUserTemplateMentionResponseSchema = z.object({
245
+ type: z.literal("template_mention_user"),
246
+ template_mention_user: z.literal("me"),
247
+ });
248
+
249
+ const templateMentionResponseSchema = z.union([
250
+ templateMentionDateTemplateMentionResponseSchema,
251
+ templateMentionUserTemplateMentionResponseSchema,
252
+ ]);
253
+
254
+ const customEmojiResponseSchema = z.object({
255
+ id: idRequestSchema,
256
+ name: z.string(),
257
+ url: z.string(),
258
+ });
259
+
260
+ const mentionRichTextItemResponseSchema = z.object({
261
+ type: z.literal("mention"),
262
+ mention: z.union([
263
+ z.object({
264
+ type: z.literal("user"),
265
+ user: z.union([
266
+ partialUserObjectResponseSchema,
267
+ userObjectResponseSchema,
268
+ ]),
269
+ }),
270
+ z.object({
271
+ type: z.literal("date"),
272
+ date: dateResponseSchema,
273
+ }),
274
+ z.object({
275
+ type: z.literal("link_preview"),
276
+ link_preview: linkPreviewMentionResponseSchema,
277
+ }),
278
+ z.object({
279
+ type: z.literal("link_mention"),
280
+ link_mention: linkMentionResponseSchema,
281
+ }),
282
+ z.object({
283
+ type: z.literal("template_mention"),
284
+ template_mention: templateMentionResponseSchema,
285
+ }),
286
+ z.object({
287
+ type: z.literal("page"),
288
+ page: z.object({
289
+ id: idRequestSchema,
290
+ }),
291
+ }),
292
+ z.object({
293
+ type: z.literal("database"),
294
+ database: z.object({
295
+ id: idRequestSchema,
296
+ }),
297
+ }),
298
+ z.object({
299
+ type: z.literal("custom_emoji"),
300
+ custom_emoji: customEmojiResponseSchema,
301
+ }),
302
+ ]),
303
+ annotations: annotationResponseSchema,
304
+ plain_text: z.string(),
305
+ href: z.string().nullable(),
306
+ });
307
+
308
+ const equationRichTextItemResponseSchema = z.object({
309
+ type: z.literal("equation"),
310
+ equation: z.object({
311
+ expression: textRequestSchema,
312
+ }),
313
+ annotations: annotationResponseSchema,
314
+ plain_text: z.string(),
315
+ href: z.string().nullable(),
316
+ });
317
+
318
+ const richTextItemResponseSchema = z.union([
319
+ textRichTextItemResponseSchema,
320
+ mentionRichTextItemResponseSchema,
321
+ equationRichTextItemResponseSchema,
322
+ ]);
323
+
324
+ const rollupFunctionSchema = z.union([
325
+ z.literal("count"),
326
+ z.literal("count_values"),
327
+ z.literal("empty"),
328
+ z.literal("not_empty"),
329
+ z.literal("unique"),
330
+ z.literal("show_unique"),
331
+ z.literal("percent_empty"),
332
+ z.literal("percent_not_empty"),
333
+ z.literal("sum"),
334
+ z.literal("average"),
335
+ z.literal("median"),
336
+ z.literal("min"),
337
+ z.literal("max"),
338
+ z.literal("range"),
339
+ z.literal("earliest_date"),
340
+ z.literal("latest_date"),
341
+ z.literal("date_range"),
342
+ z.literal("checked"),
343
+ z.literal("unchecked"),
344
+ z.literal("percent_checked"),
345
+ z.literal("percent_unchecked"),
346
+ z.literal("count_per_group"),
347
+ z.literal("percent_per_group"),
348
+ z.literal("show_original"),
349
+ ]);
350
+
351
+ export const numberPropertyPageObjectResponseSchema = z.object({
352
+ type: z.literal("number"),
353
+ number: z.number().nullable(),
354
+ id: z.string(),
355
+ });
356
+
357
+ export const urlPropertyPageObjectResponseSchema = z.object({
358
+ type: z.literal("url"),
359
+ url: z.string().nullable(),
360
+ id: z.string(),
361
+ });
362
+
363
+ export const selectPropertyPageObjectResponseSchema = z.object({
364
+ type: z.literal("select"),
365
+ select: partialSelectResponseSchema.nullable(),
366
+ id: z.string(),
367
+ });
368
+
369
+ export const multiSelectPropertyPageObjectResponseSchema = z.object({
370
+ type: z.literal("multi_select"),
371
+ multi_select: z.array(partialSelectResponseSchema),
372
+ id: z.string(),
373
+ });
374
+
375
+ export const statusPropertyPageObjectResponseSchema = z.object({
376
+ type: z.literal("status"),
377
+ status: partialSelectResponseSchema.nullable(),
378
+ id: z.string(),
379
+ });
380
+
381
+ export const datePropertyPageObjectResponseSchema = z.object({
382
+ type: z.literal("date"),
383
+ date: dateResponseSchema.nullable(),
384
+ id: z.string(),
385
+ });
386
+
387
+ export const emailPropertyPageObjectResponseSchema = z.object({
388
+ type: z.literal("email"),
389
+ email: z.string().nullable(),
390
+ id: z.string(),
391
+ });
392
+
393
+ export const phoneNumberPropertyPageObjectResponseSchema = z.object({
394
+ type: z.literal("phone_number"),
395
+ phone_number: z.string().nullable(),
396
+ id: z.string(),
397
+ });
398
+
399
+ export const checkboxPropertyPageObjectResponseSchema = z.object({
400
+ type: z.literal("checkbox"),
401
+ checkbox: z.boolean(),
402
+ id: z.string(),
403
+ });
404
+
405
+ export const filesPropertyPageObjectResponseSchema = z.object({
406
+ type: z.literal("files"),
407
+ files: z.array(
408
+ z.union([
409
+ z.object({
410
+ file: z.object({
411
+ url: z.string(),
412
+ expiry_time: z.string(),
413
+ }),
414
+ name: stringRequestSchema,
415
+ type: z.literal("file").optional(),
416
+ }),
417
+ z.object({
418
+ external: z.object({
419
+ url: textRequestSchema,
420
+ }),
421
+ name: stringRequestSchema,
422
+ type: z.literal("external").optional(),
423
+ }),
424
+ ]),
425
+ ),
426
+ id: z.string(),
427
+ });
428
+
429
+ export const createdByPropertyPageObjectResponseSchema = z.object({
430
+ type: z.literal("created_by"),
431
+ created_by: z.union([
432
+ partialUserObjectResponseSchema,
433
+ userObjectResponseSchema,
434
+ ]),
435
+ id: z.string(),
436
+ });
437
+
438
+ export const createdTimePropertyPageObjectResponseSchema = z.object({
439
+ type: z.literal("created_time"),
440
+ created_time: z.string(),
441
+ id: z.string(),
442
+ });
443
+
444
+ export const lastEditedByPropertyPageObjectResponseSchema = z.object({
445
+ type: z.literal("last_edited_by"),
446
+ last_edited_by: z.union([
447
+ partialUserObjectResponseSchema,
448
+ userObjectResponseSchema,
449
+ ]),
450
+ id: z.string(),
451
+ });
452
+
453
+ export const lastEditedTimePropertyPageObjectResponseSchema = z.object({
454
+ type: z.literal("last_edited_time"),
455
+ last_edited_time: z.string(),
456
+ id: z.string(),
457
+ });
458
+
459
+ export const formulaPropertyPageObjectResponseSchema = z.object({
460
+ type: z.literal("formula"),
461
+ formula: formulaPropertyResponseSchema,
462
+ id: z.string(),
463
+ });
464
+
465
+ export const buttonPropertyPageObjectResponseSchema = z.object({
466
+ type: z.literal("button"),
467
+ button: z.record(z.never()),
468
+ id: z.string(),
469
+ });
470
+
471
+ export const uniqueIdPropertyPageObjectResponseSchema = z.object({
472
+ type: z.literal("unique_id"),
473
+ unique_id: z.object({
474
+ prefix: z.string().nullable(),
475
+ number: z.number().nullable(),
476
+ }),
477
+ id: z.string(),
478
+ });
479
+
480
+ export const verificationPropertyPageObjectResponseSchema = z.object({
481
+ type: z.literal("verification"),
482
+ verification: z
483
+ .union([
484
+ verificationPropertyUnverifiedResponseSchema,
485
+ verificationPropertyResponseSchema,
486
+ ])
487
+ .nullable(),
488
+ id: z.string(),
489
+ });
490
+
491
+ export const titlePropertyPageObjectResponseSchema = z.object({
492
+ type: z.literal("title"),
493
+ title: z.array(textRichTextItemResponseSchema),
494
+ id: z.string(),
495
+ });
496
+
497
+ export const richTextPropertyPageObjectResponseSchema = z.object({
498
+ type: z.literal("rich_text"),
499
+ rich_text: z.array(textRichTextItemResponseSchema),
500
+ id: z.string(),
501
+ });
502
+
503
+ export const peoplePropertyPageObjectResponseSchema = z.object({
504
+ type: z.literal("people"),
505
+ people: z.array(
506
+ z.union([partialUserObjectResponseSchema, userObjectResponseSchema]),
507
+ ),
508
+ id: z.string(),
509
+ });
510
+
511
+ export const relationPropertyPageObjectResponseSchema = z.object({
512
+ type: z.literal("relation"),
513
+ relation: z.array(
514
+ z.object({
515
+ id: z.string(),
516
+ }),
517
+ ),
518
+ id: z.string(),
519
+ });
520
+
521
+ export const rollupPropertyPageObjectResponseSchema = z.object({
522
+ type: z.literal("rollup"),
523
+ rollup: z.union([
524
+ z.object({
525
+ type: z.literal("number"),
526
+ number: z.number().nullable(),
527
+ function: rollupFunctionSchema,
528
+ }),
529
+ z.object({
530
+ type: z.literal("date"),
531
+ date: dateResponseSchema.nullable(),
532
+ function: rollupFunctionSchema,
533
+ }),
534
+ z.object({
535
+ type: z.literal("array"),
536
+ array: z.array(
537
+ z.union([
538
+ z.object({
539
+ type: z.literal("number"),
540
+ number: z.number().nullable(),
541
+ }),
542
+ z.object({
543
+ type: z.literal("url"),
544
+ url: z.string().nullable(),
545
+ }),
546
+ z.object({
547
+ type: z.literal("select"),
548
+ select: partialSelectResponseSchema.nullable(),
549
+ }),
550
+ z.object({
551
+ type: z.literal("multi_select"),
552
+ multi_select: z.array(partialSelectResponseSchema),
553
+ }),
554
+ z.object({
555
+ type: z.literal("status"),
556
+ status: partialSelectResponseSchema.nullable(),
557
+ }),
558
+ z.object({
559
+ type: z.literal("date"),
560
+ date: dateResponseSchema.nullable(),
561
+ }),
562
+ z.object({
563
+ type: z.literal("email"),
564
+ email: z.string().nullable(),
565
+ }),
566
+ z.object({
567
+ type: z.literal("phone_number"),
568
+ phone_number: z.string().nullable(),
569
+ }),
570
+ z.object({
571
+ type: z.literal("checkbox"),
572
+ checkbox: z.boolean(),
573
+ }),
574
+ z.object({
575
+ type: z.literal("files"),
576
+ files: z.array(
577
+ z.union([
578
+ z.object({
579
+ file: z.object({
580
+ url: z.string(),
581
+ expiry_time: z.string(),
582
+ }),
583
+ name: stringRequestSchema,
584
+ type: z.literal("file").optional(),
585
+ }),
586
+ z.object({
587
+ external: z.object({
588
+ url: textRequestSchema,
589
+ }),
590
+ name: stringRequestSchema,
591
+ type: z.literal("external").optional(),
592
+ }),
593
+ ]),
594
+ ),
595
+ }),
596
+ z.object({
597
+ type: z.literal("created_by"),
598
+ created_by: z.union([
599
+ partialUserObjectResponseSchema,
600
+ userObjectResponseSchema,
601
+ ]),
602
+ }),
603
+ z.object({
604
+ type: z.literal("created_time"),
605
+ created_time: z.string(),
606
+ }),
607
+ z.object({
608
+ type: z.literal("last_edited_by"),
609
+ last_edited_by: z.union([
610
+ partialUserObjectResponseSchema,
611
+ userObjectResponseSchema,
612
+ ]),
613
+ }),
614
+ z.object({
615
+ type: z.literal("last_edited_time"),
616
+ last_edited_time: z.string(),
617
+ }),
618
+ z.object({
619
+ type: z.literal("formula"),
620
+ formula: formulaPropertyResponseSchema,
621
+ }),
622
+ z.object({
623
+ type: z.literal("button"),
624
+ button: z.record(z.never()),
625
+ }),
626
+ z.object({
627
+ type: z.literal("unique_id"),
628
+ unique_id: z.object({
629
+ prefix: z.string().nullable(),
630
+ number: z.number().nullable(),
631
+ }),
632
+ }),
633
+ z.object({
634
+ type: z.literal("verification"),
635
+ verification: z
636
+ .union([
637
+ verificationPropertyUnverifiedResponseSchema,
638
+ verificationPropertyResponseSchema,
639
+ ])
640
+ .nullable(),
641
+ }),
642
+ z.object({
643
+ type: z.literal("title"),
644
+ title: z.array(richTextItemResponseSchema),
645
+ }),
646
+ z.object({
647
+ type: z.literal("rich_text"),
648
+ rich_text: z.array(richTextItemResponseSchema),
649
+ }),
650
+ z.object({
651
+ type: z.literal("people"),
652
+ people: z.array(
653
+ z.union([
654
+ partialUserObjectResponseSchema,
655
+ userObjectResponseSchema,
656
+ ]),
657
+ ),
658
+ }),
659
+ z.object({
660
+ type: z.literal("relation"),
661
+ relation: z.array(
662
+ z.object({
663
+ id: z.string(),
664
+ }),
665
+ ),
666
+ }),
667
+ ]),
668
+ ),
669
+ function: rollupFunctionSchema,
670
+ }),
671
+ ]),
672
+ id: z.string(),
673
+ });
674
+
675
+ export const propertyPageObjectResponseSchema = z.union([
676
+ numberPropertyPageObjectResponseSchema,
677
+ urlPropertyPageObjectResponseSchema,
678
+ selectPropertyPageObjectResponseSchema,
679
+ multiSelectPropertyPageObjectResponseSchema,
680
+ statusPropertyPageObjectResponseSchema,
681
+ datePropertyPageObjectResponseSchema,
682
+ emailPropertyPageObjectResponseSchema,
683
+ phoneNumberPropertyPageObjectResponseSchema,
684
+ checkboxPropertyPageObjectResponseSchema,
685
+ filesPropertyPageObjectResponseSchema,
686
+ createdByPropertyPageObjectResponseSchema,
687
+ createdTimePropertyPageObjectResponseSchema,
688
+ lastEditedByPropertyPageObjectResponseSchema,
689
+ lastEditedTimePropertyPageObjectResponseSchema,
690
+ formulaPropertyPageObjectResponseSchema,
691
+ buttonPropertyPageObjectResponseSchema,
692
+ uniqueIdPropertyPageObjectResponseSchema,
693
+ verificationPropertyPageObjectResponseSchema,
694
+ titlePropertyPageObjectResponseSchema,
695
+ richTextPropertyPageObjectResponseSchema,
696
+ peoplePropertyPageObjectResponseSchema,
697
+ relationPropertyPageObjectResponseSchema,
698
+ rollupPropertyPageObjectResponseSchema,
699
+ ]);
700
+
701
+ export const pageObjectResponseSchema = z.object({
702
+ parent: z.union([
703
+ z.object({
704
+ type: z.literal("database_id"),
705
+ database_id: z.string(),
706
+ }),
707
+ z.object({
708
+ type: z.literal("page_id"),
709
+ page_id: z.string(),
710
+ }),
711
+ z.object({
712
+ type: z.literal("block_id"),
713
+ block_id: z.string(),
714
+ }),
715
+ z.object({
716
+ type: z.literal("workspace"),
717
+ workspace: z.literal(true),
718
+ }),
719
+ z.object({
720
+ type: z.literal("data_source_id"),
721
+ data_source_id: z.string(),
722
+ }),
723
+ ]),
724
+ properties: z.record(propertyPageObjectResponseSchema),
725
+ icon: z
726
+ .union([
727
+ z.object({
728
+ type: z.literal("emoji"),
729
+ emoji: emojiRequestSchema,
730
+ }),
731
+ z.object({
732
+ type: z.literal("external"),
733
+ external: z.object({
734
+ url: textRequestSchema,
735
+ }),
736
+ }),
737
+ z.object({
738
+ type: z.literal("file"),
739
+ file: z.object({
740
+ url: z.string(),
741
+ expiry_time: z.string(),
742
+ }),
743
+ }),
744
+ z.object({
745
+ type: z.literal("custom_emoji"),
746
+ custom_emoji: customEmojiResponseSchema,
747
+ }),
748
+ ])
749
+ .nullable(),
750
+ cover: z
751
+ .union([
752
+ z.object({
753
+ type: z.literal("external"),
754
+ external: z.object({
755
+ url: textRequestSchema,
756
+ }),
757
+ }),
758
+ z.object({
759
+ type: z.literal("file"),
760
+ file: z.object({
761
+ url: z.string(),
762
+ expiry_time: z.string(),
763
+ }),
764
+ }),
765
+ ])
766
+ .nullable(),
767
+ created_by: partialUserObjectResponseSchema,
768
+ last_edited_by: partialUserObjectResponseSchema,
769
+ object: z.literal("page"),
770
+ id: z.string(),
771
+ created_time: z.string(),
772
+ last_edited_time: z.string(),
773
+ archived: z.boolean().optional().default(false),
774
+ in_trash: z.boolean().optional().default(false),
775
+ url: z.string(),
776
+ public_url: z.string().nullable(),
777
+ });
778
+
779
+ export type PropertyPageObjectResponseType = z.infer<
780
+ typeof propertyPageObjectResponseSchema
781
+ >;
782
+ export type PageObjectResponseType = z.infer<typeof pageObjectResponseSchema>;
783
+
784
+ export const pageWithMarkdownSchema = pageObjectResponseSchema.extend({
785
+ markdown: z.string(),
786
+ truncated: z.boolean().default(false),
787
+ });
788
+ export type PageWithMarkdownType = z.infer<typeof pageWithMarkdownSchema>;
789
+
790
+ /**
791
+ * Shorthand aliases for Notion property schemas.
792
+ *
793
+ * Instead of importing each schema by its full name, you can use this object
794
+ * to define your content collection schema more concisely.
795
+ *
796
+ * @example
797
+ * ```ts
798
+ * // Before
799
+ * import { titlePropertyPageObjectResponseSchema, richTextPropertyPageObjectResponseSchema } from "notro";
800
+ * properties: z.object({
801
+ * Name: titlePropertyPageObjectResponseSchema,
802
+ * Description: richTextPropertyPageObjectResponseSchema,
803
+ * })
804
+ *
805
+ * // After
806
+ * import { notroProperties } from "notro";
807
+ * properties: z.object({
808
+ * Name: notroProperties.title,
809
+ * Description: notroProperties.richText,
810
+ * })
811
+ * ```
812
+ */
813
+ export const notroProperties = {
814
+ title: titlePropertyPageObjectResponseSchema,
815
+ richText: richTextPropertyPageObjectResponseSchema,
816
+ number: numberPropertyPageObjectResponseSchema,
817
+ select: selectPropertyPageObjectResponseSchema,
818
+ multiSelect: multiSelectPropertyPageObjectResponseSchema,
819
+ status: statusPropertyPageObjectResponseSchema,
820
+ date: datePropertyPageObjectResponseSchema,
821
+ checkbox: checkboxPropertyPageObjectResponseSchema,
822
+ url: urlPropertyPageObjectResponseSchema,
823
+ email: emailPropertyPageObjectResponseSchema,
824
+ phoneNumber: phoneNumberPropertyPageObjectResponseSchema,
825
+ files: filesPropertyPageObjectResponseSchema,
826
+ people: peoplePropertyPageObjectResponseSchema,
827
+ relation: relationPropertyPageObjectResponseSchema,
828
+ rollup: rollupPropertyPageObjectResponseSchema,
829
+ formula: formulaPropertyPageObjectResponseSchema,
830
+ button: buttonPropertyPageObjectResponseSchema,
831
+ uniqueId: uniqueIdPropertyPageObjectResponseSchema,
832
+ verification: verificationPropertyPageObjectResponseSchema,
833
+ createdBy: createdByPropertyPageObjectResponseSchema,
834
+ createdTime: createdTimePropertyPageObjectResponseSchema,
835
+ lastEditedBy: lastEditedByPropertyPageObjectResponseSchema,
836
+ lastEditedTime: lastEditedTimePropertyPageObjectResponseSchema,
837
+ } as const;