@keystrokehq/notion 0.0.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.
@@ -0,0 +1,125 @@
1
+ import { z } from "zod";
2
+ import * as _keystrokehq_core0 from "@keystrokehq/core";
3
+ import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
4
+
5
+ //#region src/blocks.d.ts
6
+ declare const getBlock: _keystrokehq_core0.Operation<z.ZodObject<{
7
+ blockId: z.ZodString;
8
+ }, z.core.$strip>, z.ZodObject<{
9
+ id: z.ZodString;
10
+ object: z.ZodLiteral<"block">;
11
+ type: z.ZodString;
12
+ hasChildren: z.ZodBoolean;
13
+ createdTime: z.ZodString;
14
+ lastEditedTime: z.ZodString;
15
+ archived: z.ZodOptional<z.ZodBoolean>;
16
+ inTrash: z.ZodOptional<z.ZodBoolean>;
17
+ parent: z.ZodOptional<z.ZodObject<{
18
+ type: z.ZodString;
19
+ pageId: z.ZodOptional<z.ZodString>;
20
+ blockId: z.ZodOptional<z.ZodString>;
21
+ dataSourceId: z.ZodOptional<z.ZodString>;
22
+ databaseId: z.ZodOptional<z.ZodString>;
23
+ workspace: z.ZodOptional<z.ZodBoolean>;
24
+ }, z.core.$strip>>;
25
+ value: z.ZodOptional<z.ZodUnknown>;
26
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
27
+ NOTION_ACCESS_TOKEN: z.ZodString;
28
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
29
+ NOTION_ACCESS_TOKEN: z.ZodString;
30
+ }, z.core.$strip>>[] | undefined>], undefined>;
31
+ declare const listBlockChildren: _keystrokehq_core0.Operation<z.ZodObject<{
32
+ blockId: z.ZodString;
33
+ limit: z.ZodOptional<z.ZodNumber>;
34
+ startCursor: z.ZodOptional<z.ZodString>;
35
+ recursive: z.ZodOptional<z.ZodBoolean>;
36
+ }, z.core.$strip>, z.ZodObject<{
37
+ results: z.ZodArray<z.ZodObject<{
38
+ id: z.ZodString;
39
+ object: z.ZodLiteral<"block">;
40
+ type: z.ZodString;
41
+ hasChildren: z.ZodBoolean;
42
+ createdTime: z.ZodString;
43
+ lastEditedTime: z.ZodString;
44
+ archived: z.ZodOptional<z.ZodBoolean>;
45
+ inTrash: z.ZodOptional<z.ZodBoolean>;
46
+ parent: z.ZodOptional<z.ZodObject<{
47
+ type: z.ZodString;
48
+ pageId: z.ZodOptional<z.ZodString>;
49
+ blockId: z.ZodOptional<z.ZodString>;
50
+ dataSourceId: z.ZodOptional<z.ZodString>;
51
+ databaseId: z.ZodOptional<z.ZodString>;
52
+ workspace: z.ZodOptional<z.ZodBoolean>;
53
+ }, z.core.$strip>>;
54
+ value: z.ZodOptional<z.ZodUnknown>;
55
+ }, z.core.$strip>>;
56
+ hasMore: z.ZodBoolean;
57
+ nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
58
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
59
+ NOTION_ACCESS_TOKEN: z.ZodString;
60
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
61
+ NOTION_ACCESS_TOKEN: z.ZodString;
62
+ }, z.core.$strip>>[] | undefined>], undefined>;
63
+ declare const appendBlockChildren: _keystrokehq_core0.Operation<z.ZodObject<{
64
+ blockId: z.ZodString;
65
+ children: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
66
+ }, z.core.$strip>, z.ZodObject<{
67
+ success: z.ZodLiteral<true>;
68
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
69
+ NOTION_ACCESS_TOKEN: z.ZodString;
70
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
71
+ NOTION_ACCESS_TOKEN: z.ZodString;
72
+ }, z.core.$strip>>[] | undefined>], undefined>;
73
+ declare const updateBlock: _keystrokehq_core0.Operation<z.ZodObject<{
74
+ blockId: z.ZodString;
75
+ block: z.ZodRecord<z.ZodString, z.ZodUnknown>;
76
+ }, z.core.$strip>, z.ZodObject<{
77
+ id: z.ZodString;
78
+ object: z.ZodLiteral<"block">;
79
+ type: z.ZodString;
80
+ hasChildren: z.ZodBoolean;
81
+ createdTime: z.ZodString;
82
+ lastEditedTime: z.ZodString;
83
+ archived: z.ZodOptional<z.ZodBoolean>;
84
+ inTrash: z.ZodOptional<z.ZodBoolean>;
85
+ parent: z.ZodOptional<z.ZodObject<{
86
+ type: z.ZodString;
87
+ pageId: z.ZodOptional<z.ZodString>;
88
+ blockId: z.ZodOptional<z.ZodString>;
89
+ dataSourceId: z.ZodOptional<z.ZodString>;
90
+ databaseId: z.ZodOptional<z.ZodString>;
91
+ workspace: z.ZodOptional<z.ZodBoolean>;
92
+ }, z.core.$strip>>;
93
+ value: z.ZodOptional<z.ZodUnknown>;
94
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
95
+ NOTION_ACCESS_TOKEN: z.ZodString;
96
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
97
+ NOTION_ACCESS_TOKEN: z.ZodString;
98
+ }, z.core.$strip>>[] | undefined>], undefined>;
99
+ declare const deleteBlock: _keystrokehq_core0.Operation<z.ZodObject<{
100
+ blockId: z.ZodString;
101
+ }, z.core.$strip>, z.ZodObject<{
102
+ id: z.ZodString;
103
+ object: z.ZodLiteral<"block">;
104
+ type: z.ZodString;
105
+ hasChildren: z.ZodBoolean;
106
+ createdTime: z.ZodString;
107
+ lastEditedTime: z.ZodString;
108
+ archived: z.ZodOptional<z.ZodBoolean>;
109
+ inTrash: z.ZodOptional<z.ZodBoolean>;
110
+ parent: z.ZodOptional<z.ZodObject<{
111
+ type: z.ZodString;
112
+ pageId: z.ZodOptional<z.ZodString>;
113
+ blockId: z.ZodOptional<z.ZodString>;
114
+ dataSourceId: z.ZodOptional<z.ZodString>;
115
+ databaseId: z.ZodOptional<z.ZodString>;
116
+ workspace: z.ZodOptional<z.ZodBoolean>;
117
+ }, z.core.$strip>>;
118
+ value: z.ZodOptional<z.ZodUnknown>;
119
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
120
+ NOTION_ACCESS_TOKEN: z.ZodString;
121
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
122
+ NOTION_ACCESS_TOKEN: z.ZodString;
123
+ }, z.core.$strip>>[] | undefined>], undefined>;
124
+ //#endregion
125
+ export { appendBlockChildren, deleteBlock, getBlock, listBlockChildren, updateBlock };
@@ -0,0 +1,104 @@
1
+ import { appendBlockChildrenInChunks, createNotionClient, listAllPaginatedResults, withRateLimitRetry } from "./client.mjs";
2
+ import { normalizeBlock, normalizeListMeta, notionBlockSchema, notionListResponseSchema, notionSuccessResponseSchema } from "./schemas.mjs";
3
+ import { t as notionOperation } from "./factory-BttZ5eEq.mjs";
4
+ import { r as buildPaginationInput } from "./shared-C6A6JPl3.mjs";
5
+ import { z } from "zod";
6
+
7
+ //#region src/blocks.ts
8
+ async function listBlockChildrenRecursively(client, blockId) {
9
+ const normalized = (await listAllPaginatedResults((cursor) => client.blocks.children.list({
10
+ block_id: blockId,
11
+ ...buildPaginationInput(void 0, cursor)
12
+ }))).map(normalizeBlock);
13
+ const nested = await Promise.all(normalized.filter((block) => block.hasChildren).map((block) => listBlockChildrenRecursively(client, block.id)));
14
+ return normalized.concat(...nested);
15
+ }
16
+ const getBlock = notionOperation({
17
+ id: "get_notion_block",
18
+ name: "Get Notion Block",
19
+ description: "Retrieve a Notion block by ID",
20
+ input: z.object({ blockId: z.string().min(1) }),
21
+ output: notionBlockSchema,
22
+ run: async (input, credentials) => {
23
+ const client = createNotionClient(credentials);
24
+ return normalizeBlock(await withRateLimitRetry(() => client.blocks.retrieve({ block_id: input.blockId })));
25
+ }
26
+ });
27
+ const listBlockChildren = notionOperation({
28
+ id: "list_notion_block_children",
29
+ name: "List Notion Block Children",
30
+ description: "List the children for a Notion block or page",
31
+ input: z.object({
32
+ blockId: z.string().min(1),
33
+ limit: z.number().int().positive().max(100).optional(),
34
+ startCursor: z.string().optional(),
35
+ recursive: z.boolean().optional()
36
+ }),
37
+ output: notionListResponseSchema(notionBlockSchema),
38
+ run: async (input, credentials) => {
39
+ const client = createNotionClient(credentials);
40
+ if (input.recursive) return {
41
+ results: await listBlockChildrenRecursively(client, input.blockId),
42
+ hasMore: false,
43
+ nextCursor: null
44
+ };
45
+ const response = await withRateLimitRetry(() => client.blocks.children.list({
46
+ block_id: input.blockId,
47
+ ...buildPaginationInput(input.limit, input.startCursor)
48
+ }));
49
+ const meta = normalizeListMeta(response);
50
+ return {
51
+ results: response.results.map(normalizeBlock),
52
+ hasMore: meta.hasMore,
53
+ nextCursor: meta.nextCursor
54
+ };
55
+ }
56
+ });
57
+ const appendBlockChildren = notionOperation({
58
+ id: "append_notion_block_children",
59
+ name: "Append Notion Block Children",
60
+ description: "Append one or more child blocks to a Notion block or page",
61
+ input: z.object({
62
+ blockId: z.string().min(1),
63
+ children: z.array(z.record(z.string(), z.unknown())).min(1)
64
+ }),
65
+ output: notionSuccessResponseSchema,
66
+ needsApproval: true,
67
+ run: async (input, credentials) => {
68
+ await appendBlockChildrenInChunks(createNotionClient(credentials), input.blockId, input.children);
69
+ return { success: true };
70
+ }
71
+ });
72
+ const updateBlock = notionOperation({
73
+ id: "update_notion_block",
74
+ name: "Update Notion Block",
75
+ description: "Update a Notion block by applying a typed block patch",
76
+ input: z.object({
77
+ blockId: z.string().min(1),
78
+ block: z.record(z.string(), z.unknown())
79
+ }),
80
+ output: notionBlockSchema,
81
+ needsApproval: true,
82
+ run: async (input, credentials) => {
83
+ const client = createNotionClient(credentials);
84
+ return normalizeBlock(await withRateLimitRetry(() => client.blocks.update({
85
+ block_id: input.blockId,
86
+ ...input.block
87
+ })));
88
+ }
89
+ });
90
+ const deleteBlock = notionOperation({
91
+ id: "delete_notion_block",
92
+ name: "Delete Notion Block",
93
+ description: "Delete a Notion block",
94
+ input: z.object({ blockId: z.string().min(1) }),
95
+ output: notionBlockSchema,
96
+ needsApproval: true,
97
+ run: async (input, credentials) => {
98
+ const client = createNotionClient(credentials);
99
+ return normalizeBlock(await withRateLimitRetry(() => client.blocks.delete({ block_id: input.blockId })));
100
+ }
101
+ });
102
+
103
+ //#endregion
104
+ export { appendBlockChildren, deleteBlock, getBlock, listBlockChildren, updateBlock };
@@ -0,0 +1,22 @@
1
+ import { t as NotionCredentials } from "./integration-C7pL009K.mjs";
2
+ import { Client } from "@notionhq/client";
3
+
4
+ //#region src/client.d.ts
5
+ declare const NOTION_API_VERSION = "2026-03-11";
6
+ declare const NOTION_MAX_PAGE_SIZE = 100;
7
+ declare const NOTION_MAX_BLOCK_CHILDREN_PER_REQUEST = 100;
8
+ declare const NOTION_MAX_RETRY_ATTEMPTS = 3;
9
+ interface NotionListResponse<TItem> {
10
+ readonly results: readonly TItem[];
11
+ readonly has_more?: boolean;
12
+ readonly next_cursor?: string | null;
13
+ }
14
+ declare function withRateLimitRetry<T>(operation: () => Promise<T>, maxAttempts?: number): Promise<T>;
15
+ declare function createNotionClient(credentials: NotionCredentials): Client;
16
+ type NotionClient = ReturnType<typeof createNotionClient>;
17
+ declare function chunkArray<T>(items: readonly T[], chunkSize: number): T[][];
18
+ declare function listAllPaginatedResults<TItem>(getPage: (cursor?: string) => Promise<NotionListResponse<TItem>>): Promise<TItem[]>;
19
+ declare function appendBlockChildrenInChunks(client: NotionClient, blockId: string, children: readonly unknown[]): Promise<void>;
20
+ declare function appendBlockChildrenAndReturnResults(client: NotionClient, blockId: string, children: readonly unknown[]): Promise<unknown[]>;
21
+ //#endregion
22
+ export { NOTION_API_VERSION, NOTION_MAX_BLOCK_CHILDREN_PER_REQUEST, NOTION_MAX_PAGE_SIZE, NOTION_MAX_RETRY_ATTEMPTS, NotionClient, appendBlockChildrenAndReturnResults, appendBlockChildrenInChunks, chunkArray, createNotionClient, listAllPaginatedResults, withRateLimitRetry };
@@ -0,0 +1,95 @@
1
+ import { t as notion } from "./integration-Hfdp-q_v.mjs";
2
+ import { CredentialRevokedError } from "@keystrokehq/core/errors";
3
+ import { createErrorNormalizingProxy } from "@keystrokehq/integration-authoring";
4
+ import { Client } from "@notionhq/client";
5
+
6
+ //#region src/client.ts
7
+ const NOTION_API_VERSION = "2026-03-11";
8
+ const NOTION_MAX_PAGE_SIZE = 100;
9
+ const NOTION_MAX_BLOCK_CHILDREN_PER_REQUEST = 100;
10
+ const NOTION_MAX_RETRY_ATTEMPTS = 3;
11
+ function getErrorStatus(error) {
12
+ if (!(error instanceof Error)) return void 0;
13
+ const record = error;
14
+ return record.status ?? record.statusCode;
15
+ }
16
+ function getErrorCode(error) {
17
+ if (!(error instanceof Error)) return void 0;
18
+ return error.code;
19
+ }
20
+ function isAuthError(error) {
21
+ const status = getErrorStatus(error);
22
+ const code = getErrorCode(error);
23
+ return status === 401 || code === "unauthorized";
24
+ }
25
+ function isRateLimitError(error) {
26
+ return getErrorStatus(error) === 429 || getErrorCode(error) === "rate_limited";
27
+ }
28
+ function normalizeNotionError(error, context) {
29
+ if (isAuthError(error)) return new CredentialRevokedError(notion.id, `Notion authentication failed while calling \`${context.methodPath}\`. The stored credentials for ${notion.id} may be revoked or expired.`);
30
+ if (error instanceof Error) return new Error(`Notion API call failed while calling \`${context.methodPath}\`: ${error.message}`, { cause: error });
31
+ return /* @__PURE__ */ new Error(`Notion API call failed while calling \`${context.methodPath}\`.`);
32
+ }
33
+ function wait(ms) {
34
+ return new Promise((resolve) => {
35
+ setTimeout(resolve, ms);
36
+ });
37
+ }
38
+ function getRetryDelayMs(error, attempt) {
39
+ if (error instanceof Error) {
40
+ const retryAfter = error.headers?.["retry-after"];
41
+ if (retryAfter) {
42
+ const retryAfterSeconds = Number.parseInt(retryAfter, 10);
43
+ if (!Number.isNaN(retryAfterSeconds)) return retryAfterSeconds * 1e3;
44
+ }
45
+ }
46
+ return Math.min(2 ** attempt * 500, 5e3);
47
+ }
48
+ async function withRateLimitRetry(operation, maxAttempts = NOTION_MAX_RETRY_ATTEMPTS) {
49
+ let attempt = 0;
50
+ for (;;) try {
51
+ return await operation();
52
+ } catch (error) {
53
+ attempt += 1;
54
+ if (!isRateLimitError(error) || attempt >= maxAttempts) throw error;
55
+ await wait(getRetryDelayMs(error, attempt));
56
+ }
57
+ }
58
+ function createNotionClient(credentials) {
59
+ return createErrorNormalizingProxy(new Client({
60
+ auth: credentials.NOTION_ACCESS_TOKEN,
61
+ notionVersion: NOTION_API_VERSION
62
+ }), normalizeNotionError);
63
+ }
64
+ function chunkArray(items, chunkSize) {
65
+ const chunks = [];
66
+ for (let index = 0; index < items.length; index += chunkSize) chunks.push([...items.slice(index, index + chunkSize)]);
67
+ return chunks;
68
+ }
69
+ async function listAllPaginatedResults(getPage) {
70
+ const results = [];
71
+ let nextCursor;
72
+ do {
73
+ const page = await withRateLimitRetry(() => getPage(nextCursor));
74
+ results.push(...page.results);
75
+ nextCursor = page.next_cursor ?? void 0;
76
+ } while (nextCursor);
77
+ return results;
78
+ }
79
+ async function appendBlockChildrenInChunks(client, blockId, children) {
80
+ for (const chunk of chunkArray(children, NOTION_MAX_BLOCK_CHILDREN_PER_REQUEST)) await withRateLimitRetry(() => client.blocks.children.append({
81
+ block_id: blockId,
82
+ children: chunk
83
+ }));
84
+ }
85
+ async function appendBlockChildrenAndReturnResults(client, blockId, children) {
86
+ const results = (await withRateLimitRetry(() => client.blocks.children.append({
87
+ block_id: blockId,
88
+ children
89
+ }))).results;
90
+ if (!Array.isArray(results)) throw new Error("Notion append block children response did not include created blocks.");
91
+ return results;
92
+ }
93
+
94
+ //#endregion
95
+ export { NOTION_API_VERSION, NOTION_MAX_BLOCK_CHILDREN_PER_REQUEST, NOTION_MAX_PAGE_SIZE, NOTION_MAX_RETRY_ATTEMPTS, appendBlockChildrenAndReturnResults, appendBlockChildrenInChunks, chunkArray, createNotionClient, listAllPaginatedResults, withRateLimitRetry };
@@ -0,0 +1,109 @@
1
+ import { z } from "zod";
2
+ import * as _keystrokehq_core0 from "@keystrokehq/core";
3
+ import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
4
+
5
+ //#region src/comments.d.ts
6
+ declare const listComments: _keystrokehq_core0.Operation<z.ZodObject<{
7
+ blockId: z.ZodString;
8
+ limit: z.ZodOptional<z.ZodNumber>;
9
+ startCursor: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>, z.ZodObject<{
11
+ results: z.ZodArray<z.ZodObject<{
12
+ id: z.ZodString;
13
+ object: z.ZodLiteral<"comment">;
14
+ discussionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
15
+ createdTime: z.ZodString;
16
+ lastEditedTime: z.ZodOptional<z.ZodNullable<z.ZodString>>;
17
+ richText: z.ZodArray<z.ZodUnknown>;
18
+ parent: z.ZodOptional<z.ZodObject<{
19
+ type: z.ZodString;
20
+ pageId: z.ZodOptional<z.ZodString>;
21
+ blockId: z.ZodOptional<z.ZodString>;
22
+ dataSourceId: z.ZodOptional<z.ZodString>;
23
+ databaseId: z.ZodOptional<z.ZodString>;
24
+ workspace: z.ZodOptional<z.ZodBoolean>;
25
+ }, z.core.$strip>>;
26
+ createdBy: z.ZodOptional<z.ZodObject<{
27
+ id: z.ZodString;
28
+ object: z.ZodLiteral<"user">;
29
+ type: z.ZodString;
30
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
+ avatarUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ }, z.core.$strip>>;
34
+ }, z.core.$strip>>;
35
+ hasMore: z.ZodBoolean;
36
+ nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
37
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
38
+ NOTION_ACCESS_TOKEN: z.ZodString;
39
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
40
+ NOTION_ACCESS_TOKEN: z.ZodString;
41
+ }, z.core.$strip>>[] | undefined>], undefined>;
42
+ declare const getComment: _keystrokehq_core0.Operation<z.ZodObject<{
43
+ commentId: z.ZodString;
44
+ }, z.core.$strip>, z.ZodObject<{
45
+ id: z.ZodString;
46
+ object: z.ZodLiteral<"comment">;
47
+ discussionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ createdTime: z.ZodString;
49
+ lastEditedTime: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ richText: z.ZodArray<z.ZodUnknown>;
51
+ parent: z.ZodOptional<z.ZodObject<{
52
+ type: z.ZodString;
53
+ pageId: z.ZodOptional<z.ZodString>;
54
+ blockId: z.ZodOptional<z.ZodString>;
55
+ dataSourceId: z.ZodOptional<z.ZodString>;
56
+ databaseId: z.ZodOptional<z.ZodString>;
57
+ workspace: z.ZodOptional<z.ZodBoolean>;
58
+ }, z.core.$strip>>;
59
+ createdBy: z.ZodOptional<z.ZodObject<{
60
+ id: z.ZodString;
61
+ object: z.ZodLiteral<"user">;
62
+ type: z.ZodString;
63
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
64
+ avatarUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
65
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
+ }, z.core.$strip>>;
67
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
68
+ NOTION_ACCESS_TOKEN: z.ZodString;
69
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
70
+ NOTION_ACCESS_TOKEN: z.ZodString;
71
+ }, z.core.$strip>>[] | undefined>], undefined>;
72
+ declare const createComment: _keystrokehq_core0.Operation<z.ZodObject<{
73
+ target: z.ZodObject<{
74
+ pageId: z.ZodOptional<z.ZodString>;
75
+ blockId: z.ZodOptional<z.ZodString>;
76
+ discussionId: z.ZodOptional<z.ZodString>;
77
+ }, z.core.$strip>;
78
+ markdown: z.ZodOptional<z.ZodString>;
79
+ richText: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
80
+ }, z.core.$strip>, z.ZodObject<{
81
+ id: z.ZodString;
82
+ object: z.ZodLiteral<"comment">;
83
+ discussionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
84
+ createdTime: z.ZodString;
85
+ lastEditedTime: z.ZodOptional<z.ZodNullable<z.ZodString>>;
86
+ richText: z.ZodArray<z.ZodUnknown>;
87
+ parent: z.ZodOptional<z.ZodObject<{
88
+ type: z.ZodString;
89
+ pageId: z.ZodOptional<z.ZodString>;
90
+ blockId: z.ZodOptional<z.ZodString>;
91
+ dataSourceId: z.ZodOptional<z.ZodString>;
92
+ databaseId: z.ZodOptional<z.ZodString>;
93
+ workspace: z.ZodOptional<z.ZodBoolean>;
94
+ }, z.core.$strip>>;
95
+ createdBy: z.ZodOptional<z.ZodObject<{
96
+ id: z.ZodString;
97
+ object: z.ZodLiteral<"user">;
98
+ type: z.ZodString;
99
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
100
+ avatarUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
101
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
102
+ }, z.core.$strip>>;
103
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
104
+ NOTION_ACCESS_TOKEN: z.ZodString;
105
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
106
+ NOTION_ACCESS_TOKEN: z.ZodString;
107
+ }, z.core.$strip>>[] | undefined>], undefined>;
108
+ //#endregion
109
+ export { createComment, getComment, listComments };
@@ -0,0 +1,78 @@
1
+ import { createNotionClient, withRateLimitRetry } from "./client.mjs";
2
+ import { normalizeComment, normalizeListMeta, notionCommentSchema, notionListResponseSchema } from "./schemas.mjs";
3
+ import { t as notionOperation } from "./factory-BttZ5eEq.mjs";
4
+ import { i as buildPlainTextRichText, r as buildPaginationInput, t as buildCommentTarget } from "./shared-C6A6JPl3.mjs";
5
+ import { z } from "zod";
6
+
7
+ //#region src/comments.ts
8
+ const commentTargetSchema = z.object({
9
+ pageId: z.string().optional(),
10
+ blockId: z.string().optional(),
11
+ discussionId: z.string().optional()
12
+ }).refine((value) => [
13
+ value.pageId,
14
+ value.blockId,
15
+ value.discussionId
16
+ ].filter((entry) => Boolean(entry)).length === 1, { error: "Provide exactly one of pageId, blockId, or discussionId." });
17
+ const listComments = notionOperation({
18
+ id: "list_notion_comments",
19
+ name: "List Notion Comments",
20
+ description: "List the open comments for a Notion page or block",
21
+ input: z.object({
22
+ blockId: z.string().min(1),
23
+ limit: z.number().int().positive().max(100).optional(),
24
+ startCursor: z.string().optional()
25
+ }),
26
+ output: notionListResponseSchema(notionCommentSchema),
27
+ run: async (input, credentials) => {
28
+ const client = createNotionClient(credentials);
29
+ const response = await withRateLimitRetry(() => client.comments.list({
30
+ block_id: input.blockId,
31
+ ...buildPaginationInput(input.limit, input.startCursor)
32
+ }));
33
+ const meta = normalizeListMeta(response);
34
+ return {
35
+ results: response.results.map(normalizeComment),
36
+ hasMore: meta.hasMore,
37
+ nextCursor: meta.nextCursor
38
+ };
39
+ }
40
+ });
41
+ const getComment = notionOperation({
42
+ id: "get_notion_comment",
43
+ name: "Get Notion Comment",
44
+ description: "Retrieve a Notion comment by ID",
45
+ input: z.object({ commentId: z.string().min(1) }),
46
+ output: notionCommentSchema,
47
+ run: async (input, credentials) => {
48
+ const client = createNotionClient(credentials);
49
+ return normalizeComment(await withRateLimitRetry(() => client.comments.retrieve({ comment_id: input.commentId })));
50
+ }
51
+ });
52
+ const createComment = notionOperation({
53
+ id: "create_notion_comment",
54
+ name: "Create Notion Comment",
55
+ description: "Create a page comment or reply to an existing Notion discussion",
56
+ input: z.object({
57
+ target: commentTargetSchema,
58
+ markdown: z.string().min(1).optional(),
59
+ richText: z.array(z.record(z.string(), z.unknown())).min(1).optional()
60
+ }).refine((value) => Boolean(value.markdown) || Boolean(value.richText), { error: "Provide markdown or richText." }),
61
+ output: notionCommentSchema,
62
+ needsApproval: true,
63
+ run: async (input, credentials) => {
64
+ const client = createNotionClient(credentials);
65
+ const target = buildCommentTarget(input.target);
66
+ if (input.markdown !== void 0) return normalizeComment(await withRateLimitRetry(() => client.comments.create({
67
+ ...target,
68
+ markdown: input.markdown
69
+ })));
70
+ return normalizeComment(await withRateLimitRetry(() => client.comments.create({
71
+ ...target,
72
+ rich_text: input.richText ?? buildPlainTextRichText("")
73
+ })));
74
+ }
75
+ });
76
+
77
+ //#endregion
78
+ export { createComment, getComment, listComments };
@@ -0,0 +1,2 @@
1
+ import { i as notionOfficialIntegration, n as notion, t as NotionCredentials } from "./integration-C7pL009K.mjs";
2
+ export { type NotionCredentials, notion, notionOfficialIntegration };
@@ -0,0 +1,3 @@
1
+ import { r as notionOfficialIntegration, t as notion } from "./integration-Hfdp-q_v.mjs";
2
+
3
+ export { notion, notionOfficialIntegration };
@@ -0,0 +1,130 @@
1
+ import { z } from "zod";
2
+ import * as _keystrokehq_core0 from "@keystrokehq/core";
3
+ import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
4
+
5
+ //#region src/data-sources.d.ts
6
+ declare const discoverDatabaseDataSources: _keystrokehq_core0.Operation<z.ZodObject<{
7
+ databaseId: z.ZodString;
8
+ }, z.core.$strip>, z.ZodObject<{
9
+ databaseId: z.ZodString;
10
+ dataSources: z.ZodArray<z.ZodObject<{
11
+ id: z.ZodString;
12
+ name: z.ZodString;
13
+ }, z.core.$strip>>;
14
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
15
+ NOTION_ACCESS_TOKEN: z.ZodString;
16
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
17
+ NOTION_ACCESS_TOKEN: z.ZodString;
18
+ }, z.core.$strip>>[] | undefined>], undefined>;
19
+ declare const getDataSource: _keystrokehq_core0.Operation<z.ZodObject<{
20
+ dataSourceId: z.ZodString;
21
+ }, z.core.$strip>, z.ZodObject<{
22
+ id: z.ZodString;
23
+ object: z.ZodLiteral<"data_source">;
24
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
+ createdTime: z.ZodOptional<z.ZodString>;
27
+ lastEditedTime: z.ZodOptional<z.ZodString>;
28
+ parent: z.ZodOptional<z.ZodObject<{
29
+ type: z.ZodString;
30
+ pageId: z.ZodOptional<z.ZodString>;
31
+ blockId: z.ZodOptional<z.ZodString>;
32
+ dataSourceId: z.ZodOptional<z.ZodString>;
33
+ databaseId: z.ZodOptional<z.ZodString>;
34
+ workspace: z.ZodOptional<z.ZodBoolean>;
35
+ }, z.core.$strip>>;
36
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
37
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
38
+ NOTION_ACCESS_TOKEN: z.ZodString;
39
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
40
+ NOTION_ACCESS_TOKEN: z.ZodString;
41
+ }, z.core.$strip>>[] | undefined>], undefined>;
42
+ declare const queryDataSource: _keystrokehq_core0.Operation<z.ZodObject<{
43
+ dataSourceId: z.ZodString;
44
+ filter: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
45
+ sorts: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
46
+ startCursor: z.ZodOptional<z.ZodString>;
47
+ pageSize: z.ZodOptional<z.ZodNumber>;
48
+ }, z.core.$strip>, z.ZodObject<{
49
+ results: z.ZodArray<z.ZodObject<{
50
+ id: z.ZodString;
51
+ object: z.ZodLiteral<"page">;
52
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
54
+ createdTime: z.ZodString;
55
+ lastEditedTime: z.ZodString;
56
+ archived: z.ZodOptional<z.ZodBoolean>;
57
+ inTrash: z.ZodOptional<z.ZodBoolean>;
58
+ parent: z.ZodOptional<z.ZodObject<{
59
+ type: z.ZodString;
60
+ pageId: z.ZodOptional<z.ZodString>;
61
+ blockId: z.ZodOptional<z.ZodString>;
62
+ dataSourceId: z.ZodOptional<z.ZodString>;
63
+ databaseId: z.ZodOptional<z.ZodString>;
64
+ workspace: z.ZodOptional<z.ZodBoolean>;
65
+ }, z.core.$strip>>;
66
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
67
+ }, z.core.$strip>>;
68
+ hasMore: z.ZodBoolean;
69
+ nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
70
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
71
+ NOTION_ACCESS_TOKEN: z.ZodString;
72
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
73
+ NOTION_ACCESS_TOKEN: z.ZodString;
74
+ }, z.core.$strip>>[] | undefined>], undefined>;
75
+ declare const createDataSourceEntry: _keystrokehq_core0.Operation<z.ZodObject<{
76
+ dataSourceId: z.ZodString;
77
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
78
+ children: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
79
+ }, z.core.$strip>, z.ZodObject<{
80
+ id: z.ZodString;
81
+ object: z.ZodLiteral<"page">;
82
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
83
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
84
+ createdTime: z.ZodString;
85
+ lastEditedTime: z.ZodString;
86
+ archived: z.ZodOptional<z.ZodBoolean>;
87
+ inTrash: z.ZodOptional<z.ZodBoolean>;
88
+ parent: z.ZodOptional<z.ZodObject<{
89
+ type: z.ZodString;
90
+ pageId: z.ZodOptional<z.ZodString>;
91
+ blockId: z.ZodOptional<z.ZodString>;
92
+ dataSourceId: z.ZodOptional<z.ZodString>;
93
+ databaseId: z.ZodOptional<z.ZodString>;
94
+ workspace: z.ZodOptional<z.ZodBoolean>;
95
+ }, z.core.$strip>>;
96
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
97
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
98
+ NOTION_ACCESS_TOKEN: z.ZodString;
99
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
100
+ NOTION_ACCESS_TOKEN: z.ZodString;
101
+ }, z.core.$strip>>[] | undefined>], undefined>;
102
+ declare const updateDataSourceEntry: _keystrokehq_core0.Operation<z.ZodObject<{
103
+ pageId: z.ZodString;
104
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
105
+ inTrash: z.ZodOptional<z.ZodBoolean>;
106
+ }, z.core.$strip>, z.ZodObject<{
107
+ id: z.ZodString;
108
+ object: z.ZodLiteral<"page">;
109
+ url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
110
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
111
+ createdTime: z.ZodString;
112
+ lastEditedTime: z.ZodString;
113
+ archived: z.ZodOptional<z.ZodBoolean>;
114
+ inTrash: z.ZodOptional<z.ZodBoolean>;
115
+ parent: z.ZodOptional<z.ZodObject<{
116
+ type: z.ZodString;
117
+ pageId: z.ZodOptional<z.ZodString>;
118
+ blockId: z.ZodOptional<z.ZodString>;
119
+ dataSourceId: z.ZodOptional<z.ZodString>;
120
+ databaseId: z.ZodOptional<z.ZodString>;
121
+ workspace: z.ZodOptional<z.ZodBoolean>;
122
+ }, z.core.$strip>>;
123
+ properties: z.ZodRecord<z.ZodString, z.ZodUnknown>;
124
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"notion", z.ZodObject<{
125
+ NOTION_ACCESS_TOKEN: z.ZodString;
126
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
127
+ NOTION_ACCESS_TOKEN: z.ZodString;
128
+ }, z.core.$strip>>[] | undefined>], undefined>;
129
+ //#endregion
130
+ export { createDataSourceEntry, discoverDatabaseDataSources, getDataSource, queryDataSource, updateDataSourceEntry };