Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/angular_sample_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@angular/cli": "^16.1.6",
"@angular/compiler-cli": "^16.1.7",
"@ngx-env/builder": "^16.1.2",
"@types/google.maps": "~3.55.8",
"@types/google.maps": "~3.65.0",
"typescript": "~5.0.2"
}
}
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 83 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.3",
"@types/google.maps": "~3.55.8",
"@types/google.maps": "~3.65.0",
"@types/jasmine": "^4.3.6",
"@types/react": "^18.2.24",
"@web/test-runner": "^0.17.1",
Expand All @@ -100,42 +100,86 @@
"!**/*_test.ts",
"!src/testing/*.ts"
],
"output": ["custom-elements.json"]
"output": [
"custom-elements.json"
]
},
"docs": {
"command": "node build/make_docs.js",
"dependencies": ["cem"],
"files": ["**/doc_src/*", "build/make_docs.js", "custom-elements.json"],
"output": ["README.md", "src/**/README.md", "!src/react/README.md"]
"dependencies": [
"cem"
],
"files": [
"**/doc_src/*",
"build/make_docs.js",
"custom-elements.json"
],
"output": [
"README.md",
"src/**/README.md",
"!src/react/README.md"
]
},
"build": {
"dependencies": ["build:ts"]
"dependencies": [
"build:ts"
]
},
"build:react": {
"command": "node build/make_react.js",
"dependencies": ["cem"],
"files": ["build/make_react.js", "custom-elements.json"],
"output": ["src/react/index.ts"]
"dependencies": [
"cem"
],
"files": [
"build/make_react.js",
"custom-elements.json"
],
"output": [
"src/react/index.ts"
]
},
"build:ts": {
"command": "tsc",
"dependencies": ["build:react"],
"files": ["tsconfig.json", "src/**/*.ts"],
"output": [".tsbuildinfo", "lib/**/*"],
"dependencies": [
"build:react"
],
"files": [
"tsconfig.json",
"src/**/*.ts"
],
"output": [
".tsbuildinfo",
"lib/**/*"
],
"clean": "if-file-deleted"
},
"build:package": {
"command": ". build/finalize_package.sh",
"dependencies": ["build:ts"],
"files": ["build/finalize_package.sh", "lib/base/constants.js"],
"output": ["lib/**/*.js", "lib/**/*.md"],
"dependencies": [
"build:ts"
],
"files": [
"build/finalize_package.sh",
"lib/base/constants.js"
],
"output": [
"lib/**/*.js",
"lib/**/*.md"
],
"clean": false
},
"build:bundle": {
"command": "rollup -c build/rollup.config.js",
"dependencies": ["build:package"],
"files": ["build/rollup.config.js", "lib/**/*.js"],
"output": ["dist/index.min.js"]
"dependencies": [
"build:package"
],
"files": [
"build/rollup.config.js",
"lib/**/*.js"
],
"output": [
"dist/index.min.js"
]
},
"example:prepare": {
"command": "chmod +x build/start_example.sh"
Expand All @@ -145,7 +189,10 @@
"env": {
"PORT": "8001"
},
"dependencies": ["build:package", "example:prepare"],
"dependencies": [
"build:package",
"example:prepare"
],
"service": {
"readyWhen": {
"lineMatches": "You can now view \\S+ in the browser"
Expand All @@ -157,7 +204,10 @@
"env": {
"PORT": "8002"
},
"dependencies": ["build:bundle", "example:prepare"],
"dependencies": [
"build:bundle",
"example:prepare"
],
"service": {
"readyWhen": {
"lineMatches": "Web Dev Server started"
Expand All @@ -169,7 +219,10 @@
"env": {
"PORT": "8003"
},
"dependencies": ["build:package", "example:prepare"],
"dependencies": [
"build:package",
"example:prepare"
],
"service": {
"readyWhen": {
"lineMatches": "Angular Live Development Server is listening on localhost"
Expand All @@ -183,13 +236,19 @@
"example:js_sample_app",
"example:angular_sample_app"
],
"files": ["e2e/**/*.js"],
"files": [
"e2e/**/*.js"
],
"output": []
},
"test": {
"command": "wtr",
"dependencies": ["build:ts"],
"files": ["web-test-runner.config.js"],
"dependencies": [
"build:ts"
],
"files": [
"web-test-runner.config.js"
],
"output": []
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/address_validation/suggest_validation_action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import {Address, AddressValidation, Granularity} from '../utils/googlemaps_types.js';
import {Address, AddressValidation} from '../utils/googlemaps_types.js';


/** Suggested action to take for this validation result. */
Expand Down Expand Up @@ -46,7 +46,7 @@ function isMissingNonSubpremiseComponent(result: AddressValidation): boolean {
*/
function hasValidationGranularityOther(result: AddressValidation): boolean {
return !result.verdict?.validationGranularity ||
result.verdict.validationGranularity === Granularity.OTHER;
result.verdict.validationGranularity === 'OTHER';
}

function hasSuspiciousComponent(result: AddressValidation): boolean {
Expand All @@ -70,7 +70,9 @@ function hasMajorInference(result: AddressValidation): boolean {
]);
return !!result.address &&
result.address.components.some(
c => c.isInferred && !minorComponents.has(c.componentType))
// TODO: Align with 3.65 typings
// @ts-ignore
c => c.isInferred && !minorComponents.has(c.componentType!))
}

function hasReplacement(result: AddressValidation): boolean {
Expand Down Expand Up @@ -158,4 +160,4 @@ export function suggestValidationAction(response: AddressValidation):
return {suggestedAction: SuggestedAction.ADD_SUBPREMISES};
}
return {suggestedAction: SuggestedAction.ACCEPT};
}
}
15 changes: 9 additions & 6 deletions src/address_validation/suggest_validation_action_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
* SPDX-License-Identifier: Apache-2.0
*/

// TODO: Align with 3.65 typings
// @ts-nocheck

// import 'jasmine'; (google3-only)

import {Address, AddressComponent, AddressValidation, ConfirmationLevel, Granularity, Verdict} from '../utils/googlemaps_types.js';
import {Address, AddressComponent, AddressValidation, Verdict} from '../utils/googlemaps_types.js';

import {SuggestedAction, suggestValidationAction} from './suggest_validation_action.js';

const GOOD_VERDICT: Verdict = {
inputGranularity: Granularity.PREMISE,
validationGranularity: Granularity.PREMISE,
geocodeGranularity: Granularity.PREMISE,
inputGranularity: 'PREMISE',
validationGranularity: 'PREMISE',
geocodeGranularity: 'PREMISE',
isAddressComplete: true,
hasUnconfirmedComponents: false,
hasInferredComponents: false,
Expand Down Expand Up @@ -67,7 +70,7 @@ describe('SuggestValidationAction', () => {

it('returns FIX when the validation granularity is OTHER', () => {
const suggestion = suggestValidationAction(makeFakeValidationResponse(
{}, {...GOOD_VERDICT, validationGranularity: Granularity.OTHER}));
{}, {...GOOD_VERDICT, validationGranularity: 'OTHER'}));
expect(suggestion.suggestedAction).toBe(SuggestedAction.FIX);
});

Expand All @@ -76,7 +79,7 @@ describe('SuggestValidationAction', () => {
{
components: [{
...LOCALITY_COMPONENT,
confirmationLevel: ConfirmationLevel.UNCONFIRMED_AND_SUSPICIOUS
confirmationLevel: 'UNCONFIRMED_AND_SUSPICIOUS'
}]
},
GOOD_VERDICT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {html, TemplateResult} from 'lit';

import {Environment} from '../../testing/environment.js';
import {makeFakePlace} from '../../testing/fake_place.js';
import {mapsJsData} from '../../utils/googlemaps_types.js';

import {PlaceAttribution} from './place_attribution.js';

Expand Down Expand Up @@ -64,8 +65,8 @@ describe('place attribution test', () => {
const place = makeFakePlace({
id: '1234567890',
attributions: [
{provider: 'Foo', providerURI: 'https://foo.com'},
{provider: 'Bar', providerURI: null}
mapsJsData({provider: 'Foo', providerURI: 'https://foo.com'}),
mapsJsData({provider: 'Bar', providerURI: null})
]
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,15 @@ describe('PlaceDataProvider', () => {
fetchFieldsSpy.and.callFake(
async ({fields}: google.maps.places.FetchFieldsRequest) => {
if (fields.includes('displayName')) {
place.displayName = 'Fake Place';
// Properties of Place are getter-only in the typings
Object.defineProperty(place, 'displayName', {
get: () => 'Fake Place',
});
}
if (fields.includes('rating')) {
place.rating = 5;
Object.defineProperty(place, 'rating', {
get: () => 5,
});
}
return {place};
});
Expand Down
Loading
Loading