@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.
Files changed (130) hide show
  1. package/README.md +20 -87
  2. package/dist/api/asyncTasks.api.d.ts +72 -0
  3. package/dist/api/asyncTasks.api.js +70 -0
  4. package/dist/api/base.api.d.ts +15 -4
  5. package/dist/api/base.api.js +20 -8
  6. package/dist/api/blocks.api.d.ts +435 -73
  7. package/dist/api/blocks.api.js +43 -1
  8. package/dist/api/comments.api.d.ts +42 -5
  9. package/dist/api/comments.api.js +45 -1
  10. package/dist/api/customEmojis.api.d.ts +38 -0
  11. package/dist/api/customEmojis.api.js +38 -0
  12. package/dist/api/dataSources.api.d.ts +67 -14
  13. package/dist/api/dataSources.api.js +26 -1
  14. package/dist/api/databases.api.d.ts +47 -11
  15. package/dist/api/databases.api.js +4 -1
  16. package/dist/api/fileUploads.api.d.ts +8 -5
  17. package/dist/api/fileUploads.api.js +11 -7
  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 +144 -10
  21. package/dist/api/pages.api.js +66 -0
  22. package/dist/api/search.api.d.ts +12 -2
  23. package/dist/api/search.api.js +5 -2
  24. package/dist/api/users.api.d.ts +3 -0
  25. package/dist/api/users.api.js +2 -0
  26. package/dist/api/views.api.d.ts +286 -0
  27. package/dist/api/views.api.js +172 -0
  28. package/dist/client.d.ts +17 -17
  29. package/dist/client.js +25 -30
  30. package/dist/errors.d.ts +19 -5
  31. package/dist/errors.js +16 -4
  32. package/dist/helpers/block.helpers.d.ts +49 -5
  33. package/dist/helpers/block.helpers.js +50 -6
  34. package/dist/helpers/file.helpers.d.ts +46 -5
  35. package/dist/helpers/file.helpers.js +36 -8
  36. package/dist/helpers/filter.helpers.d.ts +8 -6
  37. package/dist/helpers/filter.helpers.js +2 -0
  38. package/dist/helpers/index.d.ts +3 -2
  39. package/dist/helpers/index.js +5 -1
  40. package/dist/helpers/pagination.helpers.d.ts +85 -13
  41. package/dist/helpers/pagination.helpers.js +114 -8
  42. package/dist/helpers/parent.helpers.d.ts +5 -3
  43. package/dist/helpers/parent.helpers.js +5 -3
  44. package/dist/helpers/property.helpers.d.ts +31 -0
  45. package/dist/helpers/property.helpers.js +30 -1
  46. package/dist/helpers/richText.helpers.d.ts +10 -5
  47. package/dist/helpers/richText.helpers.js +11 -6
  48. package/dist/helpers/sort.helpers.d.ts +2 -0
  49. package/dist/helpers/sort.helpers.js +2 -0
  50. package/dist/helpers/webhook.helpers.d.ts +54 -0
  51. package/dist/helpers/webhook.helpers.js +83 -0
  52. package/dist/models/asyncTask.model.d.ts +61 -0
  53. package/dist/models/asyncTask.model.js +91 -0
  54. package/dist/models/base.model.d.ts +16 -4
  55. package/dist/models/base.model.js +17 -5
  56. package/dist/models/block.model.d.ts +6 -2
  57. package/dist/models/block.model.js +48 -33
  58. package/dist/models/comment.model.d.ts +4 -2
  59. package/dist/models/comment.model.js +4 -2
  60. package/dist/models/customEmoji.model.d.ts +30 -0
  61. package/dist/models/customEmoji.model.js +44 -0
  62. package/dist/models/dataSource.model.d.ts +7 -5
  63. package/dist/models/dataSource.model.js +5 -3
  64. package/dist/models/database.model.d.ts +13 -5
  65. package/dist/models/database.model.js +15 -5
  66. package/dist/models/fileUpload.model.d.ts +6 -4
  67. package/dist/models/fileUpload.model.js +6 -4
  68. package/dist/models/index.d.ts +3 -0
  69. package/dist/models/index.js +7 -1
  70. package/dist/models/page.model.d.ts +8 -2
  71. package/dist/models/page.model.js +14 -4
  72. package/dist/models/richText.model.d.ts +3 -1
  73. package/dist/models/richText.model.js +3 -1
  74. package/dist/models/user.model.d.ts +4 -2
  75. package/dist/models/user.model.js +4 -2
  76. package/dist/models/view.model.d.ts +81 -0
  77. package/dist/models/view.model.js +121 -0
  78. package/dist/notion.d.ts +32 -8
  79. package/dist/notion.js +25 -4
  80. package/dist/schemas/asyncTask.schema.d.ts +53 -0
  81. package/dist/schemas/asyncTask.schema.js +88 -0
  82. package/dist/schemas/block.schema.d.ts +390 -73
  83. package/dist/schemas/block.schema.js +39 -8
  84. package/dist/schemas/codeLanguages.d.ts +7 -1
  85. package/dist/schemas/codeLanguages.js +4 -1
  86. package/dist/schemas/colors.d.ts +7 -1
  87. package/dist/schemas/colors.js +4 -1
  88. package/dist/schemas/comment.schema.d.ts +28 -5
  89. package/dist/schemas/comment.schema.js +11 -2
  90. package/dist/schemas/customEmoji.schema.d.ts +18 -0
  91. package/dist/schemas/customEmoji.schema.js +50 -0
  92. package/dist/schemas/dataSource.schema.d.ts +84 -10
  93. package/dist/schemas/dataSource.schema.js +31 -6
  94. package/dist/schemas/database.schema.d.ts +51 -7
  95. package/dist/schemas/database.schema.js +10 -3
  96. package/dist/schemas/emoji.schema.d.ts +7 -2
  97. package/dist/schemas/emoji.schema.js +4 -2
  98. package/dist/schemas/file.schema.d.ts +18 -2
  99. package/dist/schemas/file.schema.js +6 -2
  100. package/dist/schemas/fileUpload.schema.d.ts +9 -3
  101. package/dist/schemas/fileUpload.schema.js +5 -2
  102. package/dist/schemas/icon.schema.d.ts +116 -0
  103. package/dist/schemas/icon.schema.js +100 -0
  104. package/dist/schemas/index.d.ts +6 -0
  105. package/dist/schemas/index.js +6 -0
  106. package/dist/schemas/meetingNotesQuery.schema.d.ts +4198 -0
  107. package/dist/schemas/meetingNotesQuery.schema.js +67 -0
  108. package/dist/schemas/page.schema.d.ts +51 -9
  109. package/dist/schemas/page.schema.js +6 -2
  110. package/dist/schemas/pageMarkdown.schema.d.ts +70 -0
  111. package/dist/schemas/pageMarkdown.schema.js +70 -0
  112. package/dist/schemas/pageProperties.schema.d.ts +105 -21
  113. package/dist/schemas/pageProperties.schema.js +8 -6
  114. package/dist/schemas/pagination.schema.d.ts +57 -7
  115. package/dist/schemas/pagination.schema.js +25 -1
  116. package/dist/schemas/parent.schema.d.ts +39 -3
  117. package/dist/schemas/parent.schema.js +17 -5
  118. package/dist/schemas/propertyObjects.schema.d.ts +93 -15
  119. package/dist/schemas/propertyObjects.schema.js +11 -5
  120. package/dist/schemas/richText.schema.d.ts +23 -6
  121. package/dist/schemas/richText.schema.js +7 -4
  122. package/dist/schemas/shared.schema.d.ts +6 -3
  123. package/dist/schemas/shared.schema.js +6 -3
  124. package/dist/schemas/user.schema.d.ts +17 -0
  125. package/dist/schemas/user.schema.js +7 -3
  126. package/dist/schemas/view.schema.d.ts +1111 -0
  127. package/dist/schemas/view.schema.js +134 -0
  128. package/dist/validation.d.ts +11 -4
  129. package/dist/validation.js +11 -4
  130. package/package.json +6 -3
@@ -0,0 +1,83 @@
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. It signs the raw JSON request body
9
+ * and keys the signature with the subscription's verification token. Notion sends the
10
+ * signature in the `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 to generate test webhook signatures.
20
+ *
21
+ * @param body - The payload to sign. This function signs a string as-is. It
22
+ * converts anything else with `JSON.stringify` first. This is safe because the
23
+ * caller controls the serialization of their own payload.
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 that Notion sent. Do not use
39
+ * `JSON.stringify(parsedBody)`. Re-serializing a parsed object can produce a different
40
+ * byte sequence (key order, whitespace) than the original signed body, and this
41
+ * silently breaks verification. Use your framework's raw-body access, for example
42
+ * Express's `express.raw()` or `req.rawBody`. Do not use `req.body` after JSON
43
+ * middleware parses 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. Returns `false` for a mismatch or
49
+ * malformed input. This function 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
+ * @category Helpers
79
+ */
80
+ exports.webhook = {
81
+ sign,
82
+ verifySignature,
83
+ };
@@ -0,0 +1,61 @@
1
+ import { BaseModel, type TRUSTED } from './base.model';
2
+ import { type NotionAsyncTask } from '../schemas';
3
+ /**
4
+ * AsyncTask model class with helper methods.
5
+ *
6
+ * Represents a long-running operation, for example an async markdown write. Poll the
7
+ * task until it reaches a terminal status.
8
+ *
9
+ * @category Async Tasks
10
+ */
11
+ export declare class AsyncTask extends BaseModel<NotionAsyncTask> {
12
+ constructor(data: NotionAsyncTask, trusted?: typeof TRUSTED);
13
+ /**
14
+ * Returns "async_task" - the object type.
15
+ */
16
+ get object(): 'async_task';
17
+ /**
18
+ * Returns the task ID.
19
+ */
20
+ get id(): string;
21
+ /**
22
+ * Returns the task status.
23
+ */
24
+ get status(): NotionAsyncTask['status'];
25
+ /**
26
+ * Returns the URL to poll for the task status.
27
+ */
28
+ get statusUrl(): string;
29
+ /**
30
+ * Returns the task creation time as a Date object.
31
+ */
32
+ get createdTime(): Date;
33
+ /**
34
+ * Returns the operation that created this task.
35
+ */
36
+ get operation(): NotionAsyncTask['operation'];
37
+ /**
38
+ * Returns the minimum number of seconds to wait before polling again, if provided.
39
+ */
40
+ get pollAfterSeconds(): number | undefined;
41
+ /**
42
+ * Returns the operation-specific result, present only when the task succeeded.
43
+ */
44
+ get result(): unknown;
45
+ /**
46
+ * Returns the error details, present only when the task failed.
47
+ */
48
+ get error(): NotionAsyncTask['error'];
49
+ /**
50
+ * Returns whether the task completed successfully.
51
+ */
52
+ isSucceeded(): boolean;
53
+ /**
54
+ * Returns whether the task failed.
55
+ */
56
+ isFailed(): boolean;
57
+ /**
58
+ * Returns whether the task has reached a terminal status (succeeded or failed).
59
+ */
60
+ isTerminal(): boolean;
61
+ }
@@ -0,0 +1,91 @@
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
+ * AsyncTask model class with helper methods.
8
+ *
9
+ * Represents a long-running operation, for example an async markdown write. Poll the
10
+ * task until it reaches a terminal status.
11
+ *
12
+ * @category Async Tasks
13
+ */
14
+ class AsyncTask extends base_model_1.BaseModel {
15
+ constructor(data, trusted) {
16
+ super(data, schemas_1.asyncTaskSchema, trusted);
17
+ }
18
+ /**
19
+ * Returns "async_task" - the object type.
20
+ */
21
+ get object() {
22
+ return this.data.object;
23
+ }
24
+ /**
25
+ * Returns the task ID.
26
+ */
27
+ get id() {
28
+ return this.data.id;
29
+ }
30
+ /**
31
+ * Returns the task status.
32
+ */
33
+ get status() {
34
+ return this.data.status;
35
+ }
36
+ /**
37
+ * Returns the URL to poll for the task status.
38
+ */
39
+ get statusUrl() {
40
+ return this.data.status_url;
41
+ }
42
+ /**
43
+ * Returns the task creation time as a Date object.
44
+ */
45
+ get createdTime() {
46
+ return new Date(this.data.created_time);
47
+ }
48
+ /**
49
+ * Returns the operation that created this task.
50
+ */
51
+ get operation() {
52
+ return this.data.operation;
53
+ }
54
+ /**
55
+ * Returns the minimum number of seconds to wait before polling again, if provided.
56
+ */
57
+ get pollAfterSeconds() {
58
+ return this.data.poll_after_seconds;
59
+ }
60
+ /**
61
+ * Returns the operation-specific result, present only when the task succeeded.
62
+ */
63
+ get result() {
64
+ return this.data.result;
65
+ }
66
+ /**
67
+ * Returns the error details, present only when the task failed.
68
+ */
69
+ get error() {
70
+ return this.data.error;
71
+ }
72
+ /**
73
+ * Returns whether the task completed successfully.
74
+ */
75
+ isSucceeded() {
76
+ return this.data.status === 'succeeded';
77
+ }
78
+ /**
79
+ * Returns whether the task failed.
80
+ */
81
+ isFailed() {
82
+ return this.data.status === 'failed';
83
+ }
84
+ /**
85
+ * Returns whether the task has reached a terminal status (succeeded or failed).
86
+ */
87
+ isTerminal() {
88
+ return this.isSucceeded() || this.isFailed();
89
+ }
90
+ }
91
+ exports.AsyncTask = AsyncTask;
@@ -1,17 +1,29 @@
1
1
  import type * as z from 'zod';
2
2
  /**
3
- * Base model class providing common functionality for all Notion models.
4
- * Models wrap validated data from schemas with methods and business logic.
3
+ * Internal marker for trusted, already-validated data.
4
+ *
5
+ * Pass this to a model constructor to skip re-parsing data an API module already
6
+ * validated. This symbol is not exported from the package's public barrel, so
7
+ * external consumers can never construct or forge it. Direct construction from
8
+ * outside the SDK always validates.
9
+ */
10
+ export declare const TRUSTED: unique symbol;
11
+ /**
12
+ * Base class for all Notion models.
13
+ *
14
+ * This class wraps validated data from a schema. It adds methods and logic for each model.
15
+ *
16
+ * @category Client & Core
5
17
  */
6
18
  export declare abstract class BaseModel<T> {
7
19
  protected readonly data: T;
8
- protected constructor(data: T, schema: z.ZodType<T>);
20
+ protected constructor(data: T, schema: z.ZodType<T>, trusted?: typeof TRUSTED);
9
21
  /**
10
22
  * Returns the raw validated data as a plain object.
11
23
  */
12
24
  toJSON(): T;
13
25
  /**
14
- * Returns the object type (e.g., "page", "block", "user").
26
+ * Returns the object type, for example "page", "block", or "user".
15
27
  */
16
28
  abstract get object(): string;
17
29
  /**
@@ -1,13 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseModel = void 0;
3
+ exports.BaseModel = exports.TRUSTED = void 0;
4
4
  /**
5
- * Base model class providing common functionality for all Notion models.
6
- * Models wrap validated data from schemas with methods and business logic.
5
+ * Internal marker for trusted, already-validated data.
6
+ *
7
+ * Pass this to a model constructor to skip re-parsing data an API module already
8
+ * validated. This symbol is not exported from the package's public barrel, so
9
+ * external consumers can never construct or forge it. Direct construction from
10
+ * outside the SDK always validates.
11
+ */
12
+ exports.TRUSTED = Symbol('trusted');
13
+ /**
14
+ * Base class for all Notion models.
15
+ *
16
+ * This class wraps validated data from a schema. It adds methods and logic for each model.
17
+ *
18
+ * @category Client & Core
7
19
  */
8
20
  class BaseModel {
9
- constructor(data, schema) {
10
- this.data = schema.parse(data);
21
+ constructor(data, schema, trusted) {
22
+ this.data = trusted === exports.TRUSTED ? data : schema.parse(data);
11
23
  }
12
24
  /**
13
25
  * Returns the raw validated data as a plain object.
@@ -1,10 +1,14 @@
1
- import { BaseModel } from './base.model';
1
+ import { BaseModel, type TRUSTED } from './base.model';
2
2
  import { type NotionBlock } from '../schemas';
3
3
  /**
4
4
  * Block model wrapping a validated Notion block object with helper methods.
5
+ *
6
+ * @category Blocks
5
7
  */
6
8
  export declare class Block extends BaseModel<NotionBlock> {
7
- constructor(data: unknown);
9
+ private cachedCreatedTimeMs?;
10
+ private cachedLastEditedTimeMs?;
11
+ constructor(data: unknown, trusted?: typeof TRUSTED);
8
12
  get object(): string;
9
13
  get id(): string;
10
14
  get type(): NotionBlock['type'];
@@ -3,12 +3,51 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Block = void 0;
4
4
  const base_model_1 = require("./base.model");
5
5
  const schemas_1 = require("../schemas");
6
+ const TEXT_BLOCK_TYPES = new Set([
7
+ 'paragraph',
8
+ 'heading_1',
9
+ 'heading_2',
10
+ 'heading_3',
11
+ 'heading_4',
12
+ 'quote',
13
+ 'callout',
14
+ 'bulleted_list_item',
15
+ 'numbered_list_item',
16
+ 'to_do',
17
+ 'toggle',
18
+ ]);
19
+ const HEADING_BLOCK_TYPES = new Set([
20
+ 'heading_1',
21
+ 'heading_2',
22
+ 'heading_3',
23
+ 'heading_4',
24
+ ]);
25
+ const CHILD_CONTAINER_BLOCK_TYPES = new Set([
26
+ 'paragraph',
27
+ 'heading_1',
28
+ 'heading_2',
29
+ 'heading_3',
30
+ 'heading_4',
31
+ 'bulleted_list_item',
32
+ 'numbered_list_item',
33
+ 'to_do',
34
+ 'toggle',
35
+ 'quote',
36
+ 'callout',
37
+ 'synced_block',
38
+ 'column',
39
+ 'column_list',
40
+ 'tab',
41
+ 'table',
42
+ ]);
6
43
  /**
7
44
  * Block model wrapping a validated Notion block object with helper methods.
45
+ *
46
+ * @category Blocks
8
47
  */
9
48
  class Block extends base_model_1.BaseModel {
10
- constructor(data) {
11
- super(data, schemas_1.blockSchema);
49
+ constructor(data, trusted) {
50
+ super(data, schemas_1.blockSchema, trusted);
12
51
  }
13
52
  get object() {
14
53
  return this.data.object;
@@ -20,10 +59,12 @@ class Block extends base_model_1.BaseModel {
20
59
  return this.data.type;
21
60
  }
22
61
  get createdTime() {
23
- return new Date(this.data.created_time);
62
+ this.cachedCreatedTimeMs ??= new Date(this.data.created_time).getTime();
63
+ return new Date(this.cachedCreatedTimeMs);
24
64
  }
25
65
  get lastEditedTime() {
26
- return new Date(this.data.last_edited_time);
66
+ this.cachedLastEditedTimeMs ??= new Date(this.data.last_edited_time).getTime();
67
+ return new Date(this.cachedLastEditedTimeMs);
27
68
  }
28
69
  get inTrash() {
29
70
  return this.data.in_trash;
@@ -35,45 +76,19 @@ class Block extends base_model_1.BaseModel {
35
76
  * Check if this is a text-based block type.
36
77
  */
37
78
  isTextBlock() {
38
- return [
39
- 'paragraph',
40
- 'heading_1',
41
- 'heading_2',
42
- 'heading_3',
43
- 'quote',
44
- 'callout',
45
- 'bulleted_list_item',
46
- 'numbered_list_item',
47
- 'to_do',
48
- 'toggle',
49
- ].includes(this.data.type);
79
+ return TEXT_BLOCK_TYPES.has(this.data.type);
50
80
  }
51
81
  /**
52
82
  * Check if this is a heading block.
53
83
  */
54
84
  isHeading() {
55
- return ['heading_1', 'heading_2', 'heading_3'].includes(this.data.type);
85
+ return HEADING_BLOCK_TYPES.has(this.data.type);
56
86
  }
57
87
  /**
58
88
  * Check if this block can contain children.
59
89
  */
60
90
  canHaveChildren() {
61
- return [
62
- 'paragraph',
63
- 'heading_1',
64
- 'heading_2',
65
- 'heading_3',
66
- 'bulleted_list_item',
67
- 'numbered_list_item',
68
- 'to_do',
69
- 'toggle',
70
- 'quote',
71
- 'callout',
72
- 'synced_block',
73
- 'column',
74
- 'column_list',
75
- 'table',
76
- ].includes(this.data.type);
91
+ return CHILD_CONTAINER_BLOCK_TYPES.has(this.data.type);
77
92
  }
78
93
  /**
79
94
  * Get the plain text content from text-based blocks.
@@ -1,10 +1,12 @@
1
- import { BaseModel } from './base.model';
1
+ import { BaseModel, type TRUSTED } from './base.model';
2
2
  import { type CommentAttachment, type CommentDisplayName, type NotionComment, type NotionParent, type NotionRichText, type NotionUser } from '../schemas';
3
3
  /**
4
4
  * Comment model class with helper methods.
5
+ *
6
+ * @category Comments
5
7
  */
6
8
  export declare class Comment extends BaseModel<NotionComment> {
7
- constructor(data: NotionComment);
9
+ constructor(data: NotionComment, trusted?: typeof TRUSTED);
8
10
  /**
9
11
  * Returns "comment" - the object type.
10
12
  */
@@ -5,10 +5,12 @@ const base_model_1 = require("./base.model");
5
5
  const schemas_1 = require("../schemas");
6
6
  /**
7
7
  * Comment model class with helper methods.
8
+ *
9
+ * @category Comments
8
10
  */
9
11
  class Comment extends base_model_1.BaseModel {
10
- constructor(data) {
11
- super(data, schemas_1.commentSchema);
12
+ constructor(data, trusted) {
13
+ super(data, schemas_1.commentSchema, trusted);
12
14
  }
13
15
  /**
14
16
  * Returns "comment" - the object type.
@@ -0,0 +1,30 @@
1
+ import { BaseModel, type TRUSTED } from './base.model';
2
+ import { type NotionCustomEmoji } from '../schemas';
3
+ /**
4
+ * Custom Emoji model class with helper methods.
5
+ *
6
+ * @category Custom Emoji & Icons
7
+ */
8
+ export declare class CustomEmoji extends BaseModel<NotionCustomEmoji> {
9
+ constructor(data: NotionCustomEmoji, trusted?: typeof TRUSTED);
10
+ /**
11
+ * Returns "custom_emoji" - the object type.
12
+ *
13
+ * Note: A custom emoji list item has no `object` field in the API response. Only
14
+ * the paginated list wrapper has that field. This getter returns a synthetic
15
+ * value, not data from the payload, to meet the {@link BaseModel} contract.
16
+ */
17
+ get object(): 'custom_emoji';
18
+ /**
19
+ * Returns the custom emoji ID.
20
+ */
21
+ get id(): string;
22
+ /**
23
+ * Returns the custom emoji name.
24
+ */
25
+ get name(): string;
26
+ /**
27
+ * Returns the custom emoji's image URL.
28
+ */
29
+ get url(): string;
30
+ }
@@ -0,0 +1,44 @@
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
+ * @category Custom Emoji & Icons
10
+ */
11
+ class CustomEmoji extends base_model_1.BaseModel {
12
+ constructor(data, trusted) {
13
+ super(data, schemas_1.customEmojiSchema, trusted);
14
+ }
15
+ /**
16
+ * Returns "custom_emoji" - the object type.
17
+ *
18
+ * Note: A custom emoji list item has no `object` field in the API response. Only
19
+ * the paginated list wrapper has that field. This getter returns a synthetic
20
+ * value, not data from the payload, to meet the {@link BaseModel} contract.
21
+ */
22
+ get object() {
23
+ return 'custom_emoji';
24
+ }
25
+ /**
26
+ * Returns the custom emoji ID.
27
+ */
28
+ get id() {
29
+ return this.data.id;
30
+ }
31
+ /**
32
+ * Returns the custom emoji name.
33
+ */
34
+ get name() {
35
+ return this.data.name;
36
+ }
37
+ /**
38
+ * Returns the custom emoji's image URL.
39
+ */
40
+ get url() {
41
+ return this.data.url;
42
+ }
43
+ }
44
+ exports.CustomEmoji = CustomEmoji;
@@ -1,12 +1,14 @@
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';
1
+ import { BaseModel, type TRUSTED } from './base.model';
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
  *
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
  */
@@ -52,9 +54,9 @@ export declare class DataSource extends BaseModel<NotionDataSource> {
52
54
  */
53
55
  get description(): NotionRichText;
54
56
  /**
55
- * Returns the data source icon (file or emoji).
57
+ * Returns the data source icon (file, emoji, native icon, or custom emoji).
56
58
  */
57
- get icon(): NotionFile | NotionEmoji | null;
59
+ get icon(): NotionIcon | null;
58
60
  /**
59
61
  * Returns the data source cover image.
60
62
  */
@@ -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.
@@ -79,7 +81,7 @@ class DataSource extends base_model_1.BaseModel {
79
81
  return this.data.description;
80
82
  }
81
83
  /**
82
- * Returns the data source icon (file or emoji).
84
+ * Returns the data source icon (file, emoji, native icon, or custom emoji).
83
85
  */
84
86
  get icon() {
85
87
  return this.data.icon;
@@ -1,10 +1,14 @@
1
- import { BaseModel } from './base.model';
2
- import { type DataSourceRef, type NotionDatabase, type NotionEmoji, type NotionFile, type NotionParent, type NotionRichText, type NotionUser } from '../schemas';
1
+ import { BaseModel, type TRUSTED } from './base.model';
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
+ *
6
+ * @category Databases & Data Sources
5
7
  */
6
8
  export declare class Database extends BaseModel<NotionDatabase> {
7
- constructor(data: NotionDatabase);
9
+ private cachedCreatedTimeMs?;
10
+ private cachedLastEditedTimeMs?;
11
+ constructor(data: NotionDatabase, trusted?: typeof TRUSTED);
8
12
  /**
9
13
  * Returns "database" - the object type.
10
14
  */
@@ -42,9 +46,9 @@ export declare class Database extends BaseModel<NotionDatabase> {
42
46
  */
43
47
  get description(): NotionRichText;
44
48
  /**
45
- * Returns the database icon (file or emoji).
49
+ * Returns the database icon (file, emoji, native icon, or custom emoji).
46
50
  */
47
- get icon(): NotionFile | NotionEmoji | null;
51
+ get icon(): NotionIcon | null;
48
52
  /**
49
53
  * Returns the database cover image.
50
54
  */
@@ -65,6 +69,10 @@ export declare class Database extends BaseModel<NotionDatabase> {
65
69
  * Returns whether the database is inline.
66
70
  */
67
71
  get isInline(): boolean;
72
+ /**
73
+ * Returns whether the database is locked from editing.
74
+ */
75
+ get isLocked(): boolean;
68
76
  /**
69
77
  * Returns the public URL if published, otherwise null.
70
78
  */