@visus-io/notion-sdk-ts 3.2.0 → 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 (39) hide show
  1. package/dist/api/blocks.api.d.ts +1083 -224
  2. package/dist/api/blocks.api.js +4 -0
  3. package/dist/api/comments.api.d.ts +19 -1
  4. package/dist/api/comments.api.js +1 -1
  5. package/dist/api/dataSources.api.d.ts +36 -0
  6. package/dist/api/databases.api.d.ts +36 -0
  7. package/dist/api/databases.api.js +1 -0
  8. package/dist/api/fileUploads.api.d.ts +17 -7
  9. package/dist/api/fileUploads.api.js +30 -16
  10. package/dist/api/pages.api.d.ts +46 -0
  11. package/dist/client.d.ts +33 -2
  12. package/dist/client.js +88 -21
  13. package/dist/helpers/filter.helpers.d.ts +11 -4
  14. package/dist/helpers/filter.helpers.js +73 -30
  15. package/dist/helpers/pagination.helpers.d.ts +7 -2
  16. package/dist/helpers/pagination.helpers.js +26 -5
  17. package/dist/models/page.model.d.ts +20 -1
  18. package/dist/models/page.model.js +33 -2
  19. package/dist/schemas/block.schema.d.ts +1082 -224
  20. package/dist/schemas/block.schema.js +40 -25
  21. package/dist/schemas/comment.schema.d.ts +18 -0
  22. package/dist/schemas/dataSource.schema.d.ts +36 -0
  23. package/dist/schemas/database.schema.d.ts +36 -0
  24. package/dist/schemas/meetingNotesQuery.schema.d.ts +1082 -224
  25. package/dist/schemas/page.schema.d.ts +46 -0
  26. package/dist/schemas/page.schema.js +2 -1
  27. package/dist/schemas/pageMarkdown.schema.js +1 -1
  28. package/dist/schemas/pageProperties.schema.d.ts +99 -1
  29. package/dist/schemas/pageProperties.schema.js +16 -1
  30. package/dist/schemas/pagination.schema.d.ts +1 -1
  31. package/dist/schemas/propertyObjects.schema.js +2 -1
  32. package/dist/schemas/richText.schema.d.ts +36 -0
  33. package/dist/schemas/richText.schema.js +21 -0
  34. package/dist/schemas/shared.schema.d.ts +3 -7
  35. package/dist/schemas/shared.schema.js +5 -9
  36. package/dist/schemas/view.schema.d.ts +46 -0
  37. package/dist/validation.d.ts +8 -0
  38. package/dist/validation.js +16 -0
  39. package/package.json +1 -1
@@ -357,6 +357,16 @@ export declare const pageSchema: z.ZodObject<{
357
357
  id: z.ZodString;
358
358
  type: z.ZodLiteral<"phone_number">;
359
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>>;
360
370
  }, z.core.$strip>, z.ZodObject<{
361
371
  id: z.ZodString;
362
372
  type: z.ZodLiteral<"relation">;
@@ -408,10 +418,23 @@ export declare const pageSchema: z.ZodObject<{
408
418
  }, z.core.$strip>, z.ZodObject<{
409
419
  type: z.ZodLiteral<"mention">;
410
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<{
411
428
  type: z.ZodLiteral<"database">;
412
429
  database: z.ZodObject<{
413
430
  id: z.ZodUUID;
414
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>;
415
438
  }, z.core.$strip>, z.ZodObject<{
416
439
  type: z.ZodLiteral<"date">;
417
440
  date: z.ZodObject<{
@@ -419,6 +442,11 @@ export declare const pageSchema: z.ZodObject<{
419
442
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
420
443
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
421
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>;
422
450
  }, z.core.$strip>, z.ZodObject<{
423
451
  type: z.ZodLiteral<"link_preview">;
424
452
  link_preview: z.ZodObject<{
@@ -688,10 +716,23 @@ export declare const pageSchema: z.ZodObject<{
688
716
  }, z.core.$strip>, z.ZodObject<{
689
717
  type: z.ZodLiteral<"mention">;
690
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<{
691
726
  type: z.ZodLiteral<"database">;
692
727
  database: z.ZodObject<{
693
728
  id: z.ZodUUID;
694
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>;
695
736
  }, z.core.$strip>, z.ZodObject<{
696
737
  type: z.ZodLiteral<"date">;
697
738
  date: z.ZodObject<{
@@ -699,6 +740,11 @@ export declare const pageSchema: z.ZodObject<{
699
740
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
700
741
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
701
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>;
702
748
  }, z.core.$strip>, z.ZodObject<{
703
749
  type: z.ZodLiteral<"link_preview">;
704
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
@@ -247,6 +247,18 @@ declare const phoneNumberPropertySchema: z.ZodObject<{
247
247
  type: z.ZodLiteral<"phone_number">;
248
248
  phone_number: z.ZodNullable<z.ZodString>;
249
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>;
250
262
  /** Relation property. */
251
263
  declare const relationPropertySchema: z.ZodObject<{
252
264
  id: z.ZodString;
@@ -301,10 +313,23 @@ declare const richTextPropertySchema: z.ZodObject<{
301
313
  }, z.core.$strip>, z.ZodObject<{
302
314
  type: z.ZodLiteral<"mention">;
303
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<{
304
323
  type: z.ZodLiteral<"database">;
305
324
  database: z.ZodObject<{
306
325
  id: z.ZodUUID;
307
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>;
308
333
  }, z.core.$strip>, z.ZodObject<{
309
334
  type: z.ZodLiteral<"date">;
310
335
  date: z.ZodObject<{
@@ -312,6 +337,11 @@ declare const richTextPropertySchema: z.ZodObject<{
312
337
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
313
338
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
314
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>;
315
345
  }, z.core.$strip>, z.ZodObject<{
316
346
  type: z.ZodLiteral<"link_preview">;
317
347
  link_preview: z.ZodObject<{
@@ -589,10 +619,23 @@ declare const titlePropertySchema: z.ZodObject<{
589
619
  }, z.core.$strip>, z.ZodObject<{
590
620
  type: z.ZodLiteral<"mention">;
591
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<{
592
629
  type: z.ZodLiteral<"database">;
593
630
  database: z.ZodObject<{
594
631
  id: z.ZodUUID;
595
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>;
596
639
  }, z.core.$strip>, z.ZodObject<{
597
640
  type: z.ZodLiteral<"date">;
598
641
  date: z.ZodObject<{
@@ -600,6 +643,11 @@ declare const titlePropertySchema: z.ZodObject<{
600
643
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
601
644
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
602
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>;
603
651
  }, z.core.$strip>, z.ZodObject<{
604
652
  type: z.ZodLiteral<"link_preview">;
605
653
  link_preview: z.ZodObject<{
@@ -1004,6 +1052,16 @@ export declare const pagePropertiesSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1004
1052
  id: z.ZodString;
1005
1053
  type: z.ZodLiteral<"phone_number">;
1006
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>>;
1007
1065
  }, z.core.$strip>, z.ZodObject<{
1008
1066
  id: z.ZodString;
1009
1067
  type: z.ZodLiteral<"relation">;
@@ -1055,10 +1113,23 @@ export declare const pagePropertiesSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1055
1113
  }, z.core.$strip>, z.ZodObject<{
1056
1114
  type: z.ZodLiteral<"mention">;
1057
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<{
1058
1123
  type: z.ZodLiteral<"database">;
1059
1124
  database: z.ZodObject<{
1060
1125
  id: z.ZodUUID;
1061
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>;
1062
1133
  }, z.core.$strip>, z.ZodObject<{
1063
1134
  type: z.ZodLiteral<"date">;
1064
1135
  date: z.ZodObject<{
@@ -1066,6 +1137,11 @@ export declare const pagePropertiesSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1066
1137
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
1067
1138
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1068
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>;
1069
1145
  }, z.core.$strip>, z.ZodObject<{
1070
1146
  type: z.ZodLiteral<"link_preview">;
1071
1147
  link_preview: z.ZodObject<{
@@ -1335,10 +1411,23 @@ export declare const pagePropertiesSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1335
1411
  }, z.core.$strip>, z.ZodObject<{
1336
1412
  type: z.ZodLiteral<"mention">;
1337
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<{
1338
1421
  type: z.ZodLiteral<"database">;
1339
1422
  database: z.ZodObject<{
1340
1423
  id: z.ZodUUID;
1341
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>;
1342
1431
  }, z.core.$strip>, z.ZodObject<{
1343
1432
  type: z.ZodLiteral<"date">;
1344
1433
  date: z.ZodObject<{
@@ -1346,6 +1435,11 @@ export declare const pagePropertiesSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
1346
1435
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
1347
1436
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1348
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>;
1349
1443
  }, z.core.$strip>, z.ZodObject<{
1350
1444
  type: z.ZodLiteral<"link_preview">;
1351
1445
  link_preview: z.ZodObject<{
@@ -1585,6 +1679,10 @@ export type PeopleProperty = z.infer<typeof peoplePropertySchema>;
1585
1679
  * @category Page Properties
1586
1680
  */
1587
1681
  export type PhoneNumberProperty = z.infer<typeof phoneNumberPropertySchema>;
1682
+ /**
1683
+ * @category Page Properties
1684
+ */
1685
+ export type PlaceProperty = z.infer<typeof placePropertySchema>;
1588
1686
  /**
1589
1687
  * @category Page Properties
1590
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
@@ -156,6 +156,20 @@ const phoneNumberPropertySchema = z.object({
156
156
  type: z.literal('phone_number'),
157
157
  phone_number: z.string().trim().nullable(),
158
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
+ });
159
173
  /** Relation property. */
160
174
  const relationPropertySchema = z.object({
161
175
  id: z.string().trim(),
@@ -292,6 +306,7 @@ exports.pagePropertiesSchema = z.discriminatedUnion('type', [
292
306
  numberPropertySchema,
293
307
  peoplePropertySchema,
294
308
  phoneNumberPropertySchema,
309
+ placePropertySchema,
295
310
  relationPropertySchema,
296
311
  richTextPropertySchema,
297
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
  ]);
@@ -551,6 +551,16 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
551
551
  id: z.ZodString;
552
552
  type: z.ZodLiteral<"phone_number">;
553
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>>;
554
564
  }, z.core.$strip>, z.ZodObject<{
555
565
  id: z.ZodString;
556
566
  type: z.ZodLiteral<"relation">;
@@ -602,10 +612,23 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
602
612
  }, z.core.$strip>, z.ZodObject<{
603
613
  type: z.ZodLiteral<"mention">;
604
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<{
605
622
  type: z.ZodLiteral<"database">;
606
623
  database: z.ZodObject<{
607
624
  id: z.ZodUUID;
608
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>;
609
632
  }, z.core.$strip>, z.ZodObject<{
610
633
  type: z.ZodLiteral<"date">;
611
634
  date: z.ZodObject<{
@@ -613,6 +636,11 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
613
636
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
614
637
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
615
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>;
616
644
  }, z.core.$strip>, z.ZodObject<{
617
645
  type: z.ZodLiteral<"link_preview">;
618
646
  link_preview: z.ZodObject<{
@@ -882,10 +910,23 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
882
910
  }, z.core.$strip>, z.ZodObject<{
883
911
  type: z.ZodLiteral<"mention">;
884
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<{
885
920
  type: z.ZodLiteral<"database">;
886
921
  database: z.ZodObject<{
887
922
  id: z.ZodUUID;
888
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>;
889
930
  }, z.core.$strip>, z.ZodObject<{
890
931
  type: z.ZodLiteral<"date">;
891
932
  date: z.ZodObject<{
@@ -893,6 +934,11 @@ export declare const viewQueryResponseSchema: z.ZodObject<{
893
934
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
894
935
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
895
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>;
896
942
  }, z.core.$strip>, z.ZodObject<{
897
943
  type: z.ZodLiteral<"link_preview">;
898
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;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NotionValidationError = exports.LIMITS = void 0;
4
4
  exports.validateStringLength = validateStringLength;
5
5
  exports.validateArrayLength = validateArrayLength;
6
+ exports.validateNumberRange = validateNumberRange;
6
7
  /**
7
8
  * Maximum sizes the Notion API allows in a request.
8
9
  *
@@ -86,3 +87,18 @@ function validateArrayLength(array, maxLength, label) {
86
87
  throw new NotionValidationError(`${label} exceeds the ${maxLength}-element limit (got ${array.length})`);
87
88
  }
88
89
  }
90
+ // ---------------------------------------------------------------------------
91
+ // Numeric range validators
92
+ // ---------------------------------------------------------------------------
93
+ /**
94
+ * Assert that a number is within the inclusive range `[min, max]`.
95
+ *
96
+ * @throws {NotionValidationError}
97
+ *
98
+ * @category Client & Core
99
+ */
100
+ function validateNumberRange(value, min, max, label) {
101
+ if (!Number.isFinite(value) || value < min || value > max) {
102
+ throw new NotionValidationError(`${label} must be between ${min} and ${max} (got ${value})`);
103
+ }
104
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visus-io/notion-sdk-ts",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "private": false,
5
5
  "description": "TypeScript SDK for the Notion API",
6
6
  "keywords": [