-
Notifications
You must be signed in to change notification settings - Fork 14k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from apache-superset/chris--core-package
[SIP-4] add lerna monorepo and`@superset-ui/core` package with `SupersetClient`
- Loading branch information
1 parent
01bcbef
commit c4b946f
Showing
22 changed files
with
1,390 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...set-frontend/temporary_superset_ui/superset-ui/.github/PULL_REQUEST_TEMPLATE.md
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 @@ | ||
💔 Breaking Changes | ||
|
||
🏆 Enhancements | ||
|
||
📜 Documentation | ||
|
||
🐛 Bug Fix | ||
|
||
🏠 Internal |
21 changes: 21 additions & 0 deletions
21
superset-frontend/temporary_superset_ui/superset-ui/.gitignore
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,21 @@ | ||
.babelrc | ||
.eslintcache | ||
.eslintignore | ||
.eslintrc.js | ||
.idea | ||
.npm | ||
.prettierignore | ||
.yarnclean | ||
|
||
*.log | ||
*.map | ||
*.min.js | ||
|
||
build/ | ||
coverage/ | ||
esm/ | ||
jest.config.js | ||
lib/ | ||
logs/ | ||
node_modules/ | ||
prettier.config.js |
Empty file.
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,61 @@ | ||
# `@superset-ui` | ||
|
||
Collection of packages that power the Apache Superset UI, and can be used to craft custom data | ||
applications that leverage a Superset backend :chart_with_upwards_trend: | ||
|
||
## Packages | ||
|
||
[@superset-ui/core](https://github.com/apache-superset/superset-ui/tree/master/packages/superset-ui-core) | ||
[![Version](https://img.shields.io/npm/v/@superset-ui/core.svg?style=flat)](https://img.shields.io/npm/v/@superset-ui/core.svg?style=flat) | ||
|
||
#### Coming :soon: | ||
|
||
- Data providers | ||
- Embeddable charts | ||
- Chart collections | ||
- Demo storybook package | ||
|
||
### Development | ||
|
||
[lerna](https://github.com/lerna/lerna/) is used to manage versions and dependencies between | ||
packages in this monorepo. | ||
|
||
``` | ||
superset-ui/ | ||
lerna.json | ||
package.json | ||
... | ||
packages/ | ||
package1/ | ||
package.json | ||
... | ||
src/ | ||
test/ | ||
... | ||
lib/ | ||
esm/ | ||
... | ||
... | ||
``` | ||
|
||
For easiest development | ||
|
||
1. clone this repo | ||
2. install the root npm modules including lerna and yarn | ||
3. have lerna install package dependencies and manage the symlinking between packages for you | ||
|
||
```sh | ||
git clone ...superset-ui && cd superset-ui | ||
npm install | ||
lerna bootstrap | ||
``` | ||
|
||
### Builds, linting, and testing | ||
|
||
Each package defines its own build config, linting, and testing. You can have lerna run commands | ||
across all packages using the syntax `lerna exec test` from the root `@superset/monorepo` root | ||
directory. | ||
|
||
### License | ||
|
||
Apache-2.0 |
5 changes: 5 additions & 0 deletions
5
superset-frontend/temporary_superset_ui/superset-ui/lerna.json
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,5 @@ | ||
{ | ||
"lerna": "3.2.1", | ||
"packages": ["packages/*"], | ||
"version": "0.0.0" | ||
} |
39 changes: 39 additions & 0 deletions
39
superset-frontend/temporary_superset_ui/superset-ui/package.json
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,39 @@ | ||
{ | ||
"name": "@superset-ui/monorepo", | ||
"version": "0.0.0", | ||
"description": "Superset UI", | ||
"private": true, | ||
"scripts": { | ||
"build": "lerna run build", | ||
"jest": "lerna run test", | ||
"lint": "lerna run lint", | ||
"prerelease": "yarn run build", | ||
"prepare-release": "git checkout master && git pull --rebase origin master && yarn run test", | ||
"release": "yarn run prepare-release && lerna publish && lerna run gh-pages", | ||
"test": "lerna bootstrap && yarn run lint && yarn run jest" | ||
}, | ||
"repository": "https://github.com/apache-superset/superset-ui.git", | ||
"keywords": [ | ||
"apache", | ||
"superset", | ||
"data", | ||
"analytics", | ||
"analysis", | ||
"visualization", | ||
"react", | ||
"d3", | ||
"data-ui", | ||
"vx" | ||
], | ||
"license": "Apache-2.0", | ||
"devDependencies": { | ||
"lerna": "^3.2.1", | ||
"yarn": "^1.9.4" | ||
}, | ||
"engines": { | ||
"node": ">=8.10.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
...-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/README.md
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,90 @@ | ||
## `@superset-ui/core` | ||
|
||
[![Version](https://img.shields.io/npm/v/@superset-ui/core.svg?style=flat)](https://img.shields.io/npm/v/@superset-ui/core.svg?style=flat) | ||
|
||
Core modules for Superset: | ||
|
||
- `SupersetClient` requests and authentication | ||
- (future) `i18n` locales and translation | ||
|
||
### SupersetClient | ||
|
||
The `SupersetClient` handles all client-side requests to the Superset backend. It can be configured | ||
for use within the Superset application, or used to issue `CORS` requests in other applications. At | ||
a high-level it supports: | ||
|
||
- `CSRF` token authentication | ||
- queues requests in the case that another request is made before the token is received | ||
- it checks for a token before every request, an external app that uses this can detect this by | ||
catching errors, or explicitly checking `SupersetClient.isAuthorized()` | ||
- supports `GET` and `POST` requests (no `PUT` or `DELETE`) | ||
- timeouts | ||
- query aborts through the `AbortController` API | ||
|
||
#### Example usage | ||
|
||
```javascript | ||
// appSetup.js | ||
import { SupersetClient } from `@superset-ui/core`; | ||
// or import SupersetClient from `@superset-ui/core/lib|esm/SupersetClient`; | ||
|
||
SupersetClient.configure(...clientConfig); | ||
SupersetClient.init(); // CSRF auth, can also chain `.configure().init(); | ||
|
||
// anotherFile.js | ||
import { SupersetClient } from `@superset-ui/core`; | ||
|
||
SupersetClient.post(...requestConfig) | ||
.then(({ request, json }) => ...) | ||
.catch((error) => ...); | ||
``` | ||
|
||
#### API | ||
|
||
##### Client Configuration | ||
|
||
The following flags can be passed in the client config call | ||
`SupersetClient.configure(...clientConfig);` | ||
|
||
- `protocol = 'http'` | ||
- `host` | ||
- `headers` | ||
- `credentials = 'same-origin'` (set to `include` for non-Superset apps) | ||
- `mode = 'same-origin'` (set to `cors` for non-Superset apps) | ||
- `timeout` | ||
|
||
##### Per-request Configuration | ||
|
||
The following flags can be passed on a per-request call `SupersetClient.get/post(...requestConfig);` | ||
|
||
- `url` or `endpoint` | ||
- `headers` | ||
- `body` | ||
- `timeout` | ||
- `signal` (for aborting, from `const { signal } = (new AbortController())`) | ||
- for `POST` requests | ||
- `postPayload` (key values are added to a `new FormData()`) | ||
- `stringify` whether to call `JSON.stringify` on `postPayload` values | ||
|
||
##### Request aborting | ||
|
||
Per-request aborting is implemented through the `AbortController` API: | ||
|
||
```javascript | ||
import { SupersetClient } from '@superset-ui/core'; | ||
import AbortController from 'abortcontroller-polyfill'; | ||
|
||
const controller = new AbortController(); | ||
const { signal } = controller; | ||
|
||
SupersetClient.get({ ..., signal }).then(...).catch(...); | ||
|
||
if (IWantToCancelForSomeReason) { | ||
signal.abort(); // Promise is rejected, request `catch` is invoked | ||
} | ||
``` | ||
|
||
### Development | ||
|
||
`@data-ui/build-config` is used to manage the build configuration for this package including babel | ||
builds, jest testing, eslint, and prettier. |
73 changes: 73 additions & 0 deletions
73
superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-core/package.json
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,73 @@ | ||
{ | ||
"name": "@superset-ui/core", | ||
"version": "0.0.0", | ||
"description": "Superset UI core 🤖", | ||
"sideEffects": false, | ||
"main": "lib/index.js", | ||
"module": "esm/index.js", | ||
"files": [ | ||
"esm", | ||
"lib" | ||
], | ||
"scripts": { | ||
"build:cjs": "beemo babel ./src --out-dir lib/ --minify", | ||
"build:esm": "beemo babel ./src --out-dir esm/ --esm --minify", | ||
"build": "yarn run build:cjs && yarn run build:esm", | ||
"dev": "beemo babel --watch ./src --out-dir esm/ --esm", | ||
"jest": "beemo jest --color --coverage", | ||
"eslint": "beemo eslint \"./{src,test}/**/*.{js,jsx,json,md}\"", | ||
"lint": "yarn run prettier --write && yarn run eslint --fix", | ||
"test": "yarn run jest", | ||
"prettier": "beemo prettier \"./{src,test}/**/*.{js,jsx,json,md}\"", | ||
"sync:gitignore": "beemo sync-dotfiles --filter=gitignore", | ||
"prepublish": "yarn run build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/apache-superset/superset-ui.git" | ||
}, | ||
"keywords": [ | ||
"superset", | ||
"client", | ||
"core", | ||
"data" | ||
], | ||
"author": "", | ||
"license": "Apache-2.0", | ||
"bugs": { | ||
"url": "https://github.com/apache-superset/superset-ui/issues" | ||
}, | ||
"homepage": "https://github.com/apache-superset/superset-ui#readme", | ||
"devDependencies": { | ||
"@data-ui/build-config": "0.0.10", | ||
"fetch-mock": "^6.5.2" | ||
}, | ||
"dependencies": { | ||
"url-search-params-polyfill": "^4.0.1", | ||
"whatwg-fetch": "^2.0.4" | ||
}, | ||
"beemo": { | ||
"module": "@data-ui/build-config", | ||
"drivers": [ | ||
"babel", | ||
"eslint", | ||
{ | ||
"driver": "jest", | ||
"env": { | ||
"NODE_ENV": "test" | ||
} | ||
}, | ||
"prettier" | ||
], | ||
"eslint": { | ||
"rules": { | ||
"prefer-promise-reject-errors": "off" | ||
} | ||
}, | ||
"jest": { | ||
"testPathIgnorePatterns": [ | ||
"node_modules" | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.