@visus-io/notion-sdk-ts 3.0.2 → 3.1.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 +7 -6
- package/dist/api/asyncTasks.api.d.ts +70 -0
- package/dist/api/asyncTasks.api.js +68 -0
- package/dist/api/base.api.js +1 -0
- package/dist/api/blocks.api.d.ts +433 -73
- package/dist/api/blocks.api.js +39 -0
- package/dist/api/comments.api.d.ts +40 -5
- package/dist/api/comments.api.js +43 -1
- package/dist/api/customEmojis.api.d.ts +36 -0
- package/dist/api/customEmojis.api.js +36 -0
- package/dist/api/dataSources.api.d.ts +62 -11
- package/dist/api/dataSources.api.js +22 -0
- package/dist/api/databases.api.d.ts +40 -6
- package/dist/api/fileUploads.api.d.ts +1 -1
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +7 -1
- package/dist/api/pages.api.d.ts +142 -10
- package/dist/api/pages.api.js +64 -0
- package/dist/api/search.api.d.ts +10 -2
- package/dist/api/users.api.d.ts +1 -0
- package/dist/api/views.api.d.ts +284 -0
- package/dist/api/views.api.js +169 -0
- package/dist/client.js +3 -3
- package/dist/errors.d.ts +5 -1
- package/dist/errors.js +6 -0
- package/dist/helpers/block.helpers.d.ts +38 -1
- package/dist/helpers/block.helpers.js +45 -3
- package/dist/helpers/file.helpers.d.ts +36 -1
- package/dist/helpers/file.helpers.js +26 -4
- package/dist/helpers/filter.helpers.d.ts +6 -6
- package/dist/helpers/index.d.ts +3 -2
- package/dist/helpers/index.js +5 -1
- package/dist/helpers/pagination.helpers.d.ts +56 -0
- package/dist/helpers/pagination.helpers.js +86 -0
- package/dist/helpers/property.helpers.d.ts +29 -0
- package/dist/helpers/property.helpers.js +27 -0
- package/dist/helpers/webhook.helpers.d.ts +52 -0
- package/dist/helpers/webhook.helpers.js +81 -0
- package/dist/models/asyncTask.model.d.ts +59 -0
- package/dist/models/asyncTask.model.js +89 -0
- package/dist/models/block.model.js +4 -1
- package/dist/models/customEmoji.model.d.ts +28 -0
- package/dist/models/customEmoji.model.js +42 -0
- package/dist/models/dataSource.model.d.ts +3 -3
- package/dist/models/dataSource.model.js +1 -1
- package/dist/models/database.model.d.ts +7 -3
- package/dist/models/database.model.js +7 -1
- package/dist/models/index.d.ts +3 -0
- package/dist/models/index.js +7 -1
- package/dist/models/page.model.d.ts +2 -0
- package/dist/models/page.model.js +6 -0
- package/dist/models/view.model.d.ts +79 -0
- package/dist/models/view.model.js +119 -0
- package/dist/notion.d.ts +26 -7
- package/dist/notion.js +19 -3
- package/dist/schemas/asyncTask.schema.d.ts +42 -0
- package/dist/schemas/asyncTask.schema.js +83 -0
- package/dist/schemas/block.schema.d.ts +378 -72
- package/dist/schemas/block.schema.js +33 -7
- package/dist/schemas/comment.schema.d.ts +8 -3
- package/dist/schemas/customEmoji.schema.d.ts +13 -0
- package/dist/schemas/customEmoji.schema.js +48 -0
- package/dist/schemas/dataSource.schema.d.ts +68 -10
- package/dist/schemas/dataSource.schema.js +22 -4
- package/dist/schemas/database.schema.d.ts +38 -6
- package/dist/schemas/database.schema.js +3 -2
- package/dist/schemas/fileUpload.schema.d.ts +1 -1
- package/dist/schemas/icon.schema.d.ts +92 -0
- package/dist/schemas/icon.schema.js +88 -0
- package/dist/schemas/index.d.ts +6 -0
- package/dist/schemas/index.js +6 -0
- package/dist/schemas/meetingNotesQuery.schema.d.ts +4187 -0
- package/dist/schemas/meetingNotesQuery.schema.js +62 -0
- package/dist/schemas/page.schema.d.ts +46 -9
- package/dist/schemas/page.schema.js +4 -2
- package/dist/schemas/pageMarkdown.schema.d.ts +59 -0
- package/dist/schemas/pageMarkdown.schema.js +65 -0
- package/dist/schemas/pageProperties.schema.d.ts +30 -18
- package/dist/schemas/pageProperties.schema.js +2 -3
- package/dist/schemas/pagination.schema.d.ts +30 -3
- package/dist/schemas/pagination.schema.js +18 -1
- package/dist/schemas/parent.schema.d.ts +10 -1
- package/dist/schemas/parent.schema.js +9 -3
- package/dist/schemas/propertyObjects.schema.d.ts +12 -12
- package/dist/schemas/richText.schema.d.ts +8 -6
- package/dist/schemas/richText.schema.js +1 -1
- package/dist/schemas/user.schema.d.ts +2 -0
- package/dist/schemas/user.schema.js +2 -1
- package/dist/schemas/view.schema.d.ts +1077 -0
- package/dist/schemas/view.schema.js +115 -0
- package/package.json +2 -2
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BaseModel } from './base.model';
|
|
2
|
+
import { type NotionAsyncTask } from '../schemas';
|
|
3
|
+
/**
|
|
4
|
+
* Async Task model class with helper methods.
|
|
5
|
+
*
|
|
6
|
+
* Represents a long-running operation (e.g. an async markdown write) that must be
|
|
7
|
+
* polled until it reaches a terminal status.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AsyncTask extends BaseModel<NotionAsyncTask> {
|
|
10
|
+
constructor(data: NotionAsyncTask);
|
|
11
|
+
/**
|
|
12
|
+
* Returns "async_task" - the object type.
|
|
13
|
+
*/
|
|
14
|
+
get object(): 'async_task';
|
|
15
|
+
/**
|
|
16
|
+
* Returns the task ID.
|
|
17
|
+
*/
|
|
18
|
+
get id(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the task status.
|
|
21
|
+
*/
|
|
22
|
+
get status(): NotionAsyncTask['status'];
|
|
23
|
+
/**
|
|
24
|
+
* Returns the URL that can be polled for task status.
|
|
25
|
+
*/
|
|
26
|
+
get statusUrl(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the task creation time as a Date object.
|
|
29
|
+
*/
|
|
30
|
+
get createdTime(): Date;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the operation that created this task.
|
|
33
|
+
*/
|
|
34
|
+
get operation(): NotionAsyncTask['operation'];
|
|
35
|
+
/**
|
|
36
|
+
* Returns the minimum number of seconds to wait before polling again, if provided.
|
|
37
|
+
*/
|
|
38
|
+
get pollAfterSeconds(): number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the operation-specific result, present only when the task succeeded.
|
|
41
|
+
*/
|
|
42
|
+
get result(): unknown;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the error details, present only when the task failed.
|
|
45
|
+
*/
|
|
46
|
+
get error(): NotionAsyncTask['error'];
|
|
47
|
+
/**
|
|
48
|
+
* Returns whether the task completed successfully.
|
|
49
|
+
*/
|
|
50
|
+
isSucceeded(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Returns whether the task failed.
|
|
53
|
+
*/
|
|
54
|
+
isFailed(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Returns whether the task has reached a terminal status (succeeded or failed).
|
|
57
|
+
*/
|
|
58
|
+
isTerminal(): boolean;
|
|
59
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AsyncTask = void 0;
|
|
4
|
+
const base_model_1 = require("./base.model");
|
|
5
|
+
const schemas_1 = require("../schemas");
|
|
6
|
+
/**
|
|
7
|
+
* Async Task model class with helper methods.
|
|
8
|
+
*
|
|
9
|
+
* Represents a long-running operation (e.g. an async markdown write) that must be
|
|
10
|
+
* polled until it reaches a terminal status.
|
|
11
|
+
*/
|
|
12
|
+
class AsyncTask extends base_model_1.BaseModel {
|
|
13
|
+
constructor(data) {
|
|
14
|
+
super(data, schemas_1.asyncTaskSchema);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns "async_task" - the object type.
|
|
18
|
+
*/
|
|
19
|
+
get object() {
|
|
20
|
+
return this.data.object;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the task ID.
|
|
24
|
+
*/
|
|
25
|
+
get id() {
|
|
26
|
+
return this.data.id;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns the task status.
|
|
30
|
+
*/
|
|
31
|
+
get status() {
|
|
32
|
+
return this.data.status;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns the URL that can be polled for task status.
|
|
36
|
+
*/
|
|
37
|
+
get statusUrl() {
|
|
38
|
+
return this.data.status_url;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns the task creation time as a Date object.
|
|
42
|
+
*/
|
|
43
|
+
get createdTime() {
|
|
44
|
+
return new Date(this.data.created_time);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns the operation that created this task.
|
|
48
|
+
*/
|
|
49
|
+
get operation() {
|
|
50
|
+
return this.data.operation;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns the minimum number of seconds to wait before polling again, if provided.
|
|
54
|
+
*/
|
|
55
|
+
get pollAfterSeconds() {
|
|
56
|
+
return this.data.poll_after_seconds;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns the operation-specific result, present only when the task succeeded.
|
|
60
|
+
*/
|
|
61
|
+
get result() {
|
|
62
|
+
return this.data.result;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns the error details, present only when the task failed.
|
|
66
|
+
*/
|
|
67
|
+
get error() {
|
|
68
|
+
return this.data.error;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns whether the task completed successfully.
|
|
72
|
+
*/
|
|
73
|
+
isSucceeded() {
|
|
74
|
+
return this.data.status === 'succeeded';
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns whether the task failed.
|
|
78
|
+
*/
|
|
79
|
+
isFailed() {
|
|
80
|
+
return this.data.status === 'failed';
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns whether the task has reached a terminal status (succeeded or failed).
|
|
84
|
+
*/
|
|
85
|
+
isTerminal() {
|
|
86
|
+
return this.isSucceeded() || this.isFailed();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.AsyncTask = AsyncTask;
|
|
@@ -40,6 +40,7 @@ class Block extends base_model_1.BaseModel {
|
|
|
40
40
|
'heading_1',
|
|
41
41
|
'heading_2',
|
|
42
42
|
'heading_3',
|
|
43
|
+
'heading_4',
|
|
43
44
|
'quote',
|
|
44
45
|
'callout',
|
|
45
46
|
'bulleted_list_item',
|
|
@@ -52,7 +53,7 @@ class Block extends base_model_1.BaseModel {
|
|
|
52
53
|
* Check if this is a heading block.
|
|
53
54
|
*/
|
|
54
55
|
isHeading() {
|
|
55
|
-
return ['heading_1', 'heading_2', 'heading_3'].includes(this.data.type);
|
|
56
|
+
return ['heading_1', 'heading_2', 'heading_3', 'heading_4'].includes(this.data.type);
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
59
|
* Check if this block can contain children.
|
|
@@ -63,6 +64,7 @@ class Block extends base_model_1.BaseModel {
|
|
|
63
64
|
'heading_1',
|
|
64
65
|
'heading_2',
|
|
65
66
|
'heading_3',
|
|
67
|
+
'heading_4',
|
|
66
68
|
'bulleted_list_item',
|
|
67
69
|
'numbered_list_item',
|
|
68
70
|
'to_do',
|
|
@@ -72,6 +74,7 @@ class Block extends base_model_1.BaseModel {
|
|
|
72
74
|
'synced_block',
|
|
73
75
|
'column',
|
|
74
76
|
'column_list',
|
|
77
|
+
'tab',
|
|
75
78
|
'table',
|
|
76
79
|
].includes(this.data.type);
|
|
77
80
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { BaseModel } from './base.model';
|
|
2
|
+
import { type NotionCustomEmoji } from '../schemas';
|
|
3
|
+
/**
|
|
4
|
+
* Custom Emoji model class with helper methods.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CustomEmoji extends BaseModel<NotionCustomEmoji> {
|
|
7
|
+
constructor(data: NotionCustomEmoji);
|
|
8
|
+
/**
|
|
9
|
+
* Returns "custom_emoji" - the object type.
|
|
10
|
+
*
|
|
11
|
+
* Note: individual custom emoji list items have no `object` field of their own in
|
|
12
|
+
* the API response (only the paginated list wrapper does) -- this getter is
|
|
13
|
+
* synthetic, not sourced from the payload, to satisfy {@link BaseModel}'s contract.
|
|
14
|
+
*/
|
|
15
|
+
get object(): 'custom_emoji';
|
|
16
|
+
/**
|
|
17
|
+
* Returns the custom emoji ID.
|
|
18
|
+
*/
|
|
19
|
+
get id(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Returns the custom emoji name.
|
|
22
|
+
*/
|
|
23
|
+
get name(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the custom emoji's image URL.
|
|
26
|
+
*/
|
|
27
|
+
get url(): string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomEmoji = void 0;
|
|
4
|
+
const base_model_1 = require("./base.model");
|
|
5
|
+
const schemas_1 = require("../schemas");
|
|
6
|
+
/**
|
|
7
|
+
* Custom Emoji model class with helper methods.
|
|
8
|
+
*/
|
|
9
|
+
class CustomEmoji extends base_model_1.BaseModel {
|
|
10
|
+
constructor(data) {
|
|
11
|
+
super(data, schemas_1.customEmojiSchema);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Returns "custom_emoji" - the object type.
|
|
15
|
+
*
|
|
16
|
+
* Note: individual custom emoji list items have no `object` field of their own in
|
|
17
|
+
* the API response (only the paginated list wrapper does) -- this getter is
|
|
18
|
+
* synthetic, not sourced from the payload, to satisfy {@link BaseModel}'s contract.
|
|
19
|
+
*/
|
|
20
|
+
get object() {
|
|
21
|
+
return 'custom_emoji';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns the custom emoji ID.
|
|
25
|
+
*/
|
|
26
|
+
get id() {
|
|
27
|
+
return this.data.id;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the custom emoji name.
|
|
31
|
+
*/
|
|
32
|
+
get name() {
|
|
33
|
+
return this.data.name;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns the custom emoji's image URL.
|
|
37
|
+
*/
|
|
38
|
+
get url() {
|
|
39
|
+
return this.data.url;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.CustomEmoji = CustomEmoji;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseModel } from './base.model';
|
|
2
|
-
import { type NotionDataSource, type
|
|
2
|
+
import { 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
|
*
|
|
@@ -52,9 +52,9 @@ export declare class DataSource extends BaseModel<NotionDataSource> {
|
|
|
52
52
|
*/
|
|
53
53
|
get description(): NotionRichText;
|
|
54
54
|
/**
|
|
55
|
-
* Returns the data source icon (file or emoji).
|
|
55
|
+
* Returns the data source icon (file, emoji, native icon, or custom emoji).
|
|
56
56
|
*/
|
|
57
|
-
get icon():
|
|
57
|
+
get icon(): NotionIcon | null;
|
|
58
58
|
/**
|
|
59
59
|
* Returns the data source cover image.
|
|
60
60
|
*/
|
|
@@ -79,7 +79,7 @@ class DataSource extends base_model_1.BaseModel {
|
|
|
79
79
|
return this.data.description;
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* Returns the data source icon (file or emoji).
|
|
82
|
+
* Returns the data source icon (file, emoji, native icon, or custom emoji).
|
|
83
83
|
*/
|
|
84
84
|
get icon() {
|
|
85
85
|
return this.data.icon;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseModel } from './base.model';
|
|
2
|
-
import { type DataSourceRef, type NotionDatabase, type
|
|
2
|
+
import { 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
5
|
*/
|
|
@@ -42,9 +42,9 @@ export declare class Database extends BaseModel<NotionDatabase> {
|
|
|
42
42
|
*/
|
|
43
43
|
get description(): NotionRichText;
|
|
44
44
|
/**
|
|
45
|
-
* Returns the database icon (file or emoji).
|
|
45
|
+
* Returns the database icon (file, emoji, native icon, or custom emoji).
|
|
46
46
|
*/
|
|
47
|
-
get icon():
|
|
47
|
+
get icon(): NotionIcon | null;
|
|
48
48
|
/**
|
|
49
49
|
* Returns the database cover image.
|
|
50
50
|
*/
|
|
@@ -65,6 +65,10 @@ export declare class Database extends BaseModel<NotionDatabase> {
|
|
|
65
65
|
* Returns whether the database is inline.
|
|
66
66
|
*/
|
|
67
67
|
get isInline(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Returns whether the database is locked from editing.
|
|
70
|
+
*/
|
|
71
|
+
get isLocked(): boolean;
|
|
68
72
|
/**
|
|
69
73
|
* Returns the public URL if published, otherwise null.
|
|
70
74
|
*/
|
|
@@ -65,7 +65,7 @@ class Database extends base_model_1.BaseModel {
|
|
|
65
65
|
return this.data.description;
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
* Returns the database icon (file or emoji).
|
|
68
|
+
* Returns the database icon (file, emoji, native icon, or custom emoji).
|
|
69
69
|
*/
|
|
70
70
|
get icon() {
|
|
71
71
|
return this.data.icon;
|
|
@@ -100,6 +100,12 @@ class Database extends base_model_1.BaseModel {
|
|
|
100
100
|
get isInline() {
|
|
101
101
|
return this.data.is_inline;
|
|
102
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns whether the database is locked from editing.
|
|
105
|
+
*/
|
|
106
|
+
get isLocked() {
|
|
107
|
+
return this.data.is_locked ?? false;
|
|
108
|
+
}
|
|
103
109
|
/**
|
|
104
110
|
* Returns the public URL if published, otherwise null.
|
|
105
111
|
*/
|
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; } });
|
|
@@ -10,6 +10,8 @@ export declare class Page extends BaseModel<NotionPage> {
|
|
|
10
10
|
get createdTime(): Date;
|
|
11
11
|
get lastEditedTime(): Date;
|
|
12
12
|
get inTrash(): boolean;
|
|
13
|
+
get isArchived(): boolean;
|
|
14
|
+
get isLocked(): boolean;
|
|
13
15
|
get url(): string;
|
|
14
16
|
get publicUrl(): string | null;
|
|
15
17
|
get properties(): Record<string, NotionPageProperties>;
|
|
@@ -25,6 +25,12 @@ class Page extends base_model_1.BaseModel {
|
|
|
25
25
|
get inTrash() {
|
|
26
26
|
return this.data.in_trash;
|
|
27
27
|
}
|
|
28
|
+
get isArchived() {
|
|
29
|
+
return this.data.is_archived ?? false;
|
|
30
|
+
}
|
|
31
|
+
get isLocked() {
|
|
32
|
+
return this.data.is_locked ?? false;
|
|
33
|
+
}
|
|
28
34
|
get url() {
|
|
29
35
|
return this.data.url;
|
|
30
36
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { BaseModel } 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
|
+
* Views control how a database/data source's rows are displayed (table, board,
|
|
7
|
+
* calendar, etc.).
|
|
8
|
+
*/
|
|
9
|
+
export declare class View extends BaseModel<NotionView> {
|
|
10
|
+
constructor(data: NotionView);
|
|
11
|
+
/**
|
|
12
|
+
* Returns "view" - the object type.
|
|
13
|
+
*/
|
|
14
|
+
get object(): 'view';
|
|
15
|
+
/**
|
|
16
|
+
* Returns the view ID.
|
|
17
|
+
*/
|
|
18
|
+
get id(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the parent object (database reference).
|
|
21
|
+
*/
|
|
22
|
+
get parent(): NotionParent;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the data source ID this view belongs to, or null for dashboard views.
|
|
25
|
+
*/
|
|
26
|
+
get dataSourceId(): string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the view name.
|
|
29
|
+
*/
|
|
30
|
+
get name(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the view type (table, board, calendar, etc.).
|
|
33
|
+
*/
|
|
34
|
+
get type(): ViewType;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the view's filter, if any.
|
|
37
|
+
*/
|
|
38
|
+
get filter(): Record<string, unknown> | null | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the view's sorts, if any.
|
|
41
|
+
*/
|
|
42
|
+
get sorts(): Record<string, unknown>[] | null | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Returns the view's quick filters, if any.
|
|
45
|
+
*/
|
|
46
|
+
get quickFilters(): Record<string, unknown> | null | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the view's per-layout configuration, if any.
|
|
49
|
+
*/
|
|
50
|
+
get configuration(): ViewConfiguration | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Returns the created time as a Date object.
|
|
53
|
+
*/
|
|
54
|
+
get createdTime(): Date;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the last edited time as a Date object.
|
|
57
|
+
*/
|
|
58
|
+
get lastEditedTime(): Date;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the user who created the view.
|
|
61
|
+
*/
|
|
62
|
+
get createdBy(): NotionUser;
|
|
63
|
+
/**
|
|
64
|
+
* Returns the user who last edited the view.
|
|
65
|
+
*/
|
|
66
|
+
get lastEditedBy(): NotionUser;
|
|
67
|
+
/**
|
|
68
|
+
* Returns the Notion URL of the view.
|
|
69
|
+
*/
|
|
70
|
+
get url(): string;
|
|
71
|
+
/**
|
|
72
|
+
* Returns the dashboard widget ID, if this view is a widget on a dashboard.
|
|
73
|
+
*/
|
|
74
|
+
get dashboardViewId(): string | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Returns whether this view is a widget view embedded in a dashboard.
|
|
77
|
+
*/
|
|
78
|
+
isWidgetView(): boolean;
|
|
79
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
* Views control how a database/data source's rows are displayed (table, board,
|
|
10
|
+
* calendar, etc.).
|
|
11
|
+
*/
|
|
12
|
+
class View extends base_model_1.BaseModel {
|
|
13
|
+
constructor(data) {
|
|
14
|
+
super(data, schemas_1.viewSchema);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns "view" - the object type.
|
|
18
|
+
*/
|
|
19
|
+
get object() {
|
|
20
|
+
return this.data.object;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the view ID.
|
|
24
|
+
*/
|
|
25
|
+
get id() {
|
|
26
|
+
return this.data.id;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns the parent object (database reference).
|
|
30
|
+
*/
|
|
31
|
+
get parent() {
|
|
32
|
+
return this.data.parent;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns the data source ID this view belongs to, or null for dashboard views.
|
|
36
|
+
*/
|
|
37
|
+
get dataSourceId() {
|
|
38
|
+
return this.data.data_source_id;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Returns the view name.
|
|
42
|
+
*/
|
|
43
|
+
get name() {
|
|
44
|
+
return this.data.name;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Returns the view type (table, board, calendar, etc.).
|
|
48
|
+
*/
|
|
49
|
+
get type() {
|
|
50
|
+
return this.data.type;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Returns the view's filter, if any.
|
|
54
|
+
*/
|
|
55
|
+
get filter() {
|
|
56
|
+
return this.data.filter;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Returns the view's sorts, if any.
|
|
60
|
+
*/
|
|
61
|
+
get sorts() {
|
|
62
|
+
return this.data.sorts;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns the view's quick filters, if any.
|
|
66
|
+
*/
|
|
67
|
+
get quickFilters() {
|
|
68
|
+
return this.data.quick_filters;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns the view's per-layout configuration, if any.
|
|
72
|
+
*/
|
|
73
|
+
get configuration() {
|
|
74
|
+
return this.data.configuration;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns the created time as a Date object.
|
|
78
|
+
*/
|
|
79
|
+
get createdTime() {
|
|
80
|
+
return new Date(this.data.created_time);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returns the last edited time as a Date object.
|
|
84
|
+
*/
|
|
85
|
+
get lastEditedTime() {
|
|
86
|
+
return new Date(this.data.last_edited_time);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns the user who created the view.
|
|
90
|
+
*/
|
|
91
|
+
get createdBy() {
|
|
92
|
+
return this.data.created_by;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Returns the user who last edited the view.
|
|
96
|
+
*/
|
|
97
|
+
get lastEditedBy() {
|
|
98
|
+
return this.data.last_edited_by;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Returns the Notion URL of the view.
|
|
102
|
+
*/
|
|
103
|
+
get url() {
|
|
104
|
+
return this.data.url;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Returns the dashboard widget ID, if this view is a widget on a dashboard.
|
|
108
|
+
*/
|
|
109
|
+
get dashboardViewId() {
|
|
110
|
+
return this.data.dashboard_view_id;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns whether this view is a widget view embedded in a dashboard.
|
|
114
|
+
*/
|
|
115
|
+
isWidgetView() {
|
|
116
|
+
return this.data.dashboard_view_id !== undefined;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.View = View;
|
package/dist/notion.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
|
* Main Notion SDK class.
|
|
5
5
|
*
|
|
@@ -32,25 +32,44 @@ import { BlocksAPI, CommentsAPI, DatabasesAPI, DataSourcesAPI, FileUploadsAPI, P
|
|
|
32
32
|
* await notion.comments.create({ parent: { page_id: 'page-id' }, rich_text: [...] });
|
|
33
33
|
*
|
|
34
34
|
* const fileUpload = await notion.fileUploads.uploadFile('image.png', buffer, 'image/png');
|
|
35
|
+
*
|
|
36
|
+
* const views = await notion.views.list({ data_source_id: 'data-source-id' });
|
|
37
|
+
* const queryResult = await notion.views.queries.create(views.results[0].id);
|
|
38
|
+
*
|
|
39
|
+
* const markdown = await notion.pages.getMarkdown('page-id');
|
|
40
|
+
* const task = await notion.pages.updateMarkdown('page-id', {
|
|
41
|
+
* type: 'replace_content',
|
|
42
|
+
* new_str: 'Updated content',
|
|
43
|
+
* allow_async: true,
|
|
44
|
+
* });
|
|
45
|
+
* await notion.asyncTasks.poll(task.id);
|
|
46
|
+
*
|
|
47
|
+
* const emojis = await notion.customEmojis.list();
|
|
35
48
|
* ```
|
|
36
49
|
*/
|
|
37
50
|
export declare class Notion {
|
|
38
51
|
private readonly client;
|
|
39
|
-
/**
|
|
40
|
-
readonly
|
|
52
|
+
/** Async Tasks API for polling long-running Notion operations */
|
|
53
|
+
readonly asyncTasks: AsyncTasksAPI;
|
|
41
54
|
/** Blocks API for working with Notion blocks */
|
|
42
55
|
readonly blocks: BlocksAPI;
|
|
56
|
+
/** Comments API for working with Notion comments */
|
|
57
|
+
readonly comments: CommentsAPI;
|
|
58
|
+
/** Custom Emojis API for listing workspace custom emojis */
|
|
59
|
+
readonly customEmojis: CustomEmojisAPI;
|
|
43
60
|
/** Databases API for working with Notion databases */
|
|
44
61
|
readonly databases: DatabasesAPI;
|
|
45
62
|
/** Data Sources API for working with Notion data sources */
|
|
46
63
|
readonly dataSources: DataSourcesAPI;
|
|
64
|
+
/** FileUploads API for uploading files to Notion */
|
|
65
|
+
readonly fileUploads: FileUploadsAPI;
|
|
66
|
+
/** Pages API for working with Notion pages */
|
|
67
|
+
readonly pages: PagesAPI;
|
|
47
68
|
/** Search API for searching across the workspace */
|
|
48
69
|
readonly search: SearchAPI;
|
|
49
70
|
/** Users API for working with Notion users */
|
|
50
71
|
readonly users: UsersAPI;
|
|
51
|
-
/**
|
|
52
|
-
readonly
|
|
53
|
-
/** FileUploads API for uploading files to Notion */
|
|
54
|
-
readonly fileUploads: FileUploadsAPI;
|
|
72
|
+
/** Views API for working with Notion database/data source views */
|
|
73
|
+
readonly views: ViewsAPI;
|
|
55
74
|
constructor(options: NotionClientOptions);
|
|
56
75
|
}
|