@secret-momo/notion 2.4.0 → 2.6.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, DEFAULT_TITLE_PROPERTY_NAME } from './utils';
3
+ export { n, DEFAULT_TITLE_PROPERTY_NAME, getNotionPageInfo } 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
@@ -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,2BAA2B,EAAE,MAAM,SAAS,CAAC;AACzD,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,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5E,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{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
+ import"@notionhq/client";import{DEFAULT_TITLE_PROPERTY_NAME as r,getNotionPageInfo as i,n}from"./utils.js";import{buildNotionPageWebUrl as g,getId as m}from"./helpers/page.js";import{NotionClient as E}from"./notion-client.js";export{r as DEFAULT_TITLE_PROPERTY_NAME,E as NotionClient,g as buildNotionPageWebUrl,m as getId,i as getNotionPageInfo,n};
@@ -1,4 +1,10 @@
1
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,6 +15,7 @@ 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>;
12
19
  updatePage(args: UpdatePageParameters): Promise<import("@notionhq/client").UpdatePageResponse>;
13
20
  traverseDataSource(cb: (item: PageObjectResponse) => void, dataSourceId?: string): Promise<void>;
14
21
  appendHeading1Block(params: AppendHeadingParameters): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"notion-client.d.ts","sourceRoot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AAE,MAAM,EAAE,YAAY,EAAE,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 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};
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
@@ -1,3 +1,8 @@
1
+ import type { PageObjectResponse } from '@notionhq/client';
1
2
  export declare const DEFAULT_TITLE_PROPERTY_NAME = "\u540D\u79F0";
2
3
  export declare function n(num?: number): number | null;
4
+ export declare function getNotionPageInfo(page: PageObjectResponse): {
5
+ notionId: number;
6
+ notionLink: string;
7
+ };
3
8
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI3D,eAAO,MAAM,2BAA2B,iBAAO,CAAC;AAEhD,wBAAgB,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,iBAE7B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,kBAAkB;;;EAKzD"}
package/lib/utils.js CHANGED
@@ -1 +1 @@
1
- const u="\u540D\u79F0";function t(n){return n??null}export{u as DEFAULT_TITLE_PROPERTY_NAME,t as n};
1
+ import{buildNotionPageWebUrl as o,getId as t}from"./helpers/page.js";const i="\u540D\u79F0";function e(n){return n??null}function r(n){return{notionId:t(n),notionLink:o(n.id)}}export{i as DEFAULT_TITLE_PROPERTY_NAME,r as getNotionPageInfo,e as n};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secret-momo/notion",
3
- "version": "2.4.0",
3
+ "version": "2.6.0",
4
4
  "engines": {
5
5
  "node": "24.19.0"
6
6
  },
@@ -42,12 +42,12 @@
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.3.0",
45
+ "lint-staged": "17.4.1",
46
46
  "prettier": "3.9.6",
47
- "rollup": "4.63.0",
47
+ "rollup": "4.63.1",
48
48
  "rollup-plugin-esbuild": "6.2.1",
49
49
  "typescript": "6.0.3",
50
- "typescript-eslint": "8.68.0"
50
+ "typescript-eslint": "8.69.0"
51
51
  },
52
52
  "lint-staged": {
53
53
  "*.{ts,tsx,js,jsx}": [