Skip to content

Commit

Permalink
feat: update npm dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ruscon committed Nov 29, 2021
1 parent 3f0bd84 commit 84e77bd
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 39 deletions.
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"*.{ts,tsx,json,js,jsx}": [
"npm run format:base"
],
"*.{md}": [
"*.md": [
"npm run prettier:base"
]
},
Expand Down Expand Up @@ -96,21 +96,21 @@
},
"dependencies": {
"@types/heremaps": "^3.1.5",
"class-transformer": "^0.4.0",
"class-validator": "^0.13.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.13.2",
"lodash.isempty": "^4.4.0",
"world-countries": "^4.0.0"
},
"devDependencies": {
"@commitlint/cli": "^14.1.0",
"@commitlint/config-conventional": "^14.1.0",
"@commitlint/travis-cli": "^14.1.0",
"@commitlint/cli": "^15.0.0",
"@commitlint/config-conventional": "^15.0.0",
"@commitlint/travis-cli": "^15.0.0",
"@goparrot/eslint-config": "^1.0.1",
"@types/chai": "^4.2.15",
"@types/chai-as-promised": "^7.1.3",
"@types/lodash.isempty": "^4.4.6",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.7",
"@types/node": "^16.11.10",
"@types/semver": "^7.3.9",
"@types/sinon": "^10.0.6",
"@types/supertest": "^2.0.10",
Expand All @@ -122,26 +122,26 @@
"conventional-github-releaser": "^3.1.5",
"dotenv": "^10.0.0",
"husky": "^7.0.4",
"lint-staged": "^12.0.2",
"lint-staged": "^12.1.2",
"mocha": "^9.1.3",
"mocha-junit-reporter": "^2.0.0",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"prettier": "^2.5.0",
"reflect-metadata": ">=0.1.13",
"remark-cli": "^10.0.0",
"remark-cli": "^10.0.1",
"remark-frontmatter": "^4.0.1",
"remark-github": "^11.2.2",
"remark-lint-emphasis-marker": "^3.1.0",
"remark-lint-strong-marker": "^3.1.0",
"rimraf": "^3.0.2",
"semver": "^7.3.5",
"sinon": "^12.0.1",
"source-map-support": "^0.5.19",
"source-map-support": "^0.5.21",
"standard-version": "^9.3.2",
"supertest": "^6.1.3",
"ts-node": "^10.4.0",
"tsconfig-paths": "^3.9.0",
"typescript": "^4.4.4"
"tsconfig-paths": "^3.12.0",
"typescript": "^4.5.2"
}
}
4 changes: 2 additions & 2 deletions src/command/abstract.command.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { plainToClass } from 'class-transformer';
import { plainToInstance } from 'class-transformer';
import { validateOrReject } from 'class-validator';
import isEmpty from 'lodash.isempty';
import type { AxiosInstance, AxiosResponse } from 'axios';
Expand Down Expand Up @@ -67,7 +67,7 @@ export abstract class AbstractCommand<
}

async execute(_query: GeocoderQueryType): Promise<GeocoderResponseType[]> {
const query: GeocoderQueryType = plainToClass<GeocoderQueryType, GeocoderQueryType>(this.constructor.queryClass(), _query);
const query: GeocoderQueryType = plainToInstance<GeocoderQueryType, GeocoderQueryType>(this.constructor.queryClass(), _query);

try {
await validateOrReject(query, {
Expand Down
4 changes: 2 additions & 2 deletions src/model/distance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { classToPlain, Exclude, Expose } from 'class-transformer';
import { instanceToPlain, Exclude, Expose } from 'class-transformer';
import type { ClassTransformOptions } from 'class-transformer';
import type { DistanceDetailsInterface } from '../interface';

Expand All @@ -17,6 +17,6 @@ export class Distance<ProviderRawEntryType = any> implements DistanceDetailsInte
raw?: ProviderRawEntryType;

toObject(options?: ClassTransformOptions): DistanceDetailsInterface<ProviderRawEntryType> {
return classToPlain<Distance<ProviderRawEntryType>>(this, options) as DistanceDetailsInterface<ProviderRawEntryType>;
return instanceToPlain<Distance<ProviderRawEntryType>>(this, options) as DistanceDetailsInterface<ProviderRawEntryType>;
}
}
4 changes: 2 additions & 2 deletions src/model/location.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { classToPlain, Exclude, Expose } from 'class-transformer';
import { instanceToPlain, Exclude, Expose } from 'class-transformer';
import type { ClassTransformOptions } from 'class-transformer';
import type { LocationInterface } from '../interface';

Expand Down Expand Up @@ -72,6 +72,6 @@ export class Location<ProviderRawEntryType = any> implements LocationInterface<P
}

toObject(options?: ClassTransformOptions): LocationInterface<ProviderRawEntryType> {
return classToPlain<Location<ProviderRawEntryType>>(this, options) as LocationInterface<ProviderRawEntryType>;
return instanceToPlain<Location<ProviderRawEntryType>>(this, options) as LocationInterface<ProviderRawEntryType>;
}
}
4 changes: 2 additions & 2 deletions src/model/suggestion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { classToPlain, Exclude, Expose } from 'class-transformer';
import { instanceToPlain, Exclude, Expose } from 'class-transformer';
import type { ClassTransformOptions } from 'class-transformer';
import type { SuggestionInterface } from '../interface';

Expand All @@ -17,6 +17,6 @@ export class Suggestion<ProviderRawEntryType = any> implements SuggestionInterfa
raw?: ProviderRawEntryType;

toObject(options?: ClassTransformOptions): SuggestionInterface<ProviderRawEntryType> {
return classToPlain<Suggestion<ProviderRawEntryType>>(this, options) as SuggestionInterface<ProviderRawEntryType>;
return instanceToPlain<Suggestion<ProviderRawEntryType>>(this, options) as SuggestionInterface<ProviderRawEntryType>;
}
}
4 changes: 2 additions & 2 deletions src/transformer/abstract-distance-transformer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { plainToClass } from 'class-transformer';
import { plainToInstance } from 'class-transformer';
import type { ClassTransformOptions } from 'class-transformer';
import { Distance } from '../model/distance';
import type { DistanceDetailsInterface } from '../interface';
Expand All @@ -20,6 +20,6 @@ export abstract class AbstractDistanceTransformer<HttpProviderClass extends Abst
distance.duration = await this.getDuration();
distance.raw = this.raw;

return plainToClass<Distance<ProviderRawEntryType>, DistanceDetailsInterface<ProviderRawEntryType>>(Distance, distance, options);
return plainToInstance<Distance<ProviderRawEntryType>, DistanceDetailsInterface<ProviderRawEntryType>>(Distance, distance, options);
}
}
4 changes: 2 additions & 2 deletions src/transformer/abstract-location-transformer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { plainToClass } from 'class-transformer';
import { plainToInstance } from 'class-transformer';
import type { ClassTransformOptions } from 'class-transformer';
import { WorldCountryUtil } from '../util/world-country';
import { Location } from '../model';
Expand Down Expand Up @@ -46,7 +46,7 @@ export abstract class AbstractLocationTransformer<HttpProviderClass extends Abst
location.formattedAddress = location.generateFormattedAddress();
}

return plainToClass<Location<ProviderRawEntryType>, LocationInterface<ProviderRawEntryType>>(Location, location, options);
return plainToInstance<Location<ProviderRawEntryType>, LocationInterface<ProviderRawEntryType>>(Location, location, options);
}

protected async getWorldCountry(query: WorldCountryQueryInterface): Promise<WorldCountry | undefined> {
Expand Down
4 changes: 2 additions & 2 deletions src/transformer/abstract-suggestion-transformer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { plainToClass } from 'class-transformer';
import { plainToInstance } from 'class-transformer';
import type { ClassTransformOptions } from 'class-transformer';
import { Suggestion } from '../model';
import type { SuggestionInterface } from '../interface';
Expand All @@ -20,6 +20,6 @@ export abstract class AbstractSuggestionTransformer<
suggestion.placeId = await this.getPlaceId();
suggestion.raw = this.raw;

return plainToClass<Suggestion<ProviderRawEntryType>, SuggestionInterface<ProviderRawEntryType>>(Suggestion, suggestion, options);
return plainToInstance<Suggestion<ProviderRawEntryType>, SuggestionInterface<ProviderRawEntryType>>(Suggestion, suggestion, options);
}
}
8 changes: 4 additions & 4 deletions src/util/world-country-state/world-country-state-util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { plainToClass } from 'class-transformer';
import { plainToInstance } from 'class-transformer';
import { validateOrReject } from 'class-validator';
import countryStates from '../../data/country-states/country-states.json';
import { WorldCountryState } from './world-country-state';
Expand All @@ -23,7 +23,7 @@ export class WorldCountryStateUtil {
}

static async find(_query: WorldCountryStateQueryInterface): Promise<WorldCountryState | undefined> {
const query: WorldCountryStateQuery = plainToClass<WorldCountryStateQuery, WorldCountryStateQueryInterface>(WorldCountryStateQuery, _query);
const query: WorldCountryStateQuery = plainToInstance<WorldCountryStateQuery, WorldCountryStateQueryInterface>(WorldCountryStateQuery, _query);
const keys: Array<keyof WorldCountryStateQuery> = Object.keys(query) as unknown as Array<keyof WorldCountryStateQuery>;

// clear undefined/empty values
Expand All @@ -45,7 +45,7 @@ export class WorldCountryStateUtil {

const stateData: WorldCountryStateInterface | undefined = (countryStates as WorldCountryStateInterface[]).find(
(plainState: WorldCountryStateInterface) => {
const state: WorldCountryState = plainToClass<WorldCountryState, WorldCountryStateInterface>(WorldCountryState, plainState);
const state: WorldCountryState = plainToInstance<WorldCountryState, WorldCountryStateInterface>(WorldCountryState, plainState);

return WorldCountryStateUtil.match(state, query);
},
Expand All @@ -55,6 +55,6 @@ export class WorldCountryStateUtil {
return;
}

return plainToClass<WorldCountryState, WorldCountryStateInterface>(WorldCountryState, stateData);
return plainToInstance<WorldCountryState, WorldCountryStateInterface>(WorldCountryState, stateData);
}
}
8 changes: 4 additions & 4 deletions src/util/world-country/world-country-util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { plainToClass } from 'class-transformer';
import { plainToInstance } from 'class-transformer';
import { validateOrReject } from 'class-validator';
import countries from 'world-countries/dist/countries-unescaped.json';
import type { Countries, Country } from 'world-countries';
Expand Down Expand Up @@ -30,7 +30,7 @@ export class WorldCountryUtil {
}

static async find(_query: WorldCountryQueryInterface): Promise<WorldCountry | undefined> {
const query: WorldCountryQuery = plainToClass<WorldCountryQuery, WorldCountryQueryInterface>(WorldCountryQuery, _query);
const query: WorldCountryQuery = plainToInstance<WorldCountryQuery, WorldCountryQueryInterface>(WorldCountryQuery, _query);
const keys: Array<keyof WorldCountryQueryInterface> = Object.keys(query) as unknown as Array<keyof WorldCountryQueryInterface>;

// clear undefined/empty values
Expand All @@ -51,7 +51,7 @@ export class WorldCountryUtil {
}

const countryData: Country | undefined = (countries as unknown as Countries).find((plainCountry: Country) => {
const country: WorldCountry = plainToClass<WorldCountry, Country>(WorldCountry, plainCountry);
const country: WorldCountry = plainToInstance<WorldCountry, Country>(WorldCountry, plainCountry);

return WorldCountryUtil.match(country, query);
});
Expand All @@ -60,6 +60,6 @@ export class WorldCountryUtil {
return;
}

return plainToClass<WorldCountry, Country>(WorldCountry, countryData);
return plainToInstance<WorldCountry, Country>(WorldCountry, countryData);
}
}
8 changes: 4 additions & 4 deletions test/unit/model/location.model.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { classToPlain, plainToClass } from 'class-transformer';
import { instanceToPlain, plainToClass } from 'class-transformer';
import { Location } from '../../../src/model';
import { locationFixture } from '../../fixture/model/address.fixture';
import type { LocationInterface } from '../../../src/interface';
Expand Down Expand Up @@ -72,19 +72,19 @@ describe('Location (unit)', () => {
});
});

describe('classToPlain', () => {
describe('instanceToPlain', () => {
it('should use #generateFormattedAddress if formattedAddress is empty', async () => {
delete location.formattedAddress;
delete location.postalCode;
delete location.country;

const addressPlainObject: LocationInterface = classToPlain<Location>(location) as LocationInterface;
const addressPlainObject: LocationInterface = instanceToPlain<Location>(location) as LocationInterface;

return (addressPlainObject.formattedAddress as string).should.be.deep.eq('1158 E 89th St, Chicago, IL, US');
});

it('should not generate street property', async () => {
const addressPlainObject: any = classToPlain<Location>(location) as LocationInterface;
const addressPlainObject: any = instanceToPlain<Location>(location) as LocationInterface;

return (typeof addressPlainObject.street).should.be.eq('undefined');
});
Expand Down

0 comments on commit 84e77bd

Please sign in to comment.