Socket
Socket
Sign inDemoInstall

@googlemaps/google-maps-services-js

Package Overview
Dependencies
Maintainers
2
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@googlemaps/google-maps-services-js - npm Package Compare versions

Comparing version 3.3.41 to 3.3.42

12

dist/adapter.js

@@ -60,7 +60,7 @@ "use strict";

else {
reject(new axios_1.default.AxiosError('Request failed with status code ' + response.status, [axios_1.default.AxiosError.ERR_BAD_REQUEST, axios_1.default.AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
reject(new axios_1.default.AxiosError("Request failed with status code " + response.status, [axios_1.default.AxiosError.ERR_BAD_REQUEST, axios_1.default.AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4], response.config, response.request, response));
}
}
exports.customAdapter = axios_1.default.getAdapter(config => {
const httpAdapter = axios_1.default.getAdapter('http');
exports.customAdapter = axios_1.default.getAdapter((config) => {
const httpAdapter = axios_1.default.getAdapter("http");
return new Promise((resolve, reject) => {

@@ -72,4 +72,6 @@ httpAdapter(config)

if (config.transformResponse) {
const t = Array.isArray(config.transformResponse) ? config.transformResponse : [config.transformResponse];
for (let fn of t) {
const t = Array.isArray(config.transformResponse)
? config.transformResponse
: [config.transformResponse];
for (const fn of t) {
data = fn.call(config, data, r.headers, r.status);

@@ -76,0 +78,0 @@ }

@@ -73,3 +73,3 @@ /**

export declare class Client {
private axiosInstance;
private readonly axiosInstance;
private experienceId;

@@ -79,3 +79,2 @@ constructor({ axiosInstance, config, experienceId }?: ClientOptions);

clearExperienceId(): void;
private clearExperienceIdHeader;
getExperienceId(): string[];

@@ -82,0 +81,0 @@ directions(request: DirectionsRequest): Promise<DirectionsResponse>;

@@ -127,9 +127,7 @@ "use strict";

this.experienceId = ids;
this.axiosInstance.defaults.headers[exports.X_GOOG_MAPS_EXPERIENCE_ID] = ids.join(",");
this.axiosInstance.defaults.headers[exports.X_GOOG_MAPS_EXPERIENCE_ID] =
ids.join(",");
}
clearExperienceId() {
this.experienceId = null;
this.clearExperienceIdHeader();
}
clearExperienceIdHeader() {
delete this.axiosInstance.defaults.headers[exports.X_GOOG_MAPS_EXPERIENCE_ID];

@@ -136,0 +134,0 @@ }

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

axiosInstance: client_1.defaultAxiosInstance,
config: { timeout: 10000 }
config: { timeout: 10000 },
});

@@ -54,3 +54,5 @@ }).toThrowError();

test("client can be override Accept-Encoding with header options", () => {
const client = new client_1.Client({ config: { headers: { "x-foo": "bar", "Accept-Encoding": "identity" } } });
const client = new client_1.Client({
config: { headers: { "x-foo": "bar", "Accept-Encoding": "identity" } },
});
expect(client["axiosInstance"]).toBeDefined();

@@ -57,0 +59,0 @@ expect(client["axiosInstance"].defaults.headers["x-foo"]).toEqual("bar");

@@ -170,5 +170,3 @@ /**

export declare const defaultUrl = "https://maps.googleapis.com/maps/api/directions/json";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function directions({ params, method, url, paramsSerializer, ...config }: DirectionsRequest, axiosInstance?: AxiosInstance): Promise<DirectionsResponse>;

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

destination: "San Francisco, CA",
key: "foo"
key: "foo",
};

@@ -41,3 +41,3 @@ (0, directions_1.directions)({ params: params }, mockedAxios);

paramsSerializer: directions_1.defaultParamsSerializer,
url: directions_1.defaultUrl
url: directions_1.defaultUrl,
});

@@ -49,7 +49,6 @@ });

destination: "San Francisco, CA",
key: "foo"
key: "foo",
};
expect((0, directions_1.defaultParamsSerializer)(params))
.toEqual("destination=San%20Francisco%2C%20CA&key=foo&origin=Seattle%2C%20WA");
expect((0, directions_1.defaultParamsSerializer)(params)).toEqual("destination=San%20Francisco%2C%20CA&key=foo&origin=Seattle%2C%20WA");
});
//# sourceMappingURL=directions.test.js.map

@@ -151,5 +151,3 @@ /**

export declare const defaultUrl = "https://maps.googleapis.com/maps/api/distancematrix/json";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function distancematrix({ params, method, url, paramsSerializer, ...config }: DistanceMatrixRequest, axiosInstance?: AxiosInstance): Promise<DistanceMatrixResponse>;

@@ -34,6 +34,6 @@ "use strict";

exports.defaultParamsSerializer = (0, serialize_1.serializer)({
origins: o => o.map(serialize_1.latLngToString),
destinations: o => o.map(serialize_1.latLngToString),
origins: (o) => o.map(serialize_1.latLngToString),
destinations: (o) => o.map(serialize_1.latLngToString),
arrival_time: serialize_1.toTimestamp,
departure_time: serialize_1.toTimestamp
departure_time: serialize_1.toTimestamp,
}, exports.defaultUrl);

@@ -40,0 +40,0 @@ function distancematrix(_a, axiosInstance) {

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

destinations: ["San Francisco, CA", "New York, NY"],
key: "foo"
key: "foo",
};

@@ -41,3 +41,3 @@ (0, distance_1.distancematrix)({ params: params }, mockedAxios);

paramsSerializer: distance_1.defaultParamsSerializer,
url: distance_1.defaultUrl
url: distance_1.defaultUrl,
});

@@ -49,7 +49,6 @@ });

destinations: ["San Francisco, CA", "New York, NY"],
key: "foo"
key: "foo",
};
expect((0, distance_1.defaultParamsSerializer)(params))
.toEqual("destinations=San%20Francisco%2C%20CA|New%20York%2C%20NY&key=foo&origins=Seattle%2C%20WA");
expect((0, distance_1.defaultParamsSerializer)(params)).toEqual("destinations=San%20Francisco%2C%20CA|New%20York%2C%20NY&key=foo&origins=Seattle%2C%20WA");
});
//# sourceMappingURL=distance.test.js.map

@@ -65,5 +65,3 @@ /**

export declare const defaultUrl = "https://maps.googleapis.com/maps/api/elevation/json";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function elevation({ params, method, url, paramsSerializer, ...config }: ElevationRequest, axiosInstance?: AxiosInstance): Promise<ElevationResponse>;

@@ -34,4 +34,4 @@ "use strict";

exports.defaultParamsSerializer = (0, serialize_1.serializer)({
locations: o => o.map(serialize_1.latLngToString),
path: o => o.map(serialize_1.latLngToString)
locations: (o) => o.map(serialize_1.latLngToString),
path: (o) => o.map(serialize_1.latLngToString),
}, exports.defaultUrl);

@@ -38,0 +38,0 @@ function elevation(_a, axiosInstance) {

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

paramsSerializer: elevation_1.defaultParamsSerializer,
url: elevation_1.defaultUrl
url: elevation_1.defaultUrl,
});

@@ -44,6 +44,6 @@ });

{ lat: 35, lng: -110 },
{ lat: 45, lng: -110 }
{ lat: 45, lng: -110 },
],
samples: 10,
key: "foo"
key: "foo",
};

@@ -56,3 +56,3 @@ (0, elevation_1.elevation)({ params: params }, mockedAxios);

paramsSerializer: elevation_1.defaultParamsSerializer,
url: elevation_1.defaultUrl
url: elevation_1.defaultUrl,
});

@@ -64,10 +64,9 @@ });

{ lat: 35, lng: -110 },
{ lat: 45, lng: -110 }
{ lat: 45, lng: -110 },
],
samples: 10,
key: "foo"
key: "foo",
};
expect((0, elevation_1.defaultParamsSerializer)(params))
.toEqual("key=foo&path=35%2C-110|45%2C-110&samples=10");
expect((0, elevation_1.defaultParamsSerializer)(params)).toEqual("key=foo&path=35%2C-110|45%2C-110&samples=10");
});
//# sourceMappingURL=elevation.test.js.map

@@ -91,5 +91,3 @@ /**

}
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function geocode({ params, method, url, paramsSerializer, ...config }: GeocodeRequest, axiosInstance?: AxiosInstance): Promise<GeocodeResponse>;

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

bounds: serialize_1.latLngBoundsToString,
components: serialize_1.objectToString
components: serialize_1.objectToString,
}, exports.defaultUrl);

@@ -38,0 +38,0 @@ function geocode(_a, axiosInstance) {

@@ -36,5 +36,5 @@ "use strict";

paramsSerializer: geocode_1.defaultParamsSerializer,
url: geocode_1.defaultUrl
url: geocode_1.defaultUrl,
});
});
//# sourceMappingURL=geocode.test.js.map

@@ -92,5 +92,3 @@ /**

export declare const defaultUrl = "https://maps.googleapis.com/maps/api/geocode/json";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function reverseGeocode({ params, method, url, paramsSerializer, ...config }: ReverseGeocodeRequest, axiosInstance?: AxiosInstance): Promise<ReverseGeocodeResponse>;

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

exports.defaultParamsSerializer = (0, serialize_1.serializer)({
latlng: serialize_1.latLngToString
latlng: serialize_1.latLngToString,
}, exports.defaultUrl);

@@ -55,0 +55,0 @@ function reverseGeocode(_a, axiosInstance) {

@@ -32,5 +32,5 @@ "use strict";

lat: 60.168997,
lng: 24.9433353
lng: 24.9433353,
},
key: "foo"
key: "foo",
};

@@ -43,5 +43,5 @@ (0, reversegeocode_1.reverseGeocode)({ params: params }, mockedAxios);

paramsSerializer: reversegeocode_1.defaultParamsSerializer,
url: reversegeocode_1.defaultUrl
url: reversegeocode_1.defaultUrl,
});
});
//# sourceMappingURL=reversegeocode.test.js.map

@@ -38,3 +38,3 @@ /**

};
params: {} & RequestParams;
params: RequestParams;
}

@@ -41,0 +41,0 @@ export interface GeolocateResponseData extends ResponseData {

@@ -37,5 +37,5 @@ "use strict";

data: data,
url: geolocate_1.defaultUrl
url: geolocate_1.defaultUrl,
});
});
//# sourceMappingURL=geolocate.test.js.map

@@ -154,5 +154,3 @@ /**

export declare const defaultUrl = "https://maps.googleapis.com/maps/api/place/autocomplete/json";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function placeAutocomplete({ params, method, url, paramsSerializer, ...config }: PlaceAutocompleteRequest, axiosInstance?: AxiosInstance): Promise<PlaceAutocompleteResponse>;

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

location: serialize_1.latLngToString,
origin: serialize_1.latLngToString
origin: serialize_1.latLngToString,
}, exports.defaultUrl);

@@ -65,0 +65,0 @@ function placeAutocomplete(_a, axiosInstance) {

@@ -36,5 +36,5 @@ "use strict";

paramsSerializer: autocomplete_1.defaultParamsSerializer,
url: autocomplete_1.defaultUrl
url: autocomplete_1.defaultUrl,
});
});
//# sourceMappingURL=autocomplete.test.js.map

@@ -61,5 +61,3 @@ /**

export declare const defaultUrl = "https://maps.googleapis.com/maps/api/place/details/json";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function placeDetails({ params, method, url, paramsSerializer, ...config }: PlaceDetailsRequest, axiosInstance?: AxiosInstance): Promise<PlaceDetailsResponse>;

@@ -33,3 +33,5 @@ "use strict";

exports.defaultUrl = "https://maps.googleapis.com/maps/api/place/details/json";
exports.defaultParamsSerializer = (0, serialize_1.serializer)({}, exports.defaultUrl, { arrayFormat: "comma" });
exports.defaultParamsSerializer = (0, serialize_1.serializer)({}, exports.defaultUrl, {
arrayFormat: "comma",
});
function placeDetails(_a, axiosInstance) {

@@ -36,0 +38,0 @@ var { params, method = "get", url = exports.defaultUrl, paramsSerializer = exports.defaultParamsSerializer } = _a, config = __rest(_a, ["params", "method", "url", "paramsSerializer"]);

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

key: "foo",
fields: ["place_id", "name"]
fields: ["place_id", "name"],
};

@@ -41,5 +41,5 @@ (0, details_1.placeDetails)({ params: params }, mockedAxios);

paramsSerializer: details_1.defaultParamsSerializer,
url: details_1.defaultUrl
url: details_1.defaultUrl,
});
});
//# sourceMappingURL=details.test.js.map

@@ -49,5 +49,3 @@ /**

export declare const defaultUrl = "https://maps.googleapis.com/maps/api/place/findplacefromtext/json";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function findPlaceFromText({ params, method, url, paramsSerializer, ...config }: FindPlaceFromTextRequest, axiosInstance?: AxiosInstance): Promise<FindPlaceFromTextResponse>;

@@ -33,3 +33,5 @@ "use strict";

exports.defaultUrl = "https://maps.googleapis.com/maps/api/place/findplacefromtext/json";
exports.defaultParamsSerializer = (0, serialize_1.serializer)({}, exports.defaultUrl, { arrayFormat: "comma" });
exports.defaultParamsSerializer = (0, serialize_1.serializer)({}, exports.defaultUrl, {
arrayFormat: "comma",
});
function findPlaceFromText(_a, axiosInstance) {

@@ -36,0 +38,0 @@ var { params, method = "get", url = exports.defaultUrl, paramsSerializer = exports.defaultParamsSerializer } = _a, config = __rest(_a, ["params", "method", "url", "paramsSerializer"]);

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

key: "foo",
fields: ["place_id", "name"]
fields: ["place_id", "name"],
};

@@ -43,5 +43,5 @@ (0, findplacefromtext_1.findPlaceFromText)({ params: params }, mockedAxios);

paramsSerializer: findplacefromtext_1.defaultParamsSerializer,
url: findplacefromtext_1.defaultUrl
url: findplacefromtext_1.defaultUrl,
});
});
//# sourceMappingURL=findplacefromtext.test.js.map

@@ -40,3 +40,3 @@ /**

} & RequestParams;
responseType: 'arraybuffer' | 'blob' | 'stream';
responseType: "arraybuffer" | "blob" | "stream";
}

@@ -43,0 +43,0 @@ /**

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

if (!responseType) {
responseType = 'arraybuffer';
responseType = "arraybuffer";
}

@@ -39,0 +39,0 @@ return axiosInstance(Object.assign({ params,

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

const params = { photoreference: "notaphotoreference", key: "foo" };
const responseType = 'arraybuffer';
const responseType = "arraybuffer";
(0, photo_1.placePhoto)({ params, responseType }, mockedAxios);

@@ -33,0 +33,0 @@ expect(mockedAxios).toHaveBeenCalledTimes(1);

@@ -101,5 +101,3 @@ /**

export declare const defaultUrl = "https://maps.googleapis.com/maps/api/place/nearbysearch/json";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function placesNearby({ params, method, url, paramsSerializer, ...config }: PlacesNearbyRequest, axiosInstance?: AxiosInstance): Promise<PlacesNearbyResponse>;

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

key: "foo",
ranking: placesnearby_1.PlacesNearbyRanking.distance
ranking: placesnearby_1.PlacesNearbyRanking.distance,
};

@@ -41,5 +41,5 @@ (0, placesnearby_1.placesNearby)({ params: params }, mockedAxios);

url: placesnearby_1.defaultUrl,
paramsSerializer: placesnearby_1.defaultParamsSerializer
paramsSerializer: placesnearby_1.defaultParamsSerializer,
});
});
//# sourceMappingURL=placesnearby.test.js.map

@@ -76,5 +76,3 @@ /**

export declare const defaultUrl = "https://maps.googleapis.com/maps/api/place/queryautocomplete/json";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function placeQueryAutocomplete({ params, method, url, paramsSerializer, ...config }: PlaceQueryAutocompleteRequest, axiosInstance?: AxiosInstance): Promise<PlaceQueryAutocompleteResponse>;

@@ -36,5 +36,5 @@ "use strict";

paramsSerializer: queryautocomplete_1.defaultParamsSerializer,
url: queryautocomplete_1.defaultUrl
url: queryautocomplete_1.defaultUrl,
});
});
//# sourceMappingURL=queryautocomplete.test.js.map

@@ -92,5 +92,3 @@ /**

export declare const defaultUrl = "https://maps.googleapis.com/maps/api/place/textsearch/json";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function textSearch({ params, method, url, paramsSerializer, ...config }: TextSearchRequest, axiosInstance?: AxiosInstance): Promise<TextSearchResponse>;

@@ -36,5 +36,5 @@ "use strict";

paramsSerializer: textsearch_1.defaultParamsSerializer,
url: textsearch_1.defaultUrl
url: textsearch_1.defaultUrl,
});
});
//# sourceMappingURL=textsearch.test.js.map

@@ -35,5 +35,3 @@ /**

export declare const defaultUrl = "https://roads.googleapis.com/v1/nearestRoads";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function nearestRoads({ params, method, url, paramsSerializer, ...config }: NearestRoadsRequest, axiosInstance?: AxiosInstance): Promise<NearestRoadsResponse>;

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

exports.defaultParamsSerializer = (0, serialize_1.serializer)({
points: o => o.map(latLng => (0, serialize_1.latLngToString)(latLng))
points: (o) => o.map((latLng) => (0, serialize_1.latLngToString)(latLng)),
}, exports.defaultUrl);

@@ -37,0 +37,0 @@ function nearestRoads(_a, axiosInstance) {

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

paramsSerializer: nearestroads_1.defaultParamsSerializer,
url: nearestroads_1.defaultUrl
url: nearestroads_1.defaultUrl,
});

@@ -42,5 +42,4 @@ });

const params = { points: ["0,0"], key: "foo" };
expect((0, nearestroads_1.defaultParamsSerializer)(params))
.toEqual("key=foo&points=0%2C0");
expect((0, nearestroads_1.defaultParamsSerializer)(params)).toEqual("key=foo&points=0%2C0");
});
//# sourceMappingURL=nearestroads.test.js.map

@@ -50,5 +50,3 @@ /**

export declare const defaultUrl = "https://roads.googleapis.com/v1/snapToRoads";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function snapToRoads({ params, method, url, paramsSerializer, ...config }: SnapToRoadsRequest, axiosInstance?: AxiosInstance): Promise<SnapToRoadsResponse>;

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

exports.defaultParamsSerializer = (0, serialize_1.serializer)({
path: o => o.map(serialize_1.latLngToString)
path: (o) => o.map(serialize_1.latLngToString),
}, exports.defaultUrl);

@@ -37,0 +37,0 @@ function snapToRoads(_a, axiosInstance) {

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

paramsSerializer: snaptoroads_1.defaultParamsSerializer,
url: snaptoroads_1.defaultUrl
url: snaptoroads_1.defaultUrl,
});

@@ -42,5 +42,4 @@ });

const params = { path: ["0,0"], key: "foo" };
expect((0, snaptoroads_1.defaultParamsSerializer)(params))
.toEqual("key=foo&path=0%2C0");
expect((0, snaptoroads_1.defaultParamsSerializer)(params)).toEqual("key=foo&path=0%2C0");
});
//# sourceMappingURL=snaptoroads.test.js.map

@@ -26,5 +26,3 @@ /**

};
export declare function serializer(format: serializerFormat, baseUrl: string, queryStringOptions?: object): (params: {
[key: string]: any;
}) => string;
export declare function serializer(format: serializerFormat, baseUrl: string, queryStringOptions?: object): (params: Record<string, any>) => string;
export declare function toTimestamp(o: "now" | number | Date): number | "now";

@@ -31,0 +29,0 @@ export declare function createPremiumPlanQueryString(serializedParams: {

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

else {
let keys = Object.keys(o);
const keys = Object.keys(o);
keys.sort();

@@ -109,11 +109,13 @@ return keys.map((k) => k + ":" + o[k]).join(separator);

}) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (params) => {
// avoid mutating params
const serializedParams = Object.assign({}, params);
Object.keys(format).forEach((key) => {
for (const key of Object.keys(format)) {
if (key in serializedParams) {
serializedParams[key] = format[key](serializedParams[key]);
}
});
if ("client_id" in serializedParams && "client_secret" in serializedParams) {
}
if ("client_id" in serializedParams &&
"client_secret" in serializedParams) {
// Special case to handle premium plan signature

@@ -120,0 +122,0 @@ return createPremiumPlanQueryString(serializedParams, queryStringOptions, baseUrl);

@@ -77,4 +77,3 @@ "use strict";

destination: serialize_1.latLngToString,
}, "https://test.url/maps/api/directions/json")(params))
.toEqual('avoid=ferries&client=testClient&destination=38.8977%2C-77.0365&mode=driving&origin=33.8121%2C-117.9190&units=imperial&signature=YRJoTd6ohbpsR14WkWv3S7H6MqU=');
}, "https://test.url/maps/api/directions/json")(params)).toEqual("avoid=ferries&client=testClient&destination=38.8977%2C-77.0365&mode=driving&origin=33.8121%2C-117.9190&units=imperial&signature=YRJoTd6ohbpsR14WkWv3S7H6MqU=");
});

@@ -114,3 +113,3 @@ test("objectToString", () => {

expect((0, serialize_1.toTimestamp)("now")).toEqual("now");
expect((0, serialize_1.toTimestamp)(new Date('2022-06-22T09:03:33.430Z'))).toEqual(1655888613);
expect((0, serialize_1.toTimestamp)(new Date("2022-06-22T09:03:33.430Z"))).toEqual(1655888613);
});

@@ -132,5 +131,4 @@ test("createPremiumPlanQueryString", () => {

const baseUrl = "https://test.url/maps/api/directions/json";
expect((0, serialize_1.createPremiumPlanQueryString)(serializedParams, queryStringOptions, baseUrl))
.toEqual('avoid=ferries&client=testClient&destination=38.8977%2C-77.0365&mode=driving&origin=33.8121%2C-117.9190&units=imperial&signature=YRJoTd6ohbpsR14WkWv3S7H6MqU=');
expect((0, serialize_1.createPremiumPlanQueryString)(serializedParams, queryStringOptions, baseUrl)).toEqual("avoid=ferries&client=testClient&destination=38.8977%2C-77.0365&mode=driving&origin=33.8121%2C-117.9190&units=imperial&signature=YRJoTd6ohbpsR14WkWv3S7H6MqU=");
});
//# sourceMappingURL=serialize.test.js.map

@@ -66,5 +66,3 @@ /**

export declare const defaultUrl = "https://maps.googleapis.com/maps/api/timezone/json";
export declare const defaultParamsSerializer: (params: {
[key: string]: any;
}) => string;
export declare const defaultParamsSerializer: (params: Record<string, any>) => string;
export declare function timezone({ params, method, url, paramsSerializer, ...config }: TimeZoneRequest, axiosInstance?: AxiosInstance): Promise<TimeZoneResponse>;

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

timestamp: serialize_1.toTimestamp,
location: serialize_1.latLngToString
location: serialize_1.latLngToString,
}, exports.defaultUrl);

@@ -38,0 +38,0 @@ function timezone(_a, axiosInstance) {

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

timestamp: 999999999,
key: "foo"
key: "foo",
};

@@ -41,3 +41,3 @@ (0, timezone_1.timezone)({ params: params }, mockedAxios);

paramsSerializer: timezone_1.defaultParamsSerializer,
url: timezone_1.defaultUrl
url: timezone_1.defaultUrl,
});

@@ -44,0 +44,0 @@ });

@@ -26,6 +26,6 @@ "use strict";

function encodePath(path) {
var result = [];
var start = [0, 0];
var end;
var encodePart = function (part) {
const result = [];
let start = [0, 0];
let end;
const encodePart = function (part) {
part = part < 0 ? ~(part << 1) : part << 1;

@@ -53,4 +53,4 @@ while (part >= 0x20) {

function decodePath(encodedPath) {
let len = encodedPath.length || 0;
let path = new Array(Math.floor(encodedPath.length / 2));
const len = encodedPath.length || 0;
const path = new Array(Math.floor(encodedPath.length / 2));
let index = 0;

@@ -57,0 +57,0 @@ let lat = 0;

@@ -24,68 +24,68 @@ "use strict";

lat: 53.489320000000006,
lng: -104.16777
lng: -104.16777,
},
{
lat: 53.490140000000004,
lng: -104.16833000000001
lng: -104.16833000000001,
},
{
lat: 53.490700000000004,
lng: -104.16936000000001
lng: -104.16936000000001,
},
{
lat: 53.49065,
lng: -104.17142000000001
lng: -104.17142000000001,
},
{
lat: 53.49011,
lng: -104.17288
lng: -104.17288,
},
{
lat: 53.488760000000006,
lng: -104.17305
lng: -104.17305,
},
{
lat: 53.48715000000001,
lng: -104.17219000000001
lng: -104.17219000000001,
},
{
lat: 53.485420000000005,
lng: -104.17022000000001
lng: -104.17022000000001,
},
{
lat: 53.483450000000005,
lng: -104.1679
lng: -104.1679,
},
{
lat: 53.48554000000001,
lng: -104.16442
lng: -104.16442,
},
{
lat: 53.487100000000005,
lng: -104.16279000000002
lng: -104.16279000000002,
},
{
lat: 53.48863000000001,
lng: -104.16236
lng: -104.16236,
},
{
lat: 53.49004000000001,
lng: -104.16249
lng: -104.16249,
},
{
lat: 53.490550000000006,
lng: -104.16361
lng: -104.16361,
},
{
lat: 53.49083,
lng: -104.16477
lng: -104.16477,
},
{
lat: 53.49045,
lng: -104.16648
lng: -104.16648,
},
{
lat: 53.48935,
lng: -104.16773
}
lng: -104.16773,
},
];

@@ -92,0 +92,0 @@ test("encodePath is correct", () => {

{
"name": "@googlemaps/google-maps-services-js",
"version": "3.3.41",
"version": "3.3.42",
"description": "Node.js client library for Google Maps API Web Services",

@@ -44,6 +44,8 @@ "keywords": [

"pretest": "npm run build",
"test": "jest ./src/* && npm run test:loading",
"test": "jest --runInBand --collectCoverage ./src/* && npm run test:loading",
"test:loading": "./test-module-loading.sh",
"test:e2e": "jest ./e2e/*",
"test:all": "jest"
"test:e2e": "jest --runInBand ./e2e/*",
"test:all": "jest --runInBand",
"format": "eslint . --fix",
"lint": "eslint ."
},

@@ -60,5 +62,11 @@ "dependencies": {

"@types/node": "^20.1.1",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^27.4.2",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.7.0",
"nock": "^13.0.4",
"prettier": "^3.0.0",
"nock": "^13.3.4",
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",

@@ -71,3 +79,6 @@ "typedoc": "^0.25.0",

"access": "public"
},
"prettier": {
"trailingComma": "es5"
}
}

@@ -20,3 +20,3 @@ /**

import axios from "axios";
import type {AxiosResponse} from "axios";
import type { AxiosResponse } from "axios";

@@ -58,36 +58,41 @@ export function statusToCode(status: Status): number {

} else {
reject(new axios.AxiosError(
'Request failed with status code ' + response.status,
[axios.AxiosError.ERR_BAD_REQUEST, axios.AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
reject(
new axios.AxiosError(
"Request failed with status code " + response.status,
[axios.AxiosError.ERR_BAD_REQUEST, axios.AxiosError.ERR_BAD_RESPONSE][
Math.floor(response.status / 100) - 4
],
response.config,
response.request,
response
));
)
);
}
}
export const customAdapter = axios.getAdapter((config) => {
const httpAdapter = axios.getAdapter("http");
export const customAdapter = axios.getAdapter(config => {
const httpAdapter = axios.getAdapter('http');
return new Promise((resolve, reject) => {
httpAdapter(config)
.then((r: AxiosResponse) => {
// unfortunately data is transformed after the adapter
let data = r.data;
if (config.transformResponse) {
const t = Array.isArray(config.transformResponse) ? config.transformResponse : [config.transformResponse];
for (let fn of t) {
data = fn.call(config, data, r.headers, r.status);
}
.then((r: AxiosResponse) => {
// unfortunately data is transformed after the adapter
let data = r.data;
if (config.transformResponse) {
const t = Array.isArray(config.transformResponse)
? config.transformResponse
: [config.transformResponse];
for (const fn of t) {
data = fn.call(config, data, r.headers, r.status);
}
}
if (r.status === 200 && data.status) {
r.status = statusToCode(data.status);
}
if (r.status === 200 && data.status) {
r.status = statusToCode(data.status);
}
settle(resolve, reject, r);
})
.catch(reject);
settle(resolve, reject, r);
})
.catch(reject);
});
});

@@ -38,3 +38,3 @@ /**

X_GOOG_MAPS_EXPERIENCE_ID,
defaultAxiosInstance
defaultAxiosInstance,
} from "./client";

@@ -71,3 +71,3 @@

axiosInstance: defaultAxiosInstance,
config: { timeout: 10000 }
config: { timeout: 10000 },
});

@@ -85,3 +85,3 @@ }).toThrowError();

expect(client["axiosInstance"].defaults.headers["Accept-Encoding"]).toBe(
acceptEncoding
acceptEncoding
);

@@ -91,10 +91,12 @@ });

test("client can be override Accept-Encoding with header options", () => {
const client = new Client({ config: { headers: { "x-foo": "bar", "Accept-Encoding": "identity" } } });
const client = new Client({
config: { headers: { "x-foo": "bar", "Accept-Encoding": "identity" } },
});
expect(client["axiosInstance"]).toBeDefined();
expect(client["axiosInstance"].defaults.headers["x-foo"]).toEqual("bar");
expect(client["axiosInstance"].defaults.headers["User-Agent"]).toEqual(
userAgent
userAgent
);
expect(client["axiosInstance"].defaults.headers["Accept-Encoding"]).toBe(
"identity"
"identity"
);

@@ -111,3 +113,3 @@ });

expect(client["axiosInstance"].defaults.headers["Accept-Encoding"]).toBe(
acceptEncoding
acceptEncoding
);

@@ -114,0 +116,0 @@ });

@@ -141,3 +141,3 @@ /**

export class Client {
private axiosInstance: AxiosInstance;
private readonly axiosInstance: AxiosInstance;
private experienceId: string[];

@@ -172,5 +172,4 @@

this.experienceId = ids;
this.axiosInstance.defaults.headers[X_GOOG_MAPS_EXPERIENCE_ID] = ids.join(
","
);
this.axiosInstance.defaults.headers[X_GOOG_MAPS_EXPERIENCE_ID] =
ids.join(",");
}

@@ -180,6 +179,2 @@

this.experienceId = null;
this.clearExperienceIdHeader();
}
private clearExperienceIdHeader() {
delete this.axiosInstance.defaults.headers[X_GOOG_MAPS_EXPERIENCE_ID];

@@ -217,3 +212,3 @@ }

* import { Client } from '@googlemaps/google-maps-services-js';
*
*
* const args = {

@@ -220,0 +215,0 @@ * params: {

@@ -32,3 +32,3 @@ /**

destination: "San Francisco, CA",
key: "foo"
key: "foo",
};

@@ -43,3 +43,3 @@

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});

@@ -52,7 +52,8 @@ });

destination: "San Francisco, CA",
key: "foo"
key: "foo",
};
expect(defaultParamsSerializer(params))
.toEqual("destination=San%20Francisco%2C%20CA&key=foo&origin=Seattle%2C%20WA");
expect(defaultParamsSerializer(params)).toEqual(
"destination=San%20Francisco%2C%20CA&key=foo&origin=Seattle%2C%20WA"
);
});

@@ -192,9 +192,12 @@ /**

export const defaultParamsSerializer = serializer({
origin: latLngToString,
destination: latLngToString,
waypoints: (o) => o.map(latLngToString),
arrival_time: toTimestamp,
departure_time: toTimestamp,
}, defaultUrl);
export const defaultParamsSerializer = serializer(
{
origin: latLngToString,
destination: latLngToString,
waypoints: (o) => o.map(latLngToString),
arrival_time: toTimestamp,
departure_time: toTimestamp,
},
defaultUrl
);

@@ -201,0 +204,0 @@ export function directions(

@@ -21,3 +21,3 @@ /**

defaultParamsSerializer,
defaultUrl
defaultUrl,
} from "./distance";

@@ -37,3 +37,3 @@

destinations: ["San Francisco, CA", "New York, NY"],
key: "foo"
key: "foo",
};

@@ -48,3 +48,3 @@

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});

@@ -57,7 +57,8 @@ });

destinations: ["San Francisco, CA", "New York, NY"],
key: "foo"
key: "foo",
};
expect(defaultParamsSerializer(params))
.toEqual("destinations=San%20Francisco%2C%20CA|New%20York%2C%20NY&key=foo&origins=Seattle%2C%20WA");
expect(defaultParamsSerializer(params)).toEqual(
"destinations=San%20Francisco%2C%20CA|New%20York%2C%20NY&key=foo&origins=Seattle%2C%20WA"
);
});

@@ -28,3 +28,3 @@ /**

TravelRestriction,
UnitSystem
UnitSystem,
} from "./common";

@@ -173,8 +173,11 @@ import { latLngToString, serializer, toTimestamp } from "./serialize";

export const defaultParamsSerializer = serializer({
origins: o => o.map(latLngToString),
destinations: o => o.map(latLngToString),
arrival_time: toTimestamp,
departure_time: toTimestamp
}, defaultUrl);
export const defaultParamsSerializer = serializer(
{
origins: (o) => o.map(latLngToString),
destinations: (o) => o.map(latLngToString),
arrival_time: toTimestamp,
departure_time: toTimestamp,
},
defaultUrl
);

@@ -196,4 +199,4 @@ export function distancematrix(

paramsSerializer,
...config
...config,
}) as Promise<DistanceMatrixResponse>;
}

@@ -38,3 +38,3 @@ /**

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});

@@ -47,6 +47,6 @@ });

{ lat: 35, lng: -110 },
{ lat: 45, lng: -110 }
{ lat: 45, lng: -110 },
],
samples: 10,
key: "foo"
key: "foo",
};

@@ -61,3 +61,3 @@

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});

@@ -70,10 +70,11 @@ });

{ lat: 35, lng: -110 },
{ lat: 45, lng: -110 }
{ lat: 45, lng: -110 },
],
samples: 10,
key: "foo"
key: "foo",
};
expect(defaultParamsSerializer(params))
.toEqual("key=foo&path=35%2C-110|45%2C-110&samples=10");
expect(defaultParamsSerializer(params)).toEqual(
"key=foo&path=35%2C-110|45%2C-110&samples=10"
);
});

@@ -47,3 +47,4 @@ /**

export interface ElevationRequest extends Partial<AxiosRequestConfig> {
params: (PositionalElevationParams | SampledPathElevationParams) & RequestParams;
params: (PositionalElevationParams | SampledPathElevationParams) &
RequestParams;
}

@@ -75,6 +76,9 @@ export interface ElevationResponseData extends ResponseData {

export const defaultParamsSerializer = serializer({
locations: o => o.map(latLngToString),
path: o => o.map(latLngToString)
}, defaultUrl);
export const defaultParamsSerializer = serializer(
{
locations: (o) => o.map(latLngToString),
path: (o) => o.map(latLngToString),
},
defaultUrl
);

@@ -96,4 +100,4 @@ export function elevation(

paramsSerializer,
...config
...config,
}) as Promise<ElevationResponse>;
}

@@ -38,4 +38,4 @@ /**

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});
});

@@ -17,3 +17,8 @@ /**

import { LatLngBounds, GeocodeResult, ResponseData, RequestParams } from "../common";
import {
LatLngBounds,
GeocodeResult,
ResponseData,
RequestParams,
} from "../common";
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";

@@ -84,3 +89,3 @@ import { defaultAxiosInstance } from "../client";

components?: string | GeocodeComponents;
} & RequestParams;
} & RequestParams;
}

@@ -102,6 +107,9 @@

export const defaultParamsSerializer = serializer({
bounds: latLngBoundsToString,
components: objectToString
}, defaultUrl);
export const defaultParamsSerializer = serializer(
{
bounds: latLngBoundsToString,
components: objectToString,
},
defaultUrl
);

@@ -123,4 +131,4 @@ export function geocode(

paramsSerializer,
...config
...config,
}) as Promise<GeocodeResponse>;
}

@@ -21,3 +21,3 @@ /**

defaultParamsSerializer,
defaultUrl
defaultUrl,
} from "./reversegeocode";

@@ -37,5 +37,5 @@

lat: 60.168997,
lng: 24.9433353
lng: 24.9433353,
},
key: "foo"
key: "foo",
};

@@ -50,4 +50,4 @@

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});
});

@@ -83,3 +83,3 @@ /**

location_type?: ReverseGeocodingLocationType[];
} & RequestParams;
} & RequestParams;
}

@@ -103,5 +103,8 @@

export const defaultParamsSerializer = serializer({
latlng: latLngToString
}, defaultUrl);
export const defaultParamsSerializer = serializer(
{
latlng: latLngToString,
},
defaultUrl
);

@@ -123,4 +126,4 @@ export function reverseGeocode(

paramsSerializer,
...config
...config,
}) as Promise<ReverseGeocodeResponse>;
}

@@ -38,4 +38,4 @@ /**

data: data,
url: defaultUrl
url: defaultUrl,
});
});

@@ -24,3 +24,3 @@ /**

ResponseData,
WifiAccessPoint
WifiAccessPoint,
} from "./common";

@@ -50,3 +50,3 @@

};
params: {} & RequestParams;
params: RequestParams;
}

@@ -138,4 +138,4 @@

url,
...config
...config,
}) as Promise<GeolocateResponse>;
}

@@ -21,3 +21,3 @@ /**

defaultParamsSerializer,
defaultUrl
defaultUrl,
} from "./autocomplete";

@@ -43,4 +43,4 @@

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});
});

@@ -24,3 +24,3 @@ /**

ResponseData,
StructuredFormatting
StructuredFormatting,
} from "../common";

@@ -120,3 +120,3 @@ import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";

strictbounds?: boolean;
} & RequestParams;
} & RequestParams;
}

@@ -176,6 +176,9 @@

export const defaultParamsSerializer = serializer({
location: latLngToString,
origin: latLngToString
}, defaultUrl);
export const defaultParamsSerializer = serializer(
{
location: latLngToString,
origin: latLngToString,
},
defaultUrl
);

@@ -197,4 +200,4 @@ export function placeAutocomplete(

paramsSerializer,
...config
...config,
}) as Promise<PlaceAutocompleteResponse>;
}

@@ -32,3 +32,3 @@ /**

key: "foo",
fields: ["place_id", "name"]
fields: ["place_id", "name"],
};

@@ -43,4 +43,4 @@

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});
});

@@ -55,3 +55,3 @@ /**

fields?: string[];
} & RequestParams;
} & RequestParams;
}

@@ -71,3 +71,5 @@ export interface PlaceDetailsResponseData extends ResponseData {

export const defaultParamsSerializer = serializer({}, defaultUrl, {arrayFormat: "comma"});
export const defaultParamsSerializer = serializer({}, defaultUrl, {
arrayFormat: "comma",
});

@@ -89,4 +91,4 @@ export function placeDetails(

paramsSerializer,
...config
...config,
}) as Promise<PlaceDetailsResponse>;
}

@@ -21,3 +21,3 @@ /**

defaultParamsSerializer,
defaultUrl
defaultUrl,
} from "./findplacefromtext";

@@ -39,3 +39,3 @@ import { PlaceInputType } from "../common";

key: "foo",
fields: ["place_id", "name"]
fields: ["place_id", "name"],
};

@@ -50,4 +50,4 @@

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});
});

@@ -17,3 +17,9 @@ /**

import { Language, ResponseData, Place, PlaceInputType, RequestParams } from "../common";
import {
Language,
ResponseData,
Place,
PlaceInputType,
RequestParams,
} from "../common";
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";

@@ -45,3 +51,3 @@ import { defaultAxiosInstance } from "../client";

locationbias?: string;
} & RequestParams;
} & RequestParams;
}

@@ -60,3 +66,5 @@

export const defaultParamsSerializer = serializer({}, defaultUrl, {arrayFormat: "comma"});
export const defaultParamsSerializer = serializer({}, defaultUrl, {
arrayFormat: "comma",
});

@@ -78,4 +86,4 @@ export function findPlaceFromText(

paramsSerializer,
...config
...config,
}) as Promise<FindPlaceFromTextResponse>;
}

@@ -30,3 +30,3 @@ /**

const params = { photoreference: "notaphotoreference", key: "foo" };
const responseType = 'arraybuffer';
const responseType = "arraybuffer";
placePhoto({ params, responseType }, mockedAxios);

@@ -33,0 +33,0 @@

@@ -42,4 +42,4 @@ /**

maxheight?: number;
} & RequestParams;
responseType: 'arraybuffer' | 'blob' | 'stream';
} & RequestParams;
responseType: "arraybuffer" | "blob" | "stream";
}

@@ -64,7 +64,13 @@

export function placePhoto(
{ params, method = "get", url = defaultUrl, responseType, ...config }: PlacePhotoRequest,
{
params,
method = "get",
url = defaultUrl,
responseType,
...config
}: PlacePhotoRequest,
axiosInstance: AxiosInstance = defaultAxiosInstance
): Promise<PlacePhotoResponse> {
if (!responseType) {
responseType = 'arraybuffer'
responseType = "arraybuffer";
}

@@ -77,4 +83,4 @@

responseType,
...config
...config,
}) as Promise<PlacePhotoResponse>;
}

@@ -21,3 +21,3 @@ /**

defaultUrl,
placesNearby
placesNearby,
} from "./placesnearby";

@@ -39,3 +39,3 @@

key: "foo",
ranking: PlacesNearbyRanking.distance
ranking: PlacesNearbyRanking.distance,
};

@@ -50,4 +50,4 @@

url: defaultUrl,
paramsSerializer: defaultParamsSerializer
paramsSerializer: defaultParamsSerializer,
});
});

@@ -118,3 +118,6 @@ /**

export const defaultParamsSerializer = serializer({ location: latLngToString }, defaultUrl);
export const defaultParamsSerializer = serializer(
{ location: latLngToString },
defaultUrl
);

@@ -121,0 +124,0 @@ export function placesNearby(

@@ -21,3 +21,3 @@ /**

defaultParamsSerializer,
defaultUrl
defaultUrl,
} from "./queryautocomplete";

@@ -43,4 +43,4 @@

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});
});

@@ -20,3 +20,2 @@ /**

Language,
Place,
ResponseData,

@@ -26,3 +25,3 @@ RequestParams,

PredictionSubstring,
StructuredFormatting
StructuredFormatting,
} from "../common";

@@ -98,3 +97,6 @@ import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";

export const defaultParamsSerializer = serializer({ location: latLngToString }, defaultUrl);
export const defaultParamsSerializer = serializer(
{ location: latLngToString },
defaultUrl
);

@@ -116,4 +118,4 @@ export function placeQueryAutocomplete(

paramsSerializer,
...config
...config,
}) as Promise<PlaceQueryAutocompleteResponse>;
}

@@ -38,4 +38,4 @@ /**

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});
});

@@ -17,3 +17,10 @@ /**

import { ResponseData, LatLng, Language, PlaceType1, Place, RequestParams } from "../common";
import {
ResponseData,
LatLng,
Language,
PlaceType1,
Place,
RequestParams,
} from "../common";
import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";

@@ -88,3 +95,3 @@ import { defaultAxiosInstance } from "../client";

type?: PlaceType1;
} & RequestParams;
} & RequestParams;
}

@@ -103,3 +110,6 @@

export const defaultParamsSerializer = serializer({ location: latLngToString }, defaultUrl);
export const defaultParamsSerializer = serializer(
{ location: latLngToString },
defaultUrl
);

@@ -121,4 +131,4 @@ export function textSearch(

paramsSerializer,
...config
...config,
}) as Promise<TextSearchResponse>;
}

@@ -21,3 +21,3 @@ /**

defaultParamsSerializer,
defaultUrl
defaultUrl,
} from "./nearestroads";

@@ -43,3 +43,3 @@

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});

@@ -51,4 +51,3 @@ });

expect(defaultParamsSerializer(params))
.toEqual("key=foo&points=0%2C0");
expect(defaultParamsSerializer(params)).toEqual("key=foo&points=0%2C0");
});

@@ -30,3 +30,3 @@ /**

points: LatLng[];
} & RequestParams;
} & RequestParams;
}

@@ -42,5 +42,8 @@

export const defaultUrl = "https://roads.googleapis.com/v1/nearestRoads";
export const defaultParamsSerializer = serializer({
points: o => o.map(latLng => latLngToString(latLng))
}, defaultUrl);
export const defaultParamsSerializer = serializer(
{
points: (o) => o.map((latLng) => latLngToString(latLng)),
},
defaultUrl
);

@@ -62,4 +65,4 @@ export function nearestRoads(

paramsSerializer,
...config
...config,
}) as Promise<NearestRoadsResponse>;
}

@@ -21,3 +21,3 @@ /**

defaultParamsSerializer,
defaultUrl
defaultUrl,
} from "./snaptoroads";

@@ -43,3 +43,3 @@

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});

@@ -51,4 +51,3 @@ });

expect(defaultParamsSerializer(params))
.toEqual("key=foo&path=0%2C0");
expect(defaultParamsSerializer(params)).toEqual("key=foo&path=0%2C0");
});

@@ -45,3 +45,3 @@ /**

interpolate?: boolean;
} & RequestParams;
} & RequestParams;
}

@@ -56,5 +56,8 @@

export const defaultUrl = "https://roads.googleapis.com/v1/snapToRoads";
export const defaultParamsSerializer = serializer({
path: o => o.map(latLngToString)
}, defaultUrl);
export const defaultParamsSerializer = serializer(
{
path: (o) => o.map(latLngToString),
},
defaultUrl
);

@@ -76,4 +79,4 @@ export function snapToRoads(

paramsSerializer,
...config
...config,
}) as Promise<SnapToRoadsResponse>;
}

@@ -51,7 +51,12 @@ /**

test("serializer", () => {
expect(serializer({ quz: (o) => o }, "http://mock.url")({ foo: ["bar"] })).toBe("foo=bar");
expect(
serializer({
foo: (o) => o.map((latLng: LatLng) => latLngToString(latLng)),
}, "http://mock.url")({
serializer({ quz: (o) => o }, "http://mock.url")({ foo: ["bar"] })
).toBe("foo=bar");
expect(
serializer(
{
foo: (o) => o.map((latLng: LatLng) => latLngToString(latLng)),
},
"http://mock.url"
)({
foo: [

@@ -76,6 +81,7 @@ [0, 1],

test("serializer should return pipe joined arrays by default", () => {
expect(serializer({}, "http://mock.url")({ foo: ["b", "a", "r"] })).toBe("foo=b|a|r");
expect(serializer({}, "http://mock.url")({ foo: ["b", "a", "r"] })).toBe(
"foo=b|a|r"
);
});
test("serializer creates premium plan query string if premium plan params are included", () => {

@@ -98,7 +104,13 @@ const params = {

expect(serializer({
origin: latLngToString,
destination: latLngToString,
}, "https://test.url/maps/api/directions/json")(params))
.toEqual('avoid=ferries&client=testClient&destination=38.8977%2C-77.0365&mode=driving&origin=33.8121%2C-117.9190&units=imperial&signature=YRJoTd6ohbpsR14WkWv3S7H6MqU=');
expect(
serializer(
{
origin: latLngToString,
destination: latLngToString,
},
"https://test.url/maps/api/directions/json"
)(params)
).toEqual(
"avoid=ferries&client=testClient&destination=38.8977%2C-77.0365&mode=driving&origin=33.8121%2C-117.9190&units=imperial&signature=YRJoTd6ohbpsR14WkWv3S7H6MqU="
);
});

@@ -146,3 +158,3 @@

expect(toTimestamp(new Date('2022-06-22T09:03:33.430Z'))).toEqual(1655888613);
expect(toTimestamp(new Date("2022-06-22T09:03:33.430Z"))).toEqual(1655888613);
});

@@ -166,4 +178,7 @@

expect(createPremiumPlanQueryString(serializedParams, queryStringOptions, baseUrl))
.toEqual('avoid=ferries&client=testClient&destination=38.8977%2C-77.0365&mode=driving&origin=33.8121%2C-117.9190&units=imperial&signature=YRJoTd6ohbpsR14WkWv3S7H6MqU=');
expect(
createPremiumPlanQueryString(serializedParams, queryStringOptions, baseUrl)
).toEqual(
"avoid=ferries&client=testClient&destination=38.8977%2C-77.0365&mode=driving&origin=33.8121%2C-117.9190&units=imperial&signature=YRJoTd6ohbpsR14WkWv3S7H6MqU="
);
});

@@ -20,4 +20,4 @@ /**

import { encodePath } from "./util";
import {createSignature} from "@googlemaps/url-signature";
import queryString from 'query-string';
import { createSignature } from "@googlemaps/url-signature";
import queryString from "query-string";

@@ -52,3 +52,3 @@ const qs = queryString.stringify;

} else {
let keys = Object.keys(o);
const keys = Object.keys(o);
keys.sort();

@@ -113,15 +113,23 @@ return keys.map((k) => k + ":" + o[k]).join(separator);

) {
return (params: { [key: string]: any }) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (params: Record<string, any>) => {
// avoid mutating params
const serializedParams = { ...params };
Object.keys(format).forEach((key: string) => {
for (const key of Object.keys(format)) {
if (key in serializedParams) {
serializedParams[key] = format[key](serializedParams[key]);
}
});
}
if ("client_id" in serializedParams && "client_secret" in serializedParams) {
if (
"client_id" in serializedParams &&
"client_secret" in serializedParams
) {
// Special case to handle premium plan signature
return createPremiumPlanQueryString(serializedParams, queryStringOptions, baseUrl);
return createPremiumPlanQueryString(
serializedParams,
queryStringOptions,
baseUrl
);
}

@@ -146,3 +154,3 @@

queryStringOptions: object,
baseUrl: string,
baseUrl: string
): string {

@@ -156,3 +164,3 @@ serializedParams.client = serializedParams.client_id;

const unsignedUrl = `${baseUrl}?${partialQueryString}`;
const signature = createSignature(unsignedUrl, clientSecret);
const signature = createSignature(unsignedUrl, clientSecret);

@@ -159,0 +167,0 @@ // The signature must come last

@@ -33,3 +33,3 @@ /**

timestamp: 999999999,
key: "foo"
key: "foo",
};

@@ -43,3 +43,3 @@ timezone({ params: params }, mockedAxios);

paramsSerializer: defaultParamsSerializer,
url: defaultUrl
url: defaultUrl,
});

@@ -50,3 +50,5 @@ });

const dt = new Date();
expect(defaultParamsSerializer({timestamp: dt})).toEqual(`timestamp=${Math.round(Number(dt)/1000)}`)
expect(defaultParamsSerializer({ timestamp: dt })).toEqual(
`timestamp=${Math.round(Number(dt) / 1000)}`
);
});

@@ -74,6 +74,9 @@ /**

export const defaultUrl = "https://maps.googleapis.com/maps/api/timezone/json";
export const defaultParamsSerializer = serializer({
timestamp: toTimestamp,
location: latLngToString
}, defaultUrl);
export const defaultParamsSerializer = serializer(
{
timestamp: toTimestamp,
location: latLngToString,
},
defaultUrl
);
export function timezone(

@@ -94,4 +97,4 @@ {

paramsSerializer,
...config
...config,
}) as Promise<TimeZoneResponse>;
}

@@ -25,68 +25,68 @@ /**

lat: 53.489320000000006,
lng: -104.16777
lng: -104.16777,
},
{
lat: 53.490140000000004,
lng: -104.16833000000001
lng: -104.16833000000001,
},
{
lat: 53.490700000000004,
lng: -104.16936000000001
lng: -104.16936000000001,
},
{
lat: 53.49065,
lng: -104.17142000000001
lng: -104.17142000000001,
},
{
lat: 53.49011,
lng: -104.17288
lng: -104.17288,
},
{
lat: 53.488760000000006,
lng: -104.17305
lng: -104.17305,
},
{
lat: 53.48715000000001,
lng: -104.17219000000001
lng: -104.17219000000001,
},
{
lat: 53.485420000000005,
lng: -104.17022000000001
lng: -104.17022000000001,
},
{
lat: 53.483450000000005,
lng: -104.1679
lng: -104.1679,
},
{
lat: 53.48554000000001,
lng: -104.16442
lng: -104.16442,
},
{
lat: 53.487100000000005,
lng: -104.16279000000002
lng: -104.16279000000002,
},
{
lat: 53.48863000000001,
lng: -104.16236
lng: -104.16236,
},
{
lat: 53.49004000000001,
lng: -104.16249
lng: -104.16249,
},
{
lat: 53.490550000000006,
lng: -104.16361
lng: -104.16361,
},
{
lat: 53.49083,
lng: -104.16477
lng: -104.16477,
},
{
lat: 53.49045,
lng: -104.16648
lng: -104.16648,
},
{
lat: 53.48935,
lng: -104.16773
}
lng: -104.16773,
},
];

@@ -93,0 +93,0 @@

@@ -26,7 +26,7 @@ /**

export function encodePath(path: LatLngLiteral[]): string {
var result: string[] = [];
var start: [number, number] = [0, 0];
var end: [number, number];
const result: string[] = [];
let start: [number, number] = [0, 0];
let end: [number, number];
var encodePart = function(part: number) {
const encodePart = function (part: number) {
part = part < 0 ? ~(part << 1) : part << 1;

@@ -56,4 +56,4 @@ while (part >= 0x20) {

export function decodePath(encodedPath: string): LatLngLiteral[] {
let len: number = encodedPath.length || 0;
let path = new Array(Math.floor(encodedPath.length / 2));
const len: number = encodedPath.length || 0;
const path = new Array(Math.floor(encodedPath.length / 2));
let index: number = 0;

@@ -60,0 +60,0 @@ let lat: number = 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 too big to display

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 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 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 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 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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc