@ideal-postcodes/core-interface
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -0,1 +1,9 @@ | ||
## [2.0.2](https://github.com/ideal-postcodes/core-interface/compare/2.0.1...2.0.2) (2021-07-19) | ||
### Bug Fixes | ||
* **Exports:** Drop namespaced exports ([9717306](https://github.com/ideal-postcodes/core-interface/commit/9717306545d6f61cd15ad7ea313727b3f3fd0446)) | ||
* **Typings:** Move into dependencies ([8caef68](https://github.com/ideal-postcodes/core-interface/commit/8caef684af0fbfdcc705efc541625d1b55ac3f21)) | ||
## [2.0.1](https://github.com/ideal-postcodes/core-interface/compare/2.0.0...2.0.1) (2021-06-04) | ||
@@ -2,0 +10,0 @@ |
/** | ||
* @module Agent Interface | ||
* | ||
* @description Describes the interface which must be defined for an Agent to work with core-interface | ||
*/ | ||
/** | ||
* Agent | ||
@@ -3,0 +8,0 @@ * |
"use strict"; | ||
/** | ||
* Agent | ||
* @module Agent Interface | ||
* | ||
* This module specifies the interface for the HTTP agent required by the bare | ||
* client library | ||
* @description Describes the interface which must be defined for an Agent to work with core-interface | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @module Client | ||
* | ||
* @description HTTP API Client | ||
*/ | ||
import { Agent, Header } from "./agent"; | ||
@@ -2,0 +7,0 @@ declare type Protocol = "http" | "https"; |
"use strict"; | ||
/** | ||
* @module Client | ||
* | ||
* @description HTTP API Client | ||
*/ | ||
var __assign = (this && this.__assign) || function () { | ||
@@ -3,0 +8,0 @@ __assign = Object.assign || function(t) { |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @module Errors | ||
* | ||
* @description Exports error classes which may be returned by this client | ||
*/ | ||
import { HttpResponse } from "./agent"; | ||
@@ -2,0 +7,0 @@ /** |
"use strict"; | ||
/** | ||
* @module Errors | ||
* | ||
* @description Exports error classes which may be returned by this client | ||
*/ | ||
var __extends = (this && this.__extends) || (function () { | ||
@@ -3,0 +8,0 @@ var extendStatics = function (d, b) { |
/** | ||
* @module | ||
* | ||
* API Helper Methods | ||
* | ||
* Exports simple methods for common API tasks | ||
* @module Helper Methods | ||
*/ | ||
@@ -12,2 +8,5 @@ import { HttpResponse } from "./agent"; | ||
import { Client } from "./client"; | ||
/** | ||
* ID lookup options interface | ||
*/ | ||
export interface LookupIdOptions extends Authenticable, Filterable, Taggable, HttpOptions { | ||
@@ -19,2 +18,5 @@ /** | ||
} | ||
/** | ||
* Address search options | ||
*/ | ||
export interface LookupAddressOptions extends Authenticable, Filterable, Taggable, Paginateable, HttpOptions { | ||
@@ -26,6 +28,11 @@ /** | ||
/** | ||
* Query for address | ||
* Query string for address | ||
* | ||
* @example "10 downing street" | ||
*/ | ||
query: string; | ||
} | ||
/** | ||
* Postcode lookup options | ||
*/ | ||
export interface LookupPostcodeOptions extends LookupIdOptions { | ||
@@ -47,2 +54,5 @@ /** | ||
} | ||
/** | ||
* UDPRN lookup options | ||
*/ | ||
export interface LookupUdprnOptions extends LookupIdOptions { | ||
@@ -58,2 +68,5 @@ /** | ||
} | ||
/** | ||
* UMPRN lookup options | ||
*/ | ||
export interface LookupUmprnOptions extends LookupIdOptions { | ||
@@ -69,2 +82,5 @@ /** | ||
} | ||
/** | ||
* Check key usab ility options | ||
*/ | ||
export interface CheckKeyUsabilityOptions extends HttpOptions { | ||
@@ -71,0 +87,0 @@ /** |
"use strict"; | ||
/** | ||
* @module | ||
* | ||
* API Helper Methods | ||
* | ||
* Exports simple methods for common API tasks | ||
* @module Helper Methods | ||
*/ | ||
@@ -9,0 +5,0 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { |
/** | ||
* Constants | ||
* @module Exports | ||
* | ||
* @description Direct exports of core-interface | ||
*/ | ||
export { Client, Config, defaults } from "./client"; | ||
export { Agent, HttpRequest, HttpResponse } from "./agent"; | ||
export * as addresses from "./resources/addresses"; | ||
export * as autocomplete from "./resources/autocomplete"; | ||
export * as keys from "./resources/keys"; | ||
export * as postcodes from "./resources/postcodes"; | ||
export * as udprn from "./resources/udprn"; | ||
export * as umprn from "./resources/umprn"; | ||
export * from "./helpers"; | ||
export * from "./types"; | ||
export * as errors from "./error"; | ||
import * as addresses from "./resources/addresses"; | ||
import * as autocomplete from "./resources/autocomplete"; | ||
import * as keys from "./resources/keys"; | ||
import * as postcodes from "./resources/postcodes"; | ||
import * as udprn from "./resources/udprn"; | ||
import * as umprn from "./resources/umprn"; | ||
import * as errors from "./error"; | ||
export { addresses, autocomplete, keys, postcodes, udprn, umprn, errors }; |
"use strict"; | ||
/** | ||
* @module Exports | ||
* | ||
* @description Direct exports of core-interface | ||
*/ | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
@@ -14,2 +19,5 @@ if (k2 === undefined) k2 = k; | ||
}); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
@@ -22,21 +30,22 @@ if (mod && mod.__esModule) return mod; | ||
}; | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.errors = exports.umprn = exports.udprn = exports.postcodes = exports.keys = exports.autocomplete = exports.addresses = exports.defaults = exports.Client = void 0; | ||
/** | ||
* Constants | ||
*/ | ||
var client_1 = require("./client"); | ||
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } }); | ||
Object.defineProperty(exports, "defaults", { enumerable: true, get: function () { return client_1.defaults; } }); | ||
exports.addresses = __importStar(require("./resources/addresses")); | ||
exports.autocomplete = __importStar(require("./resources/autocomplete")); | ||
exports.keys = __importStar(require("./resources/keys")); | ||
exports.postcodes = __importStar(require("./resources/postcodes")); | ||
exports.udprn = __importStar(require("./resources/udprn")); | ||
exports.umprn = __importStar(require("./resources/umprn")); | ||
__exportStar(require("./helpers"), exports); | ||
__exportStar(require("./types"), exports); | ||
exports.errors = __importStar(require("./error")); | ||
var addresses = __importStar(require("./resources/addresses")); | ||
exports.addresses = addresses; | ||
var autocomplete = __importStar(require("./resources/autocomplete")); | ||
exports.autocomplete = autocomplete; | ||
var keys = __importStar(require("./resources/keys")); | ||
exports.keys = keys; | ||
var postcodes = __importStar(require("./resources/postcodes")); | ||
exports.postcodes = postcodes; | ||
var udprn = __importStar(require("./resources/udprn")); | ||
exports.udprn = udprn; | ||
var umprn = __importStar(require("./resources/umprn")); | ||
exports.umprn = umprn; | ||
var errors = __importStar(require("./error")); | ||
exports.errors = errors; |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module Misc Types | ||
*/ | ||
import { Address } from "@ideal-postcodes/api-typings"; | ||
@@ -28,2 +31,5 @@ /** | ||
} | ||
/** | ||
* Address object attributes | ||
*/ | ||
export declare type AddressKeys = keyof Address; | ||
@@ -30,0 +36,0 @@ /** |
"use strict"; | ||
/** | ||
* @module Misc Types | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module Utils | ||
*/ | ||
import { Client } from "./client"; | ||
@@ -2,0 +5,0 @@ import { Header } from "./agent"; |
"use strict"; | ||
/** | ||
* @module Utils | ||
*/ | ||
var __assign = (this && this.__assign) || function () { | ||
@@ -3,0 +6,0 @@ __assign = Object.assign || function(t) { |
/** | ||
* @module Agent Interface | ||
* | ||
* @description Describes the interface which must be defined for an Agent to work with core-interface | ||
*/ | ||
/** | ||
* Agent | ||
@@ -3,0 +8,0 @@ * |
/** | ||
* Agent | ||
* @module Agent Interface | ||
* | ||
* This module specifies the interface for the HTTP agent required by the bare | ||
* client library | ||
* @description Describes the interface which must be defined for an Agent to work with core-interface | ||
*/ | ||
export {}; |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @module Client | ||
* | ||
* @description HTTP API Client | ||
*/ | ||
import { Agent, Header } from "./agent"; | ||
@@ -2,0 +7,0 @@ declare type Protocol = "http" | "https"; |
/** | ||
* @module Client | ||
* | ||
* @description HTTP API Client | ||
*/ | ||
/** | ||
* Default configuration | ||
@@ -22,2 +27,3 @@ */ | ||
export class Client { | ||
config; | ||
constructor(config) { | ||
@@ -24,0 +30,0 @@ this.config = { ...defaults, ...config }; |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @module Errors | ||
* | ||
* @description Exports error classes which may be returned by this client | ||
*/ | ||
import { HttpResponse } from "./agent"; | ||
@@ -2,0 +7,0 @@ /** |
@@ -0,1 +1,6 @@ | ||
/** | ||
* @module Errors | ||
* | ||
* @description Exports error classes which may be returned by this client | ||
*/ | ||
// Take note of https://github.com/Microsoft/TypeScript/issues/13965 | ||
@@ -10,2 +15,5 @@ /** | ||
export class IdealPostcodesError extends Error { | ||
__proto__; | ||
httpStatus; | ||
metadata; | ||
/** | ||
@@ -36,2 +44,6 @@ * Instantiate IdealPostcodesError | ||
/** | ||
* Raw HTTP response | ||
*/ | ||
response; | ||
/** | ||
* Returns an API error instance | ||
@@ -38,0 +50,0 @@ */ |
/** | ||
* @module | ||
* | ||
* API Helper Methods | ||
* | ||
* Exports simple methods for common API tasks | ||
* @module Helper Methods | ||
*/ | ||
@@ -12,2 +8,5 @@ import { HttpResponse } from "./agent"; | ||
import { Client } from "./client"; | ||
/** | ||
* ID lookup options interface | ||
*/ | ||
export interface LookupIdOptions extends Authenticable, Filterable, Taggable, HttpOptions { | ||
@@ -19,2 +18,5 @@ /** | ||
} | ||
/** | ||
* Address search options | ||
*/ | ||
export interface LookupAddressOptions extends Authenticable, Filterable, Taggable, Paginateable, HttpOptions { | ||
@@ -26,6 +28,11 @@ /** | ||
/** | ||
* Query for address | ||
* Query string for address | ||
* | ||
* @example "10 downing street" | ||
*/ | ||
query: string; | ||
} | ||
/** | ||
* Postcode lookup options | ||
*/ | ||
export interface LookupPostcodeOptions extends LookupIdOptions { | ||
@@ -47,2 +54,5 @@ /** | ||
} | ||
/** | ||
* UDPRN lookup options | ||
*/ | ||
export interface LookupUdprnOptions extends LookupIdOptions { | ||
@@ -58,2 +68,5 @@ /** | ||
} | ||
/** | ||
* UMPRN lookup options | ||
*/ | ||
export interface LookupUmprnOptions extends LookupIdOptions { | ||
@@ -69,2 +82,5 @@ /** | ||
} | ||
/** | ||
* Check key usab ility options | ||
*/ | ||
export interface CheckKeyUsabilityOptions extends HttpOptions { | ||
@@ -71,0 +87,0 @@ /** |
/** | ||
* @module | ||
* | ||
* API Helper Methods | ||
* | ||
* Exports simple methods for common API tasks | ||
* @module Helper Methods | ||
*/ | ||
@@ -8,0 +4,0 @@ import * as addresses from "./resources/addresses"; |
/** | ||
* Constants | ||
* @module Exports | ||
* | ||
* @description Direct exports of core-interface | ||
*/ | ||
export { Client, Config, defaults } from "./client"; | ||
export { Agent, HttpRequest, HttpResponse } from "./agent"; | ||
export * as addresses from "./resources/addresses"; | ||
export * as autocomplete from "./resources/autocomplete"; | ||
export * as keys from "./resources/keys"; | ||
export * as postcodes from "./resources/postcodes"; | ||
export * as udprn from "./resources/udprn"; | ||
export * as umprn from "./resources/umprn"; | ||
export * from "./helpers"; | ||
export * from "./types"; | ||
export * as errors from "./error"; | ||
import * as addresses from "./resources/addresses"; | ||
import * as autocomplete from "./resources/autocomplete"; | ||
import * as keys from "./resources/keys"; | ||
import * as postcodes from "./resources/postcodes"; | ||
import * as udprn from "./resources/udprn"; | ||
import * as umprn from "./resources/umprn"; | ||
import * as errors from "./error"; | ||
export { addresses, autocomplete, keys, postcodes, udprn, umprn, errors }; |
/** | ||
* Constants | ||
* @module Exports | ||
* | ||
* @description Direct exports of core-interface | ||
*/ | ||
export { Client, defaults } from "./client"; | ||
export * as addresses from "./resources/addresses"; | ||
export * as autocomplete from "./resources/autocomplete"; | ||
export * as keys from "./resources/keys"; | ||
export * as postcodes from "./resources/postcodes"; | ||
export * as udprn from "./resources/udprn"; | ||
export * as umprn from "./resources/umprn"; | ||
export * from "./helpers"; | ||
export * from "./types"; | ||
export * as errors from "./error"; | ||
import * as addresses from "./resources/addresses"; | ||
import * as autocomplete from "./resources/autocomplete"; | ||
import * as keys from "./resources/keys"; | ||
import * as postcodes from "./resources/postcodes"; | ||
import * as udprn from "./resources/udprn"; | ||
import * as umprn from "./resources/umprn"; | ||
import * as errors from "./error"; | ||
export { addresses, autocomplete, keys, postcodes, udprn, umprn, errors }; |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module Misc Types | ||
*/ | ||
import { Address } from "@ideal-postcodes/api-typings"; | ||
@@ -28,2 +31,5 @@ /** | ||
} | ||
/** | ||
* Address object attributes | ||
*/ | ||
export declare type AddressKeys = keyof Address; | ||
@@ -30,0 +36,0 @@ /** |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module Misc Types | ||
*/ | ||
export {}; |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module Utils | ||
*/ | ||
import { Client } from "./client"; | ||
@@ -2,0 +5,0 @@ import { Header } from "./agent"; |
/** | ||
* @module Utils | ||
*/ | ||
/** | ||
* toQuery | ||
@@ -3,0 +6,0 @@ * |
{ | ||
"name": "@ideal-postcodes/core-interface", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Interface specification for javascript based API Clients to api.ideal-postcodes.co.uk", | ||
@@ -97,2 +97,5 @@ "author": { | ||
"license": "MIT", | ||
"dependencies": { | ||
"@ideal-postcodes/api-typings": "~2.1.0" | ||
}, | ||
"devDependencies": { | ||
@@ -105,3 +108,2 @@ "@babel/polyfill": "~7.12.1", | ||
"@ideal-postcodes/api-fixtures": "~1.3.0", | ||
"@ideal-postcodes/api-typings": "~2.1.0", | ||
"@ideal-postcodes/doc-assets": "~1.0.3", | ||
@@ -113,13 +115,13 @@ "@ideal-postcodes/supported-browsers": "~2.5.0", | ||
"@types/mocha": "~8.2.0", | ||
"@types/node": "~14.14.3", | ||
"@types/prettier": "~2.2.0", | ||
"@types/node": "~16.3.1", | ||
"@types/prettier": "~2.3.0", | ||
"@types/sinon": "~10.0.0", | ||
"@typescript-eslint/eslint-plugin": "~3.0.2", | ||
"@typescript-eslint/eslint-plugin": "~4.28.1", | ||
"chai": "~4.3.0", | ||
"codecov": "~3.8.0", | ||
"core-js": "~3.11.0", | ||
"core-js": "~3.15.0", | ||
"dotenv": "~8.2.0", | ||
"eslint": "~7.25.0", | ||
"eslint": "~7.30.0", | ||
"eslint-plugin-compat": "~3.9.0", | ||
"karma": "~6.1.1", | ||
"karma": "~6.3.3", | ||
"karma-chrome-launcher": "~3.1.0", | ||
@@ -131,17 +133,17 @@ "karma-cli": "~2.0.0", | ||
"karma-typescript": "~5.5.1", | ||
"karma-typescript-es6-transform": "~5.2.0", | ||
"mocha": "~8.3.0", | ||
"karma-typescript-es6-transform": "~5.3.0", | ||
"mocha": "~9.0.1", | ||
"nyc": "~15.1.0", | ||
"prettier": "~2.2.1", | ||
"puppeteer": "~9.0.0", | ||
"prettier": "~2.3.1", | ||
"puppeteer": "~10.1.0", | ||
"regenerator-runtime": "~0.13.3", | ||
"semantic-release": "~17.4.1", | ||
"sinon": "~10.0.0", | ||
"sinon": "~11.1.1", | ||
"source-map-support": "~0.5.10", | ||
"ts-node": "~9.1.1", | ||
"ts-node": "~10.1.0", | ||
"tslint": "~6.1.2", | ||
"type-zoo": "~3.4.0", | ||
"typedoc": "^0.20.35", | ||
"typescript": "~4.2.3" | ||
"typedoc": "^0.21.0", | ||
"typescript": "~4.3.4" | ||
} | ||
} |
@@ -80,3 +80,3 @@ <h1 align="center"> | ||
The client exposes a number of simple methods to get at the most common tasks when interacting with the API | ||
The library exposes a number of simple methods to get at the most common tasks when interacting with the API | ||
@@ -96,2 +96,4 @@ - [Lookup a Postcode](#lookup-a-postcode) | ||
```javascript | ||
import { lookupPostcode } from "@ideal-postcodes/core-browser"; | ||
const postcode = "id11qd"; | ||
@@ -118,2 +120,4 @@ | ||
```javascript | ||
import { lookupAddress } from "@ideal-postcodes/core-browser"; | ||
const query = "10 downing street sw1a"; | ||
@@ -142,2 +146,4 @@ | ||
```javascript | ||
import { lookupUdprn } from "@ideal-postcodes/core-browser"; | ||
const udprn = 23747771; | ||
@@ -166,2 +172,4 @@ | ||
```javascript | ||
import { lookupUmprn } from "@ideal-postcodes/core-browser"; | ||
const umprn = 50906066; | ||
@@ -211,6 +219,6 @@ | ||
The first argument is the resource ID. The second argument is an object which accepts `header` and `query` attributes that map to HTTP header and the request querystring. | ||
The first argument is the client object. The second is the resource ID. The last argument is an object which accepts `header` and `query` attributes that map to HTTP header and the request querystring. | ||
```javascript | ||
resourceName.retrieve("id", { | ||
resourceName.retrieve(client, "id", { | ||
query: { | ||
@@ -233,3 +241,3 @@ api_key: "foo", | ||
```javascript | ||
resourceName.list({ | ||
resourceName.list(client, { | ||
query: { | ||
@@ -246,3 +254,3 @@ api_key: "foo", | ||
The first and only argument is an object which accepts `header` and `query` attributes that map to HTTP header and the request querystring. | ||
The first argument is the client. The second is an object which accepts `header` and `query` attributes that map to HTTP header and the request querystring. | ||
@@ -256,3 +264,3 @@ #### Custom Actions | ||
```javascript | ||
keys.usage(api_key, { | ||
keys.usage(client, api_key, { | ||
query: { | ||
@@ -272,3 +280,3 @@ tags: "checkout,production", | ||
Listed below are the available resources exposed by the client: | ||
Listed below are the available resources exposed by the library: | ||
@@ -289,3 +297,3 @@ - [Postcodes](#postcodes) | ||
postcodes | ||
.retrieve("SW1A2AA", { | ||
.retrieve(client, "SW1A2AA", { | ||
header: { | ||
@@ -313,3 +321,3 @@ Authorization: 'IDEALPOSTCODES api_key="iddqd"', | ||
addresses | ||
.list({ | ||
.list(client, { | ||
query: { | ||
@@ -340,3 +348,3 @@ query: "10 Downing street", | ||
autocomplete | ||
.list({ | ||
.list(client, { | ||
query: { | ||
@@ -367,3 +375,3 @@ query: "10 Downing stre", | ||
udprn | ||
.retrieve("12345678", { | ||
.retrieve(client, "12345678", { | ||
header: { | ||
@@ -391,3 +399,3 @@ Authorization: 'IDEALPOSTCODES api_key="iddqd"', | ||
umprn | ||
.retrieve("87654321", { | ||
.retrieve(client, "87654321", { | ||
header: { | ||
@@ -415,3 +423,3 @@ Authorization: 'IDEALPOSTCODES api_key="iddqd"', | ||
keys | ||
.retrieve("iddqd", {}) | ||
.retrieve(client, "iddqd", {}) | ||
.then((response) => { | ||
@@ -431,3 +439,3 @@ const { available } = response.body.result; | ||
keys | ||
.retrieve("iddqd", { | ||
.retrieve(client, "iddqd", { | ||
header: { | ||
@@ -451,3 +459,3 @@ Authorization: 'IDEALPOSTCODES user_token="secret-token"', | ||
keys | ||
.usage("iddqd", { | ||
.usage(client, "iddqd", { | ||
header: { | ||
@@ -481,3 +489,3 @@ Authorization: 'IDEALPOSTCODES user_token="secret-token"', | ||
try { | ||
const addresses = client.lookupPostcode({ postcode: "SW1A2AA" }); | ||
const addresses = lookupPostcode({ client, postcode: "SW1A2AA" }); | ||
} catch (error) { | ||
@@ -553,4 +561,4 @@ if (error instanceof IdpcInvalidKeyError) { | ||
- Convenience: They are frequently tested for (e.g. invalid postcode, postcode not found) | ||
- Developer QoL. They are useful for debug purposes during the implementation stages | ||
- Convenience. They are frequently tested for (e.g. invalid postcode, postcode not found) | ||
- Useful for debug purposes during the implementation stages | ||
@@ -557,0 +565,0 @@ ```javascript |
128692
43
3475
596
1
+ Added@ideal-postcodes/api-typings@2.1.0(transitive)