@secret-momo/notion 2.4.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 CHANGED
@@ -2,5 +2,5 @@ import { type NumberPropertyItemObjectResponse, type PageObjectResponse, type Ri
2
2
  export type { NumberPropertyItemObjectResponse, PageObjectResponse, RichTextItemResponse };
3
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
@@ -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,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,KAAK,6BAA6B,EAAE,MAAM,iBAAiB,CAAC"}
@@ -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":"","sources":["../src/notion-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,oBAAoB,EACzB,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,UAAU,CAAC,IAAI,EAAE,oBAAoB;IAIrC,kBAAkB,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,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AS,CAAC,EAAE,MAAM;IAQxB,UAAU,CAAC,IAAI,EAAE,oBAAoB;IAIrC,mBAAmB,CAAC,MAAM,EAAE,6BAA6B;IAqBzD,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,kBAAkB,CAAC,YAAY,EAAE,MAAM;IAI7C;;;;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;;;;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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secret-momo/notion",
3
- "version": "2.4.0",
3
+ "version": "2.5.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}": [