Skip to content

Commit

Permalink
Optimize configs for bundles
Browse files Browse the repository at this point in the history
Also the READMEs are improved a bit

Relates-To: OLPEDGE-893
Signed-off-by: Oleksii Zubko <ext-oleksii.zubko@here.com>
  • Loading branch information
OleksiiZubko authored and Olesii Zubko committed Oct 18, 2019
1 parent 8c0c79a commit e530df7
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 41 deletions.
14 changes: 6 additions & 8 deletions @here/olp-sdk-authentication/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Add minified JavaScript file to your `html` and create an object of userAuth:
<!DOCTYPE html>
<html lang="en">
<head>
<script src="dist/bundle/olp-sdk-authentification.0.9.0.min.js"></script>
<script src="https://unpkg.com/browse/@here/olp-sdk-authentication@0.9.1/dist/olp-sdk-authentication.min.js"></script>
</head>
<body>
<script>
Expand All @@ -120,15 +120,13 @@ Add minified JavaScript file to your `html` and create an object of userAuth:
credentials: {
accessKeyId: "replace-with-your-access-key-id",
accessKeySecret: "replace-with-your-access-key-secret"
}
});
userAuth.setCredentials().then((result) => {
if (result.ok) {
const token = await userauth.getToken();
}
},
tokenRequester: requestToken
});
userAuth.getToken().then(token => {
// your token here
});
</script>
</body>
</html>
Expand Down
4 changes: 2 additions & 2 deletions @here/olp-sdk-authentication/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"test": "mocha > xunit.xml",
"coverage": "nyc mocha > xunit.xml",
"prepare": "tsc --sourceMap false",
"bundle": "webpack --env.NODE_ENV=development",
"bundle": "npm run bundle:dev && npm run bundle:prod",
"bundle:prod": "webpack --env.NODE_ENV=production",
"prepublish-bundle": "npm run bundle && npm run bundle:prod"
"bundle:dev": "webpack --env.NODE_ENV=development"
},
"nyc": {
"include": [
Expand Down
4 changes: 2 additions & 2 deletions @here/olp-sdk-authentication/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = env => {
},
entry: "./index.web.ts",
output: {
filename: `olp-sdk-authentification.${packageInfo.version}${isProd ? '.min' : '.dev'}.js`,
path: path.resolve(__dirname, `dist/bundle`),
filename: `olp-sdk-authentification${isProd ? '.min' : '.dev'}.js`,
path: path.resolve(__dirname, `dist`),
libraryTarget: "umd",
globalObject: 'this'
},
Expand Down
2 changes: 1 addition & 1 deletion @here/olp-sdk-dataservice-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Add minified JavaScript files to your `html`:
<!DOCTYPE html>
<html lang="en">
<head>
<script src="dist/bundle/olp-sdk-dataservice-api.0.9.0.min.js"></script>
<script src="https://unpkg.com/browse/@here/olp-sdk-dataservice-api@0.9.1/dist/olp-sdk-dataservice-api.min.js"></script>
</head>
<body>
</body>
Expand Down
4 changes: 2 additions & 2 deletions @here/olp-sdk-dataservice-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"test": "mocha > xunit.xml",
"coverage": "nyc mocha > xunit.xml",
"prepare": "tsc --sourceMap false",
"bundle": "webpack --env.NODE_ENV=development",
"bundle": "npm run bundle:dev && npm run bundle:prod",
"bundle:prod": "webpack --env.NODE_ENV=production",
"prepublish-bundle": "npm run bundle && npm run bundle:prod"
"bundle:dev": "webpack --env.NODE_ENV=development"
},
"nyc": {
"include": [
Expand Down
4 changes: 2 additions & 2 deletions @here/olp-sdk-dataservice-api/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module.exports = env => {
},
entry: "./index.ts",
output: {
filename: `olp-sdk-dataservice-api.${packageInfo.version}${isProd ? '.min' : '.dev'}.js`,
path: path.resolve(__dirname, `dist/bundle`),
filename: `olp-sdk-dataservice-api${isProd ? '.min' : '.dev'}.js`,
path: path.resolve(__dirname, `dist`),
libraryTarget: "umd",
globalObject: 'this'
},
Expand Down
49 changes: 38 additions & 11 deletions @here/olp-sdk-dataservice-read/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,50 @@ Add minified JavaScript files to your `html` and create an object of userAuth an
<!DOCTYPE html>
<html lang="en">
<head>
<script src="dist/bundle/olp-sdk-dataservice-read.0.9.0.min.js"></script>
<script src="https://unpkg.com/browse/@here/olp-sdk-fetch@0.9.1/dist/olp-sdk-fetch.min.js"></script>
<script src="https://unpkg.com/browse/@here/olp-sdk-authentication@0.9.1/dist/olp-sdk-authentication.min.js"></script>
<script src="https://unpkg.com/browse/@here/olp-sdk-dataservice-api@0.9.1/dist/olp-sdk-dataservice-api.min.js"></script>
<script src="https://unpkg.com/browse/@here/olp-sdk-dataservice-read@0.9.1/dist/olp-sdk-dataservice-read.min.js"></script>
</head>
<body>
<script>
let userauth = new UserAuth({
credentials: {
accessKeyId: "your-app-key",
accessKeySecret: "your-app-secret"
}
/**
* Authentification with olp-sdk-authentification
*/
const userAuth = new UserAuth({
env: "here",
credentials: {
accessKeyId: "your-access-key",
accessKeySecret: "your-access-secret"
},
tokenRequester: requestToken
});
let token = userauth.getToken();
const getBearerToken = () => Promise.resolve(token);
const dataStoreClient = new DataStoreClient({
getBearerToken: getBearerToken,
hrn: HRN.fromString("hrn:here:data:::here-optimized-map-for-location-library-2")
/**
* Create DatastoreContext with olp-sdk-dataservice-read
*/
const context = new DataStoreContext({
environment: "here",
getToken: () => userAuth.getToken()
});
/**
* Create client to the volatile layer with olp-sdk-dataservice-read
*/
const volatileLayerClient = new VolatileLayerClient({
context,
hrn: "your-catalog-hrn",
layerId: "your-layer-id",
});
/**
* Get some partition from the layer by ID
*/
volatileLayerClient.getPartition('some-partition-id').then(partitionResponse => {
partitionResponse.blob().then(partitionBlob => {
// your blob here
});
});
</script>
</body>
</html>
Expand Down
4 changes: 2 additions & 2 deletions @here/olp-sdk-dataservice-read/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"test": "mocha > xunit.xml",
"coverage": "nyc mocha > xunit.xml",
"prepare": "tsc --sourceMap false",
"bundle": "webpack --env.NODE_ENV=development",
"bundle": "npm run bundle:dev && npm run bundle:prod",
"bundle:prod": "webpack --env.NODE_ENV=production",
"prepublish-bundle": "npm run bundle && npm run bundle:prod"
"bundle:dev": "webpack --env.NODE_ENV=development"
},
"nyc": {
"include": [
Expand Down
4 changes: 2 additions & 2 deletions @here/olp-sdk-dataservice-read/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module.exports = env => {
},
entry: "./index.ts",
output: {
filename: `olp-sdk-dataservice-read.${packageInfo.version}${isProd ? '.min' : '.dev'}.js`,
path: path.resolve(__dirname, `dist/bundle`),
filename: `olp-sdk-dataservice-read${isProd ? '.min' : '.dev'}.js`,
path: path.resolve(__dirname, `dist`),
libraryTarget: "umd",
globalObject: 'this'
},
Expand Down
4 changes: 2 additions & 2 deletions @here/olp-sdk-fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"coverage": "nyc mocha > xunit.xml",
"copy-tests-resourses": "cp -r test/resources dist/@here/olp-sdk-fetch/test",
"prepare": "tsc --sourceMap false",
"bundle": "webpack --env.NODE_ENV=development",
"bundle": "npm run bundle:dev && npm run bundle:prod",
"bundle:prod": "webpack --env.NODE_ENV=production",
"prepublish-bundle": "npm run bundle && npm run bundle:prod"
"bundle:dev": "webpack --env.NODE_ENV=development"
},
"nyc": {
"include": [
Expand Down
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ npm run docs
If you want to have a compiled project, you can use bundle commands. After running each of the following commands, get the js bundled files from the root folder for each package:

```sh
@here/olp-sdk-authentication/dist/bundle
@here/olp-sdk-dataservice-read/dist/bundle
@here/olp-sdk-dataservice-api/dist/bundle
@here/olp-sdk-fetch/dist/bundle
@here/olp-sdk-authentication/dist
@here/olp-sdk-dataservice-read/dist
@here/olp-sdk-dataservice-api/dist
@here/olp-sdk-fetch/dist
```

To get bundled js files for all modules, run:
To get bundled js with sourcemaps files for all modules, run:

```sh
npm run bundle
npm run bundle:dev
```

To get minified version for production, run:
Expand All @@ -111,9 +111,17 @@ npm run bundle:prod
To get bundled and minified js files, run:

```sh
npm run prepublish-bundle
npm run bundle
```

Or use from CDN:

https://unpkg.com/browse/@here/olp-sdk-authentication@0.9.1/dist/olp-sdk-authentication.min.js
https://unpkg.com/browse/@here/olp-sdk-dataservice-api@0.9.1/dist/olp-sdk-dataservice-api.min.js
https://unpkg.com/browse/@here/olp-sdk-dataservice-read@0.9.1/dist/olp-sdk-dataservice-read.min.js
https://unpkg.com/browse/@here/olp-sdk-fetch@0.9.1/dist/olp-sdk-fetch.min.js


## LICENSE

Copyright (C) 2019 HERE Europe B.V.
Expand Down

0 comments on commit e530df7

Please sign in to comment.