@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
@@ -37,7 +37,6 @@ exports.blockSchema = exports.blockPositionSchema = void 0;
37
37
  const z = __importStar(require("zod"));
38
38
  const codeLanguages_1 = require("./codeLanguages");
39
39
  const colors_1 = require("./colors");
40
- const file_schema_1 = require("./file.schema");
41
40
  const icon_schema_1 = require("./icon.schema");
42
41
  const parent_schema_1 = require("./parent.schema");
43
42
  const richText_schema_1 = require("./richText.schema");
@@ -47,7 +46,7 @@ const user_schema_1 = require("./user.schema");
47
46
  * Notion block object schema.
48
47
  *
49
48
  * Blocks are the individual pieces of content that make up pages. Notion supports
50
- * 31 different block types including paragraphs, headings, lists, media, and more.
49
+ * many block types, including paragraphs, headings, lists, media, and more.
51
50
  *
52
51
  * Notion API reference:
53
52
  * https://developers.notion.com/reference/block
@@ -75,6 +74,26 @@ const headingsObjectSchema = z.object({
75
74
  return getChildrenSchema();
76
75
  },
77
76
  });
77
+ /**
78
+ * Content of a media block (`audio`, `image`, `video`, `file`, `pdf`). The file-object
79
+ * body is inlined, so `external` is `{ url }`, not a full nested file object.
80
+ *
81
+ * The `type` field names which body object is present. The schema rejects a value
82
+ * whose `type` has no matching `file`, `external`, or `file_upload` object.
83
+ */
84
+ const mediaBlockContentSchema = z
85
+ .object({
86
+ caption: richText_schema_1.richTextSchema.default([]),
87
+ type: z.enum(['file', 'file_upload', 'external']),
88
+ file: z.object({ url: z.url(), expiry_time: shared_schema_1.notionDateStringSchema }).optional(),
89
+ external: z.object({ url: z.url() }).optional(),
90
+ file_upload: z.object({ id: z.uuid() }).optional(),
91
+ name: z.string().trim().optional(),
92
+ })
93
+ .refine((value) => value[value.type] !== undefined, {
94
+ error: 'A media block must include the file object that matches its `type`.',
95
+ path: ['type'],
96
+ });
78
97
  /**
79
98
  * @category Blocks
80
99
  */
@@ -103,6 +122,7 @@ exports.blockSchema = z.object({
103
122
  'heading_4',
104
123
  'image',
105
124
  'link_preview',
125
+ 'link_to_page',
106
126
  'numbered_list_item',
107
127
  'paragraph',
108
128
  'pdf',
@@ -126,7 +146,7 @@ exports.blockSchema = z.object({
126
146
  in_trash: z.boolean(),
127
147
  has_children: z.boolean(),
128
148
  // Block-specific properties
129
- audio: file_schema_1.fileSchema.optional(),
149
+ audio: mediaBlockContentSchema.optional(),
130
150
  bookmark: z
131
151
  .object({
132
152
  caption: richText_schema_1.richTextSchema,
@@ -197,22 +217,26 @@ exports.blockSchema = z.object({
197
217
  expression: z.string(),
198
218
  })
199
219
  .optional(),
200
- file: z
201
- .object({
202
- caption: richText_schema_1.richTextSchema,
203
- type: z.enum(['file', 'file_upload', 'external']),
204
- file: file_schema_1.fileSchema.optional(),
205
- external: file_schema_1.fileSchema.optional(),
206
- file_upload: file_schema_1.fileSchema.optional(),
207
- name: z.string().trim().optional(),
208
- })
209
- .optional(),
220
+ file: mediaBlockContentSchema.optional(),
210
221
  heading_1: headingsObjectSchema.optional(),
211
222
  heading_2: headingsObjectSchema.optional(),
212
223
  heading_3: headingsObjectSchema.optional(),
213
224
  heading_4: headingsObjectSchema.optional(),
214
- image: file_schema_1.fileSchema.optional(),
225
+ image: mediaBlockContentSchema.optional(),
215
226
  link_preview: z.object({ url: z.url() }).optional(),
227
+ link_to_page: z
228
+ .object({
229
+ type: z.enum(['page_id', 'data_source_id', 'database_id', 'comment_id']),
230
+ page_id: z.uuid().optional(),
231
+ data_source_id: z.uuid().optional(),
232
+ database_id: z.uuid().optional(),
233
+ comment_id: z.uuid().optional(),
234
+ })
235
+ .refine((value) => value[value.type] !== undefined, {
236
+ error: 'A link_to_page block must include the ID field that matches its `type`.',
237
+ path: ['type'],
238
+ })
239
+ .optional(),
216
240
  numbered_list_item: z
217
241
  .object({
218
242
  rich_text: richText_schema_1.richTextSchema,
@@ -234,16 +258,7 @@ exports.blockSchema = z.object({
234
258
  },
235
259
  })
236
260
  .optional(),
237
- pdf: z
238
- .object({
239
- caption: richText_schema_1.richTextSchema,
240
- type: z.enum(['file', 'file_upload', 'external']),
241
- file: file_schema_1.fileSchema.optional(),
242
- external: file_schema_1.fileSchema.optional(),
243
- file_upload: file_schema_1.fileSchema.optional(),
244
- name: z.string().trim().optional(),
245
- })
246
- .optional(),
261
+ pdf: mediaBlockContentSchema.optional(),
247
262
  quote: z
248
263
  .object({
249
264
  rich_text: richText_schema_1.richTextSchema,
@@ -335,5 +350,5 @@ exports.blockSchema = z.object({
335
350
  })
336
351
  .optional(),
337
352
  unsupported: z.object({}).optional(),
338
- video: file_schema_1.fileSchema.optional(),
353
+ video: mediaBlockContentSchema.optional(),
339
354
  });
@@ -138,10 +138,23 @@ export declare const commentSchema: z.ZodObject<{
138
138
  }, z.core.$strip>, z.ZodObject<{
139
139
  type: z.ZodLiteral<"mention">;
140
140
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
141
+ type: z.ZodLiteral<"custom_emoji">;
142
+ custom_emoji: z.ZodObject<{
143
+ id: z.ZodUUID;
144
+ name: z.ZodString;
145
+ url: z.ZodURL;
146
+ }, z.core.$strip>;
147
+ }, z.core.$strip>, z.ZodObject<{
141
148
  type: z.ZodLiteral<"database">;
142
149
  database: z.ZodObject<{
143
150
  id: z.ZodUUID;
144
151
  }, z.core.$strip>;
152
+ }, z.core.$strip>, z.ZodObject<{
153
+ type: z.ZodLiteral<"data_source">;
154
+ data_source: z.ZodObject<{
155
+ id: z.ZodUUID;
156
+ database_id: z.ZodOptional<z.ZodUUID>;
157
+ }, z.core.$strip>;
145
158
  }, z.core.$strip>, z.ZodObject<{
146
159
  type: z.ZodLiteral<"date">;
147
160
  date: z.ZodObject<{
@@ -149,6 +162,11 @@ export declare const commentSchema: z.ZodObject<{
149
162
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
150
163
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
151
164
  }, z.core.$strip>;
165
+ }, z.core.$strip>, z.ZodObject<{
166
+ type: z.ZodLiteral<"link_mention">;
167
+ link_mention: z.ZodObject<{
168
+ href: z.ZodString;
169
+ }, z.core.$loose>;
152
170
  }, z.core.$strip>, z.ZodObject<{
153
171
  type: z.ZodLiteral<"link_preview">;
154
172
  link_preview: z.ZodObject<{
@@ -446,10 +446,23 @@ export declare const dataSourceSchema: z.ZodObject<{
446
446
  }, z.core.$strip>, z.ZodObject<{
447
447
  type: z.ZodLiteral<"mention">;
448
448
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
449
+ type: z.ZodLiteral<"custom_emoji">;
450
+ custom_emoji: z.ZodObject<{
451
+ id: z.ZodUUID;
452
+ name: z.ZodString;
453
+ url: z.ZodURL;
454
+ }, z.core.$strip>;
455
+ }, z.core.$strip>, z.ZodObject<{
449
456
  type: z.ZodLiteral<"database">;
450
457
  database: z.ZodObject<{
451
458
  id: z.ZodUUID;
452
459
  }, z.core.$strip>;
460
+ }, z.core.$strip>, z.ZodObject<{
461
+ type: z.ZodLiteral<"data_source">;
462
+ data_source: z.ZodObject<{
463
+ id: z.ZodUUID;
464
+ database_id: z.ZodOptional<z.ZodUUID>;
465
+ }, z.core.$strip>;
453
466
  }, z.core.$strip>, z.ZodObject<{
454
467
  type: z.ZodLiteral<"date">;
455
468
  date: z.ZodObject<{
@@ -457,6 +470,11 @@ export declare const dataSourceSchema: z.ZodObject<{
457
470
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
458
471
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
459
472
  }, z.core.$strip>;
473
+ }, z.core.$strip>, z.ZodObject<{
474
+ type: z.ZodLiteral<"link_mention">;
475
+ link_mention: z.ZodObject<{
476
+ href: z.ZodString;
477
+ }, z.core.$loose>;
460
478
  }, z.core.$strip>, z.ZodObject<{
461
479
  type: z.ZodLiteral<"link_preview">;
462
480
  link_preview: z.ZodObject<{
@@ -622,10 +640,23 @@ export declare const dataSourceSchema: z.ZodObject<{
622
640
  }, z.core.$strip>, z.ZodObject<{
623
641
  type: z.ZodLiteral<"mention">;
624
642
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
643
+ type: z.ZodLiteral<"custom_emoji">;
644
+ custom_emoji: z.ZodObject<{
645
+ id: z.ZodUUID;
646
+ name: z.ZodString;
647
+ url: z.ZodURL;
648
+ }, z.core.$strip>;
649
+ }, z.core.$strip>, z.ZodObject<{
625
650
  type: z.ZodLiteral<"database">;
626
651
  database: z.ZodObject<{
627
652
  id: z.ZodUUID;
628
653
  }, z.core.$strip>;
654
+ }, z.core.$strip>, z.ZodObject<{
655
+ type: z.ZodLiteral<"data_source">;
656
+ data_source: z.ZodObject<{
657
+ id: z.ZodUUID;
658
+ database_id: z.ZodOptional<z.ZodUUID>;
659
+ }, z.core.$strip>;
629
660
  }, z.core.$strip>, z.ZodObject<{
630
661
  type: z.ZodLiteral<"date">;
631
662
  date: z.ZodObject<{
@@ -633,6 +664,11 @@ export declare const dataSourceSchema: z.ZodObject<{
633
664
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
634
665
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
635
666
  }, z.core.$strip>;
667
+ }, z.core.$strip>, z.ZodObject<{
668
+ type: z.ZodLiteral<"link_mention">;
669
+ link_mention: z.ZodObject<{
670
+ href: z.ZodString;
671
+ }, z.core.$loose>;
636
672
  }, z.core.$strip>, z.ZodObject<{
637
673
  type: z.ZodLiteral<"link_preview">;
638
674
  link_preview: z.ZodObject<{
@@ -822,6 +858,11 @@ export declare const dataSourceSchema: z.ZodObject<{
822
858
  public_url: z.ZodUnion<readonly [z.ZodURL, z.ZodNull]>;
823
859
  is_inline: z.ZodBoolean;
824
860
  in_trash: z.ZodBoolean;
861
+ database_type: z.ZodOptional<z.ZodEnum<{
862
+ tasks: "tasks";
863
+ projects: "projects";
864
+ skills: "skills";
865
+ }>>;
825
866
  }, z.core.$strip>;
826
867
  /**
827
868
  * @category Databases & Data Sources
@@ -42,6 +42,7 @@ const richText_schema_1 = require("./richText.schema");
42
42
  const shared_schema_1 = require("./shared.schema");
43
43
  const user_schema_1 = require("./user.schema");
44
44
  const propertyObjects_schema_1 = require("./propertyObjects.schema");
45
+ const database_schema_1 = require("./database.schema");
45
46
  /**
46
47
  * Notion data source object schema.
47
48
  *
@@ -88,6 +89,8 @@ exports.dataSourceSchema = z.object({
88
89
  is_inline: z.boolean(),
89
90
  /** Whether the data source is in the trash */
90
91
  in_trash: z.boolean(),
92
+ /** Canonical database type this data source's parent database was built from, if any */
93
+ database_type: z.enum(database_schema_1.DATABASE_TYPES).optional(),
91
94
  });
92
95
  /**
93
96
  * A single data source template reference. The List data source templates endpoint
@@ -20,6 +20,19 @@ export declare const dataSourceRefSchema: z.ZodObject<{
20
20
  * @category Databases & Data Sources
21
21
  */
22
22
  export type DataSourceRef = z.infer<typeof dataSourceRefSchema>;
23
+ /**
24
+ * A canonical database type.
25
+ *
26
+ * Pass one of these values as `database_type` when you create a database. Notion builds the
27
+ * database from its schema for that type, not a custom schema.
28
+ *
29
+ * @category Databases & Data Sources
30
+ */
31
+ export declare const DATABASE_TYPES: readonly ["tasks", "projects", "skills"];
32
+ /**
33
+ * @category Databases & Data Sources
34
+ */
35
+ export type DatabaseType = (typeof DATABASE_TYPES)[number];
23
36
  /**
24
37
  * @category Databases & Data Sources
25
38
  */
@@ -139,10 +152,23 @@ export declare const databaseSchema: z.ZodObject<{
139
152
  }, z.core.$strip>, z.ZodObject<{
140
153
  type: z.ZodLiteral<"mention">;
141
154
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
155
+ type: z.ZodLiteral<"custom_emoji">;
156
+ custom_emoji: z.ZodObject<{
157
+ id: z.ZodUUID;
158
+ name: z.ZodString;
159
+ url: z.ZodURL;
160
+ }, z.core.$strip>;
161
+ }, z.core.$strip>, z.ZodObject<{
142
162
  type: z.ZodLiteral<"database">;
143
163
  database: z.ZodObject<{
144
164
  id: z.ZodUUID;
145
165
  }, z.core.$strip>;
166
+ }, z.core.$strip>, z.ZodObject<{
167
+ type: z.ZodLiteral<"data_source">;
168
+ data_source: z.ZodObject<{
169
+ id: z.ZodUUID;
170
+ database_id: z.ZodOptional<z.ZodUUID>;
171
+ }, z.core.$strip>;
146
172
  }, z.core.$strip>, z.ZodObject<{
147
173
  type: z.ZodLiteral<"date">;
148
174
  date: z.ZodObject<{
@@ -150,6 +176,11 @@ export declare const databaseSchema: z.ZodObject<{
150
176
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
151
177
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
152
178
  }, z.core.$strip>;
179
+ }, z.core.$strip>, z.ZodObject<{
180
+ type: z.ZodLiteral<"link_mention">;
181
+ link_mention: z.ZodObject<{
182
+ href: z.ZodString;
183
+ }, z.core.$loose>;
153
184
  }, z.core.$strip>, z.ZodObject<{
154
185
  type: z.ZodLiteral<"link_preview">;
155
186
  link_preview: z.ZodObject<{
@@ -315,10 +346,23 @@ export declare const databaseSchema: z.ZodObject<{
315
346
  }, z.core.$strip>, z.ZodObject<{
316
347
  type: z.ZodLiteral<"mention">;
317
348
  mention: z.ZodDiscriminatedUnion<[z.ZodObject<{
349
+ type: z.ZodLiteral<"custom_emoji">;
350
+ custom_emoji: z.ZodObject<{
351
+ id: z.ZodUUID;
352
+ name: z.ZodString;
353
+ url: z.ZodURL;
354
+ }, z.core.$strip>;
355
+ }, z.core.$strip>, z.ZodObject<{
318
356
  type: z.ZodLiteral<"database">;
319
357
  database: z.ZodObject<{
320
358
  id: z.ZodUUID;
321
359
  }, z.core.$strip>;
360
+ }, z.core.$strip>, z.ZodObject<{
361
+ type: z.ZodLiteral<"data_source">;
362
+ data_source: z.ZodObject<{
363
+ id: z.ZodUUID;
364
+ database_id: z.ZodOptional<z.ZodUUID>;
365
+ }, z.core.$strip>;
322
366
  }, z.core.$strip>, z.ZodObject<{
323
367
  type: z.ZodLiteral<"date">;
324
368
  date: z.ZodObject<{
@@ -326,6 +370,11 @@ export declare const databaseSchema: z.ZodObject<{
326
370
  end: z.ZodNullable<z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>>;
327
371
  time_zone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
328
372
  }, z.core.$strip>;
373
+ }, z.core.$strip>, z.ZodObject<{
374
+ type: z.ZodLiteral<"link_mention">;
375
+ link_mention: z.ZodObject<{
376
+ href: z.ZodString;
377
+ }, z.core.$loose>;
329
378
  }, z.core.$strip>, z.ZodObject<{
330
379
  type: z.ZodLiteral<"link_preview">;
331
380
  link_preview: z.ZodObject<{
@@ -536,6 +585,11 @@ export declare const databaseSchema: z.ZodObject<{
536
585
  is_inline: z.ZodBoolean;
537
586
  is_locked: z.ZodOptional<z.ZodBoolean>;
538
587
  public_url: z.ZodNullable<z.ZodURL>;
588
+ database_type: z.ZodOptional<z.ZodEnum<{
589
+ tasks: "tasks";
590
+ projects: "projects";
591
+ skills: "skills";
592
+ }>>;
539
593
  }, z.core.$strip>;
540
594
  /**
541
595
  * @category Databases & Data Sources
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.databaseSchema = exports.dataSourceRefSchema = void 0;
36
+ exports.databaseSchema = exports.DATABASE_TYPES = exports.dataSourceRefSchema = void 0;
37
37
  const z = __importStar(require("zod"));
38
38
  const file_schema_1 = require("./file.schema");
39
39
  const icon_schema_1 = require("./icon.schema");
@@ -58,6 +58,15 @@ exports.dataSourceRefSchema = z.object({
58
58
  id: z.uuid(),
59
59
  name: z.string().trim(),
60
60
  });
61
+ /**
62
+ * A canonical database type.
63
+ *
64
+ * Pass one of these values as `database_type` when you create a database. Notion builds the
65
+ * database from its schema for that type, not a custom schema.
66
+ *
67
+ * @category Databases & Data Sources
68
+ */
69
+ exports.DATABASE_TYPES = ['tasks', 'projects', 'skills'];
61
70
  /**
62
71
  * @category Databases & Data Sources
63
72
  */
@@ -79,4 +88,5 @@ exports.databaseSchema = z.object({
79
88
  is_inline: z.boolean(),
80
89
  is_locked: z.boolean().optional(),
81
90
  public_url: z.nullable(z.url()),
91
+ database_type: z.enum(exports.DATABASE_TYPES).optional(),
82
92
  });