@ideal-postcodes/core-interface
Advanced tools
Comparing version 3.2.0 to 3.2.1
@@ -0,1 +1,8 @@ | ||
## [3.2.1](https://github.com/ideal-postcodes/core-interface/compare/3.2.0...3.2.1) (2022-08-31) | ||
### Bug Fixes | ||
* **Internal:** Export internal address lookup methods ([4965c73](https://github.com/ideal-postcodes/core-interface/commit/4965c739380e8a334ed72e9122c16f9b48413fbd)) | ||
# [3.2.0](https://github.com/ideal-postcodes/core-interface/compare/3.1.0...3.2.0) (2022-08-05) | ||
@@ -2,0 +9,0 @@ |
/** | ||
* @module Helper Methods | ||
*/ | ||
import { HttpResponse } from "./agent"; | ||
import { HttpResponse, StringMap } from "./agent"; | ||
import { Request as BaseRequest } from "./resources/resource"; | ||
import { UkAddress, PafAddress, NybAddress, MrAddress, KeyStatus } from "./types"; | ||
import { Authenticable, Filterable, Taggable, HttpOptions, Paginateable } from "./types"; | ||
import { Client } from "./client"; | ||
interface Request extends BaseRequest { | ||
query: StringMap; | ||
header: StringMap; | ||
} | ||
/** | ||
@@ -120,2 +125,11 @@ * ID lookup options interface | ||
/** | ||
* Generates a request object. Bundles together commonly used header/query extractions: | ||
* - Authorization (api_key, licensee, user_token) | ||
* - Source IP forwarding | ||
* - Result filtering | ||
* - Tagging | ||
*/ | ||
export declare const toAddressIdQuery: (options: LookupIdOptions) => Request; | ||
export declare const toAddressLookupQuery: (options: LookupAddressOptions) => Request; | ||
/** | ||
* Lookup UDPRN | ||
@@ -148,1 +162,2 @@ * | ||
export declare const checkKeyUsability: (options: CheckKeyUsabilityOptions) => Promise<KeyStatus>; | ||
export {}; |
@@ -25,3 +25,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkKeyUsability = exports.lookupUmprn = exports.lookupUdprn = exports.lookupAddress = exports.lookupPostcode = exports.ping = void 0; | ||
exports.checkKeyUsability = exports.lookupUmprn = exports.lookupUdprn = exports.toAddressLookupQuery = exports.toAddressIdQuery = exports.lookupAddress = exports.lookupPostcode = exports.ping = void 0; | ||
var addresses = __importStar(require("./resources/addresses")); | ||
@@ -61,3 +61,3 @@ var keys = __importStar(require("./resources/keys")); | ||
var lookupPostcode = function (options) { | ||
var queryOptions = toAddressIdQuery(options); | ||
var queryOptions = (0, exports.toAddressIdQuery)(options); | ||
var page = options.page; | ||
@@ -84,15 +84,5 @@ if (page !== undefined) | ||
var lookupAddress = function (options) { | ||
var header = {}; | ||
var query = { query: options.query }; | ||
var client = options.client; | ||
(0, util_1.appendAuthorization)({ client: client, header: header, options: options }); | ||
(0, util_1.appendIp)({ header: header, options: options }); | ||
(0, util_1.appendFilter)({ query: query, options: options }); | ||
(0, util_1.appendTags)({ client: client, query: query, options: options }); | ||
(0, util_1.appendPage)({ query: query, options: options }); | ||
var queryOptions = { header: header, query: query }; | ||
if (options.timeout !== undefined) | ||
queryOptions.timeout = options.timeout; | ||
var queryOptions = (0, exports.toAddressLookupQuery)(options); | ||
return addresses | ||
.list(client, queryOptions) | ||
.list(options.client, queryOptions) | ||
.then(function (response) { return response.body.result.hits; }); | ||
@@ -121,2 +111,18 @@ }; | ||
}; | ||
exports.toAddressIdQuery = toAddressIdQuery; | ||
var toAddressLookupQuery = function (options) { | ||
var header = {}; | ||
var query = { query: options.query }; | ||
var client = options.client; | ||
(0, util_1.appendAuthorization)({ client: client, header: header, options: options }); | ||
(0, util_1.appendIp)({ header: header, options: options }); | ||
(0, util_1.appendFilter)({ query: query, options: options }); | ||
(0, util_1.appendTags)({ client: client, query: query, options: options }); | ||
(0, util_1.appendPage)({ query: query, options: options }); | ||
var queryOptions = { header: header, query: query }; | ||
if (options.timeout !== undefined) | ||
queryOptions.timeout = options.timeout; | ||
return queryOptions; | ||
}; | ||
exports.toAddressLookupQuery = toAddressLookupQuery; | ||
/** | ||
@@ -132,3 +138,3 @@ * Lookup UDPRN | ||
var lookupUdprn = function (options) { | ||
var queryOptions = toAddressIdQuery(options); | ||
var queryOptions = (0, exports.toAddressIdQuery)(options); | ||
return udprn | ||
@@ -154,3 +160,3 @@ .retrieve(options.client, options.udprn.toString(), queryOptions) | ||
var lookupUmprn = function (options) { | ||
var queryOptions = toAddressIdQuery(options); | ||
var queryOptions = (0, exports.toAddressIdQuery)(options); | ||
return umprn | ||
@@ -157,0 +163,0 @@ .retrieve(options.client, options.umprn.toString(), queryOptions) |
/** | ||
* @module Helper Methods | ||
*/ | ||
import { HttpResponse } from "./agent"; | ||
import { HttpResponse, StringMap } from "./agent"; | ||
import { Request as BaseRequest } from "./resources/resource"; | ||
import { UkAddress, PafAddress, NybAddress, MrAddress, KeyStatus } from "./types"; | ||
import { Authenticable, Filterable, Taggable, HttpOptions, Paginateable } from "./types"; | ||
import { Client } from "./client"; | ||
interface Request extends BaseRequest { | ||
query: StringMap; | ||
header: StringMap; | ||
} | ||
/** | ||
@@ -120,2 +125,11 @@ * ID lookup options interface | ||
/** | ||
* Generates a request object. Bundles together commonly used header/query extractions: | ||
* - Authorization (api_key, licensee, user_token) | ||
* - Source IP forwarding | ||
* - Result filtering | ||
* - Tagging | ||
*/ | ||
export declare const toAddressIdQuery: (options: LookupIdOptions) => Request; | ||
export declare const toAddressLookupQuery: (options: LookupAddressOptions) => Request; | ||
/** | ||
* Lookup UDPRN | ||
@@ -148,1 +162,2 @@ * | ||
export declare const checkKeyUsability: (options: CheckKeyUsabilityOptions) => Promise<KeyStatus>; | ||
export {}; |
@@ -58,15 +58,5 @@ /** | ||
export const lookupAddress = (options) => { | ||
const header = {}; | ||
const query = { query: options.query }; | ||
const { client } = options; | ||
appendAuthorization({ client, header, options }); | ||
appendIp({ header, options }); | ||
appendFilter({ query, options }); | ||
appendTags({ client, query, options }); | ||
appendPage({ query, options }); | ||
const queryOptions = { header, query }; | ||
if (options.timeout !== undefined) | ||
queryOptions.timeout = options.timeout; | ||
const queryOptions = toAddressLookupQuery(options); | ||
return addresses | ||
.list(client, queryOptions) | ||
.list(options.client, queryOptions) | ||
.then((response) => response.body.result.hits); | ||
@@ -81,3 +71,3 @@ }; | ||
*/ | ||
const toAddressIdQuery = (options) => { | ||
export const toAddressIdQuery = (options) => { | ||
const header = {}; | ||
@@ -95,2 +85,16 @@ const query = {}; | ||
}; | ||
export const toAddressLookupQuery = (options) => { | ||
const header = {}; | ||
const query = { query: options.query }; | ||
const { client } = options; | ||
appendAuthorization({ client, header, options }); | ||
appendIp({ header, options }); | ||
appendFilter({ query, options }); | ||
appendTags({ client, query, options }); | ||
appendPage({ query, options }); | ||
const queryOptions = { header, query }; | ||
if (options.timeout !== undefined) | ||
queryOptions.timeout = options.timeout; | ||
return queryOptions; | ||
}; | ||
/** | ||
@@ -97,0 +101,0 @@ * Lookup UDPRN |
{ | ||
"name": "@ideal-postcodes/core-interface", | ||
"version": "3.2.0", | ||
"version": "3.2.1", | ||
"description": "Interface specification for javascript based API Clients to api.ideal-postcodes.co.uk", | ||
@@ -109,3 +109,3 @@ "author": { | ||
"@babel/polyfill": "~7.12.1", | ||
"@cablanchard/eslint-config": "~2.1.1", | ||
"@cablanchard/eslint-config": "~3.1.1", | ||
"@cablanchard/semantic-release": "~1.3.1", | ||
@@ -122,3 +122,3 @@ "@cablanchard/tsconfig": "2.0.0", | ||
"@types/node": "~17.0.5", | ||
"@types/prettier": "~2.4.1", | ||
"@types/prettier": "~2.6.1", | ||
"@types/sinon": "~10.0.0", | ||
@@ -128,3 +128,3 @@ "@typescript-eslint/eslint-plugin": "~5.8.0", | ||
"codecov": "~3.8.0", | ||
"core-js": "~3.20.1", | ||
"core-js": "~3.25.0", | ||
"dotenv": "~8.2.0", | ||
@@ -143,3 +143,3 @@ "eslint": "~7.32.0", | ||
"nyc": "~15.1.0", | ||
"prettier": "~2.4.0", | ||
"prettier": "~2.6.2", | ||
"puppeteer": "~13.0.1", | ||
@@ -146,0 +146,0 @@ "regenerator-runtime": "~0.13.3", |
137725
3593