Skip to content

Commit

Permalink
feat!: drop node8 support (#123)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The library now supports Node.js v10+. The last version to support Node.js v8 is tagged legacy-8 on NPM.
  • Loading branch information
alexander-fenster authored Mar 31, 2020
1 parent c8de7e3 commit 84927e2
Show file tree
Hide file tree
Showing 14 changed files with 405 additions and 279 deletions.
3 changes: 3 additions & 0 deletions packages/google-cloud-phishingprotection/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/gts"
}
15 changes: 0 additions & 15 deletions packages/google-cloud-phishingprotection/.eslintrc.yml

This file was deleted.

8 changes: 0 additions & 8 deletions packages/google-cloud-phishingprotection/.prettierrc

This file was deleted.

17 changes: 17 additions & 0 deletions packages/google-cloud-phishingprotection/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

module.exports = {
...require('gts/.prettierrc.json')
}
10 changes: 6 additions & 4 deletions packages/google-cloud-phishingprotection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@
"Phishing Protection API"
],
"dependencies": {
"google-gax": "^1.9.0"
"google-gax": "^2.0.1"
},
"devDependencies": {
"@types/mocha": "^7.0.0",
"@types/node": "^12.0.0",
"@types/sinon": "^7.5.2",
"c8": "^7.0.0",
"chai": "^4.2.0",
"eslint": "^6.0.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.0.1",
"gts": "^1.0.0",
"gts": "2.0.0-alpha.9",
"jsdoc": "^3.6.2",
"jsdoc-fresh": "^1.0.1",
"jsdoc-region-tag": "^1.0.2",
Expand All @@ -45,8 +46,9 @@
"null-loader": "^3.0.0",
"pack-n-play": "^1.0.0-2",
"prettier": "^1.17.0",
"sinon": "^9.0.1",
"ts-loader": "^6.2.1",
"typescript": "^3.7.0",
"typescript": "^3.8.3",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10"
},
Expand All @@ -67,6 +69,6 @@
},
"license": "Apache-2.0",
"engines": {
"node": ">=8.10.0"
"node": ">=10"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ const URI = 'http://testsafebrowsing.appspot.com/s/phishing.html';

describe('Quickstart', () => {
it('should run quickstart', async () => {
const stdout = execSync(
`node ./quickstart.js ${URI} ${PROJECT_ID}`,
{cwd}
);
const stdout = execSync(`node ./quickstart.js ${URI} ${PROJECT_ID}`, {cwd});
assert.include(stdout, 'reported');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {
APICallback,
Callback,
CallOptions,
Descriptors,
ClientOptions,
} from 'google-gax';
import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
import * as path from 'path';

import * as protosTypes from '../../protos/protos';
import * as protos from '../../protos/protos';
import * as gapicConfig from './phishing_protection_service_v1_beta1_client_config.json';

const version = require('../../../package.json').version;
Expand All @@ -37,21 +31,21 @@ const version = require('../../../package.json').version;
* @memberof v1beta1
*/
export class PhishingProtectionServiceV1Beta1Client {
private _descriptors: Descriptors = {
page: {},
stream: {},
longrunning: {},
batching: {},
};
private _innerApiCalls: {[name: string]: Function};
private _pathTemplates: {[name: string]: gax.PathTemplate};
private _terminated = false;
private _opts: ClientOptions;
private _gaxModule: typeof gax | typeof gax.fallback;
private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient;
private _protos: {};
private _defaults: {[method: string]: gax.CallSettings};
auth: gax.GoogleAuth;
descriptors: Descriptors = {
page: {},
stream: {},
longrunning: {},
batching: {},
};
innerApiCalls: {[name: string]: Function};
pathTemplates: {[name: string]: gax.PathTemplate};
phishingProtectionServiceV1Beta1Stub?: Promise<{[name: string]: Function}>;

/**
Expand Down Expand Up @@ -145,13 +139,16 @@ export class PhishingProtectionServiceV1Beta1Client {
'protos.json'
);
this._protos = this._gaxGrpc.loadProto(
opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath
opts.fallback
? // eslint-disable-next-line @typescript-eslint/no-var-requires
require('../../protos/protos.json')
: nodejsProtoPath
);

// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
// Create useful helper objects for these.
this._pathTemplates = {
this.pathTemplates = {
projectPathTemplate: new this._gaxModule.PathTemplate(
'projects/{project}'
),
Expand All @@ -168,7 +165,7 @@ export class PhishingProtectionServiceV1Beta1Client {
// Set up a dictionary of "inner API calls"; the core implementation
// of calling the API is handled in `google-gax`, with this code
// merely providing the destination and request information.
this._innerApiCalls = {};
this.innerApiCalls = {};
}

/**
Expand All @@ -195,7 +192,7 @@ export class PhishingProtectionServiceV1Beta1Client {
? (this._protos as protobuf.Root).lookupService(
'google.cloud.phishingprotection.v1beta1.PhishingProtectionServiceV1Beta1'
)
: // tslint:disable-next-line no-any
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
(this._protos as any).google.cloud.phishingprotection.v1beta1
.PhishingProtectionServiceV1Beta1,
this._opts
Expand All @@ -204,9 +201,8 @@ export class PhishingProtectionServiceV1Beta1Client {
// Iterate over each of the methods that the service provides
// and create an API call method for each.
const phishingProtectionServiceV1Beta1StubMethods = ['reportPhishing'];

for (const methodName of phishingProtectionServiceV1Beta1StubMethods) {
const innerCallPromise = this.phishingProtectionServiceV1Beta1Stub.then(
const callPromise = this.phishingProtectionServiceV1Beta1Stub.then(
stub => (...args: Array<{}>) => {
if (this._terminated) {
return Promise.reject('The client has already been closed.');
Expand All @@ -220,20 +216,14 @@ export class PhishingProtectionServiceV1Beta1Client {
);

const apiCall = this._gaxModule.createApiCall(
innerCallPromise,
callPromise,
this._defaults[methodName],
this._descriptors.page[methodName] ||
this._descriptors.stream[methodName] ||
this._descriptors.longrunning[methodName]
this.descriptors.page[methodName] ||
this.descriptors.stream[methodName] ||
this.descriptors.longrunning[methodName]
);

this._innerApiCalls[methodName] = (
argument: {},
callOptions?: CallOptions,
callback?: APICallback
) => {
return apiCall(argument, callOptions, callback);
};
this.innerApiCalls[methodName] = apiCall;
}

return this.phishingProtectionServiceV1Beta1Stub;
Expand Down Expand Up @@ -290,26 +280,37 @@ export class PhishingProtectionServiceV1Beta1Client {
// -- Service calls --
// -------------------
reportPhishing(
request: protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest,
request: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest,
options?: gax.CallOptions
): Promise<
[
protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse,
protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse,
(
| protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest
| protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest
| undefined
),
{} | undefined
]
>;
reportPhishing(
request: protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest,
request: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest,
options: gax.CallOptions,
callback: Callback<
protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse,
| protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest
protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse,
| protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest
| null
| undefined,
{} | undefined
{} | null | undefined
>
): void;
reportPhishing(
request: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest,
callback: Callback<
protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse,
| protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest
| null
| undefined,
{} | null | undefined
>
): void;
/**
Expand All @@ -335,26 +336,28 @@ export class PhishingProtectionServiceV1Beta1Client {
* The promise has a method named "cancel" which cancels the ongoing API call.
*/
reportPhishing(
request: protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest,
request: protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest,
optionsOrCallback?:
| gax.CallOptions
| Callback<
protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse,
| protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest
protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse,
| protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest
| null
| undefined,
{} | undefined
{} | null | undefined
>,
callback?: Callback<
protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse,
| protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest
protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse,
| protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest
| null
| undefined,
{} | undefined
{} | null | undefined
>
): Promise<
[
protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse,
protos.google.cloud.phishingprotection.v1beta1.IReportPhishingResponse,
(
| protosTypes.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest
| protos.google.cloud.phishingprotection.v1beta1.IReportPhishingRequest
| undefined
),
{} | undefined
Expand All @@ -377,7 +380,7 @@ export class PhishingProtectionServiceV1Beta1Client {
parent: request.parent || '',
});
this.initialize();
return this._innerApiCalls.reportPhishing(request, options, callback);
return this.innerApiCalls.reportPhishing(request, options, callback);
}

// --------------------
Expand All @@ -391,8 +394,8 @@ export class PhishingProtectionServiceV1Beta1Client {
* @returns {string} Resource name string.
*/
projectPath(project: string) {
return this._pathTemplates.projectPathTemplate.render({
project,
return this.pathTemplates.projectPathTemplate.render({
project: project,
});
}

Expand All @@ -404,7 +407,7 @@ export class PhishingProtectionServiceV1Beta1Client {
* @returns {string} A string representing the project.
*/
matchProjectFromProjectName(projectName: string) {
return this._pathTemplates.projectPathTemplate.match(projectName).project;
return this.pathTemplates.projectPathTemplate.match(projectName).project;
}

/**
Expand Down
Loading

0 comments on commit 84927e2

Please sign in to comment.