Socket
Socket
Sign inDemoInstall

google-gax

Package Overview
Dependencies
125
Maintainers
3
Versions
356
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.2 to 3.1.3

2

build/src/bundlingCalls/bundleDescriptor.js

@@ -61,3 +61,3 @@ "use strict";

this.requestDiscriminatorFields =
requestDiscriminatorFields.map(util_1.snakeToCamelCase);
requestDiscriminatorFields.map(util_1.toCamelCase);
this.subresponseField = subresponseField;

@@ -64,0 +64,0 @@ this.byteLengthFunction = byteLengthFunction;

@@ -17,6 +17,6 @@ /**

/// <reference types="node" />
import { OutgoingHttpHeaders } from 'http';
import * as protobuf from 'protobufjs';
import * as gax from './gax';
import * as routingHeader from './routingHeader';
import { OutgoingHttpHeaders } from 'http';
import { GoogleAuth, OAuth2Client, Compute, JWT, UserRefreshClient, BaseExternalAccountClient } from 'google-auth-library';

@@ -23,0 +23,0 @@ import { OperationsClientBuilder } from './operationsClient';

@@ -19,2 +19,3 @@ "use strict";

exports.fallback = exports.protobufMinimal = exports.protobuf = exports.createApiCall = exports.lro = exports.GrpcClient = exports.defaultToObjectOptions = exports.StreamType = exports.StreamDescriptor = exports.PageDescriptor = exports.LongrunningDescriptor = exports.BundleDescriptor = exports.version = exports.RetryOptions = exports.constructSettings = exports.CallSettings = exports.routingHeader = exports.PathTemplate = void 0;
const objectHash = require("object-hash");
const protobuf = require("protobufjs");

@@ -34,3 +35,3 @@ exports.protobuf = protobuf;

const streaming_1 = require("./streamingCalls/streaming");
const objectHash = require("object-hash");
const util_1 = require("./util");
var pathTemplate_1 = require("./pathTemplate");

@@ -114,3 +115,3 @@ Object.defineProperty(exports, "PathTemplate", { enumerable: true, get: function () { return pathTemplate_1.PathTemplate; } });

for (const [methodName, methodObject] of Object.entries(service.methods)) {
const methodNameLowerCamelCase = methodName[0].toLowerCase() + methodName.substring(1);
const methodNameLowerCamelCase = (0, util_1.toLowerCamelCase)(methodName);
methods[methodNameLowerCamelCase] = methodObject;

@@ -117,0 +118,0 @@ }

@@ -19,2 +19,3 @@ "use strict";

exports.constructSettings = exports.createBundleOptions = exports.createMaxRetriesBackoffSettings = exports.createDefaultBackoffSettings = exports.createBackoffSettings = exports.createRetryOptions = exports.CallSettings = exports.RetryOptions = void 0;
const util_1 = require("./util");
/**

@@ -479,3 +480,3 @@ * Encapsulates the overridable settings for a particular API call.

const methodConfig = methods[methodName];
const jsName = methodName[0].toLowerCase() + methodName.slice(1);
const jsName = (0, util_1.toLowerCamelCase)(methodName);
let retry = constructRetry(methodConfig, serviceConfig.retry_codes, serviceConfig.retry_params, retryNames);

@@ -482,0 +483,0 @@ let bundlingConfig = methodConfig.bundling;

@@ -263,3 +263,3 @@ "use strict";

for (const key in data) {
if (optionalFields.has((0, util_1.snakeToCamelCase)(key)) &&
if (optionalFields.has((0, util_1.toCamelCase)(key)) &&
(!(key in snakeRequest) || snakeRequest[key] === 'undefined')) {

@@ -270,3 +270,3 @@ delete data[key];

// HTTP endpoint expects camelCase but we have snake_case at this point
const camelCaseData = requestChangeCaseAndCleanup(data, util_1.snakeToCamelCase);
const camelCaseData = requestChangeCaseAndCleanup(data, util_1.toCamelCase);
return { httpMethod, url, queryString: '', data: camelCaseData };

@@ -279,3 +279,3 @@ }

if (body) {
deleteField(queryStringObject, (0, util_1.snakeToCamelCase)(body));
deleteField(queryStringObject, (0, util_1.toCamelCase)(body));
// Unset optional field should not add in body request.

@@ -288,3 +288,3 @@ data =

for (const field of matchedFields) {
deleteField(queryStringObject, (0, util_1.snakeToCamelCase)(field));
deleteField(queryStringObject, (0, util_1.toCamelCase)(field));
}

@@ -304,3 +304,3 @@ // Unset proto3 optional field does not appear in the query params.

else {
camelCaseData = requestChangeCaseAndCleanup(data, util_1.snakeToCamelCase);
camelCaseData = requestChangeCaseAndCleanup(data, util_1.toCamelCase);
}

@@ -307,0 +307,0 @@ return { httpMethod, url, queryString, data: camelCaseData };

@@ -22,5 +22,11 @@ /**

/**
* Converts a given string from snake_case (normally used in proto definitions) to
* camelCase (used by protobuf.js)
* Converts a given string from snake_case (normally used in proto definitions) or
* PascalCase (also used in proto definitions) to camelCase (used by protobuf.js).
* Preserves capitalization of the first character.
*/
export declare function snakeToCamelCase(str: string): string;
export declare function toCamelCase(str: string): string;
/**
* Converts a given string to lower camel case (forcing the first character to be
* in lower case).
*/
export declare function toLowerCamelCase(str: string): string;

@@ -18,4 +18,31 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.snakeToCamelCase = exports.camelToSnakeCase = void 0;
exports.toLowerCamelCase = exports.toCamelCase = exports.camelToSnakeCase = void 0;
function words(str, normalize = false) {
if (normalize) {
// strings like somethingABCSomething are special case for protobuf.js,
// they should be split as "something", "abc", "something".
// Deal with sequences of capital letters first.
str = str.replace(/([A-Z])([A-Z]+)([A-Z])/g, (str) => {
return (str[0] +
str.slice(1, str.length - 1).toLowerCase() +
str[str.length - 1]);
});
}
// split on spaces, non-alphanumeric, or capital letters
// note: we keep the capitalization of the first word (special case: IPProtocol)
return str
.split(/(?=[A-Z])|[^A-Za-z0-9.]+/)
.filter(w => w.length > 0)
.map((w, index) => (index === 0 ? w : w.toLowerCase()));
}
/**
* Converts the first character of the given string to lower case.
*/
function lowercase(str) {
if (str.length === 0) {
return str;
}
return str[0].toLowerCase() + str.slice(1);
}
/**
* Converts a given string from camelCase (used by protobuf.js and in JSON)

@@ -26,3 +53,9 @@ * to snake_case (normally used in proto definitions).

// Keep the first position capitalization, otherwise decapitalize with underscore.
return str.replace(/(?!^)[A-Z]/g, letter => `_${letter.toLowerCase()}`);
const wordsList = words(str);
if (wordsList.length === 0) {
return str;
}
const result = [wordsList[0]];
result.push(...wordsList.slice(1).map(lowercase));
return result.join('_');
}

@@ -40,18 +73,33 @@ exports.camelToSnakeCase = camelToSnakeCase;

/**
* Converts a given string from snake_case (normally used in proto definitions) to
* camelCase (used by protobuf.js)
* Converts a given string from snake_case (normally used in proto definitions) or
* PascalCase (also used in proto definitions) to camelCase (used by protobuf.js).
* Preserves capitalization of the first character.
*/
function snakeToCamelCase(str) {
// split on spaces, underscore, or capital letters
const splitted = str
.split(/(?=[A-Z])|(?:(?!(_(\W+)))[\s_])+/)
.filter(w => w && w.length > 0)
// Keep the capitalization for the first split.
.map((word, index) => (index === 0 ? word : word.toLowerCase()));
if (splitted.length === 0) {
function toCamelCase(str) {
const wordsList = words(str, /*normalize:*/ true);
if (wordsList.length === 0) {
return str;
}
return [splitted[0], ...splitted.slice(1).map(capitalize)].join('');
const result = [wordsList[0]];
result.push(...wordsList.slice(1).map(w => {
if (w.match(/^\d+$/)) {
return '_' + w;
}
return capitalize(w);
}));
return result.join('');
}
exports.snakeToCamelCase = snakeToCamelCase;
exports.toCamelCase = toCamelCase;
/**
* Converts a given string to lower camel case (forcing the first character to be
* in lower case).
*/
function toLowerCamelCase(str) {
const camelCase = toCamelCase(str);
if (camelCase.length === 0) {
return camelCase;
}
return camelCase[0].toLowerCase() + camelCase.slice(1);
}
exports.toLowerCamelCase = toLowerCamelCase;
//# sourceMappingURL=util.js.map
{
"name": "google-gax",
"version": "3.1.2",
"version": "3.1.3",
"description": "Google API Extensions",

@@ -69,3 +69,3 @@ "main": "build/src/index.js",

"pumpify": "^2.0.0",
"puppeteer": "^14.0.0",
"puppeteer": "^15.0.0",
"rimraf": "^3.0.0",

@@ -72,0 +72,0 @@ "sinon": "^14.0.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc