-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support personal access token and can drop down to select table…
… and base (#11) * feat: support personal access token and can drop down to select table and base * docs: update widget description and instructions
- Loading branch information
Showing
40 changed files
with
18,513 additions
and
17,333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"bracketSpacing": true, | ||
"printWidth": 150, | ||
"semi": true, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "all", | ||
"useTabs": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,4 @@ | |
|
||
.importAddRecordFail { | ||
color: var(--textDangerDefault); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { AIRTABLE_API_VERSION, AIRTABLE_URL } from '../constants'; | ||
import { Base } from '../types'; | ||
|
||
export const GetBases = async (personalAccessToken: string) => { | ||
if (!personalAccessToken) { | ||
throw new Error('personalAccessToken is required'); | ||
} | ||
|
||
const url = `${AIRTABLE_URL}/${AIRTABLE_API_VERSION}/meta/bases`; | ||
|
||
const response = await fetch(url, { | ||
method: 'GET', | ||
headers: { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${personalAccessToken}`, | ||
Host: AIRTABLE_URL, | ||
}, | ||
}); | ||
|
||
if (!response.ok) { | ||
if (response.status === 401) { | ||
throw new Error('Unauthorized: Error Personal Access Token.'); | ||
} else { | ||
const json = await response.json(); | ||
throw new Error(json.error.message || 'Error fetching bases, please check your Personal Access Token.'); | ||
} | ||
} | ||
|
||
const json = await response.json(); | ||
const bases = json.bases.map((base: Base) => ({ id: base.id, name: base.name })); | ||
return bases; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { AIRTABLE_API_VERSION, AIRTABLE_URL } from '../constants'; | ||
import { Table } from '../types'; | ||
|
||
export const GetTables = async (personalAccessToken: string, baseId: string) => { | ||
if (!personalAccessToken) return null; | ||
|
||
const url = `${AIRTABLE_URL}/${AIRTABLE_API_VERSION}/meta/bases/${baseId}/tables`; | ||
|
||
const response = await fetch(url, { | ||
method: 'GET', | ||
headers: { | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
Authorization: 'Bearer ' + personalAccessToken, | ||
Host: AIRTABLE_URL, | ||
}, | ||
}); | ||
|
||
const json = await response.json(); | ||
const tables = json.tables.map((table: Table) => ({ id: table.id, name: table.name })); | ||
return tables; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export * from './get-records'; | ||
export * from './get-records'; | ||
export * from './get-bases'; | ||
export * from './get-tables'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.