@secret-momo/notion 2.3.0 → 2.5.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/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/notion-client.d.ts +21 -1
- package/lib/notion-client.d.ts.map +1 -1
- package/lib/notion-client.js +1 -1
- package/lib/utils.d.ts +1 -0
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +1 -1
- package/package.json +6 -6
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type NumberPropertyItemObjectResponse, type PageObjectResponse, type RichTextItemResponse } from '@notionhq/client';
|
|
2
2
|
export type { NumberPropertyItemObjectResponse, PageObjectResponse, RichTextItemResponse };
|
|
3
|
-
export { n } from './utils';
|
|
3
|
+
export { n, DEFAULT_TITLE_PROPERTY_NAME } from './utils';
|
|
4
4
|
export { buildNotionPageWebUrl, getId } from './helpers/page';
|
|
5
|
-
export { NotionClient } from './notion-client';
|
|
5
|
+
export { NotionClient, type CreatePageWithTitleParameters } from './notion-client';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,CAAC;AAE3F,OAAO,EAAE,CAAC,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gCAAgC,EACrC,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,gCAAgC,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,CAAC;AAE3F,OAAO,EAAE,CAAC,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,6BAA6B,EAAE,MAAM,iBAAiB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"@notionhq/client";import{n as
|
|
1
|
+
import"@notionhq/client";import{DEFAULT_TITLE_PROPERTY_NAME as e,n as i}from"./utils.js";import{buildNotionPageWebUrl as n,getId as p}from"./helpers/page.js";import{NotionClient as T}from"./notion-client.js";export{e as DEFAULT_TITLE_PROPERTY_NAME,T as NotionClient,n as buildNotionPageWebUrl,p as getId,i as n};
|
package/lib/notion-client.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { type ApiColor, type CreatePageParameters, type PageObjectResponse } from '@notionhq/client';
|
|
1
|
+
import { type ApiColor, type CreatePageParameters, type UpdatePageParameters, type PageObjectResponse } from '@notionhq/client';
|
|
2
|
+
export interface CreatePageWithTitleParameters {
|
|
3
|
+
dataSourceId: string;
|
|
4
|
+
titlePropertyName?: string;
|
|
5
|
+
title: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
}
|
|
2
8
|
interface AppendHeadingParameters {
|
|
3
9
|
blockId: string;
|
|
4
10
|
content: string;
|
|
@@ -9,11 +15,19 @@ export declare class NotionClient {
|
|
|
9
15
|
private readonly client;
|
|
10
16
|
constructor(authToken?: string);
|
|
11
17
|
createPage(args: CreatePageParameters): Promise<import("@notionhq/client").CreatePageResponse>;
|
|
18
|
+
createPageWithTitle(params: CreatePageWithTitleParameters): Promise<import("@notionhq/client").CreatePageResponse>;
|
|
19
|
+
updatePage(args: UpdatePageParameters): Promise<import("@notionhq/client").UpdatePageResponse>;
|
|
12
20
|
traverseDataSource(cb: (item: PageObjectResponse) => void, dataSourceId?: string): Promise<void>;
|
|
13
21
|
appendHeading1Block(params: AppendHeadingParameters): Promise<string>;
|
|
14
22
|
appendMarkdownToBlock(blockId: string, markdown: string): Promise<void>;
|
|
15
23
|
appendDivider(blockId: string): Promise<void>;
|
|
16
24
|
appendMarkdown(pageId: string, markdown: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* 上传本地文件到 Notion(数据库中附件属性中需要使用到这个函数)
|
|
27
|
+
* @param absolutePath - 本地文件路径
|
|
28
|
+
* @returns - 文件上传 ID
|
|
29
|
+
*/
|
|
30
|
+
uploadFileToNotion(absolutePath: string): Promise<string>;
|
|
17
31
|
/**
|
|
18
32
|
* 将本地文件经 Notion File Upload API 上传后,作为「文件」块挂到页面正文中。
|
|
19
33
|
* @param pageId - 页面 ID
|
|
@@ -30,6 +44,12 @@ export declare class NotionClient {
|
|
|
30
44
|
* 上传本地图片并在页面正文插入「图片」块(`image`)。
|
|
31
45
|
*/
|
|
32
46
|
uploadImageToPageBody(pageId: string, absolutePath: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* 上传本地视频到 Notion(数据库中附件属性中需要使用到这个函数)
|
|
49
|
+
* @param absolutePath - 本地视频路径
|
|
50
|
+
* @returns - 文件上传 ID
|
|
51
|
+
*/
|
|
52
|
+
uploadVideoToNotion(absolutePath: string): Promise<string>;
|
|
33
53
|
/**
|
|
34
54
|
* 上传本地视频并在页面正文插入「视频」块(`video`)。
|
|
35
55
|
*/
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"notion-client.d.ts","sourceRoot":"","sources":["../src/notion-client.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Y,EAAE,MAAM;IAiBhE;;;;OAIG;IACG,mBAAmB,CAAC,YAAY,EAAE,MAAM;IAI9C;;OAEG;IACG,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAUjE"}
|
package/lib/notion-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Client as
|
|
1
|
+
import{Client as c}from"@notionhq/client";import{markdownToBlocks as l}from"@tryfabric/martian";import{customFetch as d}from"./helpers/custom-fetch.js";import{uploadFileToNotion as r,uploadImageToNotion as s,uploadVideoToNotion as p}from"./helpers/upload/index.js";import{DEFAULT_TITLE_PROPERTY_NAME as u}from"./utils.js";class h{client;constructor(e){this.client=new c({auth:e??process.env.NOTION_AUTH_TOKEN,fetch:d,timeoutMs:1e3*60*10})}async createPage(e){return this.client.pages.create(e)}async createPageWithTitle(e){const{dataSourceId:t,titlePropertyName:i=u,title:o,url:a}=e;return this.createPage({parent:{data_source_id:t},properties:{[i]:{title:[{type:"text",text:{content:o,...a===void 0?{}:{link:{url:a}}}}]}}})}async updatePage(e){return this.client.pages.update(e)}async traverseDataSource(e,t){const i=t??process.env.NOTION_DATA_SOURCE_ID??"";let o;do{const a=await this.client.dataSources.query({data_source_id:i,start_cursor:o});a.results.forEach(n=>e(n)),o=a.next_cursor??void 0}while(o)}async appendHeading1Block(e){const{blockId:t,content:i,color:o,isToggleable:a}=e,{results:n}=await this.client.blocks.children.append({block_id:t,children:[{type:"heading_1",heading_1:{rich_text:[{type:"text",text:{content:i}}],color:o,is_toggleable:a}}]});return n[0]?.id??""}async appendMarkdownToBlock(e,t){await this.client.blocks.children.append({block_id:e,children:l(t)})}async appendDivider(e){await this.client.blocks.children.append({block_id:e,children:[{type:"divider",divider:{}}]})}async appendMarkdown(e,t){await this.client.pages.updateMarkdown({page_id:e,type:"insert_content",insert_content:{content:t}})}async uploadFileToNotion(e){return r(this.client,e)}async uploadFileToPageBody(e,t){const i=await this.uploadFileToNotion(t);await this.client.blocks.children.append({block_id:e,children:[{type:"file",file:{type:"file_upload",file_upload:{id:i}}}]})}async uploadImageToNotion(e){return s(this.client,e)}async uploadImageToPageBody(e,t){const i=await this.uploadImageToNotion(t);await this.client.blocks.children.append({block_id:e,children:[{type:"image",image:{type:"file_upload",file_upload:{id:i}}}]})}async uploadVideoToNotion(e){return p(this.client,e)}async uploadVideoToPageBody(e,t){const i=await this.uploadVideoToNotion(t);await this.client.blocks.children.append({block_id:e,children:[{type:"video",video:{type:"file_upload",file_upload:{id:i}}}]})}}export{h as NotionClient};
|
package/lib/utils.d.ts
CHANGED
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,iBAE7B"}
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,iBAAO,CAAC;AAEhD,wBAAgB,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,iBAE7B"}
|
package/lib/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const u="\u540D\u79F0";function t(n){return n??null}export{u as DEFAULT_TITLE_PROPERTY_NAME,t as n};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@secret-momo/notion",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": "24.19.0"
|
|
6
6
|
},
|
|
@@ -28,26 +28,26 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@notionhq/client": "5.26.0",
|
|
31
|
-
"@secret-momo/utils": "1.2
|
|
31
|
+
"@secret-momo/utils": "1.4.2",
|
|
32
32
|
"@tryfabric/martian": "1.2.4"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@eslint/config-helpers": "0.7.0",
|
|
36
36
|
"@eslint/js": "10.0.1",
|
|
37
37
|
"@types/bun": "1.4.0",
|
|
38
|
-
"eslint": "10.9.
|
|
38
|
+
"eslint": "10.9.1",
|
|
39
39
|
"eslint-plugin-import-x": "4.17.1",
|
|
40
40
|
"eslint-plugin-react": "7.37.5",
|
|
41
41
|
"eslint-plugin-react-hooks": "7.1.1",
|
|
42
42
|
"eslint-plugin-unused-imports": "4.4.1",
|
|
43
43
|
"husky": "9.1.7",
|
|
44
44
|
"jiti": "2.7.0",
|
|
45
|
-
"lint-staged": "17.
|
|
45
|
+
"lint-staged": "17.4.1",
|
|
46
46
|
"prettier": "3.9.6",
|
|
47
|
-
"rollup": "4.
|
|
47
|
+
"rollup": "4.63.1",
|
|
48
48
|
"rollup-plugin-esbuild": "6.2.1",
|
|
49
49
|
"typescript": "6.0.3",
|
|
50
|
-
"typescript-eslint": "8.
|
|
50
|
+
"typescript-eslint": "8.69.0"
|
|
51
51
|
},
|
|
52
52
|
"lint-staged": {
|
|
53
53
|
"*.{ts,tsx,js,jsx}": [
|