@secret-momo/notion 2.2.1 → 2.2.2
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.
|
@@ -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;
|
|
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;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 +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
|
|
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};
|