From 46efab86f0acce893e31046eec7a6127e98e070a Mon Sep 17 00:00:00 2001 From: Cami Blanch Date: Mon, 10 Nov 2025 16:14:38 -0700 Subject: [PATCH 01/10] npm i --- package-lock.json | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 324841f..beac9ca 100644 --- a/package-lock.json +++ b/package-lock.json @@ -374,7 +374,6 @@ "integrity": "sha512-HFN59MmQXGHVyYadKLVumYsA9dBFun/ldYxipEjzA4196jpLZd8UjEEBLkbEkvfYreDqJhZxYAWFPtrfhNpj4w==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/template": "^7.27.2", "@babel/types": "^7.28.4" @@ -2026,7 +2025,6 @@ "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" @@ -2706,6 +2704,7 @@ "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.1.tgz", "integrity": "sha512-hU4EGxxt+j7TQijx1oYdAjw4xuIp1wRQSsbMFwSthCWeBQur1eF+qJ5iQ5sN3Tw8YRzQNKb8jszgBdMDVqwJcw==", "license": "MIT", + "peer": true, "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.4", @@ -2833,6 +2832,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.19", "caniuse-lite": "^1.0.30001751", @@ -3086,8 +3086,7 @@ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/core-js-compat": { "version": "3.46.0", @@ -3543,7 +3542,6 @@ "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=6.9.0" } @@ -3940,7 +3938,6 @@ "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "json5": "lib/cli.js" }, @@ -4281,6 +4278,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -4484,6 +4482,7 @@ "integrity": "sha512-3GuObel8h7Kqdjt0gxkEzaifHTqLVW56Y/bjN7PSQtkKr0w3V/QYSdt6QWYtd7A1xUtYQigtdUfgj1RvWVtorw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@types/estree": "1.0.8" }, @@ -4870,7 +4869,8 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "license": "0BSD" + "license": "0BSD", + "peer": true }, "node_modules/tsx": { "version": "4.20.6", @@ -4898,6 +4898,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" From 90456f8bf7d3fb46f7a02f9fbff965897749d1d9 Mon Sep 17 00:00:00 2001 From: Cami Blanch Date: Mon, 10 Nov 2025 16:47:10 -0700 Subject: [PATCH 02/10] Adds features and component analysis capabilities --- src/ClientBuilder.js | 41 ++++++++++++++++++++++++++++++++- src/CustomQuerySender.ts | 20 ++++++++++++++++ tests/test_CustomQuerySender.ts | 33 ++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 src/CustomQuerySender.ts create mode 100644 tests/test_CustomQuerySender.ts diff --git a/src/ClientBuilder.js b/src/ClientBuilder.js index ae30f31..d2ab4a1 100644 --- a/src/ClientBuilder.js +++ b/src/ClientBuilder.js @@ -7,6 +7,7 @@ const SharedCredentials = require("./SharedCredentials"); const CustomHeaderSender = require("./CustomHeaderSender"); const StatusCodeSender = require("./StatusCodeSender"); const LicenseSender = require("./LicenseSender"); +const CustomQuerySender = require("@/src/CustomQuerySender"); const BadCredentialsError = require("./Errors").BadCredentialsError; const RetrySender = require("./RetrySender"); const Sleeper = require("./util/Sleeper.ts"); @@ -50,6 +51,7 @@ class ClientBuilder { this.customHeaders = {}; this.debug = undefined; this.licenses = []; + this.customQueries = new Map(); function noCredentialsProvided() { return (!signer) instanceof StaticCredentials || (!signer) instanceof SharedCredentials; @@ -152,6 +154,42 @@ class ClientBuilder { return this; } + /** + * Allows the caller to specify key and value pair that is added to the request + * @param {string} key - The query parameter key + * @param {string} value - The query parameter value + * @return Returns this to accommodate method chaining. + */ + withCustomQuery(key, value) { + this.customQueries.set(key, value); + + return this; + } + + /** + * Allows the caller to specify key and value pair and appends the value associated with the key, seperated by a comma. + * @param {string} key - The query parameter key + * @param {string} value - The query parameter value + * @return Returns this to accommodate method chaining. + */ + withCustomCommaSeperatedQuery(key, value) { + let values = this.customQueries.get(key); + if (values === "") { + values = value; + } else { + values += "," + value; + } + this.customQueries.set(key, values); + } + + /** + * Adds to the request query to use the component analysis feature. + * @return Returns this to accommodate method chaining. + */ + withFeatureComponentAnalysis() { + return this.withCustomCommaSeperatedQuery("features", "component-analysis"); + } + buildSender() { if (this.httpSender) return this.httpSender; @@ -166,8 +204,9 @@ class ClientBuilder { const customHeaderSender = new CustomHeaderSender(agentSender, this.customHeaders); const baseUrlSender = new BaseUrlSender(customHeaderSender, this.baseUrl); const licenseSender = new LicenseSender(baseUrlSender, this.licenses); + const customQuerySender = new CustomQuerySender(licenseSender, this.customQueries); - return licenseSender; + return customQuerySender; } buildClient(baseUrl, Client) { diff --git a/src/CustomQuerySender.ts b/src/CustomQuerySender.ts new file mode 100644 index 0000000..c587aa4 --- /dev/null +++ b/src/CustomQuerySender.ts @@ -0,0 +1,20 @@ +import { Request, Response, Sender } from "./types"; + +export default class CustomQuerySender { + private queries: Map; + private sender: Sender; + + constructor(innerSender: Sender, queries: Map) { + this.queries = queries; + this.sender = innerSender; + } + + send(request: Request): Promise { + this.queries.forEach((value, key) => { + const existingValue = request.parameters[key]; + request.parameters[key] = existingValue ? `${existingValue},${value}` : value; + }); + + return this.sender.send(request); + } +} diff --git a/tests/test_CustomQuerySender.ts b/tests/test_CustomQuerySender.ts new file mode 100644 index 0000000..72b1ef6 --- /dev/null +++ b/tests/test_CustomQuerySender.ts @@ -0,0 +1,33 @@ +import { expect } from "chai"; +import CustomQuerySender from "../src/CustomQuerySender"; +import Request from "../src/Request.js"; +import Response from "../src/Response.js"; +import { Sender } from "@/src/types"; + +describe("A custom query sender", function () { + it("adds custom query parameters to the request.", function () { + class MockSender implements Sender { + request?: Request; + + send = (request: Request): Promise => { + this.request = request; + return Promise.resolve(new Response(200, {})); + }; + } + + const mockSender = new MockSender(); + const customQueries = new Map([ + ["a", "1"], + ["b", "2"], + ]); + const customQuerySender = new CustomQuerySender(mockSender, customQueries); + const request = new Request(); + + customQuerySender.send(request); + + expect("a" in mockSender.request!.parameters).to.equal(true); + expect((mockSender.request!.parameters as Record)["a"]).to.equal("1"); + expect("b" in mockSender.request!.parameters).to.equal(true); + expect((mockSender.request!.parameters as Record)["b"]).to.equal("2"); + }); +}); From d76fcdd2b4c27c91471608666d096c416b6edf33 Mon Sep 17 00:00:00 2001 From: Cami Blanch Date: Mon, 10 Nov 2025 16:57:24 -0700 Subject: [PATCH 03/10] Properly check for credentials --- src/ClientBuilder.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ClientBuilder.js b/src/ClientBuilder.js index d2ab4a1..51f28fa 100644 --- a/src/ClientBuilder.js +++ b/src/ClientBuilder.js @@ -40,7 +40,7 @@ const INTERNATIONAL_POSTAL_CODE_API_URL = "https://international-postal-code.api */ class ClientBuilder { constructor(signer) { - if (noCredentialsProvided()) throw new BadCredentialsError(); + if (!credentialsProvided()) throw new BadCredentialsError(); this.signer = signer; this.httpSender = undefined; @@ -53,8 +53,8 @@ class ClientBuilder { this.licenses = []; this.customQueries = new Map(); - function noCredentialsProvided() { - return (!signer) instanceof StaticCredentials || (!signer) instanceof SharedCredentials; + function credentialsProvided() { + return signer instanceof StaticCredentials || signer instanceof SharedCredentials; } } From 752ef3ef393199c7fcb8e47e2305730efb69b9a5 Mon Sep 17 00:00:00 2001 From: Cami Blanch Date: Thu, 13 Nov 2025 16:17:47 -0700 Subject: [PATCH 04/10] Return this --- src/ClientBuilder.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ClientBuilder.js b/src/ClientBuilder.js index 51f28fa..d6232be 100644 --- a/src/ClientBuilder.js +++ b/src/ClientBuilder.js @@ -180,6 +180,7 @@ class ClientBuilder { values += "," + value; } this.customQueries.set(key, values); + return this; } /** From 17be0da4f2eb4b5a735d6f3e5bc2ce5d652f94d1 Mon Sep 17 00:00:00 2001 From: Cami Blanch Date: Thu, 13 Nov 2025 16:18:16 -0700 Subject: [PATCH 05/10] Update return docs to reflect what is being returned --- src/ClientBuilder.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/ClientBuilder.js b/src/ClientBuilder.js index d6232be..51ff894 100644 --- a/src/ClientBuilder.js +++ b/src/ClientBuilder.js @@ -60,7 +60,7 @@ class ClientBuilder { /** * @param retries The maximum number of times to retry sending the request to the API. (Default is 5) - * @return Returns this to accommodate method chaining. + * @return ClientBuilder this to accommodate method chaining. */ withMaxRetries(retries) { this.maxRetries = retries; @@ -70,7 +70,7 @@ class ClientBuilder { /** * @param timeout The maximum time (in milliseconds) to wait for a connection, and also to wait for
* the response to be read. (Default is 10000) - * @return Returns this to accommodate method chaining. + * @return ClientBuilder this to accommodate method chaining. */ withMaxTimeout(timeout) { this.maxTimeout = timeout; @@ -79,7 +79,7 @@ class ClientBuilder { /** * @param sender Default is a series of nested senders. See buildSender(). - * @return Returns this to accommodate method chaining. + * @return ClientBuilder this to accommodate method chaining. */ withSender(sender) { this.httpSender = sender; @@ -89,7 +89,7 @@ class ClientBuilder { /** * This may be useful when using a local installation of the Smarty APIs. * @param url Defaults to the URL for the API corresponding to the Client object being built. - * @return Returns this to accommodate method chaining. + * @return ClientBuilder this to accommodate method chaining. */ withBaseUrl(url) { this.baseUrl = url; @@ -103,7 +103,7 @@ class ClientBuilder { * @param protocol The protocol on the proxy server to which you wish to connect. If the proxy server uses HTTPS, then you must set the protocol to 'https'. * @param username The username to login to the proxy. * @param password The password to login to the proxy. - * @return Returns this to accommodate method chaining. + * @return ClientBuilder this to accommodate method chaining. */ withProxy(host, port, protocol, username, password) { this.proxy = { @@ -125,32 +125,29 @@ class ClientBuilder { /** * Use this to add any additional headers you need. * @param customHeaders A String to Object Map of header name/value pairs. - * @return Returns this to accommodate method chaining. + * @return ClientBuilder this to accommodate method chaining. */ withCustomHeaders(customHeaders) { this.customHeaders = customHeaders; - return this; } /** * Enables debug mode, which will print information about the HTTP request and response to console.log - * @return Returns this to accommodate method chaining. + * @return ClientBuilder this to accommodate method chaining. */ withDebug() { this.debug = true; - return this; } /** * Allows the caller to specify the subscription license (aka "track") they wish to use. * @param licenses A String Array of licenses. - * @returns Returns this to accommodate method chaining. + * @returns ClientBuilder this to accommodate method chaining. */ withLicenses(licenses) { this.licenses = licenses; - return this; } @@ -158,11 +155,10 @@ class ClientBuilder { * Allows the caller to specify key and value pair that is added to the request * @param {string} key - The query parameter key * @param {string} value - The query parameter value - * @return Returns this to accommodate method chaining. + * @return ClientBuilder this to accommodate method chaining. */ withCustomQuery(key, value) { this.customQueries.set(key, value); - return this; } @@ -170,7 +166,7 @@ class ClientBuilder { * Allows the caller to specify key and value pair and appends the value associated with the key, seperated by a comma. * @param {string} key - The query parameter key * @param {string} value - The query parameter value - * @return Returns this to accommodate method chaining. + * @return ClientBuilder this to accommodate method chaining. */ withCustomCommaSeperatedQuery(key, value) { let values = this.customQueries.get(key); @@ -185,7 +181,7 @@ class ClientBuilder { /** * Adds to the request query to use the component analysis feature. - * @return Returns this to accommodate method chaining. + * @return ClientBuilder this to accommodate method chaining. */ withFeatureComponentAnalysis() { return this.withCustomCommaSeperatedQuery("features", "component-analysis"); From a34e37ff96200c46857065b899ce15d06a9b9027 Mon Sep 17 00:00:00 2001 From: Cami Blanch Date: Mon, 17 Nov 2025 11:11:41 -0700 Subject: [PATCH 06/10] Default to enhanced matching --- examples/us_street.mjs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/us_street.mjs b/examples/us_street.mjs index 4648a44..78ff764 100644 --- a/examples/us_street.mjs +++ b/examples/us_street.mjs @@ -34,9 +34,8 @@ lookup1.city = "Provo"; lookup1.state = "Utah"; lookup1.zipCode = "84601"; lookup1.maxCandidates = 3; -lookup1.match = "invalid"; // "invalid" is the most permissive match, - // this will always return at least one result even if the address is invalid. - // Refer to the documentation for additional MatchStrategy options. +lookup1.match = "enhanced"; // The API will return detailed output based on a more aggressive matching mechanism. It also includes a more comprehensive address dataset beyond just the postal address data. Requires a US Core license or a US Rooftop Geocoding license. +// Refer to the documentation for additional MatchStrategy options. let lookup2 = new Lookup(); lookup2.street = "1600 Amphitheater Pkwy"; From 7d4153cfee286a0e9113cc25a932ab932315ad1c Mon Sep 17 00:00:00 2001 From: Cami Blanch Date: Mon, 17 Nov 2025 11:14:29 -0700 Subject: [PATCH 07/10] Whitespace --- examples/us_street.mjs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/us_street.mjs b/examples/us_street.mjs index 78ff764..5017470 100644 --- a/examples/us_street.mjs +++ b/examples/us_street.mjs @@ -15,8 +15,10 @@ const credentials = new SmartyCore.SharedCredentials(key); // The appropriate license values to be used for your subscriptions // can be found on the Subscription page of the account dashboard. // https://www.smarty.com/docs/cloud/licensing -let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses(["us-rooftop-geocoding-cloud"]); - // .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API +let clientBuilder = new SmartyCore.ClientBuilder(credentials) + .withLicenses(["us-rooftop-geocoding-cloud"]) + .withFeatureComponentAnalysis(); +// .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API let client = clientBuilder.buildUsStreetApiClient(); @@ -24,12 +26,12 @@ let client = clientBuilder.buildUsStreetApiClient(); // https://www.smarty.com/docs/us-street-api#input-fields let lookup1 = new Lookup(); -lookup1.inputId = "24601"; // Optional ID from your system +lookup1.inputId = "24601"; // Optional ID from your system lookup1.addressee = "John Doe"; lookup1.street = "330 N 100 W"; lookup1.street2 = "closet under the stairs"; lookup1.secondary = "APT 2"; -lookup1.urbanization = ""; // Only applies to Puerto Rico addresses +lookup1.urbanization = ""; // Only applies to Puerto Rico addresses lookup1.city = "Provo"; lookup1.state = "Utah"; lookup1.zipCode = "84601"; @@ -58,7 +60,7 @@ batch.add(lookup3); await handleResponse(batch); function handleSuccess(response) { - response.lookups.map(lookup => console.log(lookup.result)); + response.lookups.map((lookup) => console.log(lookup.result)); } function handleError(response) { @@ -69,7 +71,7 @@ async function handleResponse(lookup) { try { const result = await client.send(lookup); handleSuccess(result); - } catch(err) { + } catch (err) { handleError(err); } -} \ No newline at end of file +} From f1a8776876f9cfdb73af2b8b41dc8c4b6b51a1eb Mon Sep 17 00:00:00 2001 From: Cami Blanch Date: Mon, 17 Nov 2025 11:15:32 -0700 Subject: [PATCH 08/10] Add component analysis to response --- src/us_street/Candidate.js | 27 +++++++++++++++++++++++- tests/us_street/test_Candidate.js | 35 +++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/src/us_street/Candidate.js b/src/us_street/Candidate.js index cdc9386..7bccbe3 100644 --- a/src/us_street/Candidate.js +++ b/src/us_street/Candidate.js @@ -82,8 +82,33 @@ class Candidate { this.analysis.lacsLinkIndicator = responseData.analysis.lacslink_indicator; this.analysis.isSuiteLinkMatch = responseData.analysis.suitelink_match; this.analysis.enhancedMatch = responseData.analysis.enhanced_match; + this.analysis.components = {}; + console.log("what are the analysis", responseData.analysis); + if (responseData.analysis.components !== undefined) { + this.analysis.components.primaryNumber = responseData.analysis.components.primary_number; + this.analysis.components.streetPredirection = + responseData.analysis.components.street_predirection; + this.analysis.components.streetName = responseData.analysis.components.street_name; + this.analysis.components.streetPostdirection = + responseData.analysis.components.street_postdirection; + this.analysis.components.streetSuffix = responseData.analysis.components.street_suffix; + this.analysis.components.secondaryNumber = + responseData.analysis.components.secondary_number; + this.analysis.components.secondaryDesignator = + responseData.analysis.components.secondary_designator; + this.analysis.components.extraSecondaryNumber = + responseData.analysis.components.extra_secondary_number; + this.analysis.components.extraSecondaryDesignator = + responseData.analysis.components.extra_secondary_designator; + this.analysis.components.cityName = responseData.analysis.components.city_name; + this.analysis.components.stateAbbreviation = + responseData.analysis.components.state_abbreviation; + this.analysis.components.zipCode = responseData.analysis.components.zipcode; + this.analysis.components.plus4Code = responseData.analysis.components.plus4_code; + this.analysis.components.urbanization = responseData.analysis.components.urbanization; + } } } } -module.exports = Candidate; \ No newline at end of file +module.exports = Candidate; diff --git a/tests/us_street/test_Candidate.js b/tests/us_street/test_Candidate.js index 731eea2..5ce8088 100644 --- a/tests/us_street/test_Candidate.js +++ b/tests/us_street/test_Candidate.js @@ -66,7 +66,23 @@ describe("A match candidate", function () { suitelink_match: "51", dpv_no_stat: "52", enhanced_match: "53", - } + components: { + primary_number: "54", + street_predirection: "55", + street_name: "56", + street_postdirection: "57", + street_suffix: "58", + secondary_number: "59", + secondary_designator: "60", + extra_secondary_number: "61", + extra_secondary_designator: "62", + city_name: "63", + state_abbreviation: "64", + zipcode: "65", + plus4_code: "66", + urbanization: "67", + }, + }, }; const candidate = new Candidate(sampleResponse); @@ -129,5 +145,20 @@ describe("A match candidate", function () { expect(candidate.analysis.isSuiteLinkMatch).to.equal('51'); expect(candidate.analysis.noStat).to.equal('52'); expect(candidate.analysis.enhancedMatch).to.equal('53'); + + expect(candidate.analysis.components.primaryNumber).to.equal("54"); + expect(candidate.analysis.components.streetPredirection).to.equal("55"); + expect(candidate.analysis.components.streetName).to.equal("56"); + expect(candidate.analysis.components.streetPostdirection).to.equal("57"); + expect(candidate.analysis.components.streetSuffix).to.equal("58"); + expect(candidate.analysis.components.secondaryNumber).to.equal("59"); + expect(candidate.analysis.components.secondaryDesignator).to.equal("60"); + expect(candidate.analysis.components.extraSecondaryNumber).to.equal("61"); + expect(candidate.analysis.components.extraSecondaryDesignator).to.equal("62"); + expect(candidate.analysis.components.cityName).to.equal("63"); + expect(candidate.analysis.components.stateAbbreviation).to.equal("64"); + expect(candidate.analysis.components.zipCode).to.equal("65"); + expect(candidate.analysis.components.plus4Code).to.equal("66"); + expect(candidate.analysis.components.urbanization).to.equal("67"); }); -}); \ No newline at end of file +}); From e2d3c7a72a3805f5b225535b31ef3e0545fd078b Mon Sep 17 00:00:00 2001 From: Cami Blanch Date: Mon, 17 Nov 2025 11:15:55 -0700 Subject: [PATCH 09/10] Prettier --- src/us_street/Candidate.js | 3 +- tests/us_street/test_Candidate.js | 104 +++++++++++++++--------------- 2 files changed, 53 insertions(+), 54 deletions(-) diff --git a/src/us_street/Candidate.js b/src/us_street/Candidate.js index 7bccbe3..c94e5d7 100644 --- a/src/us_street/Candidate.js +++ b/src/us_street/Candidate.js @@ -53,8 +53,7 @@ class Candidate { this.metadata.elotSort = responseData.metadata.elot_sort; this.metadata.latitude = responseData.metadata.latitude; this.metadata.longitude = responseData.metadata.longitude; - switch (responseData.metadata.coordinate_license) - { + switch (responseData.metadata.coordinate_license) { case 1: this.metadata.coordinateLicense = "SmartyStreets Proprietary"; break; diff --git a/tests/us_street/test_Candidate.js b/tests/us_street/test_Candidate.js index 5ce8088..2bfd515 100644 --- a/tests/us_street/test_Candidate.js +++ b/tests/us_street/test_Candidate.js @@ -32,7 +32,7 @@ describe("A match candidate", function () { zipcode: "22", plus4_code: "23", delivery_point: "24", - delivery_point_check_digit: "25" + delivery_point_check_digit: "25", }, metadata: { record_type: "26", @@ -52,7 +52,7 @@ describe("A match candidate", function () { time_zone: "39", utc_offset: 40.0, dst: "41", - ews_match: "47" + ews_match: "47", }, analysis: { dpv_match_code: "42", @@ -88,63 +88,63 @@ describe("A match candidate", function () { expect(candidate.inputIndex).to.equal(0); expect(candidate.candidateIndex).to.equal(1); - expect(candidate.addressee).to.equal('2'); - expect(candidate.deliveryLine1).to.equal('3'); - expect(candidate.deliveryLine2).to.equal('4'); - expect(candidate.lastLine).to.equal('5'); - expect(candidate.deliveryPointBarcode).to.equal('6'); - expect(candidate.smartyKey).to.equal('0000'); + expect(candidate.addressee).to.equal("2"); + expect(candidate.deliveryLine1).to.equal("3"); + expect(candidate.deliveryLine2).to.equal("4"); + expect(candidate.lastLine).to.equal("5"); + expect(candidate.deliveryPointBarcode).to.equal("6"); + expect(candidate.smartyKey).to.equal("0000"); - expect(candidate.components.urbanization).to.equal('7'); - expect(candidate.components.primaryNumber).to.equal('8'); - expect(candidate.components.streetName).to.equal('9'); - expect(candidate.components.streetPredirection).to.equal('10'); - expect(candidate.components.streetPostdirection).to.equal('11'); - expect(candidate.components.streetSuffix).to.equal('12'); - expect(candidate.components.secondaryNumber).to.equal('13'); - expect(candidate.components.secondaryDesignator).to.equal('14'); - expect(candidate.components.extraSecondaryNumber).to.equal('15'); - expect(candidate.components.extraSecondaryDesignator).to.equal('16'); - expect(candidate.components.pmbDesignator).to.equal('17'); - expect(candidate.components.pmbNumber).to.equal('18'); - expect(candidate.components.cityName).to.equal('19'); - expect(candidate.components.defaultCityName).to.equal('20'); - expect(candidate.components.state).to.equal('21'); - expect(candidate.components.zipCode).to.equal('22'); - expect(candidate.components.plus4Code).to.equal('23'); - expect(candidate.components.deliveryPoint).to.equal('24'); - expect(candidate.components.deliveryPointCheckDigit).to.equal('25'); + expect(candidate.components.urbanization).to.equal("7"); + expect(candidate.components.primaryNumber).to.equal("8"); + expect(candidate.components.streetName).to.equal("9"); + expect(candidate.components.streetPredirection).to.equal("10"); + expect(candidate.components.streetPostdirection).to.equal("11"); + expect(candidate.components.streetSuffix).to.equal("12"); + expect(candidate.components.secondaryNumber).to.equal("13"); + expect(candidate.components.secondaryDesignator).to.equal("14"); + expect(candidate.components.extraSecondaryNumber).to.equal("15"); + expect(candidate.components.extraSecondaryDesignator).to.equal("16"); + expect(candidate.components.pmbDesignator).to.equal("17"); + expect(candidate.components.pmbNumber).to.equal("18"); + expect(candidate.components.cityName).to.equal("19"); + expect(candidate.components.defaultCityName).to.equal("20"); + expect(candidate.components.state).to.equal("21"); + expect(candidate.components.zipCode).to.equal("22"); + expect(candidate.components.plus4Code).to.equal("23"); + expect(candidate.components.deliveryPoint).to.equal("24"); + expect(candidate.components.deliveryPointCheckDigit).to.equal("25"); - expect(candidate.metadata.recordType).to.equal('26'); - expect(candidate.metadata.zipType).to.equal('27'); - expect(candidate.metadata.countyFips).to.equal('28'); - expect(candidate.metadata.countyName).to.equal('29'); - expect(candidate.metadata.carrierRoute).to.equal('30'); - expect(candidate.metadata.congressionalDistrict).to.equal('31'); - expect(candidate.metadata.buildingDefaultIndicator).to.equal('32'); - expect(candidate.metadata.rdi).to.equal('33'); - expect(candidate.metadata.elotSequence).to.equal('34'); - expect(candidate.metadata.elotSort).to.equal('35'); + expect(candidate.metadata.recordType).to.equal("26"); + expect(candidate.metadata.zipType).to.equal("27"); + expect(candidate.metadata.countyFips).to.equal("28"); + expect(candidate.metadata.countyName).to.equal("29"); + expect(candidate.metadata.carrierRoute).to.equal("30"); + expect(candidate.metadata.congressionalDistrict).to.equal("31"); + expect(candidate.metadata.buildingDefaultIndicator).to.equal("32"); + expect(candidate.metadata.rdi).to.equal("33"); + expect(candidate.metadata.elotSequence).to.equal("34"); + expect(candidate.metadata.elotSort).to.equal("35"); expect(candidate.metadata.latitude).to.equal(36.0); expect(candidate.metadata.longitude).to.equal(37.0); expect(candidate.metadata.coordinateLicense).to.equal("SmartyStreets Proprietary"); - expect(candidate.metadata.precision).to.equal('38'); - expect(candidate.metadata.timeZone).to.equal('39'); + expect(candidate.metadata.precision).to.equal("38"); + expect(candidate.metadata.timeZone).to.equal("39"); expect(candidate.metadata.utcOffset).to.equal(40.0); - expect(candidate.metadata.obeysDst).to.equal('41'); - expect(candidate.metadata.isEwsMatch).to.equal('47'); + expect(candidate.metadata.obeysDst).to.equal("41"); + expect(candidate.metadata.isEwsMatch).to.equal("47"); - expect(candidate.analysis.dpvMatchCode).to.equal('42'); - expect(candidate.analysis.dpvFootnotes).to.equal('43'); - expect(candidate.analysis.cmra).to.equal('44'); - expect(candidate.analysis.vacant).to.equal('45'); - expect(candidate.analysis.active).to.equal('46'); - expect(candidate.analysis.footnotes).to.equal('48'); - expect(candidate.analysis.lacsLinkCode).to.equal('49'); - expect(candidate.analysis.lacsLinkIndicator).to.equal('50'); - expect(candidate.analysis.isSuiteLinkMatch).to.equal('51'); - expect(candidate.analysis.noStat).to.equal('52'); - expect(candidate.analysis.enhancedMatch).to.equal('53'); + expect(candidate.analysis.dpvMatchCode).to.equal("42"); + expect(candidate.analysis.dpvFootnotes).to.equal("43"); + expect(candidate.analysis.cmra).to.equal("44"); + expect(candidate.analysis.vacant).to.equal("45"); + expect(candidate.analysis.active).to.equal("46"); + expect(candidate.analysis.footnotes).to.equal("48"); + expect(candidate.analysis.lacsLinkCode).to.equal("49"); + expect(candidate.analysis.lacsLinkIndicator).to.equal("50"); + expect(candidate.analysis.isSuiteLinkMatch).to.equal("51"); + expect(candidate.analysis.noStat).to.equal("52"); + expect(candidate.analysis.enhancedMatch).to.equal("53"); expect(candidate.analysis.components.primaryNumber).to.equal("54"); expect(candidate.analysis.components.streetPredirection).to.equal("55"); From 5b49c5d275c724f30f8496956b4fa92af2f7b216 Mon Sep 17 00:00:00 2001 From: Cami Blanch Date: Mon, 17 Nov 2025 11:20:20 -0700 Subject: [PATCH 10/10] Don't default to using component analysis --- examples/us_street.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/us_street.mjs b/examples/us_street.mjs index 5017470..01fc28a 100644 --- a/examples/us_street.mjs +++ b/examples/us_street.mjs @@ -15,9 +15,9 @@ const credentials = new SmartyCore.SharedCredentials(key); // The appropriate license values to be used for your subscriptions // can be found on the Subscription page of the account dashboard. // https://www.smarty.com/docs/cloud/licensing -let clientBuilder = new SmartyCore.ClientBuilder(credentials) - .withLicenses(["us-rooftop-geocoding-cloud"]) - .withFeatureComponentAnalysis(); +let clientBuilder = new SmartyCore.ClientBuilder(credentials).withLicenses([ + "us-rooftop-geocoding-cloud", +]); // .withBaseUrl("YOUR URL") // withBaseUrl() should be used if you are self-hosting the Smarty API let client = clientBuilder.buildUsStreetApiClient();