@secret-momo/notion 2.0.1 → 2.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.
- package/lib/notion-client.d.ts +11 -2
- package/lib/notion-client.d.ts.map +1 -1
- package/lib/notion-client.js +24 -0
- package/package.json +3 -2
package/lib/notion-client.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { type CreatePageParameters, 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);
|
|
5
11
|
createPage(args: CreatePageParameters): Promise<import("@notionhq/client").CreatePageResponse>;
|
|
6
12
|
traverseDataSource(cb: (item: PageObjectResponse) => void, dataSourceId?: string): Promise<void>;
|
|
13
|
+
appendHeading1Block(params: AppendHeadingParameters): Promise<string>;
|
|
14
|
+
appendMarkdownToBlock(blockId: string, markdown: string): Promise<void>;
|
|
7
15
|
appendDivider(blockId: string): Promise<void>;
|
|
8
16
|
appendMarkdown(pageId: string, markdown: string): Promise<void>;
|
|
9
17
|
/**
|
|
@@ -27,4 +35,5 @@ export declare class NotionClient {
|
|
|
27
35
|
*/
|
|
28
36
|
uploadVideoToPageBody(pageId: string, absolutePath: string): Promise<void>;
|
|
29
37
|
}
|
|
38
|
+
export {};
|
|
30
39
|
//# 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;AAM1B,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,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAOvD,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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Client } from '@notionhq/client';
|
|
2
|
+
import { markdownToBlocks } from '@tryfabric/martian';
|
|
2
3
|
import { customFetch } from './helpers/custom-fetch.js';
|
|
3
4
|
import { uploadFileToNotion, uploadImageToNotion, uploadVideoToNotion } from './helpers/upload/index.js';
|
|
4
5
|
|
|
@@ -20,6 +21,29 @@ class NotionClient {
|
|
|
20
21
|
const data = await this.client.dataSources.query({ data_source_id });
|
|
21
22
|
data.results.forEach((item) => cb(item));
|
|
22
23
|
}
|
|
24
|
+
async appendHeading1Block(params) {
|
|
25
|
+
const { blockId, content, color, isToggleable } = params;
|
|
26
|
+
const { results } = await this.client.blocks.children.append({
|
|
27
|
+
block_id: blockId,
|
|
28
|
+
children: [
|
|
29
|
+
{
|
|
30
|
+
type: "heading_1",
|
|
31
|
+
heading_1: {
|
|
32
|
+
rich_text: [{ type: "text", text: { content } }],
|
|
33
|
+
color,
|
|
34
|
+
is_toggleable: isToggleable
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
});
|
|
39
|
+
return results[0]?.id ?? "";
|
|
40
|
+
}
|
|
41
|
+
async appendMarkdownToBlock(blockId, markdown) {
|
|
42
|
+
await this.client.blocks.children.append({
|
|
43
|
+
block_id: blockId,
|
|
44
|
+
children: markdownToBlocks(markdown)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
23
47
|
async appendDivider(blockId) {
|
|
24
48
|
await this.client.blocks.children.append({
|
|
25
49
|
block_id: blockId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secret-momo/notion",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib"
|
|
6
6
|
],
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@notionhq/client": "5.23.2",
|
|
28
|
-
"@secret-momo/utils": "1.2.0"
|
|
28
|
+
"@secret-momo/utils": "1.2.0",
|
|
29
|
+
"@tryfabric/martian": "1.2.4"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@eslint/config-helpers": "0.6.0",
|