@visus-io/notion-sdk-ts 3.0.1 → 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.
Files changed (95) hide show
  1. package/README.md +7 -6
  2. package/dist/api/asyncTasks.api.d.ts +70 -0
  3. package/dist/api/asyncTasks.api.js +68 -0
  4. package/dist/api/base.api.d.ts +7 -16
  5. package/dist/api/base.api.js +6 -21
  6. package/dist/api/blocks.api.d.ts +433 -73
  7. package/dist/api/blocks.api.js +39 -0
  8. package/dist/api/comments.api.d.ts +40 -5
  9. package/dist/api/comments.api.js +43 -1
  10. package/dist/api/customEmojis.api.d.ts +36 -0
  11. package/dist/api/customEmojis.api.js +36 -0
  12. package/dist/api/dataSources.api.d.ts +70 -12
  13. package/dist/api/dataSources.api.js +29 -5
  14. package/dist/api/databases.api.d.ts +40 -6
  15. package/dist/api/databases.api.js +2 -1
  16. package/dist/api/fileUploads.api.d.ts +7 -1
  17. package/dist/api/fileUploads.api.js +16 -1
  18. package/dist/api/index.d.ts +3 -0
  19. package/dist/api/index.js +7 -1
  20. package/dist/api/pages.api.d.ts +142 -10
  21. package/dist/api/pages.api.js +64 -0
  22. package/dist/api/search.api.d.ts +10 -2
  23. package/dist/api/users.api.d.ts +1 -0
  24. package/dist/api/views.api.d.ts +284 -0
  25. package/dist/api/views.api.js +169 -0
  26. package/dist/client.d.ts +1 -1
  27. package/dist/client.js +10 -4
  28. package/dist/errors.d.ts +5 -1
  29. package/dist/errors.js +6 -0
  30. package/dist/helpers/block.helpers.d.ts +38 -1
  31. package/dist/helpers/block.helpers.js +45 -3
  32. package/dist/helpers/file.helpers.d.ts +36 -1
  33. package/dist/helpers/file.helpers.js +26 -4
  34. package/dist/helpers/filter.helpers.d.ts +6 -6
  35. package/dist/helpers/index.d.ts +3 -2
  36. package/dist/helpers/index.js +5 -1
  37. package/dist/helpers/pagination.helpers.d.ts +56 -0
  38. package/dist/helpers/pagination.helpers.js +86 -0
  39. package/dist/helpers/property.helpers.d.ts +29 -0
  40. package/dist/helpers/property.helpers.js +27 -0
  41. package/dist/helpers/webhook.helpers.d.ts +52 -0
  42. package/dist/helpers/webhook.helpers.js +81 -0
  43. package/dist/models/asyncTask.model.d.ts +59 -0
  44. package/dist/models/asyncTask.model.js +89 -0
  45. package/dist/models/block.model.js +4 -1
  46. package/dist/models/customEmoji.model.d.ts +28 -0
  47. package/dist/models/customEmoji.model.js +42 -0
  48. package/dist/models/dataSource.model.d.ts +3 -3
  49. package/dist/models/dataSource.model.js +1 -1
  50. package/dist/models/database.model.d.ts +7 -3
  51. package/dist/models/database.model.js +7 -1
  52. package/dist/models/index.d.ts +3 -0
  53. package/dist/models/index.js +7 -1
  54. package/dist/models/page.model.d.ts +2 -0
  55. package/dist/models/page.model.js +6 -0
  56. package/dist/models/view.model.d.ts +79 -0
  57. package/dist/models/view.model.js +119 -0
  58. package/dist/notion.d.ts +26 -7
  59. package/dist/notion.js +19 -3
  60. package/dist/schemas/asyncTask.schema.d.ts +42 -0
  61. package/dist/schemas/asyncTask.schema.js +83 -0
  62. package/dist/schemas/block.schema.d.ts +378 -72
  63. package/dist/schemas/block.schema.js +33 -7
  64. package/dist/schemas/comment.schema.d.ts +8 -3
  65. package/dist/schemas/customEmoji.schema.d.ts +13 -0
  66. package/dist/schemas/customEmoji.schema.js +48 -0
  67. package/dist/schemas/dataSource.schema.d.ts +68 -10
  68. package/dist/schemas/dataSource.schema.js +22 -4
  69. package/dist/schemas/database.schema.d.ts +38 -6
  70. package/dist/schemas/database.schema.js +3 -2
  71. package/dist/schemas/fileUpload.schema.d.ts +1 -1
  72. package/dist/schemas/icon.schema.d.ts +92 -0
  73. package/dist/schemas/icon.schema.js +88 -0
  74. package/dist/schemas/index.d.ts +6 -0
  75. package/dist/schemas/index.js +6 -0
  76. package/dist/schemas/meetingNotesQuery.schema.d.ts +4187 -0
  77. package/dist/schemas/meetingNotesQuery.schema.js +62 -0
  78. package/dist/schemas/page.schema.d.ts +46 -9
  79. package/dist/schemas/page.schema.js +4 -2
  80. package/dist/schemas/pageMarkdown.schema.d.ts +59 -0
  81. package/dist/schemas/pageMarkdown.schema.js +65 -0
  82. package/dist/schemas/pageProperties.schema.d.ts +30 -18
  83. package/dist/schemas/pageProperties.schema.js +2 -3
  84. package/dist/schemas/pagination.schema.d.ts +30 -3
  85. package/dist/schemas/pagination.schema.js +18 -1
  86. package/dist/schemas/parent.schema.d.ts +10 -1
  87. package/dist/schemas/parent.schema.js +9 -3
  88. package/dist/schemas/propertyObjects.schema.d.ts +12 -12
  89. package/dist/schemas/richText.schema.d.ts +8 -6
  90. package/dist/schemas/richText.schema.js +1 -1
  91. package/dist/schemas/user.schema.d.ts +2 -0
  92. package/dist/schemas/user.schema.js +2 -1
  93. package/dist/schemas/view.schema.d.ts +1077 -0
  94. package/dist/schemas/view.schema.js +115 -0
  95. package/package.json +4 -3
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webhook = void 0;
4
+ const node_crypto_1 = require("node:crypto");
5
+ /**
6
+ * Webhook signature helpers.
7
+ *
8
+ * Notion signs webhook payloads with HMAC-SHA256, keyed by the subscription's
9
+ * verification token, over the raw JSON request body. The signature is sent in the
10
+ * `X-Notion-Signature` header as `sha256=<hex digest>`.
11
+ *
12
+ * Notion API reference:
13
+ * https://developers.notion.com/reference/webhooks
14
+ */
15
+ function computeSignature(rawBody, verificationToken) {
16
+ return `sha256=${(0, node_crypto_1.createHmac)('sha256', verificationToken).update(rawBody).digest('hex')}`;
17
+ }
18
+ /**
19
+ * Sign a payload, for generating test webhook signatures.
20
+ *
21
+ * @param body - The payload to sign. A string is signed as-is; anything else is
22
+ * `JSON.stringify`'d first -- safe here because the caller controls the exact
23
+ * serialization of a payload they're constructing themselves.
24
+ * @param verificationToken - The webhook subscription's verification token
25
+ * @returns The `sha256=<hex digest>` signature
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const signature = webhook.sign({ event: 'page.updated' }, verificationToken);
30
+ * ```
31
+ */
32
+ function sign(body, verificationToken) {
33
+ return computeSignature(typeof body === 'string' ? body : JSON.stringify(body), verificationToken);
34
+ }
35
+ /**
36
+ * Verify an incoming webhook's `X-Notion-Signature` header via constant-time comparison.
37
+ *
38
+ * IMPORTANT: `rawBody` must be the exact raw request body Notion sent, not
39
+ * `JSON.stringify(parsedBody)` -- re-serializing a parsed object can produce a
40
+ * different byte sequence (key order, whitespace) than what was actually signed,
41
+ * silently breaking verification. Use your framework's raw-body access (e.g.
42
+ * Express's `express.raw()` / `req.rawBody`), not `req.body` after JSON middleware
43
+ * has already parsed it.
44
+ *
45
+ * @param rawBody - The exact raw request body string Notion sent
46
+ * @param signatureHeader - The value of the `X-Notion-Signature` request header
47
+ * @param verificationToken - The webhook subscription's verification token
48
+ * @returns `true` if the signature is valid; `false` for any mismatch or malformed
49
+ * input (never throws)
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const isValid = webhook.verifySignature(rawBody, req.headers['x-notion-signature'], verificationToken);
54
+ * ```
55
+ */
56
+ function verifySignature(rawBody, signatureHeader, verificationToken) {
57
+ if (!signatureHeader) {
58
+ return false;
59
+ }
60
+ const expected = Buffer.from(computeSignature(rawBody, verificationToken));
61
+ const actual = Buffer.from(signatureHeader);
62
+ // timingSafeEqual throws on mismatched buffer lengths, so guard explicitly.
63
+ if (expected.length !== actual.length) {
64
+ return false;
65
+ }
66
+ return (0, node_crypto_1.timingSafeEqual)(expected, actual);
67
+ }
68
+ /**
69
+ * Helpers for signing and verifying Notion webhook payloads.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * import { webhook } from '@visus-io/notion-sdk-ts';
74
+ *
75
+ * const isValid = webhook.verifySignature(rawBody, req.headers['x-notion-signature'], verificationToken);
76
+ * ```
77
+ */
78
+ exports.webhook = {
79
+ sign,
80
+ verifySignature,
81
+ };
@@ -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 NotionEmoji, type NotionFile, type NotionParent, type NotionPropertiesObject, type NotionPropertyObject, type NotionRichText, type NotionUser } from '../schemas';
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(): NotionFile | NotionEmoji | null;
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 NotionEmoji, type NotionFile, type NotionParent, type NotionRichText, type NotionUser } from '../schemas';
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(): NotionFile | NotionEmoji | null;
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
  */
@@ -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';
@@ -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;