@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.
- package/README.md +20 -88
- package/dist/api/asyncTasks.api.d.ts +5 -3
- package/dist/api/asyncTasks.api.js +5 -3
- package/dist/api/base.api.d.ts +15 -4
- package/dist/api/base.api.js +19 -8
- package/dist/api/blocks.api.d.ts +2 -0
- package/dist/api/blocks.api.js +5 -2
- package/dist/api/comments.api.d.ts +2 -0
- package/dist/api/comments.api.js +2 -0
- package/dist/api/customEmojis.api.d.ts +2 -0
- package/dist/api/customEmojis.api.js +2 -0
- package/dist/api/dataSources.api.d.ts +10 -3
- package/dist/api/dataSources.api.js +4 -1
- package/dist/api/databases.api.d.ts +21 -8
- package/dist/api/databases.api.js +8 -4
- package/dist/api/fileUploads.api.d.ts +7 -4
- package/dist/api/fileUploads.api.js +11 -7
- package/dist/api/pages.api.d.ts +8 -3
- package/dist/api/pages.api.js +5 -3
- package/dist/api/search.api.d.ts +4 -2
- package/dist/api/search.api.js +5 -2
- package/dist/api/users.api.d.ts +2 -0
- package/dist/api/users.api.js +2 -0
- package/dist/api/views.api.d.ts +15 -13
- package/dist/api/views.api.js +10 -7
- package/dist/client.d.ts +17 -17
- package/dist/client.js +22 -27
- package/dist/errors.d.ts +21 -4
- package/dist/errors.js +17 -4
- package/dist/helpers/block.helpers.d.ts +22 -15
- package/dist/helpers/block.helpers.js +14 -12
- package/dist/helpers/file.helpers.d.ts +12 -6
- package/dist/helpers/file.helpers.js +12 -6
- package/dist/helpers/filter.helpers.d.ts +2 -0
- package/dist/helpers/filter.helpers.js +2 -0
- package/dist/helpers/pagination.helpers.d.ts +52 -36
- package/dist/helpers/pagination.helpers.js +49 -29
- package/dist/helpers/parent.helpers.d.ts +5 -3
- package/dist/helpers/parent.helpers.js +5 -3
- package/dist/helpers/property.helpers.d.ts +2 -0
- package/dist/helpers/property.helpers.js +3 -1
- package/dist/helpers/richText.helpers.d.ts +10 -5
- package/dist/helpers/richText.helpers.js +11 -6
- package/dist/helpers/sort.helpers.d.ts +2 -0
- package/dist/helpers/sort.helpers.js +2 -0
- package/dist/helpers/webhook.helpers.d.ts +14 -12
- package/dist/helpers/webhook.helpers.js +17 -15
- package/dist/models/asyncTask.model.d.ts +8 -6
- package/dist/models/asyncTask.model.js +8 -6
- package/dist/models/base.model.d.ts +16 -4
- package/dist/models/base.model.js +17 -5
- package/dist/models/block.model.d.ts +6 -2
- package/dist/models/block.model.js +48 -36
- package/dist/models/comment.model.d.ts +4 -2
- package/dist/models/comment.model.js +4 -2
- package/dist/models/customEmoji.model.d.ts +7 -5
- package/dist/models/customEmoji.model.js +7 -5
- package/dist/models/dataSource.model.d.ts +10 -3
- package/dist/models/dataSource.model.js +11 -2
- package/dist/models/database.model.d.ts +11 -3
- package/dist/models/database.model.js +14 -4
- package/dist/models/fileUpload.model.d.ts +6 -4
- package/dist/models/fileUpload.model.js +6 -4
- package/dist/models/page.model.d.ts +6 -2
- package/dist/models/page.model.js +8 -4
- package/dist/models/richText.model.d.ts +3 -1
- package/dist/models/richText.model.js +3 -1
- package/dist/models/user.model.d.ts +9 -2
- package/dist/models/user.model.js +14 -2
- package/dist/models/view.model.d.ts +9 -7
- package/dist/models/view.model.js +9 -7
- package/dist/notion.d.ts +6 -1
- package/dist/notion.js +6 -1
- package/dist/schemas/asyncTask.schema.d.ts +11 -0
- package/dist/schemas/asyncTask.schema.js +5 -0
- package/dist/schemas/block.schema.d.ts +12 -1
- package/dist/schemas/block.schema.js +6 -1
- package/dist/schemas/codeLanguages.d.ts +7 -1
- package/dist/schemas/codeLanguages.js +4 -1
- package/dist/schemas/colors.d.ts +7 -1
- package/dist/schemas/colors.js +4 -1
- package/dist/schemas/comment.schema.d.ts +20 -2
- package/dist/schemas/comment.schema.js +11 -2
- package/dist/schemas/customEmoji.schema.d.ts +5 -0
- package/dist/schemas/customEmoji.schema.js +2 -0
- package/dist/schemas/dataSource.schema.d.ts +24 -3
- package/dist/schemas/dataSource.schema.js +15 -5
- package/dist/schemas/database.schema.d.ts +31 -1
- package/dist/schemas/database.schema.js +18 -2
- package/dist/schemas/emoji.schema.d.ts +7 -2
- package/dist/schemas/emoji.schema.js +4 -2
- package/dist/schemas/file.schema.d.ts +18 -2
- package/dist/schemas/file.schema.js +6 -2
- package/dist/schemas/fileUpload.schema.d.ts +8 -2
- package/dist/schemas/fileUpload.schema.js +5 -2
- package/dist/schemas/icon.schema.d.ts +28 -4
- package/dist/schemas/icon.schema.js +16 -4
- package/dist/schemas/meetingNotesQuery.schema.d.ts +13 -2
- package/dist/schemas/meetingNotesQuery.schema.js +7 -2
- package/dist/schemas/page.schema.d.ts +8 -0
- package/dist/schemas/page.schema.js +2 -0
- package/dist/schemas/pageMarkdown.schema.d.ts +15 -4
- package/dist/schemas/pageMarkdown.schema.js +9 -4
- package/dist/schemas/pageProperties.schema.d.ts +81 -3
- package/dist/schemas/pageProperties.schema.js +7 -3
- package/dist/schemas/pagination.schema.d.ts +33 -10
- package/dist/schemas/pagination.schema.js +12 -5
- package/dist/schemas/parent.schema.d.ts +29 -2
- package/dist/schemas/parent.schema.js +8 -2
- package/dist/schemas/propertyObjects.schema.d.ts +81 -3
- package/dist/schemas/propertyObjects.schema.js +11 -5
- package/dist/schemas/richText.schema.d.ts +15 -0
- package/dist/schemas/richText.schema.js +6 -3
- package/dist/schemas/shared.schema.d.ts +6 -3
- package/dist/schemas/shared.schema.js +6 -3
- package/dist/schemas/user.schema.d.ts +15 -0
- package/dist/schemas/user.schema.js +5 -2
- package/dist/schemas/view.schema.d.ts +46 -9
- package/dist/schemas/view.schema.js +28 -9
- package/dist/validation.d.ts +11 -4
- package/dist/validation.js +11 -4
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
43
|
+
* Returns the URL to upload the file.
|
|
42
44
|
*/
|
|
43
45
|
get uploadUrl(): string;
|
|
44
46
|
/**
|
|
45
|
-
* Returns the
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
22
|
+
this.cachedCreatedTimeMs ??= new Date(this.data.created_time).getTime();
|
|
23
|
+
return new Date(this.cachedCreatedTimeMs);
|
|
21
24
|
}
|
|
22
25
|
get lastEditedTime() {
|
|
23
|
-
|
|
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
|
|
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
|
|
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
|
-
*
|
|
7
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
10
|
-
*
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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',
|
package/dist/schemas/colors.d.ts
CHANGED
|
@@ -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];
|
package/dist/schemas/colors.js
CHANGED
|
@@ -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>;
|