@secret-momo/notion 2.0.0 → 2.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/lib/notion-client.d.ts +11 -2
- package/lib/notion-client.d.ts.map +1 -1
- package/lib/notion-client.js +20 -0
- package/package.json +1 -1
package/lib/notion-client.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { type PageObjectResponse } from '@notionhq/client';
|
|
1
|
+
import { type ApiColor, type CreatePageParameters, type PageObjectResponse } from '@notionhq/client';
|
|
2
|
+
interface AppendHeadingParameters {
|
|
3
|
+
blockId: string;
|
|
4
|
+
content: string;
|
|
5
|
+
isToggleable: boolean;
|
|
6
|
+
color?: ApiColor;
|
|
7
|
+
}
|
|
2
8
|
export declare class NotionClient {
|
|
3
|
-
private client;
|
|
9
|
+
private readonly client;
|
|
4
10
|
constructor(authToken?: string);
|
|
11
|
+
createPage(args: CreatePageParameters): Promise<import("@notionhq/client").CreatePageResponse>;
|
|
5
12
|
traverseDataSource(cb: (item: PageObjectResponse) => void, dataSourceId?: string): Promise<void>;
|
|
13
|
+
appendHeading1Block(params: AppendHeadingParameters): Promise<string>;
|
|
6
14
|
appendDivider(blockId: string): Promise<void>;
|
|
7
15
|
appendMarkdown(pageId: string, markdown: string): Promise<void>;
|
|
8
16
|
/**
|
|
@@ -26,4 +34,5 @@ export declare class NotionClient {
|
|
|
26
34
|
*/
|
|
27
35
|
uploadVideoToPageBody(pageId: string, absolutePath: string): Promise<void>;
|
|
28
36
|
}
|
|
37
|
+
export {};
|
|
29
38
|
//# sourceMappingURL=notion-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notion-client.d.ts","sourceRoot":"","sources":["../src/notion-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"notion-client.d.ts","sourceRoot":"","sources":["../src/notion-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAK1B,UAAU,uBAAuB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,QAAQ,CAAC;CAClB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,SAAS,CAAC,EAAE,MAAM;IAQxB,UAAU,CAAC,IAAI,EAAE,oBAAoB;IAIrC,kBAAkB,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,EAAE,YAAY,CAAC,EAAE,MAAM;IAOhF,mBAAmB,CAAC,MAAM,EAAE,uBAAuB;IAmBnD,aAAa,CAAC,OAAO,EAAE,MAAM;IAO7B,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAQrD;;;;OAIG;IACG,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAiB/D;;;;OAIG;IACG,mBAAmB,CAAC,YAAY,EAAE,MAAM;IAI9C;;OAEG;IACG,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IAiBhE;;OAEG;IACG,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAUjE"}
|
package/lib/notion-client.js
CHANGED
|
@@ -12,11 +12,31 @@ class NotionClient {
|
|
|
12
12
|
// 10 分钟超时的时间
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
+
async createPage(args) {
|
|
16
|
+
return this.client.pages.create(args);
|
|
17
|
+
}
|
|
15
18
|
async traverseDataSource(cb, dataSourceId) {
|
|
16
19
|
const data_source_id = dataSourceId ?? process.env.NOTION_DATA_SOURCE_ID ?? "";
|
|
17
20
|
const data = await this.client.dataSources.query({ data_source_id });
|
|
18
21
|
data.results.forEach((item) => cb(item));
|
|
19
22
|
}
|
|
23
|
+
async appendHeading1Block(params) {
|
|
24
|
+
const { blockId, content, color, isToggleable } = params;
|
|
25
|
+
const { results } = await this.client.blocks.children.append({
|
|
26
|
+
block_id: blockId,
|
|
27
|
+
children: [
|
|
28
|
+
{
|
|
29
|
+
type: "heading_1",
|
|
30
|
+
heading_1: {
|
|
31
|
+
rich_text: [{ type: "text", text: { content } }],
|
|
32
|
+
color,
|
|
33
|
+
is_toggleable: isToggleable
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
return results[0]?.id ?? "";
|
|
39
|
+
}
|
|
20
40
|
async appendDivider(blockId) {
|
|
21
41
|
await this.client.blocks.children.append({
|
|
22
42
|
block_id: blockId,
|