Skip to content

Commit

Permalink
NodeJS 18x support
Browse files Browse the repository at this point in the history
Drop suporting nodejs < 18x.
Remove node_fetch from the dependencies.
Update development dependencies.

Relates-To: OLPEDGE-2889

Signed-off-by: Oleksii Zubko <ext-oleksii.zubko@here.com>
  • Loading branch information
OleksiiZubko committed Apr 29, 2024
1 parent f6b8762 commit 4b962ce
Show file tree
Hide file tree
Showing 11 changed files with 1,280 additions and 933 deletions.
19 changes: 9 additions & 10 deletions @here/olp-sdk-authentication/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@here/olp-sdk-authentication",
"version": "1.13.1",
"version": "2.0.0",
"description": "Wrapper around the HERE Authentication and Authorization REST API obtaining short-lived access tokens that are used to authenticate requests to HERE services.",
"main": "index.js",
"browser": "index.web.js",
Expand Down Expand Up @@ -49,20 +49,20 @@
},
"license": "Apache-2.0",
"dependencies": {
"@here/olp-sdk-core": "^1.8.0",
"@here/olp-sdk-fetch": "^1.9.0",
"properties-reader": "2.2.0"
"@here/olp-sdk-core": "^2.0.0",
"@here/olp-sdk-fetch": "^2.0.0",
"properties-reader": "2.3.0"
},
"devDependencies": {
"@types/properties-reader": "^0.0.1",
"@types/properties-reader": "^2.1.3",
"@types/chai": "^4.2.7",
"@types/fetch-mock": "^7.3.2",
"@types/mocha": "^5.2.7",
"@types/node": "^14.11.8",
"@types/node": "18.7.14",
"@types/sinon-chai": "^3.2.3",
"@types/sinon": "7.0.3",
"chai": "^4.2.0",
"fetch-mock": "^8.3.1",
"fetch-mock": "^9.11.0",
"husky": "^3.1.0",
"lint-staged": "^9.5.0",
"mocha": "^6.2.2",
Expand All @@ -71,16 +71,15 @@
"sinon-chai": "^3.4.0",
"sinon": "7.4.2",
"source-map-support": "^0.5.16",
"ts-node": "^8.5.4",
"ts-node": "10.9.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typedoc": "^0.22.13",
"typescript": "4.0.3",
"tslib": "1.13.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.10"
},
"engines": {
"node": ">= 10.18.0"
"node": ">= 18.0.0"
}
}
13 changes: 6 additions & 7 deletions @here/olp-sdk-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@here/olp-sdk-core",
"version": "1.8.1",
"version": "2.0.0",
"description": "Core features of the HERE Data Platform",
"main": "index.js",
"browser": "index.web.js",
Expand Down Expand Up @@ -49,13 +49,13 @@
},
"license": "Apache-2.0",
"dependencies": {
"@here/olp-sdk-fetch": "^1.9.0",
"@here/olp-sdk-dataservice-api": "^1.13.0"
"@here/olp-sdk-fetch": "^2.0.0",
"@here/olp-sdk-dataservice-api": "^2.0.0"
},
"devDependencies": {
"@types/chai": "^4.2.7",
"@types/mocha": "^5.2.7",
"@types/node": "^14.11.8",
"@types/node": "18.7.14",
"@types/sinon": "7.0.3",
"@types/sinon-chai": "^3.2.3",
"chai": "^4.2.0",
Expand All @@ -68,16 +68,15 @@
"sinon": "7.4.2",
"sinon-chai": "^3.4.0",
"source-map-support": "^0.5.16",
"ts-node": "^8.5.4",
"ts-node": "10.9.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typedoc": "^0.22.13",
"typescript": "4.0.3",
"tslib": "1.13.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.10"
},
"engines": {
"node": ">= 10.18.0"
"node": ">= 18.0.0"
}
}
7 changes: 3 additions & 4 deletions @here/olp-sdk-dataservice-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@here/olp-sdk-dataservice-api",
"version": "1.13.1",
"version": "2.0.0",
"description": "Generated from the OpenAPI specification of the HERE Open Location Platform Data API",
"main": "index.js",
"typings": "index",
Expand Down Expand Up @@ -61,17 +61,16 @@
"sinon": "7.4.2",
"nyc": "^15.0.0",
"prettier": "^1.19.1",
"ts-node": "^8.5.4",
"ts-node": "10.9.2",
"source-map-support": "^0.5.16",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "4.0.3",
"tslib": "1.13.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.10",
"typedoc": "^0.22.13"
},
"engines": {
"node": ">= 10.18.0"
"node": ">= 18.0.0"
}
}
15 changes: 7 additions & 8 deletions @here/olp-sdk-dataservice-read/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@here/olp-sdk-dataservice-read",
"version": "1.13.1",
"version": "2.0.0",
"description": "Wrapper around a subset of the HERE Open Location Platform Data REST API related to reading data from OLP catalogs",
"main": "index.js",
"browser": "index.web.js",
Expand Down Expand Up @@ -49,14 +49,14 @@
},
"license": "Apache-2.0",
"dependencies": {
"@here/olp-sdk-core": "^1.8.0",
"@here/olp-sdk-dataservice-api": "^1.13.0",
"@here/olp-sdk-fetch": "^1.9.0"
"@here/olp-sdk-core": "^2.0.0",
"@here/olp-sdk-dataservice-api": "^2.0.0",
"@here/olp-sdk-fetch": "^2.0.0"
},
"devDependencies": {
"@types/chai": "^4.2.7",
"@types/mocha": "^5.2.7",
"@types/node": "^14.11.8",
"@types/node": "18.7.14",
"@types/sinon": "7.0.3",
"@types/sinon-chai": "^3.2.3",
"chai": "^4.2.0",
Expand All @@ -69,16 +69,15 @@
"sinon": "7.4.2",
"sinon-chai": "^3.4.0",
"source-map-support": "^0.5.16",
"ts-node": "^8.5.4",
"ts-node": "10.9.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typedoc": "^0.22.13",
"typescript": "4.0.3",
"tslib": "1.13.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.10"
},
"engines": {
"node": ">= 10.18.0"
"node": ">= 18.0.0"
}
}
15 changes: 7 additions & 8 deletions @here/olp-sdk-dataservice-write/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@here/olp-sdk-dataservice-write",
"version": "1.8.1",
"version": "2.0.0",
"description": "Wrapper around a subset of the HERE Open Location Platform Data REST API related to writing data to OLP catalogs",
"main": "index.js",
"browser": "index.web.js",
Expand Down Expand Up @@ -50,14 +50,14 @@
},
"license": "Apache-2.0",
"dependencies": {
"@here/olp-sdk-core": "^1.8.0",
"@here/olp-sdk-dataservice-api": "^1.13.0",
"@here/olp-sdk-fetch": "^1.9.0"
"@here/olp-sdk-core": "^2.0.0",
"@here/olp-sdk-dataservice-api": "^2.0.0",
"@here/olp-sdk-fetch": "^2.0.0"
},
"devDependencies": {
"@types/chai": "^4.2.7",
"@types/mocha": "^5.2.7",
"@types/node": "^14.11.8",
"@types/node": "18.7.14",
"@types/sinon": "7.0.3",
"@types/sinon-chai": "^3.2.3",
"chai": "^4.2.0",
Expand All @@ -70,16 +70,15 @@
"sinon": "7.4.2",
"sinon-chai": "^3.4.0",
"source-map-support": "^0.5.16",
"ts-node": "^8.5.4",
"ts-node": "10.9.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typedoc": "^0.22.13",
"typescript": "4.0.3",
"tslib": "1.13.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.10"
},
"engines": {
"node": ">= 10.18.0"
"node": ">= 18.0.0"
}
}
42 changes: 16 additions & 26 deletions @here/olp-sdk-fetch/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 HERE Europe B.V.
* Copyright (C) 2019-2024 HERE Europe B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,32 +19,13 @@

// @here:check-imports:environment:node

// tslint:disable-next-line:no-var-requires
const node_fetch = require("node-fetch");

import * as fs from "fs";
import { URL } from "url";

declare const global: any;

class AbortSignal {
aborted = false;
}

class AbortController {
signal = new AbortSignal();
abort() {
this.signal.aborted = true;
}
}

if (global.fetch === undefined) {
if (global.fetch && !global.fetch.sdkImplementation) {
global.fetch = fetchWithFileSupport;
global.Response = node_fetch.Response;
global.Headers = node_fetch.Headers;
global.Request = node_fetch.Request;
global.AbortController = AbortController;
global.AbortSignal = AbortSignal;
}

export type FetchFunction = typeof fetch;
Expand All @@ -58,7 +39,7 @@ export type FetchFunction = typeof fetch;
* * supports `file:` protocol
* * treats relative URIs as relative to `process.cwd()`
*
* `@here/harp-fetch` exposes this function as `global.fetch` in the Node.js environment, so it
* `@here/olp-sdk-fetch` exposes this function as `global.fetch` in the Node.js environment, so it
* mimics the _browser_ `fetch` that supports relative URLs which are resolved against baseUrl.
*
* It also supports fetching local `file://` resources without the need to stub the `global.fetch`.
Expand All @@ -75,15 +56,20 @@ export type FetchFunction = typeof fetch;
*
* @see [fetch documentation](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
*/
async function fetchWithFileSupport(input: RequestInfo, init?: RequestInit): Promise<Response> {
async function fetchWithFileSupport(
input: RequestInfo,
init?: RequestInit
): Promise<Response> {
const url = typeof input === "object" ? input.url : input;
const parentUrl = `file://${process.cwd()}/`;
const actualUrl = new URL(url, parentUrl);
if (actualUrl.protocol === "file:") {
return new Promise((resolve, reject) => {
fs.readFile(actualUrl, async (error, buffer) => {
if (error) {
reject(new Error(`failed to read file ${actualUrl}: ${error}`));
reject(
new Error(`failed to read file ${actualUrl}: ${error}`)
);
return;
}

Expand All @@ -105,7 +91,9 @@ async function fetchWithFileSupport(input: RequestInfo, init?: RequestInit): Pro
return Promise.resolve(buffer.buffer as ArrayBuffer);
},
async json() {
return Promise.resolve(JSON.parse(buffer.toString("utf-8")));
return Promise.resolve(
JSON.parse(buffer.toString("utf-8"))
);
},
async text() {
return Promise.resolve(buffer.toString("utf-8"));
Expand All @@ -119,6 +107,8 @@ async function fetchWithFileSupport(input: RequestInfo, init?: RequestInit): Pro
});
});
} else {
return node_fetch(url, init);
return fetch(url, init);
}
}

fetchWithFileSupport.sdkImplementation = true;
15 changes: 5 additions & 10 deletions @here/olp-sdk-fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@here/olp-sdk-fetch",
"version": "1.9.0",
"version": "2.0.0",
"description": "Adds a subset of the fetch API for Node.js",
"main": "index.js",
"browser": "index.web.js",
Expand Down Expand Up @@ -47,13 +47,10 @@
"url": "https://here.com"
},
"license": "Apache-2.0",
"dependencies": {
"node-fetch": "2.6.7"
},
"devDependencies": {
"@types/chai": "^4.2.7",
"@types/mocha": "^5.2.7",
"@types/node": "^14.11.8",
"@types/node": "18.7.14",
"@types/sinon": "7.0.3",
"@types/sinon-chai": "^3.2.3",
"chai": "^4.2.0",
Expand All @@ -66,17 +63,15 @@
"sinon": "7.4.2",
"sinon-chai": "^3.4.0",
"source-map-support": "^0.5.16",
"ts-node": "^8.5.4",
"ts-node": "10.9.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"typedoc": "^0.22.13",
"typescript": "4.0.3",
"tslib": "1.13.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.10",
"zlib": "^1.0.5"
"webpack-cli": "^3.3.10"
},
"engines": {
"node": ">= 10.18.0"
"node": ">= 18.0.0"
}
}
2 changes: 1 addition & 1 deletion @here/olp-sdk-fetch/test/Fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import "../index";
const isNode = typeof window === "undefined";
const describeOnlyNode = isNode ? describe : xdescribe;

describe("@here/harp-fetch", function() {
describe("@here/olp-sdk-fetch", function() {
it("fetch", function() {
assert.isFunction(fetch);
});
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@here/olp-sdk-ts",
"version": "1.13.0",
"version": "2.0.0",
"description": "HERE OLP SDK for TypeScript",
"author": {
"name": "HERE Europe B.V.",
Expand Down Expand Up @@ -59,14 +59,13 @@
"typedoc": "npx typedoc --options typedoc.json"
},
"devDependencies": {
"@types/node": "^14.11.8",
"@types/node": "18.7.14",
"lerna": "^4.0.0",
"typescript": "4.0.3",
"tslib": "1.13.0",
"codecov": "3.7.2",
"mockserver-node": "^5.12.0",
"mockserver-client": "^5.12.0",
"ts-node": "9.0.0",
"ts-node": "10.9.2",
"puppeteer": "^13.1.3",
"puppeteer-to-istanbul": "^1.4.0",
"nyc": "^15.0.0",
Expand Down
Loading

0 comments on commit 4b962ce

Please sign in to comment.