@@ -1668,59 +1668,67 @@ var action_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _a
16681668
16691669function action ( ) {
16701670 return action_awaiter ( this , void 0 , void 0 , function * ( ) {
1671- const NOTION_TOKEN_V2 = core . getInput ( 'token_v2' ) ;
1672- let id = core . getInput ( 'database_id' ) . replace ( / - / g, '' ) ;
1673- const databaseId = `${ id . substr ( 0 , 8 ) } -${ id . substr ( 8 , 4 ) } -${ id . substr ( 12 , 4 ) } -${ id . substr ( 16 , 4 ) } -${ id . substr ( 20 ) } ` ;
1674- const headers = {
1675- Accept : 'application/json' ,
1676- 'Content-Type' : 'application/json' ,
1677- cookie : `token_v2=${ NOTION_TOKEN_V2 } `
1678- } ;
1679- const http = new http_client /* HttpClient */ . eN ( undefined , undefined , {
1680- headers
1681- } ) ;
1682- const collectionView = yield ActionUtils . fetchData ( databaseId , 'block' , http ) ;
1683- core . info ( 'Fetched database' ) ;
1684- const collection_id = collectionView . collection_id ;
1685- const collection = yield ActionUtils . fetchData ( collection_id , 'collection' , http ) ;
1686- core . info ( 'Fetched collection' ) ;
1687- const response = yield http . post ( `https://www.notion.so/api/v3/queryCollection` , JSON . stringify ( {
1688- collection : {
1689- id : collection_id ,
1690- spaceId : collectionView . space_id
1691- } ,
1692- collectionView : {
1693- id : collectionView . view_ids [ 0 ] ,
1694- spaceId : collectionView . space_id
1695- } ,
1696- query : { } ,
1697- loader : {
1698- type : 'table' ,
1699- loadContentCover : false ,
1700- limit : 10000 ,
1701- userTimeZone : ''
1702- }
1703- } ) ) ;
1704- const { recordMap } = JSON . parse ( yield response . readBody ( ) ) ;
1705- core . info ( 'Fetched rows' ) ;
1706- const { schema } = collection ;
1707- const [ category_schema_entry , color_schema_entry ] = ActionUtils . getSchemaEntries ( schema ) ;
1708- const rows = ActionUtils . modifyRows ( recordMap , databaseId ) ;
1709- const categories_map = ActionUtils . constructCategoriesMap ( category_schema_entry [ 1 ] ) ;
1710- ActionUtils . populateCategoriesMapItems ( rows , category_schema_entry [ 0 ] , categories_map ) ;
1711- const README_PATH = `${ process . env . GITHUB_WORKSPACE } /README.md` ;
1712- core . info ( `Reading from ${ README_PATH } ` ) ;
1713- const readmeLines = external_fs_default ( ) . readFileSync ( README_PATH , 'utf-8' ) . split ( '\n' ) ;
1714- const [ startIdx , endIdx ] = ActionUtils . checkForSections ( readmeLines ) ;
1715- const newLines = ActionUtils . constructNewContents ( categories_map , color_schema_entry [ 0 ] ) ;
1716- const finalLines = [
1717- ...readmeLines . slice ( 0 , startIdx + 1 ) ,
1718- ...newLines ,
1719- ...readmeLines . slice ( endIdx )
1720- ] ;
1721- core . info ( `Writing to ${ README_PATH } ` ) ;
1722- external_fs_default ( ) . writeFileSync ( README_PATH , finalLines . join ( '\n' ) , 'utf-8' ) ;
1723- yield ActionUtils . commitFile ( ) ;
1671+ try {
1672+ const NOTION_TOKEN_V2 = core . getInput ( 'token_v2' ) ;
1673+ let id = core . getInput ( 'database_id' ) . replace ( / - / g, '' ) ;
1674+ const databaseId = `${ id . substr ( 0 , 8 ) } -${ id . substr ( 8 , 4 ) } -${ id . substr ( 12 , 4 ) } -${ id . substr ( 16 , 4 ) } -${ id . substr ( 20 ) } ` ;
1675+ const headers = {
1676+ Accept : 'application/json' ,
1677+ 'Content-Type' : 'application/json' ,
1678+ cookie : `token_v2=${ NOTION_TOKEN_V2 } `
1679+ } ;
1680+ const http = new http_client /* HttpClient */ . eN ( undefined , undefined , {
1681+ headers
1682+ } ) ;
1683+ const collectionView = yield ActionUtils . fetchData ( databaseId , 'block' , http ) ;
1684+ core . info ( 'Fetched database' ) ;
1685+ const collection_id = collectionView . collection_id ;
1686+ const collection = yield ActionUtils . fetchData ( collection_id , 'collection' , http ) ;
1687+ core . info ( 'Fetched collection' ) ;
1688+ const response = yield http . post ( `https://www.notion.so/api/v3/queryCollection` , JSON . stringify ( {
1689+ collection : {
1690+ id : collection_id ,
1691+ spaceId : collectionView . space_id
1692+ } ,
1693+ collectionView : {
1694+ id : collectionView . view_ids [ 0 ] ,
1695+ spaceId : collectionView . space_id
1696+ } ,
1697+ loader : {
1698+ type : 'reducer' ,
1699+ reducers : {
1700+ collection_group_results : {
1701+ type : 'results'
1702+ }
1703+ } ,
1704+ searchQuery : '' ,
1705+ userTimeZone : 'Asia/Dhaka'
1706+ }
1707+ } ) ) ;
1708+ const { recordMap } = JSON . parse ( yield response . readBody ( ) ) ;
1709+ core . info ( 'Fetched rows' ) ;
1710+ const { schema } = collection ;
1711+ const [ category_schema_entry , color_schema_entry ] = ActionUtils . getSchemaEntries ( schema ) ;
1712+ const rows = ActionUtils . modifyRows ( recordMap , databaseId ) ;
1713+ const categories_map = ActionUtils . constructCategoriesMap ( category_schema_entry [ 1 ] ) ;
1714+ ActionUtils . populateCategoriesMapItems ( rows , category_schema_entry [ 0 ] , categories_map ) ;
1715+ const README_PATH = `${ process . env . GITHUB_WORKSPACE } /README.md` ;
1716+ core . info ( `Reading from ${ README_PATH } ` ) ;
1717+ const readmeLines = external_fs_default ( ) . readFileSync ( README_PATH , 'utf-8' ) . split ( '\n' ) ;
1718+ const [ startIdx , endIdx ] = ActionUtils . checkForSections ( readmeLines ) ;
1719+ const newLines = ActionUtils . constructNewContents ( categories_map , color_schema_entry [ 0 ] ) ;
1720+ const finalLines = [
1721+ ...readmeLines . slice ( 0 , startIdx + 1 ) ,
1722+ ...newLines ,
1723+ ...readmeLines . slice ( endIdx )
1724+ ] ;
1725+ core . info ( `Writing to ${ README_PATH } ` ) ;
1726+ external_fs_default ( ) . writeFileSync ( README_PATH , finalLines . join ( '\n' ) , 'utf-8' ) ;
1727+ yield ActionUtils . commitFile ( ) ;
1728+ }
1729+ catch ( err ) {
1730+ core . setFailed ( err . message ) ;
1731+ }
17241732 } ) ;
17251733}
17261734
0 commit comments