-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5c45906
Showing
8 changed files
with
2,018 additions
and
0 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,4 @@ | ||
{ | ||
"presets": [ "@babel/preset-env" ], | ||
"plugins": [ "@babel/plugin-transform-modules-commonjs" ] | ||
} |
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,14 @@ | ||
# dependencies | ||
/node_modules | ||
|
||
# misc | ||
.DS_Store | ||
|
||
# log | ||
*.log | ||
|
||
# dist | ||
/dist | ||
|
||
# lib | ||
/lib |
Large diffs are not rendered by default.
Oops, something went wrong.
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,35 @@ | ||
{ | ||
"name": "seatable-api", | ||
"version": "1.0.0", | ||
"description": "A tool library for accessing seatable base, providing interface services for third-party developers", | ||
"files": [ | ||
"dist", | ||
"package.json", | ||
"package-lock.json" | ||
], | ||
"main": "./lib/index.js", | ||
"scripts": { | ||
"clean": "rm -rf dist && mkdir dist", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "./node_modules/.bin/babel src --out-dir lib", | ||
"prepublishOnly": "npm run clean && npm run build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/seatable/seatable-api.git" | ||
}, | ||
"author": "seafile", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/seatable/seatable-api/issues" | ||
}, | ||
"homepage": "https://github.com/seatable/seatable-api#readme", | ||
"dependencies": { | ||
"axios": "0.23.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "7.15.7", | ||
"@babel/core": "7.15.8", | ||
"@babel/preset-env": "7.15.8" | ||
} | ||
} |
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,28 @@ | ||
#! /bin/bash | ||
|
||
echo "=====================" | ||
echo "auto git" | ||
echo "======= 🤪 =========" | ||
echo "" | ||
echo "git add ." | ||
|
||
git add . | ||
git status | ||
|
||
echo "" | ||
echo "git commit -m 'update version'" | ||
echo "" | ||
|
||
git commit -m 'update version' | ||
|
||
current_banch=$(git symbolic-ref --short -q HEAD) | ||
|
||
echo "" | ||
echo "git push origin $current_banch" | ||
echo "" | ||
|
||
git push origin $current_banch | ||
|
||
echo "npm publish" | ||
echo "" | ||
npm publish |
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,7 @@ | ||
# SeatableAPI | ||
|
||
## Introduce | ||
|
||
A tool library for accessing seatable base, providing interface services for third-party developers | ||
|
||
## |
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,70 @@ | ||
import axios from "axios"; | ||
import { getAccessToken } from './utils'; | ||
|
||
class SeatableAPI { | ||
|
||
constructor() { | ||
this.appName = ''; | ||
this.accessToken = ''; | ||
this.dtableServer = ''; | ||
this.dtableSocket = ''; | ||
this.lang = 'en'; | ||
this.req = null; | ||
} | ||
|
||
async buildConnectionWithBase(config) { | ||
const response = await getAccessToken(config); | ||
const { app_name, access_token, dtable_uuid, dtable_server, dtable_socket } = response.data; | ||
this.appName = app_name; | ||
this.accessToken = access_token; | ||
this.dtableServer = dtable_server; | ||
this.dtableSocket = dtable_socket; | ||
this.dtableUuid = dtable_uuid; | ||
this.req = axios.create({ | ||
baseURL: this.dtableServer, | ||
headers: {Authorization: 'Token ' + this.accessToken} | ||
}); | ||
} | ||
|
||
getDTable() { | ||
const url = `dtables/${this.dtableUuid}/?lang=${this.lang}`; | ||
return this.req.get(url); | ||
} | ||
|
||
getRelatedUsers() { | ||
const url = `api/v1/dtables/${this.dtableUuid}/related-users/`; | ||
return this.req.get(url); | ||
} | ||
|
||
listViews(tableName) { | ||
const url = `api/v1/dtables/${this.dtableUuid}/views/`; | ||
const params = { | ||
table_name: encodeURIComponent(tableName), | ||
} | ||
return this.req.get(url, params); | ||
} | ||
|
||
listColumns(tableName, viewName) { | ||
const url = `api/v1/dtables/${this.dtableUuid}/columns/`; | ||
const params = { | ||
table_name: tableName, | ||
view_name: viewName | ||
} | ||
return this.req.get(url, {params}); | ||
} | ||
|
||
listRows(tableName, viewName) { | ||
const url = `api/v1/dtables/${this.dtableUuid}/rows/`; | ||
const params = { | ||
table_name: tableName, | ||
view_name: viewName, | ||
convert_link_id: true, | ||
} | ||
return this.req.get(url, {params}); | ||
} | ||
|
||
} | ||
|
||
const seatableAPI = new SeatableAPI(); | ||
|
||
export default seatableAPI; |
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,12 @@ | ||
import axios from "axios"; | ||
|
||
const getAccessToken = () => { | ||
const { server, APIToken } = config; | ||
const url = server + '/api/v2.1/dtable/app-access-token/'; | ||
const headers = { 'Authorization': 'Token ' + APIToken }; | ||
return axios.get(url, { headers: headers }); | ||
}; | ||
|
||
export { | ||
getAccessToken | ||
} |