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