@visus-io/notion-sdk-ts 3.0.2 → 3.1.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.
- package/README.md +20 -87
- package/dist/api/asyncTasks.api.d.ts +72 -0
- package/dist/api/asyncTasks.api.js +70 -0
- package/dist/api/base.api.d.ts +15 -4
- package/dist/api/base.api.js +20 -8
- package/dist/api/blocks.api.d.ts +435 -73
- package/dist/api/blocks.api.js +43 -1
- package/dist/api/comments.api.d.ts +42 -5
- package/dist/api/comments.api.js +45 -1
- package/dist/api/customEmojis.api.d.ts +38 -0
- package/dist/api/customEmojis.api.js +38 -0
- package/dist/api/dataSources.api.d.ts +67 -14
- package/dist/api/dataSources.api.js +26 -1
- package/dist/api/databases.api.d.ts +47 -11
- package/dist/api/databases.api.js +4 -1
- package/dist/api/fileUploads.api.d.ts +8 -5
- package/dist/api/fileUploads.api.js +11 -7
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +7 -1
- package/dist/api/pages.api.d.ts +144 -10
- package/dist/api/pages.api.js +66 -0
- package/dist/api/search.api.d.ts +12 -2
- package/dist/api/search.api.js +5 -2
- package/dist/api/users.api.d.ts +3 -0
- package/dist/api/users.api.js +2 -0
- package/dist/api/views.api.d.ts +286 -0
- package/dist/api/views.api.js +172 -0
- package/dist/client.d.ts +17 -17
- package/dist/client.js +25 -30
- package/dist/errors.d.ts +19 -5
- package/dist/errors.js +16 -4
- package/dist/helpers/block.helpers.d.ts +49 -5
- package/dist/helpers/block.helpers.js +50 -6
- package/dist/helpers/file.helpers.d.ts +46 -5
- package/dist/helpers/file.helpers.js +36 -8
- package/dist/helpers/filter.helpers.d.ts +8 -6
- package/dist/helpers/filter.helpers.js +2 -0
- package/dist/helpers/index.d.ts +3 -2
- package/dist/helpers/index.js +5 -1
- package/dist/helpers/pagination.helpers.d.ts +85 -13
- package/dist/helpers/pagination.helpers.js +114 -8
- package/dist/helpers/parent.helpers.d.ts +5 -3
- package/dist/helpers/parent.helpers.js +5 -3
- package/dist/helpers/property.helpers.d.ts +31 -0
- package/dist/helpers/property.helpers.js +30 -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 +54 -0
- package/dist/helpers/webhook.helpers.js +83 -0
- package/dist/models/asyncTask.model.d.ts +61 -0
- package/dist/models/asyncTask.model.js +91 -0
- 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 -33
- package/dist/models/comment.model.d.ts +4 -2
- package/dist/models/comment.model.js +4 -2
- package/dist/models/customEmoji.model.d.ts +30 -0
- package/dist/models/customEmoji.model.js +44 -0
- package/dist/models/dataSource.model.d.ts +7 -5
- package/dist/models/dataSource.model.js +5 -3
- package/dist/models/database.model.d.ts +13 -5
- package/dist/models/database.model.js +15 -5
- package/dist/models/fileUpload.model.d.ts +6 -4
- package/dist/models/fileUpload.model.js +6 -4
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.js +7 -1
- package/dist/models/page.model.d.ts +8 -2
- package/dist/models/page.model.js +14 -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 +4 -2
- package/dist/models/user.model.js +4 -2
- package/dist/models/view.model.d.ts +81 -0
- package/dist/models/view.model.js +121 -0
- package/dist/notion.d.ts +32 -8
- package/dist/notion.js +25 -4
- package/dist/schemas/asyncTask.schema.d.ts +53 -0
- package/dist/schemas/asyncTask.schema.js +88 -0
- package/dist/schemas/block.schema.d.ts +390 -73
- package/dist/schemas/block.schema.js +39 -8
- 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 +28 -5
- package/dist/schemas/comment.schema.js +11 -2
- package/dist/schemas/customEmoji.schema.d.ts +18 -0
- package/dist/schemas/customEmoji.schema.js +50 -0
- package/dist/schemas/dataSource.schema.d.ts +84 -10
- package/dist/schemas/dataSource.schema.js +31 -6
- package/dist/schemas/database.schema.d.ts +51 -7
- package/dist/schemas/database.schema.js +10 -3
- 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 +9 -3
- package/dist/schemas/fileUpload.schema.js +5 -2
- package/dist/schemas/icon.schema.d.ts +116 -0
- package/dist/schemas/icon.schema.js +100 -0
- package/dist/schemas/index.d.ts +6 -0
- package/dist/schemas/index.js +6 -0
- package/dist/schemas/meetingNotesQuery.schema.d.ts +4198 -0
- package/dist/schemas/meetingNotesQuery.schema.js +67 -0
- package/dist/schemas/page.schema.d.ts +51 -9
- package/dist/schemas/page.schema.js +6 -2
- package/dist/schemas/pageMarkdown.schema.d.ts +70 -0
- package/dist/schemas/pageMarkdown.schema.js +70 -0
- package/dist/schemas/pageProperties.schema.d.ts +105 -21
- package/dist/schemas/pageProperties.schema.js +8 -6
- package/dist/schemas/pagination.schema.d.ts +57 -7
- package/dist/schemas/pagination.schema.js +25 -1
- package/dist/schemas/parent.schema.d.ts +39 -3
- package/dist/schemas/parent.schema.js +17 -5
- package/dist/schemas/propertyObjects.schema.d.ts +93 -15
- package/dist/schemas/propertyObjects.schema.js +11 -5
- package/dist/schemas/richText.schema.d.ts +23 -6
- package/dist/schemas/richText.schema.js +7 -4
- package/dist/schemas/shared.schema.d.ts +6 -3
- package/dist/schemas/shared.schema.js +6 -3
- package/dist/schemas/user.schema.d.ts +17 -0
- package/dist/schemas/user.schema.js +7 -3
- package/dist/schemas/view.schema.d.ts +1111 -0
- package/dist/schemas/view.schema.js +134 -0
- package/dist/validation.d.ts +11 -4
- package/dist/validation.js +11 -4
- package/package.json +6 -3
|
@@ -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.
|
|
@@ -65,7 +69,7 @@ class Database extends base_model_1.BaseModel {
|
|
|
65
69
|
return this.data.description;
|
|
66
70
|
}
|
|
67
71
|
/**
|
|
68
|
-
* Returns the database icon (file or emoji).
|
|
72
|
+
* Returns the database icon (file, emoji, native icon, or custom emoji).
|
|
69
73
|
*/
|
|
70
74
|
get icon() {
|
|
71
75
|
return this.data.icon;
|
|
@@ -100,6 +104,12 @@ class Database extends base_model_1.BaseModel {
|
|
|
100
104
|
get isInline() {
|
|
101
105
|
return this.data.is_inline;
|
|
102
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Returns whether the database is locked from editing.
|
|
109
|
+
*/
|
|
110
|
+
get isLocked() {
|
|
111
|
+
return this.data.is_locked ?? false;
|
|
112
|
+
}
|
|
103
113
|
/**
|
|
104
114
|
* Returns the public URL if published, otherwise null.
|
|
105
115
|
*/
|
|
@@ -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;
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
export { AsyncTask } from './asyncTask.model';
|
|
1
2
|
export { BaseModel } from './base.model';
|
|
2
3
|
export { Block } from './block.model';
|
|
3
4
|
export { Comment } from './comment.model';
|
|
5
|
+
export { CustomEmoji } from './customEmoji.model';
|
|
4
6
|
export { Database } from './database.model';
|
|
5
7
|
export { DataSource } from './dataSource.model';
|
|
6
8
|
export { FileUpload } from './fileUpload.model';
|
|
7
9
|
export { Page } from './page.model';
|
|
8
10
|
export { RichText } from './richText.model';
|
|
9
11
|
export { User } from './user.model';
|
|
12
|
+
export { View } from './view.model';
|
package/dist/models/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.User = exports.RichText = exports.Page = exports.FileUpload = exports.DataSource = exports.Database = exports.Comment = exports.Block = exports.BaseModel = void 0;
|
|
3
|
+
exports.View = exports.User = exports.RichText = exports.Page = exports.FileUpload = exports.DataSource = exports.Database = exports.CustomEmoji = exports.Comment = exports.Block = exports.BaseModel = exports.AsyncTask = void 0;
|
|
4
|
+
var asyncTask_model_1 = require("./asyncTask.model");
|
|
5
|
+
Object.defineProperty(exports, "AsyncTask", { enumerable: true, get: function () { return asyncTask_model_1.AsyncTask; } });
|
|
4
6
|
var base_model_1 = require("./base.model");
|
|
5
7
|
Object.defineProperty(exports, "BaseModel", { enumerable: true, get: function () { return base_model_1.BaseModel; } });
|
|
6
8
|
var block_model_1 = require("./block.model");
|
|
7
9
|
Object.defineProperty(exports, "Block", { enumerable: true, get: function () { return block_model_1.Block; } });
|
|
8
10
|
var comment_model_1 = require("./comment.model");
|
|
9
11
|
Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return comment_model_1.Comment; } });
|
|
12
|
+
var customEmoji_model_1 = require("./customEmoji.model");
|
|
13
|
+
Object.defineProperty(exports, "CustomEmoji", { enumerable: true, get: function () { return customEmoji_model_1.CustomEmoji; } });
|
|
10
14
|
var database_model_1 = require("./database.model");
|
|
11
15
|
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return database_model_1.Database; } });
|
|
12
16
|
var dataSource_model_1 = require("./dataSource.model");
|
|
@@ -19,3 +23,5 @@ var richText_model_1 = require("./richText.model");
|
|
|
19
23
|
Object.defineProperty(exports, "RichText", { enumerable: true, get: function () { return richText_model_1.RichText; } });
|
|
20
24
|
var user_model_1 = require("./user.model");
|
|
21
25
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_model_1.User; } });
|
|
26
|
+
var view_model_1 = require("./view.model");
|
|
27
|
+
Object.defineProperty(exports, "View", { enumerable: true, get: function () { return view_model_1.View; } });
|
|
@@ -1,15 +1,21 @@
|
|
|
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;
|
|
11
15
|
get lastEditedTime(): Date;
|
|
12
16
|
get inTrash(): boolean;
|
|
17
|
+
get isArchived(): boolean;
|
|
18
|
+
get isLocked(): boolean;
|
|
13
19
|
get url(): string;
|
|
14
20
|
get publicUrl(): string | null;
|
|
15
21
|
get properties(): Record<string, NotionPageProperties>;
|
|
@@ -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,14 +19,22 @@ 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;
|
|
27
31
|
}
|
|
32
|
+
get isArchived() {
|
|
33
|
+
return this.data.is_archived ?? false;
|
|
34
|
+
}
|
|
35
|
+
get isLocked() {
|
|
36
|
+
return this.data.is_locked ?? false;
|
|
37
|
+
}
|
|
28
38
|
get url() {
|
|
29
39
|
return this.data.url;
|
|
30
40
|
}
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { BaseModel, type TRUSTED } from './base.model';
|
|
2
|
+
import { type NotionParent, type NotionUser, type NotionView, type ViewConfiguration, type ViewType } from '../schemas';
|
|
3
|
+
/**
|
|
4
|
+
* View model class with helper methods.
|
|
5
|
+
*
|
|
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
|
|
10
|
+
*/
|
|
11
|
+
export declare class View extends BaseModel<NotionView> {
|
|
12
|
+
constructor(data: NotionView, trusted?: typeof TRUSTED);
|
|
13
|
+
/**
|
|
14
|
+
* Returns "view" - the object type.
|
|
15
|
+
*/
|
|
16
|
+
get object(): 'view';
|
|
17
|
+
/**
|
|
18
|
+
* Returns the view ID.
|
|
19
|
+
*/
|
|
20
|
+
get id(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the parent object (database reference).
|
|
23
|
+
*/
|
|
24
|
+
get parent(): NotionParent;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the data source ID this view belongs to, or null for dashboard views.
|
|
27
|
+
*/
|
|
28
|
+
get dataSourceId(): string | null;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the view name.
|
|
31
|
+
*/
|
|
32
|
+
get name(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the view type, for example table, board, or calendar.
|
|
35
|
+
*/
|
|
36
|
+
get type(): ViewType;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the view's filter, if any.
|
|
39
|
+
*/
|
|
40
|
+
get filter(): Record<string, unknown> | null | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the view's sorts, if any.
|
|
43
|
+
*/
|
|
44
|
+
get sorts(): Record<string, unknown>[] | null | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the view's quick filters, if any.
|
|
47
|
+
*/
|
|
48
|
+
get quickFilters(): Record<string, unknown> | null | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the view's per-layout configuration, if any.
|
|
51
|
+
*/
|
|
52
|
+
get configuration(): ViewConfiguration | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the created time as a Date object.
|
|
55
|
+
*/
|
|
56
|
+
get createdTime(): Date;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the last edited time as a Date object.
|
|
59
|
+
*/
|
|
60
|
+
get lastEditedTime(): Date;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the user who created the view.
|
|
63
|
+
*/
|
|
64
|
+
get createdBy(): NotionUser;
|
|
65
|
+
/**
|
|
66
|
+
* Returns the user who last edited the view.
|
|
67
|
+
*/
|
|
68
|
+
get lastEditedBy(): NotionUser;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the Notion URL of the view.
|
|
71
|
+
*/
|
|
72
|
+
get url(): string;
|
|
73
|
+
/**
|
|
74
|
+
* Returns the widget ID, if a dashboard shows this view as a widget.
|
|
75
|
+
*/
|
|
76
|
+
get dashboardViewId(): string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Returns whether a dashboard shows this view as a widget.
|
|
79
|
+
*/
|
|
80
|
+
isWidgetView(): boolean;
|
|
81
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.View = void 0;
|
|
4
|
+
const base_model_1 = require("./base.model");
|
|
5
|
+
const schemas_1 = require("../schemas");
|
|
6
|
+
/**
|
|
7
|
+
* View model class with helper methods.
|
|
8
|
+
*
|
|
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
|
|
13
|
+
*/
|
|
14
|
+
class View extends base_model_1.BaseModel {
|
|
15
|
+
constructor(data, trusted) {
|
|
16
|
+
super(data, schemas_1.viewSchema, trusted);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns "view" - the object type.
|
|
20
|
+
*/
|
|
21
|
+
get object() {
|
|
22
|
+
return this.data.object;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns the view ID.
|
|
26
|
+
*/
|
|
27
|
+
get id() {
|
|
28
|
+
return this.data.id;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns the parent object (database reference).
|
|
32
|
+
*/
|
|
33
|
+
get parent() {
|
|
34
|
+
return this.data.parent;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Returns the data source ID this view belongs to, or null for dashboard views.
|
|
38
|
+
*/
|
|
39
|
+
get dataSourceId() {
|
|
40
|
+
return this.data.data_source_id;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns the view name.
|
|
44
|
+
*/
|
|
45
|
+
get name() {
|
|
46
|
+
return this.data.name;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns the view type, for example table, board, or calendar.
|
|
50
|
+
*/
|
|
51
|
+
get type() {
|
|
52
|
+
return this.data.type;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns the view's filter, if any.
|
|
56
|
+
*/
|
|
57
|
+
get filter() {
|
|
58
|
+
return this.data.filter;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns the view's sorts, if any.
|
|
62
|
+
*/
|
|
63
|
+
get sorts() {
|
|
64
|
+
return this.data.sorts;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Returns the view's quick filters, if any.
|
|
68
|
+
*/
|
|
69
|
+
get quickFilters() {
|
|
70
|
+
return this.data.quick_filters;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns the view's per-layout configuration, if any.
|
|
74
|
+
*/
|
|
75
|
+
get configuration() {
|
|
76
|
+
return this.data.configuration;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Returns the created time as a Date object.
|
|
80
|
+
*/
|
|
81
|
+
get createdTime() {
|
|
82
|
+
return new Date(this.data.created_time);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns the last edited time as a Date object.
|
|
86
|
+
*/
|
|
87
|
+
get lastEditedTime() {
|
|
88
|
+
return new Date(this.data.last_edited_time);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns the user who created the view.
|
|
92
|
+
*/
|
|
93
|
+
get createdBy() {
|
|
94
|
+
return this.data.created_by;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Returns the user who last edited the view.
|
|
98
|
+
*/
|
|
99
|
+
get lastEditedBy() {
|
|
100
|
+
return this.data.last_edited_by;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns the Notion URL of the view.
|
|
104
|
+
*/
|
|
105
|
+
get url() {
|
|
106
|
+
return this.data.url;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Returns the widget ID, if a dashboard shows this view as a widget.
|
|
110
|
+
*/
|
|
111
|
+
get dashboardViewId() {
|
|
112
|
+
return this.data.dashboard_view_id;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Returns whether a dashboard shows this view as a widget.
|
|
116
|
+
*/
|
|
117
|
+
isWidgetView() {
|
|
118
|
+
return this.data.dashboard_view_id !== undefined;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.View = View;
|
package/dist/notion.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type NotionClientOptions } from './client';
|
|
2
|
-
import { BlocksAPI, CommentsAPI, DatabasesAPI, DataSourcesAPI, FileUploadsAPI, PagesAPI, SearchAPI, UsersAPI } from './api';
|
|
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
|
|
@@ -32,25 +35,46 @@ import { BlocksAPI, CommentsAPI, DatabasesAPI, DataSourcesAPI, FileUploadsAPI, P
|
|
|
32
35
|
* await notion.comments.create({ parent: { page_id: 'page-id' }, rich_text: [...] });
|
|
33
36
|
*
|
|
34
37
|
* const fileUpload = await notion.fileUploads.uploadFile('image.png', buffer, 'image/png');
|
|
38
|
+
*
|
|
39
|
+
* const views = await notion.views.list({ data_source_id: 'data-source-id' });
|
|
40
|
+
* const queryResult = await notion.views.queries.create(views.results[0].id);
|
|
41
|
+
*
|
|
42
|
+
* const markdown = await notion.pages.getMarkdown('page-id');
|
|
43
|
+
* const task = await notion.pages.updateMarkdown('page-id', {
|
|
44
|
+
* type: 'replace_content',
|
|
45
|
+
* new_str: 'Updated content',
|
|
46
|
+
* allow_async: true,
|
|
47
|
+
* });
|
|
48
|
+
* await notion.asyncTasks.poll(task.id);
|
|
49
|
+
*
|
|
50
|
+
* const emojis = await notion.customEmojis.list();
|
|
35
51
|
* ```
|
|
52
|
+
*
|
|
53
|
+
* @category Client & Core
|
|
36
54
|
*/
|
|
37
55
|
export declare class Notion {
|
|
38
56
|
private readonly client;
|
|
39
|
-
/**
|
|
40
|
-
readonly
|
|
57
|
+
/** Async Tasks API for polling long-running Notion operations */
|
|
58
|
+
readonly asyncTasks: AsyncTasksAPI;
|
|
41
59
|
/** Blocks API for working with Notion blocks */
|
|
42
60
|
readonly blocks: BlocksAPI;
|
|
61
|
+
/** Comments API for working with Notion comments */
|
|
62
|
+
readonly comments: CommentsAPI;
|
|
63
|
+
/** Custom Emojis API for listing workspace custom emojis */
|
|
64
|
+
readonly customEmojis: CustomEmojisAPI;
|
|
43
65
|
/** Databases API for working with Notion databases */
|
|
44
66
|
readonly databases: DatabasesAPI;
|
|
45
67
|
/** Data Sources API for working with Notion data sources */
|
|
46
68
|
readonly dataSources: DataSourcesAPI;
|
|
69
|
+
/** FileUploads API for uploading files to Notion */
|
|
70
|
+
readonly fileUploads: FileUploadsAPI;
|
|
71
|
+
/** Pages API for working with Notion pages */
|
|
72
|
+
readonly pages: PagesAPI;
|
|
47
73
|
/** Search API for searching across the workspace */
|
|
48
74
|
readonly search: SearchAPI;
|
|
49
75
|
/** Users API for working with Notion users */
|
|
50
76
|
readonly users: UsersAPI;
|
|
51
|
-
/**
|
|
52
|
-
readonly
|
|
53
|
-
/** FileUploads API for uploading files to Notion */
|
|
54
|
-
readonly fileUploads: FileUploadsAPI;
|
|
77
|
+
/** Views API for working with Notion database/data source views */
|
|
78
|
+
readonly views: ViewsAPI;
|
|
55
79
|
constructor(options: NotionClientOptions);
|
|
56
80
|
}
|
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
|
|
@@ -35,19 +38,37 @@ const api_1 = require("./api");
|
|
|
35
38
|
* await notion.comments.create({ parent: { page_id: 'page-id' }, rich_text: [...] });
|
|
36
39
|
*
|
|
37
40
|
* const fileUpload = await notion.fileUploads.uploadFile('image.png', buffer, 'image/png');
|
|
41
|
+
*
|
|
42
|
+
* const views = await notion.views.list({ data_source_id: 'data-source-id' });
|
|
43
|
+
* const queryResult = await notion.views.queries.create(views.results[0].id);
|
|
44
|
+
*
|
|
45
|
+
* const markdown = await notion.pages.getMarkdown('page-id');
|
|
46
|
+
* const task = await notion.pages.updateMarkdown('page-id', {
|
|
47
|
+
* type: 'replace_content',
|
|
48
|
+
* new_str: 'Updated content',
|
|
49
|
+
* allow_async: true,
|
|
50
|
+
* });
|
|
51
|
+
* await notion.asyncTasks.poll(task.id);
|
|
52
|
+
*
|
|
53
|
+
* const emojis = await notion.customEmojis.list();
|
|
38
54
|
* ```
|
|
55
|
+
*
|
|
56
|
+
* @category Client & Core
|
|
39
57
|
*/
|
|
40
58
|
class Notion {
|
|
41
59
|
constructor(options) {
|
|
42
60
|
this.client = new client_1.NotionClient(options);
|
|
43
|
-
this.
|
|
61
|
+
this.asyncTasks = new api_1.AsyncTasksAPI(this.client);
|
|
44
62
|
this.blocks = new api_1.BlocksAPI(this.client);
|
|
63
|
+
this.comments = new api_1.CommentsAPI(this.client);
|
|
64
|
+
this.customEmojis = new api_1.CustomEmojisAPI(this.client);
|
|
45
65
|
this.databases = new api_1.DatabasesAPI(this.client);
|
|
46
66
|
this.dataSources = new api_1.DataSourcesAPI(this.client);
|
|
67
|
+
this.fileUploads = new api_1.FileUploadsAPI(this.client);
|
|
68
|
+
this.pages = new api_1.PagesAPI(this.client);
|
|
47
69
|
this.search = new api_1.SearchAPI(this.client);
|
|
48
70
|
this.users = new api_1.UsersAPI(this.client);
|
|
49
|
-
this.
|
|
50
|
-
this.fileUploads = new api_1.FileUploadsAPI(this.client);
|
|
71
|
+
this.views = new api_1.ViewsAPI(this.client);
|
|
51
72
|
}
|
|
52
73
|
}
|
|
53
74
|
exports.Notion = Notion;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Async task object schema.
|
|
4
|
+
*
|
|
5
|
+
* Long-running operations (e.g. markdown writes with `allow_async: true`) return an
|
|
6
|
+
* async task handle instead of completing synchronously. Poll `GET /v1/async_tasks/{id}`
|
|
7
|
+
* until the task reaches a terminal status.
|
|
8
|
+
*
|
|
9
|
+
* Notion API reference:
|
|
10
|
+
* https://developers.notion.com/reference/retrieve-async-task
|
|
11
|
+
*
|
|
12
|
+
* @category Async Tasks
|
|
13
|
+
*/
|
|
14
|
+
export declare const ASYNC_TASK_STATUSES: readonly ["queued", "running", "retrying", "succeeded", "failed"];
|
|
15
|
+
/**
|
|
16
|
+
* @category Async Tasks
|
|
17
|
+
*/
|
|
18
|
+
export type AsyncTaskStatus = (typeof ASYNC_TASK_STATUSES)[number];
|
|
19
|
+
/**
|
|
20
|
+
* @category Async Tasks
|
|
21
|
+
*/
|
|
22
|
+
export declare const asyncTaskSchema: z.ZodObject<{
|
|
23
|
+
object: z.ZodLiteral<"async_task">;
|
|
24
|
+
id: z.ZodUUID;
|
|
25
|
+
status: z.ZodEnum<{
|
|
26
|
+
queued: "queued";
|
|
27
|
+
running: "running";
|
|
28
|
+
retrying: "retrying";
|
|
29
|
+
succeeded: "succeeded";
|
|
30
|
+
failed: "failed";
|
|
31
|
+
}>;
|
|
32
|
+
status_url: z.ZodURL;
|
|
33
|
+
created_time: z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODate]>;
|
|
34
|
+
operation: z.ZodObject<{
|
|
35
|
+
surface: z.ZodEnum<{
|
|
36
|
+
rest: "rest";
|
|
37
|
+
mcp: "mcp";
|
|
38
|
+
}>;
|
|
39
|
+
name: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
poll_after_seconds: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
43
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
44
|
+
object: z.ZodLiteral<"error">;
|
|
45
|
+
status: z.ZodNumber;
|
|
46
|
+
code: z.ZodString;
|
|
47
|
+
message: z.ZodString;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
/**
|
|
51
|
+
* @category Async Tasks
|
|
52
|
+
*/
|
|
53
|
+
export type NotionAsyncTask = z.infer<typeof asyncTaskSchema>;
|