@visus-io/notion-sdk-ts 3.1.1 → 3.2.1

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.
Files changed (50) hide show
  1. package/README.md +3 -3
  2. package/dist/api/blocks.api.d.ts +1083 -224
  3. package/dist/api/blocks.api.js +4 -0
  4. package/dist/api/comments.api.d.ts +19 -1
  5. package/dist/api/comments.api.js +1 -1
  6. package/dist/api/dataSources.api.d.ts +41 -0
  7. package/dist/api/databases.api.d.ts +52 -5
  8. package/dist/api/databases.api.js +5 -3
  9. package/dist/api/fileUploads.api.d.ts +17 -7
  10. package/dist/api/fileUploads.api.js +30 -16
  11. package/dist/api/pages.api.d.ts +49 -0
  12. package/dist/client.d.ts +33 -2
  13. package/dist/client.js +88 -21
  14. package/dist/errors.d.ts +7 -0
  15. package/dist/errors.js +7 -0
  16. package/dist/helpers/filter.helpers.d.ts +11 -4
  17. package/dist/helpers/filter.helpers.js +73 -30
  18. package/dist/helpers/pagination.helpers.d.ts +7 -2
  19. package/dist/helpers/pagination.helpers.js +26 -5
  20. package/dist/models/dataSource.model.d.ts +6 -1
  21. package/dist/models/dataSource.model.js +7 -0
  22. package/dist/models/database.model.d.ts +5 -1
  23. package/dist/models/database.model.js +6 -0
  24. package/dist/models/page.model.d.ts +20 -1
  25. package/dist/models/page.model.js +33 -2
  26. package/dist/models/user.model.d.ts +5 -0
  27. package/dist/models/user.model.js +10 -0
  28. package/dist/schemas/block.schema.d.ts +1082 -224
  29. package/dist/schemas/block.schema.js +40 -25
  30. package/dist/schemas/comment.schema.d.ts +18 -0
  31. package/dist/schemas/dataSource.schema.d.ts +41 -0
  32. package/dist/schemas/dataSource.schema.js +3 -0
  33. package/dist/schemas/database.schema.d.ts +54 -0
  34. package/dist/schemas/database.schema.js +11 -1
  35. package/dist/schemas/meetingNotesQuery.schema.d.ts +1082 -224
  36. package/dist/schemas/page.schema.d.ts +49 -0
  37. package/dist/schemas/page.schema.js +2 -1
  38. package/dist/schemas/pageMarkdown.schema.js +1 -1
  39. package/dist/schemas/pageProperties.schema.d.ts +105 -1
  40. package/dist/schemas/pageProperties.schema.js +17 -1
  41. package/dist/schemas/pagination.schema.d.ts +1 -1
  42. package/dist/schemas/propertyObjects.schema.js +2 -1
  43. package/dist/schemas/richText.schema.d.ts +36 -0
  44. package/dist/schemas/richText.schema.js +21 -0
  45. package/dist/schemas/shared.schema.d.ts +3 -7
  46. package/dist/schemas/shared.schema.js +5 -9
  47. package/dist/schemas/view.schema.d.ts +49 -0
  48. package/dist/validation.d.ts +8 -0
  49. package/dist/validation.js +16 -0
  50. package/package.json +16 -15
@@ -241,6 +241,9 @@ export declare const pageSchema: z.ZodObject<{
241
241
  }, z.core.$strip>, z.ZodObject<{
242
242
  type: z.ZodLiteral<"string">;
243
243
  string: z.ZodNullable<z.ZodString>;
244
+ }, z.core.$strip>, z.ZodObject<{
245
+ type: z.ZodLiteral<"unsupported">;
246
+ unsupported: z.ZodObject<{}, z.core.$strip>;
244
247
  }, z.core.$strip>], "type">;
245
248
  }, z.core.$strip>, z.ZodObject<{
246
249
  id: z.ZodString;
@@ -354,6 +357,16 @@ export declare const pageSchema: z.ZodObject<{
354
357
  id: z.ZodString;
355
358
  type: z.ZodLiteral<"phone_number">;
356
359
  phone_number: z.ZodNullable<z.ZodString>;
360
+ }, z.core.$strip>, z.ZodObject<{
361
+ id: z.ZodString;
362
+ type: z.ZodLiteral<"place">;
363
+ place: z.ZodNullable<z.ZodObject<{
364
+ name: z.ZodOptional<z.ZodString>;
365
+ address: z.ZodOptional<z.ZodString>;
366
+ latitude: z.ZodOptional<z.ZodNumber>;
367
+ longitude: z.ZodOptional<z.ZodNumber>;
368
+ google_place_id: z.ZodOptional<z.ZodString>;
369
+ }, z.core.$loose>>;
357
370
  }, z.core.$strip>, z.ZodObject<{
358
371
  id: z.ZodString;
359
372
  type: z.ZodLiteral<"relation">;
@@ -405,10 +418,23 @@ export declare const pageSchema: z.ZodObject<{
405
418
  }, z.core.$strip>, z.ZodObject<{
406
419
  type: z.ZodLiteral<"mention">;
407
420
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
421
+ type: z.ZodLiteral<"custom_emoji">;
422
+ custom_emoji: z.ZodObject<{
423
+ id: z.ZodUUID;
424
+ name: z.ZodString;
425
+ url: z.ZodURL;
426
+ }, z.core.$strip>;
427
+ }, z.core.$strip>, z.ZodObject<{
408
428
  type: z.ZodLiteral<"database">;
409
429
  database: z.ZodObject<{
410
430
  id: z.ZodUUID;
411
431
  }, z.core.$strip>;
432
+ }, z.core.$strip>, z.ZodObject<{
433
+ type: z.ZodLiteral<"data_source">;
434
+ data_source: z.ZodObject<{
435
+ id: z.ZodUUID;
436
+ database_id: z.ZodOptional<z.ZodUUID>;
437
+ }, z.core.$strip>;
412
438
  }, z.core.$strip>, z.ZodObject<{
413
439
  type: z.ZodLiteral<"date">;
414
440
  date: z.ZodObject<{
@@ -416,6 +442,11 @@ export declare const pageSchema: z.ZodObject<{
416
442
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
417
443
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
418
444
  }, z.core.$strip>;
445
+ }, z.core.$strip>, z.ZodObject<{
446
+ type: z.ZodLiteral<"link_mention">;
447
+ link_mention: z.ZodObject<{
448
+ href: z.ZodString;
449
+ }, z.core.$loose>;
419
450
  }, z.core.$strip>, z.ZodObject<{
420
451
  type: z.ZodLiteral<"link_preview">;
421
452
  link_preview: z.ZodObject<{
@@ -685,10 +716,23 @@ export declare const pageSchema: z.ZodObject<{
685
716
  }, z.core.$strip>, z.ZodObject<{
686
717
  type: z.ZodLiteral<"mention">;
687
718
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
719
+ type: z.ZodLiteral<"custom_emoji">;
720
+ custom_emoji: z.ZodObject<{
721
+ id: z.ZodUUID;
722
+ name: z.ZodString;
723
+ url: z.ZodURL;
724
+ }, z.core.$strip>;
725
+ }, z.core.$strip>, z.ZodObject<{
688
726
  type: z.ZodLiteral<"database">;
689
727
  database: z.ZodObject<{
690
728
  id: z.ZodUUID;
691
729
  }, z.core.$strip>;
730
+ }, z.core.$strip>, z.ZodObject<{
731
+ type: z.ZodLiteral<"data_source">;
732
+ data_source: z.ZodObject<{
733
+ id: z.ZodUUID;
734
+ database_id: z.ZodOptional<z.ZodUUID>;
735
+ }, z.core.$strip>;
692
736
  }, z.core.$strip>, z.ZodObject<{
693
737
  type: z.ZodLiteral<"date">;
694
738
  date: z.ZodObject<{
@@ -696,6 +740,11 @@ export declare const pageSchema: z.ZodObject<{
696
740
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
697
741
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
698
742
  }, z.core.$strip>;
743
+ }, z.core.$strip>, z.ZodObject<{
744
+ type: z.ZodLiteral<"link_mention">;
745
+ link_mention: z.ZodObject<{
746
+ href: z.ZodString;
747
+ }, z.core.$loose>;
699
748
  }, z.core.$strip>, z.ZodObject<{
700
749
  type: z.ZodLiteral<"link_preview">;
701
750
  link_preview: z.ZodObject<{
@@ -64,7 +64,8 @@ exports.pageSchema = z.object({
64
64
  is_locked: z.boolean().optional(),
65
65
  icon: z.nullable(icon_schema_1.iconSchema),
66
66
  cover: z.nullable(file_schema_1.fileSchema),
67
- properties: z.record(z.string().trim(), pageProperties_schema_1.pagePropertiesSchema),
67
+ // Do not trim: property names can carry significant leading/trailing spaces.
68
+ properties: z.record(z.string(), pageProperties_schema_1.pagePropertiesSchema),
68
69
  parent: parent_schema_1.parentSchema,
69
70
  url: z.url(),
70
71
  public_url: z.url().nullable(),
@@ -53,7 +53,7 @@ exports.pageMarkdownSchema = z.object({
53
53
  // eslint-disable-next-line zod/prefer-string-schema-with-trim -- markdown content must preserve leading/trailing whitespace and newlines
54
54
  markdown: z.string(),
55
55
  truncated: z.boolean(),
56
- unknown_block_ids: z.array(z.uuid()).max(100),
56
+ unknown_block_ids: z.array(z.uuid()),
57
57
  });
58
58
  /**
59
59
  * `PATCH /v1/pages/{page_id}/markdown` returns `pageMarkdownSchema` synchronously. If
@@ -4,7 +4,7 @@ import * as z from 'zod';
4
4
  *
5
5
  * These schemas define the data values in page properties (database columns).
6
6
  * Property objects define the schema and configuration instead.
7
- * This file supports 22 property types, including title, rich text, number, and select.
7
+ * This file supports 23 property types, including title, rich text, number, and select.
8
8
  *
9
9
  * Notion API reference:
10
10
  * https://developers.notion.com/reference/page-property-values
@@ -118,6 +118,9 @@ declare const formulaPropertySchema: z.ZodObject<{
118
118
  }, z.core.$strip>, z.ZodObject<{
119
119
  type: z.ZodLiteral<"string">;
120
120
  string: z.ZodNullable<z.ZodString>;
121
+ }, z.core.$strip>, z.ZodObject<{
122
+ type: z.ZodLiteral<"unsupported">;
123
+ unsupported: z.ZodObject<{}, z.core.$strip>;
121
124
  }, z.core.$strip>], "type">;
122
125
  }, z.core.$strip>;
123
126
  /** Last edited by property. */
@@ -244,6 +247,18 @@ declare const phoneNumberPropertySchema: z.ZodObject<{
244
247
  type: z.ZodLiteral<"phone_number">;
245
248
  phone_number: z.ZodNullable<z.ZodString>;
246
249
  }, z.core.$strip>;
250
+ /** Place property. Unknown keys on the location value pass through. */
251
+ declare const placePropertySchema: z.ZodObject<{
252
+ id: z.ZodString;
253
+ type: z.ZodLiteral<"place">;
254
+ place: z.ZodNullable<z.ZodObject<{
255
+ name: z.ZodOptional<z.ZodString>;
256
+ address: z.ZodOptional<z.ZodString>;
257
+ latitude: z.ZodOptional<z.ZodNumber>;
258
+ longitude: z.ZodOptional<z.ZodNumber>;
259
+ google_place_id: z.ZodOptional<z.ZodString>;
260
+ }, z.core.$loose>>;
261
+ }, z.core.$strip>;
247
262
  /** Relation property. */
248
263
  declare const relationPropertySchema: z.ZodObject<{
249
264
  id: z.ZodString;
@@ -298,10 +313,23 @@ declare const richTextPropertySchema: z.ZodObject<{
298
313
  }, z.core.$strip>, z.ZodObject<{
299
314
  type: z.ZodLiteral<"mention">;
300
315
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
316
+ type: z.ZodLiteral<"custom_emoji">;
317
+ custom_emoji: z.ZodObject<{
318
+ id: z.ZodUUID;
319
+ name: z.ZodString;
320
+ url: z.ZodURL;
321
+ }, z.core.$strip>;
322
+ }, z.core.$strip>, z.ZodObject<{
301
323
  type: z.ZodLiteral<"database">;
302
324
  database: z.ZodObject<{
303
325
  id: z.ZodUUID;
304
326
  }, z.core.$strip>;
327
+ }, z.core.$strip>, z.ZodObject<{
328
+ type: z.ZodLiteral<"data_source">;
329
+ data_source: z.ZodObject<{
330
+ id: z.ZodUUID;
331
+ database_id: z.ZodOptional<z.ZodUUID>;
332
+ }, z.core.$strip>;
305
333
  }, z.core.$strip>, z.ZodObject<{
306
334
  type: z.ZodLiteral<"date">;
307
335
  date: z.ZodObject<{
@@ -309,6 +337,11 @@ declare const richTextPropertySchema: z.ZodObject<{
309
337
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
310
338
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
311
339
  }, z.core.$strip>;
340
+ }, z.core.$strip>, z.ZodObject<{
341
+ type: z.ZodLiteral<"link_mention">;
342
+ link_mention: z.ZodObject<{
343
+ href: z.ZodString;
344
+ }, z.core.$loose>;
312
345
  }, z.core.$strip>, z.ZodObject<{
313
346
  type: z.ZodLiteral<"link_preview">;
314
347
  link_preview: z.ZodObject<{
@@ -586,10 +619,23 @@ declare const titlePropertySchema: z.ZodObject<{
586
619
  }, z.core.$strip>, z.ZodObject<{
587
620
  type: z.ZodLiteral<"mention">;
588
621
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
622
+ type: z.ZodLiteral<"custom_emoji">;
623
+ custom_emoji: z.ZodObject<{
624
+ id: z.ZodUUID;
625
+ name: z.ZodString;
626
+ url: z.ZodURL;
627
+ }, z.core.$strip>;
628
+ }, z.core.$strip>, z.ZodObject<{
589
629
  type: z.ZodLiteral<"database">;
590
630
  database: z.ZodObject<{
591
631
  id: z.ZodUUID;
592
632
  }, z.core.$strip>;
633
+ }, z.core.$strip>, z.ZodObject<{
634
+ type: z.ZodLiteral<"data_source">;
635
+ data_source: z.ZodObject<{
636
+ id: z.ZodUUID;
637
+ database_id: z.ZodOptional<z.ZodUUID>;
638
+ }, z.core.$strip>;
593
639
  }, z.core.$strip>, z.ZodObject<{
594
640
  type: z.ZodLiteral<"date">;
595
641
  date: z.ZodObject<{
@@ -597,6 +643,11 @@ declare const titlePropertySchema: z.ZodObject<{
597
643
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
598
644
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
599
645
  }, z.core.$strip>;
646
+ }, z.core.$strip>, z.ZodObject<{
647
+ type: z.ZodLiteral<"link_mention">;
648
+ link_mention: z.ZodObject<{
649
+ href: z.ZodString;
650
+ }, z.core.$loose>;
600
651
  }, z.core.$strip>, z.ZodObject<{
601
652
  type: z.ZodLiteral<"link_preview">;
602
653
  link_preview: z.ZodObject<{
@@ -885,6 +936,9 @@ export declare const pagePropertiesSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
885
936
  }, z.core.$strip>, z.ZodObject<{
886
937
  type: z.ZodLiteral<"string">;
887
938
  string: z.ZodNullable<z.ZodString>;
939
+ }, z.core.$strip>, z.ZodObject<{
940
+ type: z.ZodLiteral<"unsupported">;
941
+ unsupported: z.ZodObject<{}, z.core.$strip>;
888
942
  }, z.core.$strip>], "type">;
889
943
  }, z.core.$strip>, z.ZodObject<{
890
944
  id: z.ZodString;
@@ -998,6 +1052,16 @@ export declare const pagePropertiesSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
998
1052
  id: z.ZodString;
999
1053
  type: z.ZodLiteral<"phone_number">;
1000
1054
  phone_number: z.ZodNullable<z.ZodString>;
1055
+ }, z.core.$strip>, z.ZodObject<{
1056
+ id: z.ZodString;
1057
+ type: z.ZodLiteral<"place">;
1058
+ place: z.ZodNullable<z.ZodObject<{
1059
+ name: z.ZodOptional<z.ZodString>;
1060
+ address: z.ZodOptional<z.ZodString>;
1061
+ latitude: z.ZodOptional<z.ZodNumber>;
1062
+ longitude: z.ZodOptional<z.ZodNumber>;
1063
+ google_place_id: z.ZodOptional<z.ZodString>;
1064
+ }, z.core.$loose>>;
1001
1065
  }, z.core.$strip>, z.ZodObject<{
1002
1066
  id: z.ZodString;
1003
1067
  type: z.ZodLiteral<"relation">;
@@ -1049,10 +1113,23 @@ export declare const pagePropertiesSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1049
1113
  }, z.core.$strip>, z.ZodObject<{
1050
1114
  type: z.ZodLiteral<"mention">;
1051
1115
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
1116
+ type: z.ZodLiteral<"custom_emoji">;
1117
+ custom_emoji: z.ZodObject<{
1118
+ id: z.ZodUUID;
1119
+ name: z.ZodString;
1120
+ url: z.ZodURL;
1121
+ }, z.core.$strip>;
1122
+ }, z.core.$strip>, z.ZodObject<{
1052
1123
  type: z.ZodLiteral<"database">;
1053
1124
  database: z.ZodObject<{
1054
1125
  id: z.ZodUUID;
1055
1126
  }, z.core.$strip>;
1127
+ }, z.core.$strip>, z.ZodObject<{
1128
+ type: z.ZodLiteral<"data_source">;
1129
+ data_source: z.ZodObject<{
1130
+ id: z.ZodUUID;
1131
+ database_id: z.ZodOptional<z.ZodUUID>;
1132
+ }, z.core.$strip>;
1056
1133
  }, z.core.$strip>, z.ZodObject<{
1057
1134
  type: z.ZodLiteral<"date">;
1058
1135
  date: z.ZodObject<{
@@ -1060,6 +1137,11 @@ export declare const pagePropertiesSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1060
1137
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
1061
1138
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1062
1139
  }, z.core.$strip>;
1140
+ }, z.core.$strip>, z.ZodObject<{
1141
+ type: z.ZodLiteral<"link_mention">;
1142
+ link_mention: z.ZodObject<{
1143
+ href: z.ZodString;
1144
+ }, z.core.$loose>;
1063
1145
  }, z.core.$strip>, z.ZodObject<{
1064
1146
  type: z.ZodLiteral<"link_preview">;
1065
1147
  link_preview: z.ZodObject<{
@@ -1329,10 +1411,23 @@ export declare const pagePropertiesSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1329
1411
  }, z.core.$strip>, z.ZodObject<{
1330
1412
  type: z.ZodLiteral<"mention">;
1331
1413
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
1414
+ type: z.ZodLiteral<"custom_emoji">;
1415
+ custom_emoji: z.ZodObject<{
1416
+ id: z.ZodUUID;
1417
+ name: z.ZodString;
1418
+ url: z.ZodURL;
1419
+ }, z.core.$strip>;
1420
+ }, z.core.$strip>, z.ZodObject<{
1332
1421
  type: z.ZodLiteral<"database">;
1333
1422
  database: z.ZodObject<{
1334
1423
  id: z.ZodUUID;
1335
1424
  }, z.core.$strip>;
1425
+ }, z.core.$strip>, z.ZodObject<{
1426
+ type: z.ZodLiteral<"data_source">;
1427
+ data_source: z.ZodObject<{
1428
+ id: z.ZodUUID;
1429
+ database_id: z.ZodOptional<z.ZodUUID>;
1430
+ }, z.core.$strip>;
1336
1431
  }, z.core.$strip>, z.ZodObject<{
1337
1432
  type: z.ZodLiteral<"date">;
1338
1433
  date: z.ZodObject<{
@@ -1340,6 +1435,11 @@ export declare const pagePropertiesSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1340
1435
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
1341
1436
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1342
1437
  }, z.core.$strip>;
1438
+ }, z.core.$strip>, z.ZodObject<{
1439
+ type: z.ZodLiteral<"link_mention">;
1440
+ link_mention: z.ZodObject<{
1441
+ href: z.ZodString;
1442
+ }, z.core.$loose>;
1343
1443
  }, z.core.$strip>, z.ZodObject<{
1344
1444
  type: z.ZodLiteral<"link_preview">;
1345
1445
  link_preview: z.ZodObject<{
@@ -1579,6 +1679,10 @@ export type PeopleProperty = z.infer<typeof peoplePropertySchema>;
1579
1679
  * @category Page Properties
1580
1680
  */
1581
1681
  export type PhoneNumberProperty = z.infer<typeof phoneNumberPropertySchema>;
1682
+ /**
1683
+ * @category Page Properties
1684
+ */
1685
+ export type PlaceProperty = z.infer<typeof placePropertySchema>;
1582
1686
  /**
1583
1687
  * @category Page Properties
1584
1688
  */
@@ -44,7 +44,7 @@ const user_schema_1 = require("./user.schema");
44
44
  *
45
45
  * These schemas define the data values in page properties (database columns).
46
46
  * Property objects define the schema and configuration instead.
47
- * This file supports 22 property types, including title, rich text, number, and select.
47
+ * This file supports 23 property types, including title, rich text, number, and select.
48
48
  *
49
49
  * Notion API reference:
50
50
  * https://developers.notion.com/reference/page-property-values
@@ -113,6 +113,7 @@ const formulaPropertySchema = z.object({
113
113
  }),
114
114
  z.object({ type: z.literal('number'), number: z.number().nullable() }),
115
115
  z.object({ type: z.literal('string'), string: z.string().trim().nullable() }),
116
+ z.object({ type: z.literal('unsupported'), unsupported: z.object({}) }),
116
117
  ]),
117
118
  });
118
119
  /** Last edited by property. */
@@ -155,6 +156,20 @@ const phoneNumberPropertySchema = z.object({
155
156
  type: z.literal('phone_number'),
156
157
  phone_number: z.string().trim().nullable(),
157
158
  });
159
+ /** Place property. Unknown keys on the location value pass through. */
160
+ const placePropertySchema = z.object({
161
+ id: z.string().trim(),
162
+ type: z.literal('place'),
163
+ place: z
164
+ .looseObject({
165
+ name: z.string().trim().optional(),
166
+ address: z.string().trim().optional(),
167
+ latitude: z.number().optional(),
168
+ longitude: z.number().optional(),
169
+ google_place_id: z.string().trim().optional(),
170
+ })
171
+ .nullable(),
172
+ });
158
173
  /** Relation property. */
159
174
  const relationPropertySchema = z.object({
160
175
  id: z.string().trim(),
@@ -291,6 +306,7 @@ exports.pagePropertiesSchema = z.discriminatedUnion('type', [
291
306
  numberPropertySchema,
292
307
  peoplePropertySchema,
293
308
  phoneNumberPropertySchema,
309
+ placePropertySchema,
294
310
  relationPropertySchema,
295
311
  richTextPropertySchema,
296
312
  rollupPropertySchema,
@@ -60,10 +60,10 @@ export declare const paginatedListSchema: <T extends z.ZodTypeAny>(resultSchema:
60
60
  custom_emoji: "custom_emoji";
61
61
  user: "user";
62
62
  database: "database";
63
+ data_source: "data_source";
63
64
  page: "page";
64
65
  block: "block";
65
66
  comment: "comment";
66
- data_source: "data_source";
67
67
  page_or_database: "page_or_database";
68
68
  page_or_data_source: "page_or_data_source";
69
69
  property_item: "property_item";
@@ -379,4 +379,5 @@ exports.propertyObjectSchema = z.discriminatedUnion('type', [
379
379
  *
380
380
  * @category Page Properties
381
381
  */
382
- exports.propertiesObjectSchema = z.record(z.string().trim(), exports.propertyObjectSchema);
382
+ // Do not trim: property names can carry significant leading/trailing spaces.
383
+ exports.propertiesObjectSchema = z.record(z.string(), exports.propertyObjectSchema);
@@ -43,10 +43,23 @@ declare const textRichTextSchema: z.ZodObject<{
43
43
  declare const mentionRichTextSchema: z.ZodObject<{
44
44
  type: z.ZodLiteral<"mention">;
45
45
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
46
+ type: z.ZodLiteral<"custom_emoji">;
47
+ custom_emoji: z.ZodObject<{
48
+ id: z.ZodUUID;
49
+ name: z.ZodString;
50
+ url: z.ZodURL;
51
+ }, z.core.$strip>;
52
+ }, z.core.$strip>, z.ZodObject<{
46
53
  type: z.ZodLiteral<"database">;
47
54
  database: z.ZodObject<{
48
55
  id: z.ZodUUID;
49
56
  }, z.core.$strip>;
57
+ }, z.core.$strip>, z.ZodObject<{
58
+ type: z.ZodLiteral<"data_source">;
59
+ data_source: z.ZodObject<{
60
+ id: z.ZodUUID;
61
+ database_id: z.ZodOptional<z.ZodUUID>;
62
+ }, z.core.$strip>;
50
63
  }, z.core.$strip>, z.ZodObject<{
51
64
  type: z.ZodLiteral<"date">;
52
65
  date: z.ZodObject<{
@@ -54,6 +67,11 @@ declare const mentionRichTextSchema: z.ZodObject<{
54
67
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
55
68
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
69
  }, z.core.$strip>;
70
+ }, z.core.$strip>, z.ZodObject<{
71
+ type: z.ZodLiteral<"link_mention">;
72
+ link_mention: z.ZodObject<{
73
+ href: z.ZodString;
74
+ }, z.core.$loose>;
57
75
  }, z.core.$strip>, z.ZodObject<{
58
76
  type: z.ZodLiteral<"link_preview">;
59
77
  link_preview: z.ZodObject<{
@@ -224,10 +242,23 @@ export declare const richTextSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodOb
224
242
  }, z.core.$strip>, z.ZodObject<{
225
243
  type: z.ZodLiteral<"mention">;
226
244
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
245
+ type: z.ZodLiteral<"custom_emoji">;
246
+ custom_emoji: z.ZodObject<{
247
+ id: z.ZodUUID;
248
+ name: z.ZodString;
249
+ url: z.ZodURL;
250
+ }, z.core.$strip>;
251
+ }, z.core.$strip>, z.ZodObject<{
227
252
  type: z.ZodLiteral<"database">;
228
253
  database: z.ZodObject<{
229
254
  id: z.ZodUUID;
230
255
  }, z.core.$strip>;
256
+ }, z.core.$strip>, z.ZodObject<{
257
+ type: z.ZodLiteral<"data_source">;
258
+ data_source: z.ZodObject<{
259
+ id: z.ZodUUID;
260
+ database_id: z.ZodOptional<z.ZodUUID>;
261
+ }, z.core.$strip>;
231
262
  }, z.core.$strip>, z.ZodObject<{
232
263
  type: z.ZodLiteral<"date">;
233
264
  date: z.ZodObject<{
@@ -235,6 +266,11 @@ export declare const richTextSchema: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodOb
235
266
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
236
267
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
237
268
  }, z.core.$strip>;
269
+ }, z.core.$strip>, z.ZodObject<{
270
+ type: z.ZodLiteral<"link_mention">;
271
+ link_mention: z.ZodObject<{
272
+ href: z.ZodString;
273
+ }, z.core.$loose>;
238
274
  }, z.core.$strip>, z.ZodObject<{
239
275
  type: z.ZodLiteral<"link_preview">;
240
276
  link_preview: z.ZodObject<{
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.richTextSchema = void 0;
37
37
  const z = __importStar(require("zod"));
38
38
  const colors_1 = require("./colors");
39
+ const customEmoji_schema_1 = require("./customEmoji.schema");
39
40
  const shared_schema_1 = require("./shared.schema");
40
41
  const user_schema_1 = require("./user.schema");
41
42
  /**
@@ -70,6 +71,23 @@ const databaseMentionSchema = z.object({
70
71
  id: z.uuid(),
71
72
  }),
72
73
  });
74
+ const dataSourceMentionSchema = z.object({
75
+ type: z.literal('data_source'),
76
+ data_source: z.object({
77
+ id: z.uuid(),
78
+ database_id: z.uuid().optional(),
79
+ }),
80
+ });
81
+ const customEmojiMentionSchema = z.object({
82
+ type: z.literal('custom_emoji'),
83
+ custom_emoji: customEmoji_schema_1.customEmojiSchema,
84
+ });
85
+ const linkMentionSchema = z.object({
86
+ type: z.literal('link_mention'),
87
+ link_mention: z.looseObject({
88
+ href: z.string().trim(),
89
+ }),
90
+ });
73
91
  const dateMentionSchema = z.object({
74
92
  type: z.literal('date'),
75
93
  date: z.object({
@@ -110,8 +128,11 @@ const userMentionSchema = z.object({
110
128
  user: user_schema_1.userSchema,
111
129
  });
112
130
  const mentionSchema = z.discriminatedUnion('type', [
131
+ customEmojiMentionSchema,
113
132
  databaseMentionSchema,
133
+ dataSourceMentionSchema,
114
134
  dateMentionSchema,
135
+ linkMentionSchema,
115
136
  linkPreviewMentionSchema,
116
137
  pageMentionSchema,
117
138
  templateMentionSchema,
@@ -5,13 +5,9 @@ import * as z from 'zod';
5
5
  * This file contains common schemas to avoid circular dependencies.
6
6
  */
7
7
  /**
8
- * Notion date string schema.
9
- *
10
- * This schema validates ISO 8601 date strings from the Notion API.
11
- * It accepts a date-only format ("2023-02-23") and a full date-time format
12
- * ("2023-02-23T00:00:00.000Z").
13
- *
14
- * The Notion API docs describe date fields as "A date, with an optional time".
8
+ * Notion date string schema. Accepts a date ("2023-02-23"), a UTC date-time
9
+ * ("2023-02-23T00:00:00.000Z"), and a date-time with a UTC offset or no zone
10
+ * ("2021-10-15T12:00:00.000-04:00", "2021-10-15T12:00:00.000").
15
11
  *
16
12
  * @category Shared Types
17
13
  */
@@ -41,17 +41,13 @@ const z = __importStar(require("zod"));
41
41
  * This file contains common schemas to avoid circular dependencies.
42
42
  */
43
43
  /**
44
- * Notion date string schema.
45
- *
46
- * This schema validates ISO 8601 date strings from the Notion API.
47
- * It accepts a date-only format ("2023-02-23") and a full date-time format
48
- * ("2023-02-23T00:00:00.000Z").
49
- *
50
- * The Notion API docs describe date fields as "A date, with an optional time".
44
+ * Notion date string schema. Accepts a date ("2023-02-23"), a UTC date-time
45
+ * ("2023-02-23T00:00:00.000Z"), and a date-time with a UTC offset or no zone
46
+ * ("2021-10-15T12:00:00.000-04:00", "2021-10-15T12:00:00.000").
51
47
  *
52
48
  * @category Shared Types
53
49
  */
54
50
  exports.notionDateStringSchema = z.union([
55
- z.iso.datetime(), // Full ISO 8601 datetime: "2023-02-23T00:00:00.000Z"
56
- z.iso.date(), // Date only: "2023-02-23"
51
+ z.iso.datetime({ offset: true, local: true }),
52
+ z.iso.date(),
57
53
  ]);
@@ -435,6 +435,9 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
435
435
  }, z.core.$strip>, z.ZodObject<{
436
436
  type: z.ZodLiteral<"string">;
437
437
  string: z.ZodNullable<z.ZodString>;
438
+ }, z.core.$strip>, z.ZodObject<{
439
+ type: z.ZodLiteral<"unsupported">;
440
+ unsupported: z.ZodObject<{}, z.core.$strip>;
438
441
  }, z.core.$strip>], "type">;
439
442
  }, z.core.$strip>, z.ZodObject<{
440
443
  id: z.ZodString;
@@ -548,6 +551,16 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
548
551
  id: z.ZodString;
549
552
  type: z.ZodLiteral<"phone_number">;
550
553
  phone_number: z.ZodNullable<z.ZodString>;
554
+ }, z.core.$strip>, z.ZodObject<{
555
+ id: z.ZodString;
556
+ type: z.ZodLiteral<"place">;
557
+ place: z.ZodNullable<z.ZodObject<{
558
+ name: z.ZodOptional<z.ZodString>;
559
+ address: z.ZodOptional<z.ZodString>;
560
+ latitude: z.ZodOptional<z.ZodNumber>;
561
+ longitude: z.ZodOptional<z.ZodNumber>;
562
+ google_place_id: z.ZodOptional<z.ZodString>;
563
+ }, z.core.$loose>>;
551
564
  }, z.core.$strip>, z.ZodObject<{
552
565
  id: z.ZodString;
553
566
  type: z.ZodLiteral<"relation">;
@@ -599,10 +612,23 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
599
612
  }, z.core.$strip>, z.ZodObject<{
600
613
  type: z.ZodLiteral<"mention">;
601
614
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
615
+ type: z.ZodLiteral<"custom_emoji">;
616
+ custom_emoji: z.ZodObject<{
617
+ id: z.ZodUUID;
618
+ name: z.ZodString;
619
+ url: z.ZodURL;
620
+ }, z.core.$strip>;
621
+ }, z.core.$strip>, z.ZodObject<{
602
622
  type: z.ZodLiteral<"database">;
603
623
  database: z.ZodObject<{
604
624
  id: z.ZodUUID;
605
625
  }, z.core.$strip>;
626
+ }, z.core.$strip>, z.ZodObject<{
627
+ type: z.ZodLiteral<"data_source">;
628
+ data_source: z.ZodObject<{
629
+ id: z.ZodUUID;
630
+ database_id: z.ZodOptional<z.ZodUUID>;
631
+ }, z.core.$strip>;
606
632
  }, z.core.$strip>, z.ZodObject<{
607
633
  type: z.ZodLiteral<"date">;
608
634
  date: z.ZodObject<{
@@ -610,6 +636,11 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
610
636
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
611
637
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
612
638
  }, z.core.$strip>;
639
+ }, z.core.$strip>, z.ZodObject<{
640
+ type: z.ZodLiteral<"link_mention">;
641
+ link_mention: z.ZodObject<{
642
+ href: z.ZodString;
643
+ }, z.core.$loose>;
613
644
  }, z.core.$strip>, z.ZodObject<{
614
645
  type: z.ZodLiteral<"link_preview">;
615
646
  link_preview: z.ZodObject<{
@@ -879,10 +910,23 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
879
910
  }, z.core.$strip>, z.ZodObject<{
880
911
  type: z.ZodLiteral<"mention">;
881
912
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
913
+ type: z.ZodLiteral<"custom_emoji">;
914
+ custom_emoji: z.ZodObject<{
915
+ id: z.ZodUUID;
916
+ name: z.ZodString;
917
+ url: z.ZodURL;
918
+ }, z.core.$strip>;
919
+ }, z.core.$strip>, z.ZodObject<{
882
920
  type: z.ZodLiteral<"database">;
883
921
  database: z.ZodObject<{
884
922
  id: z.ZodUUID;
885
923
  }, z.core.$strip>;
924
+ }, z.core.$strip>, z.ZodObject<{
925
+ type: z.ZodLiteral<"data_source">;
926
+ data_source: z.ZodObject<{
927
+ id: z.ZodUUID;
928
+ database_id: z.ZodOptional<z.ZodUUID>;
929
+ }, z.core.$strip>;
886
930
  }, z.core.$strip>, z.ZodObject<{
887
931
  type: z.ZodLiteral<"date">;
888
932
  date: z.ZodObject<{
@@ -890,6 +934,11 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
890
934
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
891
935
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
892
936
  }, z.core.$strip>;
937
+ }, z.core.$strip>, z.ZodObject<{
938
+ type: z.ZodLiteral<"link_mention">;
939
+ link_mention: z.ZodObject<{
940
+ href: z.ZodString;
941
+ }, z.core.$loose>;
893
942
  }, z.core.$strip>, z.ZodObject<{
894
943
  type: z.ZodLiteral<"link_preview">;
895
944
  link_preview: z.ZodObject<{
@@ -60,3 +60,11 @@ export declare function validateStringLength(value: string, maxLength: number, l
60
60
  * @category Client & Core
61
61
  */
62
62
  export declare function validateArrayLength(array: unknown[], maxLength: number, label: string): void;
63
+ /**
64
+ * Assert that a number is within the inclusive range `[min, max]`.
65
+ *
66
+ * @throws {NotionValidationError}
67
+ *
68
+ * @category Client & Core
69
+ */
70
+ export declare function validateNumberRange(value: number, min: number, max: number, label: string): void;