@visus-io/notion-sdk-ts 3.1.0 → 3.2.0

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 (122) hide show
  1. package/README.md +20 -88
  2. package/dist/api/asyncTasks.api.d.ts +5 -3
  3. package/dist/api/asyncTasks.api.js +5 -3
  4. package/dist/api/base.api.d.ts +15 -4
  5. package/dist/api/base.api.js +19 -8
  6. package/dist/api/blocks.api.d.ts +2 -0
  7. package/dist/api/blocks.api.js +5 -2
  8. package/dist/api/comments.api.d.ts +2 -0
  9. package/dist/api/comments.api.js +2 -0
  10. package/dist/api/customEmojis.api.d.ts +2 -0
  11. package/dist/api/customEmojis.api.js +2 -0
  12. package/dist/api/dataSources.api.d.ts +10 -3
  13. package/dist/api/dataSources.api.js +4 -1
  14. package/dist/api/databases.api.d.ts +21 -8
  15. package/dist/api/databases.api.js +8 -4
  16. package/dist/api/fileUploads.api.d.ts +7 -4
  17. package/dist/api/fileUploads.api.js +11 -7
  18. package/dist/api/pages.api.d.ts +8 -3
  19. package/dist/api/pages.api.js +5 -3
  20. package/dist/api/search.api.d.ts +4 -2
  21. package/dist/api/search.api.js +5 -2
  22. package/dist/api/users.api.d.ts +2 -0
  23. package/dist/api/users.api.js +2 -0
  24. package/dist/api/views.api.d.ts +15 -13
  25. package/dist/api/views.api.js +10 -7
  26. package/dist/client.d.ts +17 -17
  27. package/dist/client.js +22 -27
  28. package/dist/errors.d.ts +21 -4
  29. package/dist/errors.js +17 -4
  30. package/dist/helpers/block.helpers.d.ts +22 -15
  31. package/dist/helpers/block.helpers.js +14 -12
  32. package/dist/helpers/file.helpers.d.ts +12 -6
  33. package/dist/helpers/file.helpers.js +12 -6
  34. package/dist/helpers/filter.helpers.d.ts +2 -0
  35. package/dist/helpers/filter.helpers.js +2 -0
  36. package/dist/helpers/pagination.helpers.d.ts +52 -36
  37. package/dist/helpers/pagination.helpers.js +49 -29
  38. package/dist/helpers/parent.helpers.d.ts +5 -3
  39. package/dist/helpers/parent.helpers.js +5 -3
  40. package/dist/helpers/property.helpers.d.ts +2 -0
  41. package/dist/helpers/property.helpers.js +3 -1
  42. package/dist/helpers/richText.helpers.d.ts +10 -5
  43. package/dist/helpers/richText.helpers.js +11 -6
  44. package/dist/helpers/sort.helpers.d.ts +2 -0
  45. package/dist/helpers/sort.helpers.js +2 -0
  46. package/dist/helpers/webhook.helpers.d.ts +14 -12
  47. package/dist/helpers/webhook.helpers.js +17 -15
  48. package/dist/models/asyncTask.model.d.ts +8 -6
  49. package/dist/models/asyncTask.model.js +8 -6
  50. package/dist/models/base.model.d.ts +16 -4
  51. package/dist/models/base.model.js +17 -5
  52. package/dist/models/block.model.d.ts +6 -2
  53. package/dist/models/block.model.js +48 -36
  54. package/dist/models/comment.model.d.ts +4 -2
  55. package/dist/models/comment.model.js +4 -2
  56. package/dist/models/customEmoji.model.d.ts +7 -5
  57. package/dist/models/customEmoji.model.js +7 -5
  58. package/dist/models/dataSource.model.d.ts +10 -3
  59. package/dist/models/dataSource.model.js +11 -2
  60. package/dist/models/database.model.d.ts +11 -3
  61. package/dist/models/database.model.js +14 -4
  62. package/dist/models/fileUpload.model.d.ts +6 -4
  63. package/dist/models/fileUpload.model.js +6 -4
  64. package/dist/models/page.model.d.ts +6 -2
  65. package/dist/models/page.model.js +8 -4
  66. package/dist/models/richText.model.d.ts +3 -1
  67. package/dist/models/richText.model.js +3 -1
  68. package/dist/models/user.model.d.ts +9 -2
  69. package/dist/models/user.model.js +14 -2
  70. package/dist/models/view.model.d.ts +9 -7
  71. package/dist/models/view.model.js +9 -7
  72. package/dist/notion.d.ts +6 -1
  73. package/dist/notion.js +6 -1
  74. package/dist/schemas/asyncTask.schema.d.ts +11 -0
  75. package/dist/schemas/asyncTask.schema.js +5 -0
  76. package/dist/schemas/block.schema.d.ts +12 -1
  77. package/dist/schemas/block.schema.js +6 -1
  78. package/dist/schemas/codeLanguages.d.ts +7 -1
  79. package/dist/schemas/codeLanguages.js +4 -1
  80. package/dist/schemas/colors.d.ts +7 -1
  81. package/dist/schemas/colors.js +4 -1
  82. package/dist/schemas/comment.schema.d.ts +20 -2
  83. package/dist/schemas/comment.schema.js +11 -2
  84. package/dist/schemas/customEmoji.schema.d.ts +5 -0
  85. package/dist/schemas/customEmoji.schema.js +2 -0
  86. package/dist/schemas/dataSource.schema.d.ts +24 -3
  87. package/dist/schemas/dataSource.schema.js +15 -5
  88. package/dist/schemas/database.schema.d.ts +31 -1
  89. package/dist/schemas/database.schema.js +18 -2
  90. package/dist/schemas/emoji.schema.d.ts +7 -2
  91. package/dist/schemas/emoji.schema.js +4 -2
  92. package/dist/schemas/file.schema.d.ts +18 -2
  93. package/dist/schemas/file.schema.js +6 -2
  94. package/dist/schemas/fileUpload.schema.d.ts +8 -2
  95. package/dist/schemas/fileUpload.schema.js +5 -2
  96. package/dist/schemas/icon.schema.d.ts +28 -4
  97. package/dist/schemas/icon.schema.js +16 -4
  98. package/dist/schemas/meetingNotesQuery.schema.d.ts +13 -2
  99. package/dist/schemas/meetingNotesQuery.schema.js +7 -2
  100. package/dist/schemas/page.schema.d.ts +8 -0
  101. package/dist/schemas/page.schema.js +2 -0
  102. package/dist/schemas/pageMarkdown.schema.d.ts +15 -4
  103. package/dist/schemas/pageMarkdown.schema.js +9 -4
  104. package/dist/schemas/pageProperties.schema.d.ts +81 -3
  105. package/dist/schemas/pageProperties.schema.js +7 -3
  106. package/dist/schemas/pagination.schema.d.ts +33 -10
  107. package/dist/schemas/pagination.schema.js +12 -5
  108. package/dist/schemas/parent.schema.d.ts +29 -2
  109. package/dist/schemas/parent.schema.js +8 -2
  110. package/dist/schemas/propertyObjects.schema.d.ts +81 -3
  111. package/dist/schemas/propertyObjects.schema.js +11 -5
  112. package/dist/schemas/richText.schema.d.ts +15 -0
  113. package/dist/schemas/richText.schema.js +6 -3
  114. package/dist/schemas/shared.schema.d.ts +6 -3
  115. package/dist/schemas/shared.schema.js +6 -3
  116. package/dist/schemas/user.schema.d.ts +15 -0
  117. package/dist/schemas/user.schema.js +5 -2
  118. package/dist/schemas/view.schema.d.ts +46 -9
  119. package/dist/schemas/view.schema.js +28 -9
  120. package/dist/validation.d.ts +11 -4
  121. package/dist/validation.js +11 -4
  122. package/package.json +20 -16
@@ -1,12 +1,14 @@
1
- import { BaseModel } from './base.model';
2
- import { type NotionDataSource, type NotionFile, type NotionIcon, type NotionParent, type NotionPropertiesObject, type NotionPropertyObject, type NotionRichText, type NotionUser } from '../schemas';
1
+ import { BaseModel, type TRUSTED } from './base.model';
2
+ import { type DatabaseType, type NotionDataSource, type NotionFile, type NotionIcon, type NotionParent, type NotionPropertiesObject, type NotionPropertyObject, type NotionRichText, type NotionUser } from '../schemas';
3
3
  /**
4
4
  * Data Source model class with helper methods.
5
5
  *
6
6
  * Data sources are individual tables of data that live under a Notion database.
7
+ *
8
+ * @category Databases & Data Sources
7
9
  */
8
10
  export declare class DataSource extends BaseModel<NotionDataSource> {
9
- constructor(data: NotionDataSource);
11
+ constructor(data: NotionDataSource, trusted?: typeof TRUSTED);
10
12
  /**
11
13
  * Returns "data_source" - the object type.
12
14
  */
@@ -75,6 +77,11 @@ export declare class DataSource extends BaseModel<NotionDataSource> {
75
77
  * Returns whether the data source is in trash.
76
78
  */
77
79
  get inTrash(): boolean;
80
+ /**
81
+ * Returns the canonical database type this data source's parent database was built from,
82
+ * if any.
83
+ */
84
+ get databaseType(): DatabaseType | undefined;
78
85
  /**
79
86
  * Extracts the plain text title from the data source.
80
87
  */
@@ -7,10 +7,12 @@ const schemas_1 = require("../schemas");
7
7
  * Data Source model class with helper methods.
8
8
  *
9
9
  * Data sources are individual tables of data that live under a Notion database.
10
+ *
11
+ * @category Databases & Data Sources
10
12
  */
11
13
  class DataSource extends base_model_1.BaseModel {
12
- constructor(data) {
13
- super(data, schemas_1.dataSourceSchema);
14
+ constructor(data, trusted) {
15
+ super(data, schemas_1.dataSourceSchema, trusted);
14
16
  }
15
17
  /**
16
18
  * Returns "data_source" - the object type.
@@ -114,6 +116,13 @@ class DataSource extends base_model_1.BaseModel {
114
116
  get inTrash() {
115
117
  return this.data.in_trash;
116
118
  }
119
+ /**
120
+ * Returns the canonical database type this data source's parent database was built from,
121
+ * if any.
122
+ */
123
+ get databaseType() {
124
+ return this.data.database_type;
125
+ }
117
126
  /**
118
127
  * Extracts the plain text title from the data source.
119
128
  */
@@ -1,10 +1,14 @@
1
- import { BaseModel } from './base.model';
2
- import { type DataSourceRef, type NotionDatabase, type NotionFile, type NotionIcon, type NotionParent, type NotionRichText, type NotionUser } from '../schemas';
1
+ import { BaseModel, type TRUSTED } from './base.model';
2
+ import { type DatabaseType, type DataSourceRef, type NotionDatabase, type NotionFile, type NotionIcon, type NotionParent, type NotionRichText, type NotionUser } from '../schemas';
3
3
  /**
4
4
  * Database model class with helper methods.
5
+ *
6
+ * @category Databases & Data Sources
5
7
  */
6
8
  export declare class Database extends BaseModel<NotionDatabase> {
7
- constructor(data: NotionDatabase);
9
+ private cachedCreatedTimeMs?;
10
+ private cachedLastEditedTimeMs?;
11
+ constructor(data: NotionDatabase, trusted?: typeof TRUSTED);
8
12
  /**
9
13
  * Returns "database" - the object type.
10
14
  */
@@ -73,6 +77,10 @@ export declare class Database extends BaseModel<NotionDatabase> {
73
77
  * Returns the public URL if published, otherwise null.
74
78
  */
75
79
  get publicUrl(): string | null;
80
+ /**
81
+ * Returns the canonical database type this database was built from, if any.
82
+ */
83
+ get databaseType(): DatabaseType | undefined;
76
84
  /**
77
85
  * Extracts the plain text title from the database.
78
86
  */
@@ -5,10 +5,12 @@ const base_model_1 = require("./base.model");
5
5
  const schemas_1 = require("../schemas");
6
6
  /**
7
7
  * Database model class with helper methods.
8
+ *
9
+ * @category Databases & Data Sources
8
10
  */
9
11
  class Database extends base_model_1.BaseModel {
10
- constructor(data) {
11
- super(data, schemas_1.databaseSchema);
12
+ constructor(data, trusted) {
13
+ super(data, schemas_1.databaseSchema, trusted);
12
14
  }
13
15
  /**
14
16
  * Returns "database" - the object type.
@@ -32,7 +34,8 @@ class Database extends base_model_1.BaseModel {
32
34
  * Returns the created time as a Date object.
33
35
  */
34
36
  get createdTime() {
35
- return new Date(this.data.created_time);
37
+ this.cachedCreatedTimeMs ??= new Date(this.data.created_time).getTime();
38
+ return new Date(this.cachedCreatedTimeMs);
36
39
  }
37
40
  /**
38
41
  * Returns the user who created the database.
@@ -44,7 +47,8 @@ class Database extends base_model_1.BaseModel {
44
47
  * Returns the last edited time as a Date object.
45
48
  */
46
49
  get lastEditedTime() {
47
- return new Date(this.data.last_edited_time);
50
+ this.cachedLastEditedTimeMs ??= new Date(this.data.last_edited_time).getTime();
51
+ return new Date(this.cachedLastEditedTimeMs);
48
52
  }
49
53
  /**
50
54
  * Returns the user who last edited the database.
@@ -112,6 +116,12 @@ class Database extends base_model_1.BaseModel {
112
116
  get publicUrl() {
113
117
  return this.data.public_url;
114
118
  }
119
+ /**
120
+ * Returns the canonical database type this database was built from, if any.
121
+ */
122
+ get databaseType() {
123
+ return this.data.database_type;
124
+ }
115
125
  /**
116
126
  * Extracts the plain text title from the database.
117
127
  */
@@ -1,10 +1,12 @@
1
- import { BaseModel } from './base.model';
1
+ import { BaseModel, type TRUSTED } from './base.model';
2
2
  import { type NotionFileUpload } from '../schemas';
3
3
  /**
4
4
  * FileUpload model class with helper methods.
5
+ *
6
+ * @category File Uploads
5
7
  */
6
8
  export declare class FileUpload extends BaseModel<NotionFileUpload> {
7
- constructor(data: NotionFileUpload);
9
+ constructor(data: NotionFileUpload, trusted?: typeof TRUSTED);
8
10
  /**
9
11
  * Returns "file_upload" - the object type.
10
12
  */
@@ -38,11 +40,11 @@ export declare class FileUpload extends BaseModel<NotionFileUpload> {
38
40
  */
39
41
  get contentLength(): number | null;
40
42
  /**
41
- * Returns the upload URL for uploading the file.
43
+ * Returns the URL to upload the file.
42
44
  */
43
45
  get uploadUrl(): string;
44
46
  /**
45
- * Returns the complete URL for finalizing the upload.
47
+ * Returns the URL to complete the upload.
46
48
  */
47
49
  get completeUrl(): string;
48
50
  /**
@@ -5,10 +5,12 @@ const base_model_1 = require("./base.model");
5
5
  const schemas_1 = require("../schemas");
6
6
  /**
7
7
  * FileUpload model class with helper methods.
8
+ *
9
+ * @category File Uploads
8
10
  */
9
11
  class FileUpload extends base_model_1.BaseModel {
10
- constructor(data) {
11
- super(data, schemas_1.fileUploadSchema);
12
+ constructor(data, trusted) {
13
+ super(data, schemas_1.fileUploadSchema, trusted);
12
14
  }
13
15
  /**
14
16
  * Returns "file_upload" - the object type.
@@ -59,13 +61,13 @@ class FileUpload extends base_model_1.BaseModel {
59
61
  return this.data.content_length;
60
62
  }
61
63
  /**
62
- * Returns the upload URL for uploading the file.
64
+ * Returns the URL to upload the file.
63
65
  */
64
66
  get uploadUrl() {
65
67
  return this.data.upload_url;
66
68
  }
67
69
  /**
68
- * Returns the complete URL for finalizing the upload.
70
+ * Returns the URL to complete the upload.
69
71
  */
70
72
  get completeUrl() {
71
73
  return this.data.complete_url;
@@ -1,10 +1,14 @@
1
- import { BaseModel } from './base.model';
1
+ import { BaseModel, type TRUSTED } from './base.model';
2
2
  import { type NotionPage, type NotionPageProperties } from '../schemas';
3
3
  /**
4
4
  * Page model wrapping a validated Notion page object with helper methods.
5
+ *
6
+ * @category Pages
5
7
  */
6
8
  export declare class Page extends BaseModel<NotionPage> {
7
- constructor(data: unknown);
9
+ private cachedCreatedTimeMs?;
10
+ private cachedLastEditedTimeMs?;
11
+ constructor(data: unknown, trusted?: typeof TRUSTED);
8
12
  get object(): string;
9
13
  get id(): string;
10
14
  get createdTime(): Date;
@@ -5,10 +5,12 @@ const base_model_1 = require("./base.model");
5
5
  const schemas_1 = require("../schemas");
6
6
  /**
7
7
  * Page model wrapping a validated Notion page object with helper methods.
8
+ *
9
+ * @category Pages
8
10
  */
9
11
  class Page extends base_model_1.BaseModel {
10
- constructor(data) {
11
- super(data, schemas_1.pageSchema);
12
+ constructor(data, trusted) {
13
+ super(data, schemas_1.pageSchema, trusted);
12
14
  }
13
15
  get object() {
14
16
  return this.data.object;
@@ -17,10 +19,12 @@ class Page extends base_model_1.BaseModel {
17
19
  return this.data.id;
18
20
  }
19
21
  get createdTime() {
20
- return new Date(this.data.created_time);
22
+ this.cachedCreatedTimeMs ??= new Date(this.data.created_time).getTime();
23
+ return new Date(this.cachedCreatedTimeMs);
21
24
  }
22
25
  get lastEditedTime() {
23
- return new Date(this.data.last_edited_time);
26
+ this.cachedLastEditedTimeMs ??= new Date(this.data.last_edited_time).getTime();
27
+ return new Date(this.cachedLastEditedTimeMs);
24
28
  }
25
29
  get inTrash() {
26
30
  return this.data.in_trash;
@@ -1,6 +1,8 @@
1
1
  import { type NotionRichText } from '../schemas';
2
2
  /**
3
- * RichText helper class for working with Notion rich text arrays.
3
+ * RichText helper class to work with Notion rich text arrays.
4
+ *
5
+ * @category Rich Text
4
6
  */
5
7
  export declare class RichText {
6
8
  private readonly data;
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RichText = void 0;
4
4
  const schemas_1 = require("../schemas");
5
5
  /**
6
- * RichText helper class for working with Notion rich text arrays.
6
+ * RichText helper class to work with Notion rich text arrays.
7
+ *
8
+ * @category Rich Text
7
9
  */
8
10
  class RichText {
9
11
  constructor(data) {
@@ -1,10 +1,12 @@
1
- import { BaseModel } from './base.model';
1
+ import { BaseModel, type TRUSTED } from './base.model';
2
2
  import { type BotUser, type NotionUser, type PersonUser } from '../schemas';
3
3
  /**
4
4
  * User model wrapping a validated Notion user object with helper methods.
5
+ *
6
+ * @category Users
5
7
  */
6
8
  export declare class User extends BaseModel<NotionUser> {
7
- constructor(data: unknown);
9
+ constructor(data: unknown, trusted?: typeof TRUSTED);
8
10
  get object(): string;
9
11
  get id(): string;
10
12
  get type(): 'person' | 'bot' | undefined;
@@ -26,6 +28,11 @@ export declare class User extends BaseModel<NotionUser> {
26
28
  * Get email if this is a person user.
27
29
  */
28
30
  getEmail(): string | undefined;
31
+ /**
32
+ * Get the person's email verification status.
33
+ * Returns `undefined` when the user is not a person.
34
+ */
35
+ getEmailVerified(): boolean | undefined;
29
36
  /**
30
37
  * Get bot information if this is a bot user.
31
38
  */
@@ -5,10 +5,12 @@ const base_model_1 = require("./base.model");
5
5
  const schemas_1 = require("../schemas");
6
6
  /**
7
7
  * User model wrapping a validated Notion user object with helper methods.
8
+ *
9
+ * @category Users
8
10
  */
9
11
  class User extends base_model_1.BaseModel {
10
- constructor(data) {
11
- super(data, schemas_1.userSchema);
12
+ constructor(data, trusted) {
13
+ super(data, schemas_1.userSchema, trusted);
12
14
  }
13
15
  get object() {
14
16
  return this.data.object;
@@ -46,6 +48,16 @@ class User extends base_model_1.BaseModel {
46
48
  }
47
49
  return undefined;
48
50
  }
51
+ /**
52
+ * Get the person's email verification status.
53
+ * Returns `undefined` when the user is not a person.
54
+ */
55
+ getEmailVerified() {
56
+ if (this.isPerson()) {
57
+ return this.data.person.email_verified;
58
+ }
59
+ return undefined;
60
+ }
49
61
  /**
50
62
  * Get bot information if this is a bot user.
51
63
  */
@@ -1,13 +1,15 @@
1
- import { BaseModel } from './base.model';
1
+ import { BaseModel, type TRUSTED } from './base.model';
2
2
  import { type NotionParent, type NotionUser, type NotionView, type ViewConfiguration, type ViewType } from '../schemas';
3
3
  /**
4
4
  * View model class with helper methods.
5
5
  *
6
- * Views control how a database/data source's rows are displayed (table, board,
7
- * calendar, etc.).
6
+ * A view controls how a database or data source shows its rows, for example as a
7
+ * table, board, or calendar.
8
+ *
9
+ * @category Views
8
10
  */
9
11
  export declare class View extends BaseModel<NotionView> {
10
- constructor(data: NotionView);
12
+ constructor(data: NotionView, trusted?: typeof TRUSTED);
11
13
  /**
12
14
  * Returns "view" - the object type.
13
15
  */
@@ -29,7 +31,7 @@ export declare class View extends BaseModel<NotionView> {
29
31
  */
30
32
  get name(): string;
31
33
  /**
32
- * Returns the view type (table, board, calendar, etc.).
34
+ * Returns the view type, for example table, board, or calendar.
33
35
  */
34
36
  get type(): ViewType;
35
37
  /**
@@ -69,11 +71,11 @@ export declare class View extends BaseModel<NotionView> {
69
71
  */
70
72
  get url(): string;
71
73
  /**
72
- * Returns the dashboard widget ID, if this view is a widget on a dashboard.
74
+ * Returns the widget ID, if a dashboard shows this view as a widget.
73
75
  */
74
76
  get dashboardViewId(): string | undefined;
75
77
  /**
76
- * Returns whether this view is a widget view embedded in a dashboard.
78
+ * Returns whether a dashboard shows this view as a widget.
77
79
  */
78
80
  isWidgetView(): boolean;
79
81
  }
@@ -6,12 +6,14 @@ const schemas_1 = require("../schemas");
6
6
  /**
7
7
  * View model class with helper methods.
8
8
  *
9
- * Views control how a database/data source's rows are displayed (table, board,
10
- * calendar, etc.).
9
+ * A view controls how a database or data source shows its rows, for example as a
10
+ * table, board, or calendar.
11
+ *
12
+ * @category Views
11
13
  */
12
14
  class View extends base_model_1.BaseModel {
13
- constructor(data) {
14
- super(data, schemas_1.viewSchema);
15
+ constructor(data, trusted) {
16
+ super(data, schemas_1.viewSchema, trusted);
15
17
  }
16
18
  /**
17
19
  * Returns "view" - the object type.
@@ -44,7 +46,7 @@ class View extends base_model_1.BaseModel {
44
46
  return this.data.name;
45
47
  }
46
48
  /**
47
- * Returns the view type (table, board, calendar, etc.).
49
+ * Returns the view type, for example table, board, or calendar.
48
50
  */
49
51
  get type() {
50
52
  return this.data.type;
@@ -104,13 +106,13 @@ class View extends base_model_1.BaseModel {
104
106
  return this.data.url;
105
107
  }
106
108
  /**
107
- * Returns the dashboard widget ID, if this view is a widget on a dashboard.
109
+ * Returns the widget ID, if a dashboard shows this view as a widget.
108
110
  */
109
111
  get dashboardViewId() {
110
112
  return this.data.dashboard_view_id;
111
113
  }
112
114
  /**
113
- * Returns whether this view is a widget view embedded in a dashboard.
115
+ * Returns whether a dashboard shows this view as a widget.
114
116
  */
115
117
  isWidgetView() {
116
118
  return this.data.dashboard_view_id !== undefined;
package/dist/notion.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import { type NotionClientOptions } from './client';
2
2
  import { AsyncTasksAPI, BlocksAPI, CommentsAPI, CustomEmojisAPI, DatabasesAPI, DataSourcesAPI, FileUploadsAPI, PagesAPI, SearchAPI, UsersAPI, ViewsAPI } from './api';
3
3
  /**
4
- * Main Notion SDK class.
4
+ * The public entry point for the SDK.
5
+ *
6
+ * Create one `Notion` instance, then call its API properties, such as
7
+ * `pages` or `blocks`, to reach Notion endpoints.
5
8
  *
6
9
  * @example
7
10
  * ```typescript
@@ -46,6 +49,8 @@ import { AsyncTasksAPI, BlocksAPI, CommentsAPI, CustomEmojisAPI, DatabasesAPI, D
46
49
  *
47
50
  * const emojis = await notion.customEmojis.list();
48
51
  * ```
52
+ *
53
+ * @category Client & Core
49
54
  */
50
55
  export declare class Notion {
51
56
  private readonly client;
package/dist/notion.js CHANGED
@@ -4,7 +4,10 @@ exports.Notion = void 0;
4
4
  const client_1 = require("./client");
5
5
  const api_1 = require("./api");
6
6
  /**
7
- * Main Notion SDK class.
7
+ * The public entry point for the SDK.
8
+ *
9
+ * Create one `Notion` instance, then call its API properties, such as
10
+ * `pages` or `blocks`, to reach Notion endpoints.
8
11
  *
9
12
  * @example
10
13
  * ```typescript
@@ -49,6 +52,8 @@ const api_1 = require("./api");
49
52
  *
50
53
  * const emojis = await notion.customEmojis.list();
51
54
  * ```
55
+ *
56
+ * @category Client & Core
52
57
  */
53
58
  class Notion {
54
59
  constructor(options) {
@@ -8,9 +8,17 @@ import * as z from 'zod';
8
8
  *
9
9
  * Notion API reference:
10
10
  * https://developers.notion.com/reference/retrieve-async-task
11
+ *
12
+ * @category Async Tasks
11
13
  */
12
14
  export declare const ASYNC_TASK_STATUSES: readonly ["queued", "running", "retrying", "succeeded", "failed"];
15
+ /**
16
+ * @category Async Tasks
17
+ */
13
18
  export type AsyncTaskStatus = (typeof ASYNC_TASK_STATUSES)[number];
19
+ /**
20
+ * @category Async Tasks
21
+ */
14
22
  export declare const asyncTaskSchema: z.ZodObject<{
15
23
  object: z.ZodLiteral<"async_task">;
16
24
  id: z.ZodUUID;
@@ -39,4 +47,7 @@ export declare const asyncTaskSchema: z.ZodObject<{
39
47
  message: z.ZodString;
40
48
  }, z.core.$strip>>;
41
49
  }, z.core.$strip>;
50
+ /**
51
+ * @category Async Tasks
52
+ */
42
53
  export type NotionAsyncTask = z.infer<typeof asyncTaskSchema>;
@@ -45,6 +45,8 @@ const shared_schema_1 = require("./shared.schema");
45
45
  *
46
46
  * Notion API reference:
47
47
  * https://developers.notion.com/reference/retrieve-async-task
48
+ *
49
+ * @category Async Tasks
48
50
  */
49
51
  exports.ASYNC_TASK_STATUSES = [
50
52
  'queued',
@@ -66,6 +68,9 @@ const asyncTaskErrorSchema = z.object({
66
68
  code: z.string().trim(),
67
69
  message: z.string().trim(),
68
70
  });
71
+ /**
72
+ * @category Async Tasks
73
+ */
69
74
  exports.asyncTaskSchema = z.object({
70
75
  object: z.literal('async_task'),
71
76
  id: z.uuid(),
@@ -1,6 +1,8 @@
1
1
  import * as z from 'zod';
2
2
  /**
3
- * Position for inserting block children in the Append Block Children endpoint.
3
+ * Position to insert block children in the Append Block Children endpoint.
4
+ *
5
+ * @category Blocks
4
6
  */
5
7
  export declare const blockPositionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
6
8
  type: z.ZodLiteral<"after_block">;
@@ -12,7 +14,13 @@ export declare const blockPositionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
12
14
  }, z.core.$strip>, z.ZodObject<{
13
15
  type: z.ZodLiteral<"end">;
14
16
  }, z.core.$strip>], "type">;
17
+ /**
18
+ * @category Blocks
19
+ */
15
20
  export type BlockPosition = z.infer<typeof blockPositionSchema>;
21
+ /**
22
+ * @category Blocks
23
+ */
16
24
  export declare const blockSchema: z.ZodObject<{
17
25
  object: z.ZodLiteral<"block">;
18
26
  id: z.ZodUUID;
@@ -4177,4 +4185,7 @@ export declare const blockSchema: z.ZodObject<{
4177
4185
  }, z.core.$strip>;
4178
4186
  }, z.core.$strip>], "type">>;
4179
4187
  }, z.core.$strip>;
4188
+ /**
4189
+ * @category Blocks
4190
+ */
4180
4191
  export type NotionBlock = z.infer<typeof blockSchema>;
@@ -58,7 +58,9 @@ const getChildrenSchema = () => {
58
58
  return childrenSchema;
59
59
  };
60
60
  /**
61
- * Position for inserting block children in the Append Block Children endpoint.
61
+ * Position to insert block children in the Append Block Children endpoint.
62
+ *
63
+ * @category Blocks
62
64
  */
63
65
  exports.blockPositionSchema = z.discriminatedUnion('type', [
64
66
  z.object({ type: z.literal('after_block'), after_block: z.object({ id: z.uuid() }) }),
@@ -73,6 +75,9 @@ const headingsObjectSchema = z.object({
73
75
  return getChildrenSchema();
74
76
  },
75
77
  });
78
+ /**
79
+ * @category Blocks
80
+ */
76
81
  exports.blockSchema = z.object({
77
82
  object: z.literal('block'),
78
83
  id: z.uuid(),
@@ -1,3 +1,9 @@
1
- /** All programming languages supported by Notion code blocks. */
1
+ /** All programming languages supported by Notion code blocks.
2
+ *
3
+ * @category Blocks
4
+ */
2
5
  export declare const CODE_BLOCK_LANGUAGES: readonly ["abap", "arduino", "bash", "basic", "c", "clojure", "coffeescript", "c++", "c#", "css", "dart", "diff", "docker", "elixir", "elm", "erlang", "flow", "fortran", "f#", "gherkin", "glsl", "go", "graphql", "groovy", "haskell", "html", "java", "javascript", "json", "julia", "kotlin", "latex", "less", "lisp", "livescript", "lua", "makefile", "markdown", "markup", "matlab", "mermaid", "nix", "objective-c", "ocaml", "pascal", "perl", "php", "plain text", "powershell", "prolog", "protobuf", "python", "r", "reason", "ruby", "rust", "sass", "scala", "scheme", "scss", "shell", "sql", "swift", "typescript", "vb.net", "verilog", "vhdl", "visual basic", "webassembly", "xml", "yaml", "java/c/c++/c#"];
6
+ /**
7
+ * @category Blocks
8
+ */
3
9
  export type CodeBlockLanguage = (typeof CODE_BLOCK_LANGUAGES)[number];
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CODE_BLOCK_LANGUAGES = void 0;
4
- /** All programming languages supported by Notion code blocks. */
4
+ /** All programming languages supported by Notion code blocks.
5
+ *
6
+ * @category Blocks
7
+ */
5
8
  exports.CODE_BLOCK_LANGUAGES = [
6
9
  'abap',
7
10
  'arduino',
@@ -1,3 +1,9 @@
1
- /** All color options supported by Notion. */
1
+ /** All color options supported by Notion.
2
+ *
3
+ * @category Shared Types
4
+ */
2
5
  export declare const NOTION_COLORS: readonly ["blue", "blue_background", "brown", "brown_background", "default", "gray", "gray_background", "green", "green_background", "orange", "orange_background", "pink", "pink_background", "purple", "purple_background", "red", "red_background", "yellow", "yellow_background"];
6
+ /**
7
+ * @category Shared Types
8
+ */
3
9
  export type NotionColor = (typeof NOTION_COLORS)[number];
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NOTION_COLORS = void 0;
4
- /** All color options supported by Notion. */
4
+ /** All color options supported by Notion.
5
+ *
6
+ * @category Shared Types
7
+ */
5
8
  exports.NOTION_COLORS = [
6
9
  'blue',
7
10
  'blue_background',
@@ -1,5 +1,8 @@
1
1
  import * as z from 'zod';
2
- /** Comment attachment schema. */
2
+ /** Comment attachment schema.
3
+ *
4
+ * @category Comments
5
+ */
3
6
  export declare const commentAttachmentSchema: z.ZodObject<{
4
7
  category: z.ZodEnum<{
5
8
  file: "file";
@@ -13,8 +16,14 @@ export declare const commentAttachmentSchema: z.ZodObject<{
13
16
  expiry_time: z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>;
14
17
  }, z.core.$strip>;
15
18
  }, z.core.$strip>;
19
+ /**
20
+ * @category Comments
21
+ */
16
22
  export type CommentAttachment = z.infer<typeof commentAttachmentSchema>;
17
- /** Comment display name schema (user or custom). */
23
+ /** Comment display name schema (user or custom).
24
+ *
25
+ * @category Comments
26
+ */
18
27
  export declare const commentDisplayNameSchema: z.ZodUnion<readonly [z.ZodObject<{
19
28
  type: z.ZodLiteral<"user">;
20
29
  resolved_name: z.ZodString;
@@ -22,7 +31,13 @@ export declare const commentDisplayNameSchema: z.ZodUnion<readonly [z.ZodObject<
22
31
  type: z.ZodLiteral<"custom">;
23
32
  resolved_name: z.ZodString;
24
33
  }, z.core.$strip>]>;
34
+ /**
35
+ * @category Comments
36
+ */
25
37
  export type CommentDisplayName = z.infer<typeof commentDisplayNameSchema>;
38
+ /**
39
+ * @category Comments
40
+ */
26
41
  export declare const commentSchema: z.ZodObject<{
27
42
  object: z.ZodLiteral<"comment">;
28
43
  id: z.ZodUUID;
@@ -279,4 +294,7 @@ export declare const commentSchema: z.ZodObject<{
279
294
  resolved_name: z.ZodString;
280
295
  }, z.core.$strip>]>>;
281
296
  }, z.core.$strip>;
297
+ /**
298
+ * @category Comments
299
+ */
282
300
  export type NotionComment = z.infer<typeof commentSchema>;