15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/authorization-example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "compile": "tsc",
5 | "build": "webpack",
6 | "start": "webpack serve"
7 | },
8 | "devDependencies": {
9 | "webpack-dev-server": "^3.11.0",
10 | "@here/olp-sdk-authentication": "2.0.0",
11 | "@here/olp-sdk-dataservice-api": "2.0.0",
12 | "copy-webpack-plugin": "^6.3.1",
13 | "ts-loader": "^8.0.11",
14 | "typescript": "^4.0.5",
15 | "webpack": "^5.5.1",
16 | "webpack-cli": "^4.2.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "lib": ["es2017", "dom"],
6 | "sourceMap": true,
7 | "declaration": true,
8 | "baseUrl": ".",
9 | "rootDir": ".",
10 | "strict": true,
11 | "resolveJsonModule": true,
12 | "downlevelIteration": true,
13 | "newLine": "LF",
14 | "noImplicitReturns": true
15 | },
16 | "include": [
17 | "tests"
18 | ],
19 | "exclude": ["node_modules", "@here/*/node_modules"]
20 | }
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: "[BUG]"
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | ### Describe the bug.
11 |
12 | ### Which version/tag/hash of the HERE OLP SDK are you using?
13 |
14 | ### What TypeScript version are you using to compile?
15 |
16 | ### Are you using node.js or browser? What type/version?
17 |
18 | ### Steps to reproduce the issue.
19 |
20 | ### Expected behavior.
21 |
22 | ### Can you provide any TRACE level logs?
23 | *Please strip sensitive data prior to upload!*
24 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-api/api-generator/README.md:
--------------------------------------------------------------------------------
1 | Generates code from OpenAPI descriptions
2 |
3 | Use the official swagger-codegen, (https://github.com/swagger-api/swagger-codegen)
4 |
5 | Here's an example invocation to generate our output:
6 |
7 | ```bash
8 | java \
9 | -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
10 | generate \
11 | -i swagger-specification.json
12 | -t templates/TypeScript-Fetch \
13 | -l typescript-fetch \
14 | -o out
15 | ```
16 |
17 | Use `--template-engine mustache` for V3 (https://github.com/swagger-api/swagger-codegen/issues/7330#issuecomment-450925645)
18 |
--------------------------------------------------------------------------------
/examples/multipart-upload-wrapper-example/README.md:
--------------------------------------------------------------------------------
1 | # Publish large data files in a browser
2 |
3 | This example app uses an HTML and JS UI and an HTTP server with mocked routes to simulate the real `DataStore` class.
4 | You can use this app to learn how to work with the `MultipartUploadWrapper` class and publish large files of more than 8 GB to a versioned layer without loading them in memory.
5 |
6 | ## Setup
7 |
8 | This example does not need any setup. Nevertheless, make sure you installed Node.js.
9 |
10 | ## Run
11 |
12 | 1. Start the server.
13 | ```
14 | node server.js
15 | ```
16 | 2. In your favorite browser, open `http://localhost:8080/`.
17 |
--------------------------------------------------------------------------------
/examples/react-app-example/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": [
5 | "dom",
6 | "dom.iterable",
7 | "esnext"
8 | ],
9 | "allowJs": true,
10 | "skipLibCheck": true,
11 | "esModuleInterop": true,
12 | "allowSyntheticDefaultImports": true,
13 | "strict": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "noFallthroughCasesInSwitch": true,
16 | "module": "esnext",
17 | "moduleResolution": "node",
18 | "resolveJsonModule": true,
19 | "isolatedModules": true,
20 | "noEmit": true,
21 | "jsx": "react"
22 | },
23 | "include": [
24 | "src"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const TerserPlugin = require("terser-webpack-plugin");
3 |
4 | module.exports = env => {
5 | const isProd = env.NODE_ENV === "production";
6 |
7 | return {
8 | target: "web",
9 | mode: env.NODE_ENV,
10 | devtool: isProd ? undefined : "inline-source-map",
11 | resolve: {
12 | extensions: [".js"]
13 | },
14 | entry: "./index.web.js",
15 | output: {
16 | filename: `bundle.umd${isProd ? '.min' : '.dev'}.js`,
17 | path: path.resolve(__dirname),
18 | libraryTarget: "umd",
19 | globalObject: 'this'
20 | },
21 | optimization: {
22 | minimize: true,
23 | minimizer: [new TerserPlugin()],
24 | }
25 | };
26 | };
27 |
--------------------------------------------------------------------------------
/@here/olp-sdk-fetch/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const TerserPlugin = require("terser-webpack-plugin");
3 |
4 | module.exports = env => {
5 | const isProd = env.NODE_ENV === "production";
6 |
7 | return {
8 | target: "web",
9 | mode: env.NODE_ENV,
10 | devtool: isProd ? undefined : "inline-source-map",
11 | resolve: {
12 | extensions: [".js"]
13 | },
14 | entry: "./index.web.js",
15 | output: {
16 | filename: `bundle.umd${isProd ? '.min' : '.dev'}.js`,
17 | path: path.resolve(__dirname),
18 | libraryTarget: "umd",
19 | globalObject: 'this'
20 | },
21 | optimization: {
22 | minimize: true,
23 | minimizer: [new TerserPlugin()],
24 | }
25 | };
26 | };
27 |
--------------------------------------------------------------------------------
/@here/olp-sdk-authentication/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const TerserPlugin = require("terser-webpack-plugin");
3 |
4 | module.exports = env => {
5 | const isProd = env.NODE_ENV === "production";
6 |
7 | return {
8 | mode: env.NODE_ENV,
9 | target: "web",
10 | devtool: isProd ? undefined : "inline-source-map",
11 | resolve: {
12 | extensions: [".js"]
13 | },
14 | entry: "./index.web.js",
15 | output: {
16 | filename: `bundle.umd${isProd ? '.min' : '.dev'}.js`,
17 | path: path.resolve(__dirname),
18 | libraryTarget: "umd",
19 | globalObject: 'this'
20 | },
21 | optimization: {
22 | minimize: true,
23 | minimizer: [new TerserPlugin()],
24 | }
25 | };
26 | };
27 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-api/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const TerserPlugin = require("terser-webpack-plugin");
3 |
4 | module.exports = env => {
5 | const isProd = env.NODE_ENV === "production";
6 |
7 | return {
8 | target: "web",
9 | mode: env.NODE_ENV,
10 | devtool: isProd ? undefined : "inline-source-map",
11 | resolve: {
12 | extensions: [".js"]
13 | },
14 | entry: "./index.js",
15 | output: {
16 | filename: `bundle.umd${isProd ? '.min' : '.dev'}.js`,
17 | path: path.resolve(__dirname),
18 | libraryTarget: "umd",
19 | globalObject: 'this'
20 | },
21 | optimization: {
22 | minimize: true,
23 | minimizer: [new TerserPlugin()],
24 | }
25 | };
26 | };
27 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const TerserPlugin = require("terser-webpack-plugin");
3 |
4 | module.exports = env => {
5 | const isProd = env.NODE_ENV === "production";
6 |
7 | return {
8 | target: "web",
9 | mode: env.NODE_ENV,
10 | devtool: isProd ? undefined : "inline-source-map",
11 | resolve: {
12 | extensions: [".js"]
13 | },
14 | entry: "./index.web.js",
15 | output: {
16 | filename: `bundle.umd${isProd ? '.min' : '.dev'}.js`,
17 | path: path.resolve(__dirname),
18 | libraryTarget: "umd",
19 | globalObject: 'this'
20 | },
21 | optimization: {
22 | minimize: true,
23 | minimizer: [new TerserPlugin()],
24 | }
25 | };
26 | };
27 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const TerserPlugin = require("terser-webpack-plugin");
3 |
4 | module.exports = env => {
5 | const isProd = env.NODE_ENV === "production";
6 |
7 | return {
8 | target: "web",
9 | mode: env.NODE_ENV,
10 | devtool: isProd ? undefined : "inline-source-map",
11 | resolve: {
12 | extensions: [".js"]
13 | },
14 | entry: "./index.web.js",
15 | output: {
16 | filename: `bundle.umd${isProd ? '.min' : '.dev'}.js`,
17 | path: path.resolve(__dirname),
18 | libraryTarget: "umd",
19 | globalObject: 'this'
20 | },
21 | optimization: {
22 | minimize: true,
23 | minimizer: [new TerserPlugin()],
24 | }
25 | };
26 | };
27 |
--------------------------------------------------------------------------------
/examples/react-app-example/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
14 | Here Data SDK Typescript Example App
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/tests/utils/mocked-olp-server/README.md:
--------------------------------------------------------------------------------
1 | # Local OLP server
2 |
3 | This folder contains sources of a server that mimics the OLP services.
4 |
5 | Supported operations:
6 |
7 | * Lookup API
8 | * Retrieve catalog configuration
9 | * Retrieve catalog latest version
10 | * Retrieve layers versions
11 | * Retrieve layer metadata (partitions)
12 | * Retrieve data from a blob service
13 |
14 | Requests are always valid (no validation performed).
15 | Blob service returns generated text data (400-500 kb. size)
16 |
17 | ## How to run a server
18 |
19 | To run a server execute the script:
20 |
21 | ```shell
22 | node server.js
23 | ```
24 |
25 | The server implemented as a proxy between the client and the OLP. Clients can connect to it directly; no authorization required.
26 | Note: server supports HTTP protocol only.
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/index.web.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./lib";
21 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/index.web.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./lib";
21 |
--------------------------------------------------------------------------------
/@here/olp-sdk-authentication/index.ts:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | * Copyright (C) 2019 HERE Europe B.V.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | * SPDX-License-Identifier: Apache-2.0
18 | * License-Filename: LICENSE
19 | */
20 |
21 | export * from "./index.node";
22 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/lib.version.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-2024 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export const LIB_VERSION = "2.0.0";
21 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/lib/client/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./OlpClientSettings";
21 |
--------------------------------------------------------------------------------
/@here/olp-sdk-fetch/index.web.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export type FetchFunction = typeof fetch;
21 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/index.web.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./lib";
21 | export * from "./lib.version";
22 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/lib/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./client";
21 | export * from "./utils";
22 |
--------------------------------------------------------------------------------
/examples/authorization-example/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const CopyWebpackPlugin = require("copy-webpack-plugin");
3 | const webpack = require("webpack");
4 |
5 | module.exports = {
6 | entry: {
7 | main: "./build/main.js",
8 | },
9 | output: {
10 | path: path.join(__dirname, "build"),
11 | filename: "[name]-bundle.js",
12 | },
13 | devServer: {
14 | contentBase: path.join(__dirname, 'build'),
15 | port: 8080
16 | },
17 | plugins: [
18 | new webpack.DefinePlugin({
19 | "credentials": JSON.stringify({
20 | appKey: process.env.OLP_APP_KEY,
21 | appSecret: process.env.OLP_APP_SECRET
22 | })
23 | }),
24 | new CopyWebpackPlugin({
25 | patterns: [
26 | {
27 | from: "index.html",
28 | },
29 | ],
30 | }),
31 | ],
32 | };
33 |
--------------------------------------------------------------------------------
/@here/olp-sdk-authentication/oauth-requester:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | /*
4 | * Copyright (C) 2020 HERE Europe B.V.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | *
18 | * SPDX-License-Identifier: Apache-2.0
19 | * License-Filename: LICENSE
20 | */
21 |
22 | require("./lib/tokenRequester");
23 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/lib/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./cache";
21 | export * from "./utils";
22 | export * from "./client";
23 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/lib/utils/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./BlobData";
21 | export * from "./MultiPartUploadWrapper";
22 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/lib/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./utils";
21 | export * from "./client";
22 | export * from "./cache";
23 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/lib/cache/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./LRUCache";
21 | export * from "./ApiCacheRepository";
22 | export * from "./KeyValueCache";
23 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/lib/cache/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./MetadataCacheRepository";
21 | export * from "./QuadTreeIndexCacheRepository";
22 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | // tslint:disable-next-line: no-import-side-effect
21 | import "@here/olp-sdk-fetch";
22 |
23 | export * from "./lib";
24 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | // tslint:disable-next-line: no-import-side-effect
21 | import "@here/olp-sdk-fetch";
22 |
23 | export * from "./lib";
24 |
--------------------------------------------------------------------------------
/examples/react-app-example/src/Catalogs.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | .catalogs-list {
21 | margin: 20px;
22 | }
23 |
24 | .catalogs-list ul li {
25 | margin-top: 10px;
26 | }
27 |
--------------------------------------------------------------------------------
/docs/create-platform-client-settings.md:
--------------------------------------------------------------------------------
1 | # Create platform client settings
2 |
3 | You need to create the `OlpClientSettings` object to publish data and get catalog and partition metadata, as well as layer data from the HERE platform.
4 |
5 | **To create the `OlpClientSettings` object:**
6 |
7 | 1. [Authenticate](authenticate.md) to the HERE platform.
8 |
9 | 2. Import the `OlpClientSettings` class from the `olp-sdk-core` module.
10 |
11 | ```typescript
12 | import { OlpClientSettings } from "@here/olp-sdk-core";
13 | ```
14 |
15 | 3. Create the `olpClientSettings` instance using the environment in which you work and the `getToken` method.
16 |
17 | ```typescript
18 | const olpClientSettings = new OlpClientSettings({
19 | environment:
20 | "here | here-dev | here-cn | here-cn-dev | http://YourLocalEnvironment",
21 | getToken: () => userAuth.getToken()
22 | });
23 | ```
24 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/lib/utils/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./validateBillingTag";
21 | export * from "./validatePartitionsIdsList";
22 | export * from "./getTile";
23 |
--------------------------------------------------------------------------------
/examples/nodejs-example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "partitions-downloader",
3 | "version": "0.0.1",
4 | "description": "An example node app for fetching tiles from layers.",
5 | "scripts": {
6 | "build": "tsc"
7 | },
8 | "bin": {
9 | "download-partitions": "index.js"
10 | },
11 | "repository": {
12 | "type": "git",
13 | "url": "https://github.com/heremaps/here-data-sdk-typescript/tree/master/docs/examples/tile-downloader"
14 | },
15 | "author": {
16 | "name": "HERE Europe B.V.",
17 | "url": "https://here.com"
18 | },
19 | "license": "Apache-2.0",
20 | "private": true,
21 | "devDependencies": {
22 | "@types/node": "^18.7.14",
23 | "@types/yargs": "^15.0.9",
24 | "typescript": "^4.0.5"
25 | },
26 | "dependencies": {
27 | "@here/olp-sdk-authentication": "2.0.0",
28 | "@here/olp-sdk-dataservice-read": "2.0.0",
29 | "yargs": "^16.1.0"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/@here/olp-sdk-authentication/index.web.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export { OAuthArgs, Token } from "./lib/requestToken_common";
21 | export * from "./lib/requestToken.web";
22 | export * from "./lib/UserAuth";
23 |
--------------------------------------------------------------------------------
/examples/nodejs-example/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
4 | "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
5 | "strict": true, /* Enable all strict type-checking options. */
6 | "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
7 | "skipLibCheck": true, /* Skip type checking of declaration files. */
8 | "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/typedoc.json:
--------------------------------------------------------------------------------
1 |
2 | {
3 | "name": "@here/olp-sdk-ts",
4 | "out": "dist/doc",
5 | "entryPoints": [
6 | "@here/olp-sdk-authentication/index.ts",
7 | "@here/olp-sdk-dataservice-read/index.ts",
8 | "@here/olp-sdk-dataservice-write/index.ts",
9 | "@here/olp-sdk-dataservice-api/index.ts",
10 | "@here/olp-sdk-core/index.ts",
11 | "@here/olp-sdk-fetch/index.ts"
12 | ],
13 | "exclude": [
14 | "**/index.ts",
15 | "**/index.node.ts",
16 | "**/index.web.ts",
17 | "**/node_modules/**",
18 | "**/test/**/*.ts",
19 | "**/tests/**/*.ts",
20 | "**/dist/**/*.ts",
21 | "**/scripts/*.ts",
22 | "@here/olp-sdk-authentication/lib.version.ts",
23 | "@here/olp-sdk-authentication/lib/HttpError.ts",
24 | "examples/**"
25 | ],
26 | "readme": "README.md",
27 | "excludePrivate": "true",
28 | "excludeExternals": "true"
29 | }
--------------------------------------------------------------------------------
/@here/olp-sdk-core/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | // tslint:disable-next-line: no-import-side-effect
21 | import "@here/olp-sdk-fetch";
22 |
23 | export * from "./lib";
24 | export * from "./lib.version";
25 |
26 | export * as fs from "fs";
27 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-api/test/DataStoreApi.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { assert } from "chai";
21 |
22 | describe("DataStoreApiTest", function() {
23 | it("ok", function() {
24 | assert(true);
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/tests/utils/mocked-olp-server/base-urls.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | exports.lookup = "/lookup-service";
21 | exports.config = "/config-service"
22 | exports.metadata = "/metadata-service"
23 | exports.query = "/query-service"
24 | exports.blob = "/blob-service"
25 |
--------------------------------------------------------------------------------
/examples/authorization-example/README.md:
--------------------------------------------------------------------------------
1 | # Authorization Web App
2 |
3 | It is a web app with configured compiling of TS into JS and bundling with webpack.
4 | The app shows how to use the APIs from `@here/olp-sdk-dataservice-api`.
5 |
6 | You can use all the `AuthorizationAPI` functions in the same way as in this example.
7 |
8 | ## Setup
9 |
10 | 1. Download the current folder to your PC.
11 | 2. Add your app key and secret to your enviropment.
12 | ```
13 | export OLP_APP_KEY=
14 | export OLP_APP_SECRET=
15 | ```
16 | 3. Install the dependencies.
17 |
18 | ```
19 | npm install
20 | ```
21 |
22 | ## Build and run
23 |
24 | 1. Compile TS into JS.
25 |
26 | ```
27 | npm run compile
28 | ```
29 |
30 | 2. Bundle with webpack.
31 |
32 | ```
33 | npm run build
34 | ```
35 |
36 | 3. Start the web server.
37 |
38 | ```
39 | npm start
40 | ```
41 |
42 | 4. Open in your favorite browser http://localhost:8080
--------------------------------------------------------------------------------
/tests/performance/longMemoryTest.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { getDataMemoryTest } from "./getDataMemoryTest";
21 |
22 | getDataMemoryTest({
23 | requestsPerSecond: 12,
24 | runTimeSeconds: 60 * 60
25 | }).then(_ => {
26 | console.log("Long memory test done.");
27 | });
28 |
--------------------------------------------------------------------------------
/tests/utils/mocked-olp-server/urls.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | exports.lookup = "api-lookup.data.api.platform.here.com";
21 | exports.config = "config_service.com"
22 | exports.metadata = "metadata_service.com"
23 | exports.query = "query_service.com"
24 | exports.blob = "blob_service.com"
25 |
--------------------------------------------------------------------------------
/tests/performance/longCacheInMemoryTest.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { getPartitionsMemoryTest } from "./getDataPartitionsTest";
21 |
22 | getPartitionsMemoryTest({
23 | requestsPerSecond: 12,
24 | runTimeSeconds: 60 * 60
25 | }).then(_ => {
26 | console.log("Long cache in memory test done.");
27 | });
28 |
--------------------------------------------------------------------------------
/tests/performance/shortMemoryTest.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /* tslint:disable */
21 |
22 | import { getDataMemoryTest } from "./getDataMemoryTest";
23 |
24 | getDataMemoryTest({
25 | requestsPerSecond: 12,
26 | runTimeSeconds: 60 * 5
27 | }).then(_ => {
28 | console.log("Short memory test done.");
29 | });
30 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | coverage:
2 | range: 80..100
3 | round: up
4 | precision: 4
5 | notify:
6 | wait_for_ci: false
7 | status:
8 | project:
9 | authentication:
10 | paths:
11 | - ./@here/olp-sdk-authentication
12 | threshold: 1
13 | dataservice-read:
14 | paths:
15 | - ./@here/olp-sdk-dataservice-read
16 | threshold: 1
17 | dataservice-write:
18 | paths:
19 | - ./@here/olp-sdk-dataservice-write
20 | threshold: 1
21 | olp-sdk-fetch:
22 | paths:
23 | - ./@here/olp-sdk-fetch
24 | threshold: 1
25 | olp-sdk-dataservice-api:
26 | paths:
27 | - ./@here/olp-sdk-dataservice-api
28 | threshold: 1
29 | ignore:
30 | - ./@here/olp-sdk-authentication/test
31 | - ./@here/olp-sdk-core/test
32 | - ./@here/olp-sdk-dataservice-api/test
33 | - ./@here/olp-sdk-dataservice-read/test
34 | - ./@here/olp-sdk-dataservice-write/test
35 | - ./@here/olp-sdk-fetch/test
36 | - docs
37 | - scripts
38 | - tests
39 |
--------------------------------------------------------------------------------
/tests/performance/shortCacheInMemoryTest.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /* tslint:disable */
21 |
22 | import { getPartitionsMemoryTest } from "./getDataPartitionsTest";
23 |
24 | getPartitionsMemoryTest({
25 | requestsPerSecond: 12,
26 | runTimeSeconds: 60 * 5
27 | }).then(_ => {
28 | console.log("Short cache in memory test done.");
29 | });
30 |
--------------------------------------------------------------------------------
/@here/olp-sdk-authentication/index.node.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | // tslint:disable-next-line: no-import-side-effect
21 | import "@here/olp-sdk-fetch";
22 | export { OAuthArgs, Token } from "./lib/requestToken_common";
23 | export * from "./lib/requestToken";
24 | export * from "./lib/UserAuth";
25 | export * from "./lib/loadCredentialsFromFile";
26 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-api/api-generator/templates/TypeScript-Fetch/licenseInfo.mustache:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-2021 HERE Europe B.V. and its affiliate(s).
3 | * All rights reserved.
4 | *
5 | * This software and other materials contain proprietary information
6 | * controlled by HERE and are protected by applicable copyright legislation.
7 | * Any use and utilization of this software and other materials and
8 | * disclosure to any third parties is conditional upon having a separate
9 | * agreement with HERE for the access, use, utilization or disclosure of this
10 | * software. In the absence of such agreement, the use of the software is not
11 | * allowed.
12 | */
13 |
14 | /**
15 | * {{{appName}}}
16 | * {{{appDescription}}}
17 | *
18 | * {{#version}}OpenAPI spec version: {{{version}}}{{/version}}
19 | *{{#infoEmail}} Contact: {{{infoEmail}}}{{/infoEmail}}
20 | *
21 | * NOTE: This class is auto generated by the swagger code generator program.
22 | * https://github.com/swagger-api/swagger-codegen.git
23 | *
24 | * Do not edit the class manually.
25 | */
26 |
--------------------------------------------------------------------------------
/examples/react-app-example/src/index.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import React from 'react';
21 | import './index.css';
22 | import App from './App';
23 | import ReactDOM from "react-dom";
24 | import { BrowserRouter as Router } from "react-router-dom";
25 |
26 | ReactDOM.render(
27 |
28 |
29 |
30 |
31 | ,
32 | document.getElementById('root')
33 | );
34 |
--------------------------------------------------------------------------------
/tests/performance/utils.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /* tslint:disable */
21 | export interface TestParams {
22 | runTimeSeconds: number;
23 | requestsPerSecond: number;
24 | }
25 |
26 | export function getSleepPeriod(countRequestsPerSec: number): number {
27 | return 1000 / countRequestsPerSec;
28 | }
29 |
30 | export async function sleep(milliseconds: number) {
31 | return new Promise(resolve => setTimeout(resolve, milliseconds));
32 | }
33 |
--------------------------------------------------------------------------------
/examples/README.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 | HERE Data SDK for TypeScript contains several examples that demonstrate some of the key use cases:
4 |
5 | - [Authorization example](https://github.com/heremaps/here-data-sdk-typescript/tree/master/examples/authorization-example) – build the Data SDK using webpack and work with the APIs from `@here/olp-sdk-dataservice-api`. You can use this example application to find the list of groups that you have access to as well as create groups.
6 | - [React App example](https://github.com/heremaps/here-data-sdk-typescript/tree/master/examples/react-app-example) – use the Data SDK and React in a browser and learn how to work with the following modules: `olp-sdk-authentication`, `olp-sdk-dataservice-read`, and `olp-sdk-dataservice-write`.
7 | - [Node.js example](https://github.com/heremaps/here-data-sdk-typescript/tree/master/examples/nodejs-example) – work with the Data SDK in Node.js and learn how to get data from versioned layers and save it to files.
8 | - [MultiPartUploadWrapper example](https://github.com/heremaps/here-data-sdk-typescript/blob/master/examples/multipart-upload-wrapper-example) – use the Data SDK to upload and publish a large amount of data in a browser.
9 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Typescript PSV CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | branches:
9 | - '*'
10 |
11 | jobs:
12 | psv-linux-build-test-codecov:
13 | name: PSV / Linux Build / Tests / Code coverage
14 | runs-on: ubuntu-22.04
15 | steps:
16 | - uses: actions/checkout@v4
17 | - name: Use Node.js
18 | uses: actions/setup-node@v4
19 | with:
20 | node-version: 18
21 | cache: npm
22 | - name: Build / Tests / Coverage
23 | run: scripts/linux/psv/build_test_psv.sh
24 | - name: Upload coverage to Codecov
25 | uses: codecov/codecov-action@v4
26 | with:
27 | fail_ci_if_error: true # optional (default = false)
28 | verbose: true # optional (default = false)
29 | env:
30 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
31 |
32 | psv-commit-checker:
33 | name: PSV.Commit.Checker
34 | runs-on: ubuntu-latest
35 | steps:
36 | - uses: actions/checkout@v4
37 | with:
38 | fetch-depth: 0
39 | - name: Commit checker script. Verify commit text
40 | run: scripts/misc/commit_checker.sh
41 | shell: bash
42 |
43 |
--------------------------------------------------------------------------------
/examples/nodejs-example/writeToFile.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import fs from "fs";
21 |
22 | /**
23 | * Saves data to the file.
24 | *
25 | * @param path The path to the file.
26 | * @param data `Buffer` that you want to save.
27 | */
28 | export function writeToFile(path: string, data: Buffer) {
29 | fs.writeFile(path, data, err => {
30 | if (err) {
31 | return console.log(err);
32 | }
33 | console.log(`The file ${path} was saved!`);
34 | });
35 | }
36 |
--------------------------------------------------------------------------------
/.github/workflows/deploy.yml:
--------------------------------------------------------------------------------
1 | name: Typescript SDK Deploy Workflow
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | chooseDeploy:
7 | description: 'Package to deploy'
8 | required: true
9 | default: ''
10 | type: choice
11 | options:
12 | - fetch
13 | - api
14 | - core
15 | - auth
16 | - read
17 | - write
18 | - verify
19 |
20 | jobs:
21 | deploy-sdk-package-to-npm:
22 | name: Typescript SDK Build and Deploy
23 | runs-on: ubuntu-latest
24 | steps:
25 | - run: |
26 | echo "Package to deploy: $PACKAGE_NAME"
27 | env:
28 | PACKAGE_NAME: ${{ inputs.chooseDeploy }}
29 | - uses: actions/checkout@v4
30 | - name: Use Node.js
31 | uses: actions/setup-node@v4
32 | with:
33 | node-version: '18'
34 | cache: npm
35 | - name: Build / Tests
36 | run: scripts/linux/psv/build_test_psv.sh && env
37 | - name: Deploy to NPM
38 | run: scripts/publish-packages.sh -${PACKAGE_NAME}
39 | env:
40 | PACKAGE_NAME: ${{ inputs.chooseDeploy }}
41 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
42 |
--------------------------------------------------------------------------------
/examples/react-app-example/src/index.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | body {
21 | margin: 50;
22 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
23 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
24 | sans-serif;
25 | -webkit-font-smoothing: antialiased;
26 | -moz-osx-font-smoothing: grayscale;
27 | }
28 |
29 | code {
30 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
31 | monospace;
32 | }
33 |
--------------------------------------------------------------------------------
/tests/integration/api-breaks/MockedRequestBuilder.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { UrlBuilder, RequestBuilder } from "@here/olp-sdk-dataservice-api";
21 |
22 | export const mockedRequestBuilder: RequestBuilder = {
23 | baseUrl: "http://mocked.url",
24 | request: async (urlBuilder: UrlBuilder, options: any) => {
25 | return Promise.resolve("success");
26 | },
27 | requestBlob: async (urlBuilder: UrlBuilder, options: any) => {
28 | return Promise.resolve("success");
29 | }
30 | } as any;
31 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/lib/client/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./VersionedLayerClient";
21 | export * from "./StartBatchRequest";
22 | export * from "./CancelBatchRequest";
23 | export * from "./CheckDataExistsRequest";
24 | export * from "./CompleteBatchRequest";
25 | export * from "./PublishSinglePartitionRequest";
26 | export * from "./UploadPartitionsRequest";
27 | export * from "./GetBatchRequest";
28 | export * from "./UploadBlobRequest";
29 | export * from "./UploadBlobResult";
30 |
--------------------------------------------------------------------------------
/examples/react-app-example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "here-data-sdk-example",
3 | "version": "0.1.0",
4 | "private": true,
5 | "devDependencies": {
6 | "@here/olp-sdk-authentication": "2.0.0",
7 | "@here/olp-sdk-core": "2.0.0",
8 | "@here/olp-sdk-dataservice-read": "2.0.0",
9 | "@here/olp-sdk-dataservice-write": "2.0.0",
10 | "@types/node": "^18.7.14",
11 | "@types/react": "^16.9.53",
12 | "@types/react-dom": "^16.9.8",
13 | "@types/react-router-dom": "^5.1.6",
14 | "react": "^17.0.1",
15 | "react-dom": "^17.0.1",
16 | "react-scripts": "^4.0.3",
17 | "react-router-dom": "^5.2.0",
18 | "typescript": "^4.0.3"
19 | },
20 | "scripts": {
21 | "start": "export NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
22 | "build": "export NODE_OPTIONS=--openssl-legacy-provider && react-scripts build"
23 | },
24 | "eslintConfig": {
25 | "extends": [
26 | "react-app"
27 | ]
28 | },
29 | "browserslist": {
30 | "production": [
31 | ">0.2%",
32 | "not dead",
33 | "not op_mini all"
34 | ],
35 | "development": [
36 | "last 1 chrome version",
37 | "last 1 firefox version",
38 | "last 1 safari version"
39 | ]
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/lib/utils/FetchOptions.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /**
21 | * Enumerates the fetch option that controls how requests are handled.
22 | */
23 | export enum FetchOptions {
24 | /**
25 | * A default option. Queries the network if the requested resource is not
26 | * found in the cache.
27 | */
28 | OnlineIfNotFound,
29 |
30 | /**
31 | * Skips cache lookups and queries the network right away.
32 | */
33 | OnlineOnly,
34 |
35 | /**
36 | * Returns immediately if a cache lookup fails.
37 | */
38 | CacheOnly
39 | }
40 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-api/README.md:
--------------------------------------------------------------------------------
1 | # DataService API Library
2 |
3 | ## Overview
4 |
5 | This API is generated directly from the official OpenAPI (former Swagger) definition of the [Data API](https://developer.here.com/documentation/data-api/data_dev_guide/index.html).
6 |
7 | ## Generate a Bundle
8 |
9 | If you want to have a compiled project, you can use bundle commands. After running each of the following commands in the `@here/olp-sdk-dataservice-api` folder from the root folder, you get the JavaScript bundled files.
10 |
11 | To get bundled files with a source map, run:
12 |
13 | ```sh
14 | npm run bundle
15 | ```
16 |
17 | To get minified version for production, run:
18 |
19 | ```sh
20 | npm run bundle:prod
21 | ```
22 |
23 | To get bundled and minified JavaScript files, run:
24 |
25 | ```sh
26 | npm run prepublish-bundle
27 | ```
28 |
29 | ## Use a Bundle from CDN
30 |
31 | Add minified JavaScript files to your `html`:
32 |
33 | ```html
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | ```
42 |
43 | ## LICENSE
44 |
45 | Copyright (C) 2019-2023 HERE Europe B.V.
46 |
47 | For license details, see the [LICENSE](LICENSE).
48 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/lib/utils/multipartupload-internal/BufferData.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { BlobData } from "@here/olp-sdk-dataservice-write";
21 |
22 | /**
23 | * @internal
24 | * Implementation of BlobData for reading bytes from buffer.
25 | */
26 | export class BufferData implements BlobData {
27 | constructor(private readonly data: ArrayBufferLike) {}
28 |
29 | async readBytes(offset: number, count: number): Promise {
30 | return this.data.slice(offset, offset + count);
31 | }
32 |
33 | size(): number {
34 | return this.data.byteLength;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/lib/utils/userAgent.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { LIB_VERSION } from "@here/olp-sdk-core/lib.version";
21 |
22 | /**
23 | * The string for adding to the requests as query parameter.
24 | */
25 | export const SENT_WITH_PARAM = `sentWith=OLP-TS-SDK-${LIB_VERSION}`;
26 |
27 | /**
28 | * Adds sentWith param to the url.
29 | * @param url the string, representing the url
30 | * @returns the string, representing updated URL
31 | */
32 | export function addSentWithParam(url: string): string {
33 | return url.split("?").length === 1
34 | ? `${url}?${SENT_WITH_PARAM}`
35 | : `${url}&${SENT_WITH_PARAM}`;
36 | }
37 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/lib/utils/multipartupload-internal/WebData.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { BlobData } from "@here/olp-sdk-dataservice-write";
21 |
22 | /**
23 | * @internal
24 | * Implementation of reading bytes from Blob or File
25 | * object in browsers.
26 | */
27 | export class WebData implements BlobData {
28 | constructor(private readonly data: Blob | File) {}
29 |
30 | async readBytes(offset: number, count: number): Promise {
31 | return this.data.slice(offset, offset + count).arrayBuffer();
32 | }
33 |
34 | size(): number {
35 | return this.data.size;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/lib/utils/validatePartitionsIdsList.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /**
21 | * Validates a list of partitions IDs.
22 | *
23 | * It must be between 1–100 items.
24 | *
25 | * @param list The lists of strings that represent the partitions IDs.
26 | * @returns The list of strings if it's valid. Otherwise, throws an error.
27 | */
28 | export function validatePartitionsIdsList(list: string[]): string[] {
29 | const LIST_MAX_LENGTH = 100;
30 | const length = list.length;
31 |
32 | if (length < 1 || length > LIST_MAX_LENGTH) {
33 | throw new Error("The partition ids quantity must be between 1 - 100");
34 | }
35 | return list;
36 | }
37 |
--------------------------------------------------------------------------------
/examples/react-app-example/src/listOfCatalogs.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { ConfigClient } from "@here/olp-sdk-dataservice-read";
21 | import { OlpClientSettings } from "@here/olp-sdk-core";
22 |
23 | async function listOfCatalogs(settings: OlpClientSettings) {
24 | const client = new ConfigClient(settings);
25 | return client
26 | .getCatalogs()
27 | .then(res => res.results && res.results.items)
28 | .then(items => {
29 | if (items) {
30 | return (items as any).map((item: any) => ({
31 | title: item.title,
32 | hrn: item.hrn
33 | }));
34 | }
35 | return [];
36 | });
37 | }
38 |
39 | export default listOfCatalogs;
40 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/lib/utils/validateBillingTag.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /**
21 | * Validates the billinig tag.
22 | *
23 | * It must be 4–16 characters long and contain only alphanumeric ASCII characters [A-Za-z0-9].
24 | *
25 | * @param tag The string that represents the billing tag.
26 | * @return The billing tag if it's valid. Otherwise, throws an error.
27 | */
28 | export function validateBillingTag(tag: string): string {
29 | const pattern = /^[A-Za-z0-9_-]{4,16}$/;
30 |
31 | if (!pattern.test(tag)) {
32 | throw new Error(
33 | "The billing tag must be between 4 - 16 characters, contain only alpha/numeric ASCII characters [A-Za-z0-9]"
34 | );
35 | }
36 |
37 | return tag;
38 | }
39 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/lib/client/UploadBlobResult.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export class UploadBlobResult {
21 | private dataHandle?: string;
22 |
23 | /**
24 | * @brief Sets the data handle of the uploaded data.
25 | * @param id The data handle.
26 | *
27 | * @returns A reference to this object
28 | */
29 | public withDataHandle(dataHandle: string): UploadBlobResult {
30 | this.dataHandle = dataHandle;
31 | return this;
32 | }
33 |
34 | /**
35 | * @brief Gets the data handle of the uploaded data.
36 | *
37 | * @returns The data handle of the uploaded data.
38 | */
39 | public getDataHandle(): string | undefined {
40 | return this.dataHandle;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/test/unit/Uuid.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { assert } from "chai";
21 | import { Uuid } from "@here/olp-sdk-core";
22 |
23 | describe("Uuid", function() {
24 | it("Should be unique and valid value", function() {
25 | const validator = new RegExp(
26 | "^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$",
27 | "i"
28 | );
29 | const uuids = [];
30 | for (let index = 0; index < 5000; index++) {
31 | const uuid = Uuid.create();
32 | assert.isTrue(validator.test(uuid));
33 | assert.isTrue(uuids.indexOf(uuid) === -1);
34 | uuids.push(uuid);
35 | }
36 |
37 | assert.isTrue(uuids.indexOf(Uuid.create()) === -1);
38 | });
39 | });
40 |
--------------------------------------------------------------------------------
/examples/nodejs-example/getOlpClientSettings.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { UserAuth } from "@here/olp-sdk-authentication";
21 | import { OlpClientSettings } from "@here/olp-sdk-core";
22 |
23 | /**
24 | * Gets the `OlpClientSettings` instance.
25 | *
26 | * @param userAuth The `UserAuth` instance.
27 | * @param env (Optional) The environment that you want to use to get the URL of the API Lookup API.
28 | * You can also specify a URL of your custom service. The default value is `here`.
29 | *
30 | * @returns The `OlpClientSettings` instance.
31 | */
32 | export function getOlpClientSettings(
33 | userAuth: UserAuth,
34 | env?: string
35 | ): OlpClientSettings {
36 | return new OlpClientSettings({
37 | getToken: () => userAuth.getToken(),
38 | environment: env || "here"
39 | });
40 | }
41 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/test/unit/userAgent.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { assert } from "chai";
21 | import { addSentWithParam, SENT_WITH_PARAM } from "@here/olp-sdk-core";
22 |
23 | describe("addSentWithParam", function() {
24 | it("Should be preparing string as an adding additional param", function() {
25 | const url = "https://example.com/test/url?someParam=test";
26 |
27 | const result = addSentWithParam(url);
28 |
29 | assert.isTrue(result === url + "&" + SENT_WITH_PARAM);
30 | });
31 |
32 | it("Should be preparing string as an adding the first param", function() {
33 | const url = "https://example.com/test/url";
34 |
35 | const result = addSentWithParam(url);
36 |
37 | assert.isTrue(result === url + "?" + SENT_WITH_PARAM);
38 | });
39 | });
40 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/lib/utils/DownloadManager.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /**
21 | * It's an interface for `@here/olp-sdk-dataservice-api` that is used to send requests to platform services.
22 | * [[DataStoreRequestBuilder]] has its own default implementation of the download manager.
23 | * If you want to use your download manager, you can implement this interface, and then set your download manager.
24 | *
25 | * @see [[DataStoreRequestBuilder]]
26 | */
27 | export interface DownloadManager {
28 | /**
29 | * Downloads data from the specified URL.
30 | *
31 | * @param url The URL that you want to download.
32 | * @param init The helper object for the request.
33 | * @return The data from the specified URL.
34 | */
35 | download(url: string, init?: RequestInit): Promise;
36 | }
37 |
--------------------------------------------------------------------------------
/scripts/linux/psv/build_test_psv.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash -ex
2 | #
3 | # Copyright (C) 2019 HERE Europe B.V.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 | # SPDX-License-Identifier: Apache-2.0
18 | # License-Filename: LICENSE
19 |
20 | ###################################################
21 | # Following script is for SDK building verification
22 | ###################################################
23 |
24 | # Install main dependencies
25 | yarn
26 |
27 | # Initialize lerna monorepo with yarn workspaces
28 | yarn bootstrap
29 |
30 | # Build the project
31 | npm run build
32 |
33 | # Generate bundles and typedocs
34 | npm run bundle
35 | npm run typedoc
36 |
37 | # Check the lints
38 | npm run lint
39 |
40 | # Run tests
41 | npm run test
42 |
43 | # Integration tests
44 | npm run integration-test
45 |
46 | # Functional tests
47 | npm run functional-test
48 |
49 | # Test the generated bundles
50 | npm run http-server-testing-bundles & npm run test-generated-bundles
51 |
52 | # Generate and upload codecov
53 | npm run codecov
54 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/lib/utils/Uuid.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | // tslint:disable:no-bitwise
21 | // tslint:disable: no-magic-numbers
22 |
23 | /**
24 | * @brief Lets you generate uuid code
25 | */
26 | export class Uuid {
27 | /**
28 | * Creates an UUID
29 | */
30 | public static create(): string {
31 | return [
32 | Uuid.generate(2),
33 | Uuid.generate(1),
34 | Uuid.generate(1),
35 | Uuid.generate(1),
36 | Uuid.generate(3)
37 | ].join("-");
38 | }
39 |
40 | private static generate(count: number) {
41 | let result = "";
42 | for (let i = 0; i < count; i++) {
43 | result += (((1 + Math.random()) * 0x10000) | 0)
44 | .toString(16)
45 | .substring(1);
46 | }
47 | return result;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/@here/olp-sdk-authentication/lib/requestToken.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import * as crypto from "crypto";
21 | import { OAuthArgs, requestToken_common, Token } from "./requestToken_common";
22 |
23 | async function sign(data: ArrayBufferLike, secretKey: string): Promise {
24 | const hmac = crypto.createHmac("sha256", secretKey);
25 | hmac.update(Buffer.from(data));
26 | return Promise.resolve(hmac.digest("base64"));
27 | }
28 |
29 | function getRandomValues(data: Uint8Array): Uint8Array {
30 | return crypto.randomFillSync(data);
31 | }
32 |
33 | /**
34 | * Creates an access token.
35 | *
36 | * @param args The arguments needed to get the access token.
37 | * @return The generated access token.
38 | */
39 | export async function requestToken(args: OAuthArgs): Promise {
40 | return requestToken_common(args, { sign, getRandomValues });
41 | }
42 |
--------------------------------------------------------------------------------
/examples/nodejs-example/getUserAuth.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import {
21 | UserAuth,
22 | requestToken,
23 | loadCredentialsFromFile
24 | } from "@here/olp-sdk-authentication";
25 |
26 | /**
27 | * Gets the configured `UserAuth` instance.
28 | *
29 | * @param pathToCredentials The path to the `credential.properties` file.
30 | * For instructions, see the [Register Your Application](https://developer.here.com/documentation/identity-access-management/dev_guide/topics/plat-token.html#step-1-register-your-application)
31 | * section in the Identity & Access Management Developer Guide.
32 | *
33 | * @returns The `UserAuth` instance.
34 | */
35 | export function getUserAuth(pathToCredentials: string): UserAuth {
36 | const credentials = loadCredentialsFromFile(pathToCredentials);
37 | return new UserAuth({
38 | tokenRequester: requestToken,
39 | credentials
40 | });
41 | }
42 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/lib/utils/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /**
21 | * Status codes of HTTP responses.
22 | */
23 | export enum STATUS_CODES {
24 | OK = 200,
25 | CREATED = 201,
26 | NO_CONTENT = 204,
27 | FOUND = 302,
28 | BAD_REQUEST = 400,
29 | NOT_FOUND = 404,
30 | TO_MANY_REQUESTS = 429,
31 | INTERNAL_SERVER_ERROR = 500,
32 | SERVICE_UNAVAIBLE = 503,
33 | NETWORK_CONNECT_TIMEOUT = 599
34 | }
35 |
36 | export * from "./DataStoreDownloadManager";
37 | export * from "./DataStoreRequestBuilder";
38 | export * from "./DownloadManager";
39 | export * from "./RequestBuilderFactory";
40 | export * from "./getEnvLookupUrl";
41 | export * from "./HRN";
42 | export * from "./getDataSizeUtil";
43 | export * from "./HttpError";
44 | export * from "./FetchOptions";
45 | export * from "./TileKey";
46 | export * from "./Uuid";
47 | export * from "./userAgent";
48 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/test/unit/BufferData.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import * as chai from "chai";
21 | import sinonChai = require("sinon-chai");
22 | import { BufferData } from "../../lib/utils/multipartupload-internal/BufferData";
23 |
24 | chai.use(sinonChai);
25 | const expect = chai.expect;
26 |
27 | describe("BufferData", function() {
28 | let mockedData: Buffer;
29 | beforeEach(() => {
30 | mockedData = Buffer.from("test-data", "utf-8");
31 | });
32 |
33 | it("readBytes", async function() {
34 | const data = new BufferData(mockedData);
35 | const bytes = await data.readBytes(2, 3);
36 | expect(bytes.byteLength).eqls(3);
37 | expect(bytes.toString()).eqls("st-");
38 | });
39 |
40 | it("size", function() {
41 | const data = new BufferData(mockedData);
42 | expect(data.size()).eqls(9);
43 | });
44 | });
45 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/test/unit/UploadBlobResult.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import * as chai from "chai";
21 | import sinonChai = require("sinon-chai");
22 | import { UploadBlobResult } from "@here/olp-sdk-dataservice-write";
23 |
24 | chai.use(sinonChai);
25 |
26 | const assert = chai.assert;
27 | const expect = chai.expect;
28 |
29 | describe("UploadBlobResult", function() {
30 | it("Should initialize", function() {
31 | const request = new UploadBlobResult();
32 |
33 | assert.isDefined(request);
34 | expect(request).be.instanceOf(UploadBlobResult);
35 | });
36 |
37 | it("Should set and get parameters", function() {
38 | const mockedDataHandle = "mocked-datahandle";
39 | const request = new UploadBlobResult().withDataHandle(mockedDataHandle);
40 | expect(request.getDataHandle()).to.be.equal(mockedDataHandle);
41 | });
42 | });
43 |
--------------------------------------------------------------------------------
/tests/integration/api-breaks/HttpError.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import * as chai from "chai";
21 | import sinonChai = require("sinon-chai");
22 |
23 | import { HttpError } from "@here/olp-sdk-core";
24 |
25 | chai.use(sinonChai);
26 |
27 | const assert = chai.assert;
28 | const expect = chai.expect;
29 |
30 | describe("HttpError", function() {
31 | it("Shoud be initialized with arguments", async function() {
32 | const testError = new HttpError(101, "Test Error");
33 | assert.isDefined(testError);
34 |
35 | expect(testError).to.be.instanceOf(HttpError);
36 | assert.isDefined(testError.status);
37 | assert.isDefined(testError.message);
38 | });
39 |
40 | it("Test isHttpError method with HttpError", async function() {
41 | const testError = new HttpError(101, "Test Error");
42 | const response = HttpError.isHttpError(testError);
43 | assert.isTrue(response);
44 | });
45 | });
46 |
--------------------------------------------------------------------------------
/tests/integration/api-breaks/HttpErrorAuth.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import * as chai from "chai";
21 | import sinonChai = require("sinon-chai");
22 |
23 | import { HttpError } from "@here/olp-sdk-core";
24 |
25 | chai.use(sinonChai);
26 |
27 | const assert = chai.assert;
28 | const expect = chai.expect;
29 |
30 | describe("Authentication HttpError", function() {
31 | it("Shoud be initialized with arguments", async function() {
32 | const testError = new HttpError(101, "Test Error");
33 | assert.isDefined(testError);
34 |
35 | expect(testError).to.be.instanceOf(HttpError);
36 | assert.isDefined(testError.status);
37 | assert.isDefined(testError.message);
38 | });
39 |
40 | it("Test isHttpError method with HttpError", async function() {
41 | const testError = new HttpError(101, "Test Error");
42 | const response = HttpError.isHttpError(testError);
43 | assert.isTrue(response);
44 | });
45 | });
46 |
--------------------------------------------------------------------------------
/scripts/misc/commit_message_recom.txt:
--------------------------------------------------------------------------------
1 | #######################################################################
2 | #######################################################################
3 | Summarize changes in around 50 characters or less.
4 |
5 | More detailed explanatory text. Wrap it to about 72
6 | characters or so. In some contexts, the first line is treated as the
7 | subject of the commit and the rest of the text as the body. The
8 | blank line separating the summary from the body is critical (unless
9 | you omit the body entirely); various tools like `log`, `shortlog`
10 | and `rebase` can get confused if you run the two together.
11 |
12 | Explain the problem that this commit is solving. Focus on why you
13 | are making this change as opposed to how (the code explains that).
14 | Are there side effects or other unintuitive consequences of this
15 | change? Here's the place to explain them.
16 |
17 | Further paragraphs come after blank lines.
18 |
19 | - Bullet points are okay, too.
20 |
21 | - Typically a hyphen or asterisk is used for the bullet, preceded
22 | by a single space, with blank lines in between, but conventions
23 | vary here.
24 |
25 | All commits need to reference a ticket (ABC-333) or Github issue (#123),
26 | again separated by a blank line from the commit message summary above.
27 | If message do not contain @here.com then following ticket reference is
28 | optional:
29 |
30 | Resolves: ABC-111, #123
31 | Relates-To: ABC-333, #321
32 | See also: ABC-432, #456, #789
33 |
34 | Signed-off-by: FirstName LastName
35 | #######################################################################
36 | #######################################################################
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/test/unit/CatalogRequest.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import sinon = require("sinon");
21 | import * as chai from "chai";
22 | import sinonChai = require("sinon-chai");
23 |
24 | import { CatalogRequest } from "../../lib";
25 |
26 | chai.use(sinonChai);
27 |
28 | const assert = chai.assert;
29 | const expect = chai.expect;
30 |
31 | describe("CatalogRequest", function() {
32 | const billingTag = "billingTag";
33 |
34 | it("Should initialize", function() {
35 | const catalogRequest = new CatalogRequest();
36 |
37 | assert.isDefined(CatalogRequest);
38 | expect(catalogRequest).be.instanceOf(CatalogRequest);
39 | });
40 |
41 | it("Should set parameters", function() {
42 | const catalogRequest = new CatalogRequest();
43 | const catalogRequestWithBillTag = catalogRequest.withBillingTag(
44 | billingTag
45 | );
46 |
47 | expect(catalogRequestWithBillTag.getBillingTag()).to.be.equal(
48 | billingTag
49 | );
50 | });
51 | });
52 |
--------------------------------------------------------------------------------
/@here/olp-sdk-authentication/test/loadCredentialsFromFile.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { assert } from "chai";
21 | import { loadCredentialsFromFile } from "../lib/loadCredentialsFromFile";
22 |
23 | describe("loadCredentialsFromFile", function() {
24 | it("should return correct AuthCredentials", function() {
25 | const credentials = loadCredentialsFromFile(
26 | "./test/test-credentials.properties"
27 | );
28 |
29 | assert.strictEqual(credentials.accessKeyId, "Tt7wZRTAar");
30 | assert.strictEqual(
31 | credentials.accessKeySecret,
32 | "khcy1LMBtMZsRVn1-dn7riw9x8"
33 | );
34 | });
35 |
36 | it("should throw an error", function() {
37 | try {
38 | loadCredentialsFromFile("./test/test-error-credentials.properties");
39 | } catch (error) {
40 | assert.strictEqual(
41 | error.message,
42 | "Error parsing value here.access.key.id from configuration"
43 | );
44 | }
45 | });
46 | });
47 |
--------------------------------------------------------------------------------
/@here/olp-sdk-fetch/README.md:
--------------------------------------------------------------------------------
1 | # Fetch Library
2 |
3 | ## Overview
4 |
5 | This module adds a supporting file:// to the [fetch](https://fetch.spec.whatwg.org/) API for [Node.js](https://nodejs.org/). This allows fetching the files from the local folders.
6 |
7 | The main goal of this module is to provide the possibility to read files from the local folders with `fetch` API in the Node.js environment.
8 |
9 | ## Usage
10 |
11 | Import the module for its side-effects:
12 |
13 | ```JavaScript
14 | import "@here/olp-sdk-fetch"
15 | ```
16 |
17 | This adds `fetch` to the global `Node.js` namespace.
18 |
19 | ## Behavior in a Browser Context
20 |
21 | When this module is used in a browser context, it does not perform any actions, nor adds any code.
22 |
23 | ## Generate a Bundle
24 |
25 | If you want to have a compiled project, you can use bundle commands. After running each of the following commands in the `@here/olp-sdk-fetch` folder from the root folder, you get the JavaScript bundled files.
26 |
27 | To have the bundled files with source map, run:
28 |
29 | ```sh
30 | npm run bundle
31 | ```
32 |
33 | To get a minified version for production, run:
34 |
35 | ```sh
36 | npm run bundle:prod
37 | ```
38 |
39 | To get a bundled and minified JavaScript files, run:
40 |
41 | ```sh
42 | npm run prepublish-bundle
43 | ```
44 |
45 | ## Use a Bundle from CDN
46 |
47 | Add minified JavaScript file to your `html` and create an object of userAuth:
48 |
49 | ```html
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | ```
58 |
59 | ## LICENSE
60 |
61 | Copyright (C) 2019-2024 HERE Europe B.V.
62 |
63 | For license details, see the [LICENSE](LICENSE).
64 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-api/test/MockedRequestBuilder.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { RequestBuilder, RequestOptions } from "../lib/RequestBuilder";
21 |
22 | export class MockedRequestBuilder extends RequestBuilder {
23 | constructor(
24 | private readonly params: {
25 | baseUrl?: string;
26 | request?: (url: string, init?: RequestOptions) => Promise;
27 | requestBlob?: (
28 | url: string,
29 | init?: RequestOptions
30 | ) => Promise;
31 | }
32 | ) {
33 | super(params.baseUrl || "http://mocked.url");
34 | }
35 |
36 | async download(url: string, init?: RequestOptions): Promise {
37 | return this.params.request
38 | ? this.params.request(url, init)
39 | : Promise.resolve({} as T);
40 | }
41 |
42 | async downloadBlob(url: string, init?: RequestOptions): Promise {
43 | return this.params.requestBlob
44 | ? this.params.requestBlob(url, init)
45 | : Promise.resolve(new Response());
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/examples/react-app-example/src/getOlpClientSettings.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { requestToken, UserAuth } from "@here/olp-sdk-authentication";
21 | import { OlpClientSettings } from "@here/olp-sdk-core";
22 |
23 | function getOlpClientSettings() {
24 | return fetch("/credentials.json")
25 | .then(res => res.json())
26 | .then(credentials => {
27 | const userAuth = new UserAuth({
28 | tokenRequester: requestToken,
29 | env: "here",
30 | credentials
31 | });
32 |
33 | return new OlpClientSettings({
34 | environment: "here",
35 | getToken: () => userAuth.getToken()
36 | });
37 | })
38 | .catch(_ => {
39 | throw new Error(`Please create file ./public/credentials.json and add your credentials in format: {
40 | "accessKeyId": "your access key id",
41 | "accessKeySecret": "your access key secret"
42 | }.
43 | For more info please visit https://developer.here.com/documentation/sdk-typescript/dev_guide/topics/authenticate.html`);
44 | });
45 | }
46 |
47 | export default getOlpClientSettings;
48 |
--------------------------------------------------------------------------------
/tests/integration/bundles/umd/olp-sdk-authentication-testCases.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import assert = require("assert");
21 | import { requestToken, UserAuth } from "@here/olp-sdk-authentication";
22 |
23 | export const OlpSdkAuthenticationTestCases: {
24 | it: string;
25 | callback: () => void;
26 | }[] = [
27 | {
28 | it: "UserAuth should be defined",
29 | callback: function() {
30 | assert(UserAuth !== undefined);
31 | }
32 | },
33 | {
34 | it: "UserAuth should be initialised",
35 | callback: function() {
36 | const userAuth = new UserAuth({
37 | credentials: {
38 | accessKeyId: "mocked-id",
39 | accessKeySecret: "mocked-str"
40 | },
41 | tokenRequester: requestToken
42 | });
43 |
44 | assert(userAuth.getToken !== undefined);
45 | assert(userAuth.getUserInfo !== undefined);
46 | assert(userAuth.validateAccessToken !== undefined);
47 | }
48 | },
49 | {
50 | it: "requestToken should be defined",
51 | callback: function() {
52 | assert(requestToken !== undefined);
53 | }
54 | }
55 | ];
56 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/test/unit/GetBatchRequest.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import * as chai from "chai";
21 | import sinonChai = require("sinon-chai");
22 | import { GetBatchRequest } from "@here/olp-sdk-dataservice-write";
23 |
24 | chai.use(sinonChai);
25 |
26 | const assert = chai.assert;
27 | const expect = chai.expect;
28 |
29 | describe("GetBatchRequest", function() {
30 | it("Should initialize", function() {
31 | const request = new GetBatchRequest();
32 |
33 | assert.isDefined(request);
34 | expect(request).be.instanceOf(GetBatchRequest);
35 | });
36 |
37 | it("Should set and get parameters", function() {
38 | const mockedPublicationId = "publication-id";
39 | const mockedBillingTag = "mocked-billing-tag";
40 |
41 | const request = new GetBatchRequest()
42 | .withPublicationId(mockedPublicationId)
43 | .withBillingTag(mockedBillingTag);
44 |
45 | expect(request.getPublicationId()).to.be.equal(mockedPublicationId);
46 | expect(request.getBillingTag()).to.be.equal(mockedBillingTag);
47 | });
48 | });
49 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/lib/client/CatalogRequest.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { validateBillingTag } from "@here/olp-sdk-dataservice-read";
21 |
22 | /**
23 | * Prepares information for calls to get catalog metadata from the platform Config Service.
24 | */
25 | export class CatalogRequest {
26 | private billingTag?: string;
27 |
28 | /**
29 | * An optional free-form tag that is used for grouping billing records together.
30 | * If supplied, it must be 4–16 characters long and contain only alphanumeric ASCII characters [A-Za-z0-9].
31 | *
32 | * @param tag The `BillingTag` string.
33 | * @return The updated [[CatalogRequest]] instance that you can use to chain methods.
34 | */
35 | public withBillingTag(tag: string): CatalogRequest {
36 | this.billingTag = validateBillingTag(tag);
37 | return this;
38 | }
39 |
40 | /**
41 | * Gets a billing tag to group billing records together.
42 | *
43 | * @return The `BillingTag` string.
44 | */
45 | public getBillingTag(): string | undefined {
46 | return this.billingTag;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/test/unit/CancelBatchRequest.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import * as chai from "chai";
21 | import sinonChai = require("sinon-chai");
22 | import { CancelBatchRequest } from "@here/olp-sdk-dataservice-write";
23 |
24 | chai.use(sinonChai);
25 |
26 | const assert = chai.assert;
27 | const expect = chai.expect;
28 |
29 | describe("CancelBatchRequest", function() {
30 | it("Should initialize", function() {
31 | const request = new CancelBatchRequest();
32 |
33 | assert.isDefined(request);
34 | expect(request).be.instanceOf(CancelBatchRequest);
35 | });
36 |
37 | it("Should set and get parameters", function() {
38 | const mockedPublicationId = "publication-id";
39 | const mockedBillingTag = "mocked-billing-tag";
40 |
41 | const request = new CancelBatchRequest()
42 | .withPublicationId(mockedPublicationId)
43 | .withBillingTag(mockedBillingTag);
44 |
45 | expect(request.getPublicationId()).to.be.equal(mockedPublicationId);
46 | expect(request.getBillingTag()).to.be.equal(mockedBillingTag);
47 | });
48 | });
49 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/lib/client/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./CatalogClient";
21 | export * from "./CatalogRequest";
22 | export * from "./DataRequest";
23 | export * from "./StatisticsClient";
24 | export * from "./StatisticsRequest";
25 | export * from "./SummaryRequest";
26 | export * from "./VersionedLayerClient";
27 | export * from "./VolatileLayerClient";
28 | export * from "./ConfigClient";
29 | export * from "./CatalogsRequest";
30 | export * from "./SchemaDetailsRequest";
31 | export * from "./ArtifactClient";
32 | export * from "./PartitionsRequest";
33 | export * from "./QueryClient";
34 | export * from "./QuadTreeIndexRequest";
35 | export * from "./QuadKeyPartitionsRequest";
36 | export * from "./SchemaRequest";
37 | export * from "./CatalogVersionRequest";
38 | export * from "./LayerVersionsRequest";
39 | export * from "./IndexLayerClient";
40 | export * from "./IndexQueryRequest";
41 | export * from "./StreamLayerClient";
42 | export * from "./SubscribeRequest";
43 | export * from "./PollRequest";
44 | export * from "./UnsubscribeRequest";
45 | export * from "./SeekRequest";
46 | export * from "./TileRequest";
47 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/test/unit/CompleteBatchRequest.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import * as chai from "chai";
21 | import sinonChai = require("sinon-chai");
22 | import { CompleteBatchRequest } from "@here/olp-sdk-dataservice-write";
23 |
24 | chai.use(sinonChai);
25 |
26 | const assert = chai.assert;
27 | const expect = chai.expect;
28 |
29 | describe("CompleteBatchRequest", function() {
30 | it("Should initialize", function() {
31 | const request = new CompleteBatchRequest();
32 |
33 | assert.isDefined(request);
34 | expect(request).be.instanceOf(CompleteBatchRequest);
35 | });
36 |
37 | it("Should set and get parameters", function() {
38 | const mockedPublicationId = "publication-id";
39 | const mockedBillingTag = "mocked-billing-tag";
40 |
41 | const request = new CompleteBatchRequest()
42 | .withPublicationId(mockedPublicationId)
43 | .withBillingTag(mockedBillingTag);
44 |
45 | expect(request.getPublicationId()).to.be.equal(mockedPublicationId);
46 | expect(request.getBillingTag()).to.be.equal(mockedBillingTag);
47 | });
48 | });
49 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/README.md:
--------------------------------------------------------------------------------
1 | # HERE Data SDK Core Library
2 |
3 | ## Overview
4 |
5 | This repository contains the complete source code for the HERE Data SDK Core for TypeScript `@here/olp-sdk-core` project. `olp-sdk-core` is a TypeScript library that contains the common code for `@here/olp-sdk-dataservice-read`, `@here/olp-sdk-dataservice-api`, and `@here/olp-sdk-authentication`.
6 |
7 | ## Directory Layout
8 |
9 | Here is an overview of the top-level files of the repository:
10 |
11 | |
12 | +- @here/olp-sdk-core
13 | |
14 | +- lib # Implementation of the project
15 | |
16 | +- test # Test code
17 |
18 | ## Development
19 |
20 | ### Prerequisites
21 |
22 | The following NPM packages are required to build/test the library:
23 |
24 | - node: >= 10.0.0
25 | - npm: >= 6.0.0
26 |
27 | ### Build
28 |
29 | Open a command prompt of the working tree's root directory and type:
30 |
31 | ```sh
32 | npm install
33 | npm run build
34 | ```
35 |
36 | ### Test
37 |
38 | Open a command prompt of the working tree's root directory and type:
39 |
40 | ```sh
41 | npm run test
42 | ```
43 |
44 | ### Generate a Bundle
45 |
46 | If you want to have a compiled project, you can use bundle commands. After running each of the following commands in the `@here/olp-sdk-dataservice-read` folder from the root folder, you get the JavaScript bundled files.
47 |
48 | To get bundled files with a source map, run:
49 |
50 | ```sh
51 | npm run bundle
52 | ```
53 |
54 | To get minified version for production, run:
55 |
56 | ```sh
57 | npm run bundle:prod
58 | ```
59 |
60 | To get bundled and minified JavaScript files, run:
61 |
62 | ```sh
63 | npm run prepublish-bundle
64 | ```
65 |
66 | ## LICENSE
67 |
68 | Copyright (C) 2020-2023 HERE Europe B.V.
69 |
70 | For license details, see the [LICENSE](LICENSE).
71 |
--------------------------------------------------------------------------------
/examples/react-app-example/src/Catalogs.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import { OlpClientSettings } from "@here/olp-sdk-core";
21 | import React from "react";
22 | import { Link } from "react-router-dom";
23 | import "./Catalogs.css";
24 | import listOfCatalogs from "./listOfCatalogs";
25 |
26 | class Catalogs extends React.Component<
27 | { settings: OlpClientSettings },
28 | {
29 | catalogs: { title: string; hrn: string }[];
30 | }
31 | > {
32 | constructor(props: { settings: OlpClientSettings }) {
33 | super(props);
34 | this.state = {
35 | catalogs: [],
36 | };
37 | }
38 |
39 | componentDidMount() {
40 | listOfCatalogs(this.props.settings).then((catalogs) => {
41 | this.setState({ catalogs });
42 | });
43 | }
44 |
45 | render() {
46 | return (
47 |
57 | );
58 | }
59 | }
60 |
61 | export default Catalogs;
62 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/lib/utils/BlobData.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /**
21 | * An abstraction for `BlobData` instances.
22 | *
23 | * The wrapper of data (`Blob`, `Buffer`, `File`, string, and so on)
24 | * that allows to read a specific range of bytes and get data size.
25 | */
26 | export abstract class BlobData {
27 | /**
28 | * Gets buffer from a range of data.
29 | *
30 | * @param offset The first byte of the data range for reading.
31 | * @param count The number of bytes to read from the underlying data.
32 | * This value will be trimmed if the count exceeded the EOF or end of the stream.
33 | *
34 | * @returns The `Promise` object with the buffer.
35 | */
36 | abstract readBytes(offset: number, count: number): Promise;
37 |
38 | /**
39 | * Gets the size of the data.
40 | *
41 | * @returns The `Promise` object with the length of the data in bytes.
42 | */
43 | abstract size(): number;
44 |
45 | /**
46 | * This method should always be called at the end of the reading process
47 | * so that we can properly clean up.
48 | */
49 | abstract finally?(): Promise;
50 | }
51 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/test/unit/WebData.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import * as chai from "chai";
21 | import sinonChai = require("sinon-chai");
22 | import { WebData } from "../../lib/utils/multipartupload-internal/WebData";
23 |
24 | chai.use(sinonChai);
25 | const expect = chai.expect;
26 |
27 | describe("WebData", function() {
28 | let mockedBlob: Blob;
29 | const mockedDataSize = 9;
30 | beforeEach(() => {
31 | mockedBlob = {
32 | slice: (from: number, to: number) => {
33 | return {
34 | arrayBuffer: () =>
35 | Promise.resolve(
36 | Buffer.from("test-data", "utf8").slice(from, to)
37 | )
38 | };
39 | },
40 | size: mockedDataSize
41 | } as any;
42 | });
43 |
44 | it("readBytes", async function() {
45 | const data = new WebData(mockedBlob);
46 | const bytes = await data.readBytes(2, 3);
47 | expect(bytes.byteLength).eqls(3);
48 | expect(bytes.toString()).eqls("st-");
49 | });
50 |
51 | it("size", function() {
52 | const data = new WebData(mockedBlob);
53 | expect(data.size()).eqls(9);
54 | });
55 | });
56 |
--------------------------------------------------------------------------------
/@here/olp-sdk-core/lib/utils/HttpError.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /**
21 | * Provides more usable errors from the HERE platform Services.
22 | *
23 | * This class is used in the methods
24 | * to propagate errors with an HTTP status code and with a message
25 | * if something goes wrong during the request.
26 | * The `HttpError` class extends generic `Error` class from V8 and
27 | * adds property code to the HTTP statuses.
28 | */
29 | export class HttpError extends Error {
30 | /** A name of the error type. The initial value is `Error`. */
31 | public readonly name: string;
32 |
33 | /**
34 | * Constructs the `HttpError` instance.
35 | *
36 | * @param status The error status number.
37 | * @param message A human-readable description of the error.
38 | */
39 | constructor(public status: number, message: string) {
40 | super(message);
41 | this.name = "HttpError";
42 | }
43 |
44 | /**
45 | * Checks if the given error is an HTTP error.
46 | *
47 | * @param error The `Error` object that is checked.
48 | * @returns True is the given error is an HTTP error; false otherwise.
49 | */
50 | public static isHttpError(error: any): error is HttpError {
51 | return error.name === "HttpError";
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/test/unit/CheckDataExistsRequest.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import * as chai from "chai";
21 | import sinonChai = require("sinon-chai");
22 | import { CheckDataExistsRequest } from "@here/olp-sdk-dataservice-write";
23 |
24 | chai.use(sinonChai);
25 |
26 | const assert = chai.assert;
27 | const expect = chai.expect;
28 |
29 | describe("CheckDataExistsRequest", function() {
30 | it("Should initialize", function() {
31 | const request = new CheckDataExistsRequest();
32 |
33 | assert.isDefined(request);
34 | expect(request).be.instanceOf(CheckDataExistsRequest);
35 | });
36 |
37 | it("Should set and get parameters", function() {
38 | const mockedLayer = "layer-0";
39 | const mockedBillingTag = "mocked-billing-tag";
40 | const mockedDataHandle = "datahandle123";
41 |
42 | const request = new CheckDataExistsRequest()
43 | .withLayerId(mockedLayer)
44 | .withDataHandle(mockedDataHandle)
45 | .withBillingTag(mockedBillingTag);
46 |
47 | expect(request.getLayerId()).to.be.equal(mockedLayer);
48 | expect(request.getBillingTag()).to.be.equal(mockedBillingTag);
49 | expect(request.getDataHandle()).to.be.equal(mockedDataHandle);
50 | });
51 | });
52 |
--------------------------------------------------------------------------------
/tests/utils/mocked-olp-server/blob_service.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | function generateGetBlobApiResponse(request) {
21 | const layer = request[1]
22 | const dataHandle = request[2] // ignored
23 |
24 | // Generate a blob 400-500 Kb
25 | var response = ""
26 | var length = (Math.floor(Math.random() * 100) + 400) * 1024
27 | var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
28 | var charactersLength = characters.length;
29 | for ( var i = 0; i < length; i++ ) {
30 | response += characters.charAt(Math.floor(Math.random() * charactersLength));
31 | }
32 |
33 | return response;
34 | }
35 |
36 | const methods = [
37 | {
38 | regex: /layers\/(.+)\/data\/(.+)$/,
39 | handler: generateGetBlobApiResponse
40 | }
41 | ]
42 |
43 | function blob_handler(pathname, query) {
44 | for (method of methods) {
45 | const match = pathname.match(method.regex)
46 | if (match) {
47 | const response = method.handler(match, query)
48 | return { status: 200, text: response, headers : {"Content-Type": "application/x-protobuf"} }
49 | }
50 | }
51 | console.log("Not handled", pathname)
52 | return { status: 404, text: "Not Found" }
53 | }
54 |
55 | exports.handler = blob_handler
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-write/lib/utils/multipartupload-internal/UploadRequest.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /**
21 | * @internal
22 | * Interfaces for upload requests classes.
23 | */
24 | export abstract class UploadRequest {
25 | abstract startMultipartUpload(opts: {
26 | layerId: string;
27 | handle: string;
28 | contentType: string;
29 | contentEncoding?: string;
30 | billingTag?: string;
31 | }): Promise<{
32 | multipartToken?: string;
33 | uploadPartUrl?: string;
34 | completeUrl?: string;
35 | statusUrl?: string;
36 | }>;
37 |
38 | abstract uploadPart(opts: {
39 | data: ArrayBuffer;
40 | multipartToken?: string;
41 | layerId?: string;
42 | url?: string;
43 | contentType?: string;
44 | partNumber?: number;
45 | contentLength?: number;
46 | billingTag?: string;
47 | }): Promise<{
48 | partNumber: number;
49 | partId: string;
50 | }>;
51 |
52 | abstract completeMultipartUpload(opts: {
53 | parts: {
54 | id: string;
55 | number: number;
56 | }[];
57 | layerId?: string;
58 | multipartToken?: string;
59 | url?: string;
60 | billingTag?: string;
61 | }): Promise;
62 | }
63 |
--------------------------------------------------------------------------------
/examples/react-app-example/README.md:
--------------------------------------------------------------------------------
1 | # Get started with the React App and HERE Data SDK for Typescript
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Run the app
6 |
7 | 1. Copy `./public/credentials.json.sample` to `./public/credentials.json`, and then add your credentials to that file.
8 |
9 | For more information, see the [related section](https://www.here.com/docs/bundle/data-sdk-for-typescript-developer-guide/page/docs/GettingStartedGuide.html) in our Developer Guide.
10 |
11 | 2. To fetch dependencies, run `yarn && yarn add react-scripts`.
12 |
13 | 3. To run the app in the development mode, run `yarn start`.
14 |
15 | 4. In your favorite browser, open `http://localhost:3000`.
16 |
17 | ## Available scripts
18 |
19 | In the project directory, you can run the following scripts:
20 |
21 | - `yarn start` – runs the app in the development mode.\
22 | To view it in the browser, open [http://localhost:3000](http://localhost:3000).
23 |
24 | The page reloads if you make edits.\
25 | You will also see no lint errors in the console.
26 |
27 | - `yarn build` – builds the app for production in the `build` folder.\
28 | It correctly bundles React in the production mode and optimizes the build for the best performance.
29 |
30 | The build is minified, and the filenames include hashes.\
31 | Your app is ready to be deployed. For more information on deployment, see the [related section](https://facebook.github.io/create-react-app/docs/deployment) in the Create React App documentation.
32 |
33 | ## Learn more
34 |
35 | For more information, see the following documentation:
36 |
37 | - Data API Developer Guide and API Reference
38 | - [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started)
39 | - [React documentation](https://reactjs.org/)
40 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/test/unit/TileRequest.test.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020-2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import sinon = require("sinon");
21 | import * as chai from "chai";
22 | import sinonChai = require("sinon-chai");
23 |
24 | import * as dataServiceRead from "../../lib";
25 | import { FetchOptions } from "@here/olp-sdk-core";
26 |
27 | chai.use(sinonChai);
28 |
29 | const assert = chai.assert;
30 | const expect = chai.expect;
31 |
32 | describe("TileRequest", function() {
33 | const mockedQuadKey = {
34 | row: 1,
35 | column: 2,
36 | level: 3
37 | };
38 |
39 | const mockedBillingTag = "billing-tag";
40 |
41 | const request = new dataServiceRead.TileRequest();
42 |
43 | it("Should initialize", function() {
44 | assert.isDefined(request);
45 | expect(request).be.instanceOf(dataServiceRead.TileRequest);
46 | });
47 |
48 | it("Should get parameters with chain", async function() {
49 | request
50 | .withTileKey(mockedQuadKey)
51 | .withBillingTag(mockedBillingTag)
52 | .withFetchOption(FetchOptions.OnlineOnly);
53 |
54 | expect(request.getTileKey()).to.be.equal(mockedQuadKey);
55 | expect(request.getFetchOption()).to.be.equal(FetchOptions.OnlineOnly);
56 | expect(request.getBillingTag()).to.be.equal(mockedBillingTag);
57 | });
58 | });
59 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-api/index.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2019-2021 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | export * from "./lib/RequestBuilder";
21 |
22 | import * as ArtifactApi from "./lib/artifact-api";
23 | import * as AuthorizationAPI from "./lib/authorization-api-v1.1";
24 | import * as BlobApi from "./lib/blob-api";
25 | import * as ConfigApi from "./lib/config-api";
26 | import * as CoverageApi from "./lib/coverage-api";
27 | import * as IndexApi from "./lib/index-api";
28 | import * as LookupApi from "./lib/lookup-api";
29 | import * as MetadataApi from "./lib/metadata-api";
30 | import * as PublishApi from "./lib/publish-api-v2";
31 | import * as QueryApi from "./lib/query-api";
32 | import * as StreamApi from "./lib/stream-api";
33 | import * as VolatileBlobApi from "./lib/volatile-blob-api";
34 | import * as ObjectStoreApi from "./lib/blob.v2.api";
35 | import * as InteractiveApi from "./lib/interactive-api-v1";
36 |
37 | // tslint:disable-next-line: array-type
38 | export type AdditionalFields = Array<
39 | "dataSize" | "checksum" | "compressedDataSize" | "crc"
40 | >;
41 |
42 | export {
43 | AuthorizationAPI,
44 | LookupApi,
45 | MetadataApi,
46 | ConfigApi,
47 | ArtifactApi,
48 | QueryApi,
49 | CoverageApi,
50 | BlobApi,
51 | VolatileBlobApi,
52 | IndexApi,
53 | StreamApi,
54 | PublishApi,
55 | ObjectStoreApi,
56 | InteractiveApi
57 | };
58 |
--------------------------------------------------------------------------------
/examples/nodejs-example/README.md:
--------------------------------------------------------------------------------
1 | # Download data with HERE Data SDK for Typescript
2 |
3 | You can use this example app to fetch data from versioned layers and save it to files.
4 |
5 | ## Build and install
6 |
7 | To build the app, run `npm run build`.
8 |
9 | If you want to use the app in any folder, install it globally by running `npm install -g .`.
10 |
11 | ## Use the app
12 |
13 | If you installed the app globally, to see the list of available parameters, run `download-partitions --help`.
14 | Otherwise, in the app folder, run `node . --help`.
15 |
16 | You can use the app to do the following:
17 |
18 | - Download and save partitions to the current directory.
19 |
20 | ```bash
21 | download-partitions -c \
22 | -l \
23 | -p partitionId1,partitionId2,partitionId3
24 | ```
25 |
26 | - Download partitions from a catalog version and save them to the current directory.
27 |
28 | ```bash
29 | download-partitions -c \
30 | -l \
31 | -p partitionId1,partitionId2,partitionId3 \
32 | -v
33 | ```
34 |
35 | - Download and save partitions to a specific directory.
36 |
37 | ```bash
38 | download-partitions -c \
39 | -l \
40 | -p partitionId1,partitionId2,partitionId3 \
41 | -o
42 | ```
43 |
44 | - Download partitions defined in a file and save them to a specific directory.
45 |
46 | ```bash
47 | download-partitions -c \
48 | -l \
49 | --pf \
50 | -o
51 | ```
52 |
53 | - Download a partition from a versioned layer with the HERE tile partitioning schema using the `row,column,level` string (a tile key) and save the partition to a specific directory.
54 |
55 | ```bash
56 | download-partitions -c \
57 | -l \
58 | -q 1580,2069,12 \
59 | -o
60 | ```
61 |
--------------------------------------------------------------------------------
/@here/olp-sdk-dataservice-read/lib/client/PollRequest.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | /**
21 | * Prepares information for calls to the platform Stream Service.
22 | */
23 | export class PollRequest {
24 | private mode?: "serial" | "parallel";
25 | private subscriptionId?: string;
26 |
27 | /**
28 | * Gets the subscription mode for the request.
29 | *
30 | * @return The subscription mode.
31 | */
32 | public getMode(): "serial" | "parallel" | undefined {
33 | return this.mode;
34 | }
35 |
36 | /**
37 | * A setter for the provided subscription mode.
38 | *
39 | * @param mode The subscription mode.
40 | * @returns The [[PollRequest]] instance that you can use to chain methods.
41 | */
42 | public withMode(mode: "serial" | "parallel"): PollRequest {
43 | this.mode = mode;
44 | return this;
45 | }
46 |
47 | /**
48 | * Gets the subscription id for the request.
49 | *
50 | * @return The subscription id.
51 | */
52 | public getSubscriptionId(): string | undefined {
53 | return this.subscriptionId;
54 | }
55 |
56 | /**
57 | * A setter for the provided subscription id.
58 | *
59 | * @param id The subscription id.
60 | * @returns The [[PollRequest]] instance that you can use to chain methods.
61 | */
62 | public withSubscriptionId(id: string): PollRequest {
63 | this.subscriptionId = id;
64 | return this;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/examples/react-app-example/src/App.tsx:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2020 HERE Europe B.V.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | * SPDX-License-Identifier: Apache-2.0
17 | * License-Filename: LICENSE
18 | */
19 |
20 | import React from "react";
21 | import { Switch, Route } from "react-router-dom";
22 | import Catalogs from "./Catalogs";
23 | import Catalog from "./Catalog";
24 | import Layer from "./Layer";
25 | import getOlpClientSettings from "./getOlpClientSettings";
26 | import { OlpClientSettings } from "@here/olp-sdk-core";
27 |
28 | export const OlpClientSettingsContext = React.createContext({});
29 | class App extends React.Component<
30 | any,
31 | {
32 | settings?: OlpClientSettings;
33 | }
34 | > {
35 | constructor(props: any) {
36 | super(props);
37 | this.state = {};
38 | }
39 |
40 | componentDidMount() {
41 | getOlpClientSettings().then((settings) => {
42 | this.setState({ settings });
43 | });
44 | }
45 | render() {
46 | if (!this.state.settings) {
47 | return null;
48 | }
49 | return (
50 |
51 |
An example React app with Here Data SDK Typescript.