From 73ce0b8ff4780fa925814f9bf279c74a513fc0ad Mon Sep 17 00:00:00 2001 From: john gravois Date: Thu, 22 Feb 2018 16:11:29 -0800 Subject: [PATCH 1/3] feat(lots more common-types): adding a lot more common data types AFFECTS PACKAGES: @esri/arcgis-rest-common-types @esri/arcgis-rest-geocoder @esri/arcgis-rest-groups @esri/arcgis-rest-items batch-geocoder BREAKING CHANGE: no longer prefacing interface names with an I --- demos/batch-geocoder-node/package-lock.json | 38 +- .../arcgis-rest-common-types/src/index.ts | 381 +++++++++++++++++- packages/arcgis-rest-geocoder/src/geocoder.ts | 82 ++-- packages/arcgis-rest-groups/src/groups.ts | 31 +- packages/arcgis-rest-items/src/items.ts | 61 +-- packages/arcgis-rest-items/test/mocks/item.ts | 4 +- .../arcgis-rest-items/test/mocks/search.ts | 2 +- tslint.json | 3 +- 8 files changed, 456 insertions(+), 146 deletions(-) diff --git a/demos/batch-geocoder-node/package-lock.json b/demos/batch-geocoder-node/package-lock.json index b0b19096c1..6cebd05c5b 100644 --- a/demos/batch-geocoder-node/package-lock.json +++ b/demos/batch-geocoder-node/package-lock.json @@ -1,38 +1,7 @@ { - "name": "batch-geocoder", - "version": "0.0.1", - "lockfileVersion": 1, "requires": true, + "lockfileVersion": 1, "dependencies": { - "@esri/arcgis-rest-auth": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@esri/arcgis-rest-auth/-/arcgis-rest-auth-1.0.2.tgz", - "integrity": "sha512-OAWEUDLLCmbgU0u0m3rfc6KKjfzbpNyn2/CfATdFpbPKBdGQAUcYRPboBvt7sKgId2uAH2OZuq7ktz2SSkf8qQ==", - "requires": { - "tslib": "1.8.1" - } - }, - "@esri/arcgis-rest-common-types": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@esri/arcgis-rest-common-types/-/arcgis-rest-common-types-1.0.2.tgz", - "integrity": "sha512-Ff9qduwKc45VacrcNvgTbZm8/Rr0caqNtLvP0heEx+rDEpuMQqyupWFEqxleLBKFWzEJrhQq+BH7ZTStrtDgfQ==" - }, - "@esri/arcgis-rest-geocoder": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@esri/arcgis-rest-geocoder/-/arcgis-rest-geocoder-1.0.2.tgz", - "integrity": "sha512-wcbw/8ufvFTnu3YouiiBDh70iXSXrGhBk2A8WxepuYD0VTWPDHgwOFz/rp1OhpI6ZLSl9NtgqSRVDZuDpqjjyA==", - "requires": { - "tslib": "1.8.1" - } - }, - "@esri/arcgis-rest-request": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@esri/arcgis-rest-request/-/arcgis-rest-request-1.0.2.tgz", - "integrity": "sha512-P44FP5Tf6GAOzN+H3UjuSwBJRwux4JxoiEc6BIvDnI2hTO0REl/ie89MESilR74Gv+9PlPEuAuF+ojEKGg0q2g==", - "requires": { - "tslib": "1.8.1" - } - }, "async": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", @@ -131,11 +100,6 @@ "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-4.3.6.tgz", "integrity": "sha1-lWbtoOyrE6/LdApiOBxpn0hssUU=" }, - "tslib": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.8.1.tgz", - "integrity": "sha1-aUavLR1lGnsYY7Ux1uWvpBqkTqw=" - }, "whatwg-fetch": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz", diff --git a/packages/arcgis-rest-common-types/src/index.ts b/packages/arcgis-rest-common-types/src/index.ts index 6708c7a6ca..e32968c015 100644 --- a/packages/arcgis-rest-common-types/src/index.ts +++ b/packages/arcgis-rest-common-types/src/index.ts @@ -2,45 +2,142 @@ * Apache-2.0 */ /** - * Spatial reference systems define mathematical transformations and coordinate systems for displaying spatial information in 2D and 3D. + * an arc can be represented as a JSON curve object */ -export interface ISpatialReference { - wkid: number; - latestWkid?: number; +export interface Arc { + a: [ + Position, // End point: x, y, , + Position2D, // Center point: center_x, center_y + number, // minor + number, // clockwise + number, // rotation + number, // axis + number // ratio + ]; } /** - * Extents are used to define rectangles and bounding boxes. + * a bezier curve can be represented as a JSON curve object + */ +export interface BezierCurve { + b: [Position, Position2D, Position2D]; +} + +/** + * a circular arc can be represented as a JSON curve object + */ +export interface CircularArc { + c: [Position, Position2D]; +} + +/** + * + */ +export type Color = [number, number, number, number]; + +/** + * + */ +export type ElipticArc = Arc; + +/** + * a spatial entity and its corresponding properties + */ +export interface Feature { + geometry?: Geometry; + attributes?: any; +} + +/** + * + */ +export interface Field { + name: string; + type: string; + alias?: string; + length?: number; +} + +/** + * a building block for discrete geometries */ -export interface IExtent { +export interface Geometry { + spatialReference?: SpatialReference; +} + +/** + * An envelope is a rectangle defined by a range of values for each coordinate and attribute. + */ +export interface Envelope extends Geometry { xmin: number; - ymin: number; xmax: number; + ymin: number; ymax: number; - spatialReference?: ISpatialReference; + + zmin?: number; + zmax?: number; + + mmin?: number; + mmax?: number; } /** - * A simple point geometry, with spatial reference defined. + * */ -export interface IPoint { - x: number; - y: number; - spatialReference?: ISpatialReference; +export type esriGeometryType = + | "esriGeometryPoint" + | "esriGeometryMultipoint" + | "esriGeometryPolyline" + | "esriGeometryPolygon" + | "esriGeometryEnvelope"; + +/** + * + */ +export interface FeatureSet extends HasZM { + objectIdFieldName?: string; // optional + globalIdFieldName?: string; // optional + displayFieldName?: string; // optional + geometryType?: esriGeometryType; // for feature layers only + spatialReference?: SpatialReference; // for feature layers only. + fields?: Field[]; + features: Feature[]; } /** - * Params for paging operations + * */ -export interface IPagingParams { - start?: number; - num?: number; +export interface Font { + family?: string; // ""; + size?: number; // ; + style?: "italic" | "normal" | "oblique"; + weight?: "bold" | "bolder" | "lighter" | "normal"; + decoration?: "line-through" | "underline" | "none"; +} + +/** + * Extents are used to define rectangles and bounding boxes. + */ +export interface Extent { + xmin: number; + ymin: number; + xmax: number; + ymax: number; + spatialReference?: SpatialReference; +} + +/** + * + */ +export interface HasZM { + hasZ?: boolean; + hasM?: boolean; } /** * Portal Item */ -export interface IItem { +export interface Item { id?: string; owner: string; title: string; @@ -58,3 +155,251 @@ export interface IItem { url?: string; [key: string]: any; } + +/** + * + */ +export type JsonCurve = CircularArc | Arc | OldCircularArc | BezierCurve; + +/** + * + */ +export interface OldCircularArc { + a: [ + Position, // End point: x, y, , + Position2D, // Center point: center_x, center_y + number, // minor + number // clockwise + ]; +} + +/** + * + */ +export interface MarkerSymbol extends Symbol { + angle?: number; + xoffset?: number; + yoffset?: number; +} + +/** + * A multipoint contains an array of points. + */ +export interface Multipoint extends HasZM, Geometry { + points: Position[]; +} + +/** + * Params for paging operations + */ +export interface PagingParams { + start?: number; + num?: number; +} + +/** + * + */ +export interface PictureFillSymbol extends Symbol, PictureSourced { + type: "esriPFS"; + outline?: SimpleLineSymbol; // if outline has been specified + xscale?: number; + yscale?: number; +} + +/** + * + */ +export interface PictureMarkerSymbol extends MarkerSymbol, PictureSourced { + type: "esriPMS"; +} + +/** + * + */ +export interface PictureSourced { + url?: string; // Relative URL for static layers and full URL for dynamic layers. Access relative URL using http:////images/ + imageData?: string; // ""; + contentType?: string; + width?: number; + height?: number; + angle?: number; + xoffset?: number; + yoffset?: number; +} + +/** + * A simple point geometry, with spatial reference defined. + */ +export interface Point extends HasZM, Geometry { + x: number; + y: number; +} + +/** + * + */ +export interface Polyline extends HasZM, Geometry { + paths: Position[][]; +} + +/** + * + */ +export interface PolylineWithCurves extends HasZM, Geometry { + curvePaths: Array>; +} + +/** + * + */ +export interface Polygon extends HasZM, Geometry { + rings: Position[][]; +} + +/** + * + */ +export interface PolygonWithCurves extends HasZM, Geometry { + curveRings: Array>; +} + +/** + * + */ +export type Position = + | Position2D + | [number, number, number] + | [number, number, number, number]; + +/** + * + */ +export type Position2D = [number, number]; + +/** + * + */ +export type SimpleMarkerSymbolStyle = + | "esriSMSCircle" + | "esriSMSCross" + | "esriSMSDiamond" + | "esriSMSSquare" + | "esriSMSX" + | "esriSMSTriangle"; + +/** + * + */ +export type SimpleLineSymbolStyle = + | "esriSLSDash" + | "esriSLSDashDot" + | "esriSLSDashDotDot" + | "esriSLSDot" + | "esriSLSNull" + | "esriSLSSolid"; + +/** + * + */ +export type SimpleFillSymbolStyle = + | "esriSFSBackwardDiagonal" + | "esriSFSCross" + | "esriSFSDiagonalCross" + | "esriSFSForwardDiagonal" + | "esriSFSHorizontal" + | "esriSFSNull" + | "esriSFSSolid" + | "esriSFSVertical"; + +/** + * + */ +export type SymbolType = + | "esriSLS" + | "esriSMS" + | "esriSFS" + | "esriPMS" + | "esriPFS" + | "esriTS"; + +/** + * + */ +export interface SimpleFillSymbol extends Symbol { + type: "esriSFS"; + style?: SimpleFillSymbolStyle; + color?: Color; + outline?: SimpleLineSymbol; // if outline has been specified +} + +/** + * + */ +export interface SimpleLineSymbol extends Symbol { + type: "esriSLS"; + style?: SimpleLineSymbolStyle; + color?: Color; + width?: number; +} + +/** + * + */ +export interface SimpleMarkerSymbol extends MarkerSymbol { + type: "esriSMS"; + style?: SimpleMarkerSymbolStyle; + color?: Color; + size?: number; + outline?: SimpleLineSymbol; +} + +/** + * Spatial reference systems define mathematical transformations and coordinate systems for displaying spatial information in 2D and 3D. + */ +export interface SpatialReferenceWkid { + wkid: number; + latestWkid?: number; + vcsWkid?: number; + latestVcsWkid?: number; +} + +/** + * + */ +export interface SpatialReferenceWkt { + wkt?: string; + latestWkt?: string; +} + +/** + * + */ +export type SpatialReference = SpatialReferenceWkt | SpatialReferenceWkid; + +/** + * + */ +export interface Symbol { + type: SymbolType; + style?: string; +} + +/** + * + */ +export interface TextSymbol extends MarkerSymbol { + type: "esriTS"; + color?: Color; + backgroundColor?: Color; + borderLineSize?: number; // ; + borderLineColor?: Color; + haloSize?: number; // ; + haloColor?: Color; + verticalAlignment?: "baseline" | "top" | "middle" | "bottom"; + horizontalAlignment?: "left" | "right" | "center" | "justify"; + rightToLeft?: boolean; + kerning?: boolean; + font?: Font; + text?: string; // only applicable when specified as a client-side graphic. +} diff --git a/packages/arcgis-rest-geocoder/src/geocoder.ts b/packages/arcgis-rest-geocoder/src/geocoder.ts index 83fed054ba..84abbd747b 100644 --- a/packages/arcgis-rest-geocoder/src/geocoder.ts +++ b/packages/arcgis-rest-geocoder/src/geocoder.ts @@ -5,9 +5,9 @@ import { request, IRequestOptions, IParams } from "@esri/arcgis-rest-request"; import { IAuthenticatedRequestOptions } from "@esri/arcgis-rest-auth"; import { - IExtent, - ISpatialReference, - IPoint + Extent, + SpatialReferenceWkid, + Point } from "@esri/arcgis-rest-common-types"; // https always @@ -35,7 +35,7 @@ export interface IAddressBulk { countryCode?: string; } -export interface ILocation { +export interface Location { latitude?: number; longitude?: number; lat?: number; @@ -43,17 +43,17 @@ export interface ILocation { } function isLocationArray( - coords: ILocation | IPoint | [number, number] + coords: Location | Point | [number, number] ): coords is [number, number] { return (coords as [number, number]).length === 2; } function isLocation( - coords: ILocation | IPoint | [number, number] -): coords is ILocation { + coords: Location | Point | [number, number] +): coords is Location { return ( - (coords as ILocation).latitude !== undefined || - (coords as ILocation).lat !== undefined + (coords as Location).latitude !== undefined || + (coords as Location).lat !== undefined ); } @@ -116,11 +116,11 @@ export interface IBulkGeocodeRequestOptions extends IEndpointRequestOptions { } export interface IGeocodeResponse { - spatialReference: ISpatialReference; + spatialReference: SpatialReferenceWkid; candidates: Array<{ address: string; - location: IPoint; - extent: IExtent; + location: Point; + extent: Extent; attributes: object; }>; } @@ -129,7 +129,7 @@ export interface IReverseGeocodeResponse { address: { [key: string]: any; }; - location: IPoint; + location: Point; } export interface ISuggestResponse { @@ -141,10 +141,10 @@ export interface ISuggestResponse { } export interface IBulkGeocodeResponse { - spatialReference: ISpatialReference; + spatialReference: SpatialReferenceWkid; locations: Array<{ address: string; - location: IPoint; + location: Point; score: number; attributes: object; }>; @@ -169,8 +169,8 @@ export interface IGeocodeServiceInfoResponse { * response.candidates[0].location; // => { x: -118.409, y: 33.943, spatialReference: { wkid: 4326 } } * }); * - * geocode({ - * params: { + * geocode({ + * params: { * address: "1600 Pennsylvania Ave", * postal: 20500, * countryCode: "USA" @@ -201,20 +201,19 @@ export function geocode( } // add spatialReference property to individual matches - return request( - options.endpoint + "findAddressCandidates", - options - ).then(response => { - const sr = response.spatialReference; - response.candidates.forEach(function(candidate: { - location: IPoint; - extent: IExtent; - }) { - candidate.location.spatialReference = sr; - candidate.extent.spatialReference = sr; - }); - return response; - }); + return request(options.endpoint + "findAddressCandidates", options).then( + response => { + const sr = response.spatialReference; + response.candidates.forEach(function(candidate: { + location: Point; + extent: Extent; + }) { + candidate.location.spatialReference = sr; + candidate.extent.spatialReference = sr; + }); + return response; + } + ); } /** @@ -280,7 +279,7 @@ export function suggest( * @returns A Promise that will resolve with the data from the response. */ export function reverseGeocode( - coords: IPoint | ILocation | [number, number], + coords: Point | Location | [number, number], requestOptions?: IEndpointRequestOptions ): Promise { const options: IGeocodeRequestOptions = { @@ -354,16 +353,15 @@ export function bulkGeocode( return Promise.reject("bulk geocoding requires authentication"); } - return request( - options.endpoint + "geocodeAddresses", - requestOptions - ).then(response => { - const sr = response.spatialReference; - response.locations.forEach(function(address: { location: IPoint }) { - address.location.spatialReference = sr; - }); - return response; - }); + return request(options.endpoint + "geocodeAddresses", requestOptions).then( + response => { + const sr = response.spatialReference; + response.locations.forEach(function(address: { location: Point }) { + address.location.spatialReference = sr; + }); + return response; + } + ); } /** diff --git a/packages/arcgis-rest-groups/src/groups.ts b/packages/arcgis-rest-groups/src/groups.ts index 00df877345..91743ad1ba 100644 --- a/packages/arcgis-rest-groups/src/groups.ts +++ b/packages/arcgis-rest-groups/src/groups.ts @@ -7,10 +7,10 @@ import { getPortalUrl } from "@esri/arcgis-rest-request"; -import { IPagingParams, IItem } from "@esri/arcgis-rest-common-types"; +import { PagingParams, Item } from "@esri/arcgis-rest-common-types"; export interface IPagingParamsRequestOptions extends IRequestOptions { - paging: IPagingParams; + paging: PagingParams; } export interface IGroupIdRequestOptions extends IRequestOptions { @@ -32,7 +32,7 @@ export interface IGroupRequestOptions extends IRequestOptions { group: IGroup; } -export interface IGroupSearchRequest extends IPagingParams { +export interface IGroupSearchRequest extends PagingParams { q: string; sortField?: string; sortOrder?: string; @@ -56,7 +56,7 @@ export interface IGroupContentResult { start: number; num: number; nextStart: number; - items: IItem[]; + items: Item[]; } export interface IGroupUsersResult { @@ -210,8 +210,9 @@ export function createGroup( export function updateGroup( requestOptions: IGroupRequestOptions ): Promise { - const url = `${getPortalUrl(requestOptions)}/community/groups/${requestOptions - .group.id}/update`; + const url = `${getPortalUrl(requestOptions)}/community/groups/${ + requestOptions.group.id + }/update`; // default to a POST request const options: IGroupRequestOptions = { ...{ httpMethod: "POST" }, @@ -230,9 +231,9 @@ export function updateGroup( export function removeGroup( requestOptions: IGroupIdRequestOptions ): Promise { - const url = `${getPortalUrl( - requestOptions - )}/community/groups/${requestOptions.id}/delete`; + const url = `${getPortalUrl(requestOptions)}/community/groups/${ + requestOptions.id + }/delete`; // default to a POST request const options: IGroupIdRequestOptions = { ...{ httpMethod: "POST" }, @@ -249,9 +250,9 @@ export function removeGroup( export function protectGroup( requestOptions: IGroupIdRequestOptions ): Promise { - const url = `${getPortalUrl( - requestOptions - )}/community/groups/${requestOptions.id}/protect`; + const url = `${getPortalUrl(requestOptions)}/community/groups/${ + requestOptions.id + }/protect`; // default to a POST request const options: IGroupIdRequestOptions = { ...{ httpMethod: "POST" }, @@ -268,9 +269,9 @@ export function protectGroup( export function unprotectGroup( requestOptions: IGroupIdRequestOptions ): Promise { - const url = `${getPortalUrl( - requestOptions - )}/community/groups/${requestOptions.id}/unprotect`; + const url = `${getPortalUrl(requestOptions)}/community/groups/${ + requestOptions.id + }/unprotect`; // default to a POST request const options: IGroupIdRequestOptions = { ...{ httpMethod: "POST" }, diff --git a/packages/arcgis-rest-items/src/items.ts b/packages/arcgis-rest-items/src/items.ts index fbfaadb268..c52a1f6d7c 100644 --- a/packages/arcgis-rest-items/src/items.ts +++ b/packages/arcgis-rest-items/src/items.ts @@ -7,12 +7,12 @@ import { getPortalUrl } from "@esri/arcgis-rest-request"; -import { IExtent, IItem, IPagingParams } from "@esri/arcgis-rest-common-types"; +import { Extent, Item, PagingParams } from "@esri/arcgis-rest-common-types"; import { IUserRequestOptions } from "@esri/arcgis-rest-auth"; export interface IItemRequestOptions extends IUserRequestOptions { - item: IItem; + item: Item; } // * @param id - Item Id @@ -54,7 +54,7 @@ export interface IItemResourceRequestOptions extends IItemIdRequestOptions { } export interface IItemCrudRequestOptions extends IUserRequestOptions { - item: IItem; + item: Item; /** * Item owner username (by default authentication session will be used). */ @@ -66,7 +66,7 @@ export interface IItemCrudRequestOptions extends IUserRequestOptions { } // this interface still needs to be docced -export interface ISearchRequest extends IPagingParams { +export interface ISearchRequest extends PagingParams { q: string; [key: string]: any; // start: number; @@ -86,7 +86,7 @@ export interface ISearchResult { start: number; num: number; nextStart: number; - results: IItem[]; + results: Item[]; } /** @@ -176,9 +176,9 @@ export function addItemJsonData( ): Promise { const owner = requestOptions.owner || requestOptions.authentication.username; - const url = `${getPortalUrl( - requestOptions - )}/content/users/${owner}/items/${requestOptions.id}/update`; + const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${ + requestOptions.id + }/update`; // Portal API requires that the 'data' be stringified and POSTed in // a `text` form field. It can also be sent with the `.create` call by sending @@ -199,7 +199,7 @@ export function addItemJsonData( export function getItem( id: string, requestOptions?: IRequestOptions -): Promise { +): Promise { const url = `${getPortalUrl(requestOptions)}/content/items/${id}`; // default to a GET request @@ -240,8 +240,9 @@ export function getItemData( * @returns A Promise that resolves with the status of the operation. */ export function updateItem(requestOptions: IItemRequestOptions): Promise { - const url = `${getPortalUrl(requestOptions)}/content/users/${requestOptions - .item.owner}/items/${requestOptions.item.id}/update`; + const url = `${getPortalUrl(requestOptions)}/content/users/${ + requestOptions.item.owner + }/items/${requestOptions.item.id}/update`; // serialize the item into something Portal will accept requestOptions.params = serializeItem(requestOptions.item); @@ -259,9 +260,9 @@ export function removeItem( requestOptions: IItemIdRequestOptions ): Promise { const owner = requestOptions.owner || requestOptions.authentication.username; - const url = `${getPortalUrl( - requestOptions - )}/content/users/${owner}/items/${requestOptions.id}/delete`; + const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${ + requestOptions.id + }/delete`; return request(url, requestOptions); } @@ -275,9 +276,9 @@ export function protectItem( requestOptions: IItemIdRequestOptions ): Promise { const owner = requestOptions.owner || requestOptions.authentication.username; - const url = `${getPortalUrl( - requestOptions - )}/content/users/${owner}/items/${requestOptions.id}/protect`; + const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${ + requestOptions.id + }/protect`; return request(url, requestOptions); } @@ -291,9 +292,9 @@ export function unprotectItem( requestOptions: IItemIdRequestOptions ): Promise { const owner = requestOptions.owner || requestOptions.authentication.username; - const url = `${getPortalUrl( - requestOptions - )}/content/users/${owner}/items/${requestOptions.id}/unprotect`; + const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${ + requestOptions.id + }/unprotect`; return request(url, requestOptions); } @@ -306,9 +307,9 @@ export function unprotectItem( export function getItemResources( requestOptions: IItemIdRequestOptions ): Promise { - const url = `${getPortalUrl( - requestOptions - )}/content/items/${requestOptions.id}/resources`; + const url = `${getPortalUrl(requestOptions)}/content/items/${ + requestOptions.id + }/resources`; requestOptions.params = { num: 1000 }; @@ -325,9 +326,9 @@ export function updateItemResource( requestOptions: IItemResourceRequestOptions ): Promise { const owner = requestOptions.owner || requestOptions.authentication.username; - const url = `${getPortalUrl( - requestOptions - )}/content/users/${owner}/items/${requestOptions.id}/updateResources`; + const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${ + requestOptions.id + }/updateResources`; requestOptions.params = { fileName: requestOptions.content, @@ -347,9 +348,9 @@ export function removeItemResource( requestOptions: IItemResourceRequestOptions ): Promise { const owner = requestOptions.owner || requestOptions.authentication.username; - const url = `${getPortalUrl( - requestOptions - )}/content/users/${owner}/items/${requestOptions.id}/removeResources`; + const url = `${getPortalUrl(requestOptions)}/content/users/${owner}/items/${ + requestOptions.id + }/removeResources`; requestOptions.params = { resource: requestOptions.resource }; return request(url, requestOptions); @@ -362,7 +363,7 @@ export function removeItemResource( * @param item IItem to be serialized * @returns a formatted json object to be sent to Portal */ -function serializeItem(item: IItem): any { +function serializeItem(item: Item): any { // create a clone so we're not messing with the original const clone = JSON.parse(JSON.stringify(item)); // join keywords and tags... diff --git a/packages/arcgis-rest-items/test/mocks/item.ts b/packages/arcgis-rest-items/test/mocks/item.ts index 11377a2196..ac7e2c01dd 100644 --- a/packages/arcgis-rest-items/test/mocks/item.ts +++ b/packages/arcgis-rest-items/test/mocks/item.ts @@ -1,11 +1,11 @@ -import { IItem } from "@esri/arcgis-rest-common-types"; +import { Item } from "@esri/arcgis-rest-common-types"; export const ItemSuccessResponse: any = { success: true, id: "3efakeitemid0000" }; -export const ItemResponse: IItem = { +export const ItemResponse: Item = { id: "4bc", owner: "jeffvader", title: "DS Plans", diff --git a/packages/arcgis-rest-items/test/mocks/search.ts b/packages/arcgis-rest-items/test/mocks/search.ts index 6d91d33fd8..687a48181b 100644 --- a/packages/arcgis-rest-items/test/mocks/search.ts +++ b/packages/arcgis-rest-items/test/mocks/search.ts @@ -1,5 +1,5 @@ import { ISearchResult } from "../../src/items"; -import { IItem } from "@esri/arcgis-rest-common-types"; +import { Item } from "@esri/arcgis-rest-common-types"; export const SearchResponse: ISearchResult = { query: "", diff --git a/tslint.json b/tslint.json index e82421a80d..c9a1984eac 100644 --- a/tslint.json +++ b/tslint.json @@ -8,6 +8,7 @@ "strict-type-predicates": false, "ordered-imports": ["any"], "only-arrow-functions": [false], - "object-literal-sort-keys": false + "object-literal-sort-keys": false, + "interface-name": [false, "always-prefix"] } } From d91dd0e127f70804beec8a4ce373c17755746c2e Mon Sep 17 00:00:00 2001 From: john gravois Date: Thu, 22 Feb 2018 17:29:37 -0800 Subject: [PATCH 2/3] feat(common-types): add more common types, keep the 'I' in front of interfaces AFFECTS PACKAGES: @esri/arcgis-rest-common-types @esri/arcgis-rest-geocoder @esri/arcgis-rest-groups @esri/arcgis-rest-items --- .../arcgis-rest-common-types/src/index.ts | 115 ++++++++---------- packages/arcgis-rest-geocoder/src/geocoder.ts | 38 +++--- packages/arcgis-rest-groups/src/groups.ts | 8 +- packages/arcgis-rest-items/src/items.ts | 14 +-- packages/arcgis-rest-items/test/mocks/item.ts | 4 +- .../arcgis-rest-items/test/mocks/search.ts | 2 +- 6 files changed, 85 insertions(+), 96 deletions(-) diff --git a/packages/arcgis-rest-common-types/src/index.ts b/packages/arcgis-rest-common-types/src/index.ts index e32968c015..c137e39d3c 100644 --- a/packages/arcgis-rest-common-types/src/index.ts +++ b/packages/arcgis-rest-common-types/src/index.ts @@ -4,7 +4,7 @@ /** * an arc can be represented as a JSON curve object */ -export interface Arc { +export interface IArc { a: [ Position, // End point: x, y, , Position2D, // Center point: center_x, center_y @@ -19,14 +19,14 @@ export interface Arc { /** * a bezier curve can be represented as a JSON curve object */ -export interface BezierCurve { +export interface IBezierCurve { b: [Position, Position2D, Position2D]; } /** * a circular arc can be represented as a JSON curve object */ -export interface CircularArc { +export interface ICircularArc { c: [Position, Position2D]; } @@ -38,20 +38,20 @@ export type Color = [number, number, number, number]; /** * */ -export type ElipticArc = Arc; +export type ElipticArc = IArc; /** * a spatial entity and its corresponding properties */ -export interface Feature { - geometry?: Geometry; +export interface IFeature { + geometry?: IGeometry; attributes?: any; } /** * */ -export interface Field { +export interface IField { name: string; type: string; alias?: string; @@ -61,14 +61,14 @@ export interface Field { /** * a building block for discrete geometries */ -export interface Geometry { - spatialReference?: SpatialReference; +export interface IGeometry { + spatialReference?: ISpatialReference; } /** * An envelope is a rectangle defined by a range of values for each coordinate and attribute. */ -export interface Envelope extends Geometry { +export interface IEnvelope extends IGeometry { xmin: number; xmax: number; ymin: number; @@ -91,23 +91,34 @@ export type esriGeometryType = | "esriGeometryPolygon" | "esriGeometryEnvelope"; +/** + * Extents are used to define rectangles and bounding boxes. + */ +export interface IExtent { + xmin: number; + ymin: number; + xmax: number; + ymax: number; + spatialReference?: ISpatialReference; +} + /** * */ -export interface FeatureSet extends HasZM { +export interface IFeatureSet extends IHasZM { objectIdFieldName?: string; // optional globalIdFieldName?: string; // optional displayFieldName?: string; // optional geometryType?: esriGeometryType; // for feature layers only - spatialReference?: SpatialReference; // for feature layers only. - fields?: Field[]; - features: Feature[]; + spatialReference?: ISpatialReference; // for feature layers only. + fields?: IField[]; + features: IFeature[]; } /** * */ -export interface Font { +export interface IFont { family?: string; // ""; size?: number; // ; style?: "italic" | "normal" | "oblique"; @@ -115,21 +126,10 @@ export interface Font { decoration?: "line-through" | "underline" | "none"; } -/** - * Extents are used to define rectangles and bounding boxes. - */ -export interface Extent { - xmin: number; - ymin: number; - xmax: number; - ymax: number; - spatialReference?: SpatialReference; -} - /** * */ -export interface HasZM { +export interface IHasZM { hasZ?: boolean; hasM?: boolean; } @@ -137,7 +137,7 @@ export interface HasZM { /** * Portal Item */ -export interface Item { +export interface IItem { id?: string; owner: string; title: string; @@ -159,12 +159,12 @@ export interface Item { /** * */ -export type JsonCurve = CircularArc | Arc | OldCircularArc | BezierCurve; +export type JsonCurve = ICircularArc | IArc | IOldCircularArc | IBezierCurve; /** * */ -export interface OldCircularArc { +export interface IOldCircularArc { a: [ Position, // End point: x, y, , Position2D, // Center point: center_x, center_y @@ -176,7 +176,7 @@ export interface OldCircularArc { /** * */ -export interface MarkerSymbol extends Symbol { +export interface IMarkerSymbol extends ISymbol { angle?: number; xoffset?: number; yoffset?: number; @@ -185,14 +185,14 @@ export interface MarkerSymbol extends Symbol { /** * A multipoint contains an array of points. */ -export interface Multipoint extends HasZM, Geometry { +export interface IMultipoint extends IHasZM, IGeometry { points: Position[]; } /** * Params for paging operations */ -export interface PagingParams { +export interface IPagingParams { start?: number; num?: number; } @@ -200,9 +200,9 @@ export interface PagingParams { /** * */ -export interface PictureFillSymbol extends Symbol, PictureSourced { +export interface IPictureFillSymbol extends ISymbol, IPictureSourced { type: "esriPFS"; - outline?: SimpleLineSymbol; // if outline has been specified + outline?: ISimpleLineSymbol; // if outline has been specified xscale?: number; yscale?: number; } @@ -210,14 +210,14 @@ export interface PictureFillSymbol extends Symbol, PictureSourced { /** * */ -export interface PictureMarkerSymbol extends MarkerSymbol, PictureSourced { +export interface IPictureMarkerSymbol extends IMarkerSymbol, IPictureSourced { type: "esriPMS"; } /** * */ -export interface PictureSourced { +export interface IPictureSourced { url?: string; // Relative URL for static layers and full URL for dynamic layers. Access relative URL using http:////images/ imageData?: string; // ""; contentType?: string; @@ -231,7 +231,7 @@ export interface PictureSourced { /** * A simple point geometry, with spatial reference defined. */ -export interface Point extends HasZM, Geometry { +export interface IPoint extends IHasZM, IGeometry { x: number; y: number; } @@ -239,28 +239,28 @@ export interface Point extends HasZM, Geometry { /** * */ -export interface Polyline extends HasZM, Geometry { +export interface IPolyline extends IHasZM, IGeometry { paths: Position[][]; } /** * */ -export interface PolylineWithCurves extends HasZM, Geometry { +export interface IPolylineWithCurves extends IHasZM, IGeometry { curvePaths: Array>; } /** * */ -export interface Polygon extends HasZM, Geometry { +export interface IPolygon extends IHasZM, IGeometry { rings: Position[][]; } /** * */ -export interface PolygonWithCurves extends HasZM, Geometry { +export interface IPolygonWithCurves extends IHasZM, IGeometry { curveRings: Array>; } @@ -326,17 +326,17 @@ export type SymbolType = /** * */ -export interface SimpleFillSymbol extends Symbol { +export interface ISimpleFillSymbol extends ISymbol { type: "esriSFS"; style?: SimpleFillSymbolStyle; color?: Color; - outline?: SimpleLineSymbol; // if outline has been specified + outline?: ISimpleLineSymbol; // if outline has been specified } /** * */ -export interface SimpleLineSymbol extends Symbol { +export interface ISimpleLineSymbol extends ISymbol { type: "esriSLS"; style?: SimpleLineSymbolStyle; color?: Color; @@ -346,28 +346,22 @@ export interface SimpleLineSymbol extends Symbol { /** * */ -export interface SimpleMarkerSymbol extends MarkerSymbol { +export interface ISimpleMarkerSymbol extends IMarkerSymbol { type: "esriSMS"; style?: SimpleMarkerSymbolStyle; color?: Color; size?: number; - outline?: SimpleLineSymbol; + outline?: ISimpleLineSymbol; } /** * Spatial reference systems define mathematical transformations and coordinate systems for displaying spatial information in 2D and 3D. */ -export interface SpatialReferenceWkid { - wkid: number; +export interface ISpatialReference { + wkid?: number; latestWkid?: number; vcsWkid?: number; latestVcsWkid?: number; -} - -/** - * - */ -export interface SpatialReferenceWkt { wkt?: string; latestWkt?: string; } @@ -375,12 +369,7 @@ export interface SpatialReferenceWkt { /** * */ -export type SpatialReference = SpatialReferenceWkt | SpatialReferenceWkid; - -/** - * - */ -export interface Symbol { +export interface ISymbol { type: SymbolType; style?: string; } @@ -388,7 +377,7 @@ export interface Symbol { /** * */ -export interface TextSymbol extends MarkerSymbol { +export interface ITextSymbol extends IMarkerSymbol { type: "esriTS"; color?: Color; backgroundColor?: Color; @@ -400,6 +389,6 @@ export interface TextSymbol extends MarkerSymbol { horizontalAlignment?: "left" | "right" | "center" | "justify"; rightToLeft?: boolean; kerning?: boolean; - font?: Font; + font?: IFont; text?: string; // only applicable when specified as a client-side graphic. } diff --git a/packages/arcgis-rest-geocoder/src/geocoder.ts b/packages/arcgis-rest-geocoder/src/geocoder.ts index 84abbd747b..bff780b61d 100644 --- a/packages/arcgis-rest-geocoder/src/geocoder.ts +++ b/packages/arcgis-rest-geocoder/src/geocoder.ts @@ -5,9 +5,9 @@ import { request, IRequestOptions, IParams } from "@esri/arcgis-rest-request"; import { IAuthenticatedRequestOptions } from "@esri/arcgis-rest-auth"; import { - Extent, - SpatialReferenceWkid, - Point + IExtent, + ISpatialReference, + IPoint } from "@esri/arcgis-rest-common-types"; // https always @@ -35,7 +35,7 @@ export interface IAddressBulk { countryCode?: string; } -export interface Location { +export interface ILocation { latitude?: number; longitude?: number; lat?: number; @@ -43,17 +43,17 @@ export interface Location { } function isLocationArray( - coords: Location | Point | [number, number] + coords: ILocation | IPoint | [number, number] ): coords is [number, number] { return (coords as [number, number]).length === 2; } function isLocation( - coords: Location | Point | [number, number] -): coords is Location { + coords: ILocation | IPoint | [number, number] +): coords is ILocation { return ( - (coords as Location).latitude !== undefined || - (coords as Location).lat !== undefined + (coords as ILocation).latitude !== undefined || + (coords as ILocation).lat !== undefined ); } @@ -116,11 +116,11 @@ export interface IBulkGeocodeRequestOptions extends IEndpointRequestOptions { } export interface IGeocodeResponse { - spatialReference: SpatialReferenceWkid; + spatialReference: ISpatialReference; candidates: Array<{ address: string; - location: Point; - extent: Extent; + location: IPoint; + extent: IExtent; attributes: object; }>; } @@ -129,7 +129,7 @@ export interface IReverseGeocodeResponse { address: { [key: string]: any; }; - location: Point; + location: IPoint; } export interface ISuggestResponse { @@ -141,10 +141,10 @@ export interface ISuggestResponse { } export interface IBulkGeocodeResponse { - spatialReference: SpatialReferenceWkid; + spatialReference: ISpatialReference; locations: Array<{ address: string; - location: Point; + location: IPoint; score: number; attributes: object; }>; @@ -205,8 +205,8 @@ export function geocode( response => { const sr = response.spatialReference; response.candidates.forEach(function(candidate: { - location: Point; - extent: Extent; + location: IPoint; + extent: IExtent; }) { candidate.location.spatialReference = sr; candidate.extent.spatialReference = sr; @@ -279,7 +279,7 @@ export function suggest( * @returns A Promise that will resolve with the data from the response. */ export function reverseGeocode( - coords: Point | Location | [number, number], + coords: IPoint | ILocation | [number, number], requestOptions?: IEndpointRequestOptions ): Promise { const options: IGeocodeRequestOptions = { @@ -356,7 +356,7 @@ export function bulkGeocode( return request(options.endpoint + "geocodeAddresses", requestOptions).then( response => { const sr = response.spatialReference; - response.locations.forEach(function(address: { location: Point }) { + response.locations.forEach(function(address: { location: IPoint }) { address.location.spatialReference = sr; }); return response; diff --git a/packages/arcgis-rest-groups/src/groups.ts b/packages/arcgis-rest-groups/src/groups.ts index 91743ad1ba..8e50040fc7 100644 --- a/packages/arcgis-rest-groups/src/groups.ts +++ b/packages/arcgis-rest-groups/src/groups.ts @@ -7,10 +7,10 @@ import { getPortalUrl } from "@esri/arcgis-rest-request"; -import { PagingParams, Item } from "@esri/arcgis-rest-common-types"; +import { IPagingParams, IItem } from "@esri/arcgis-rest-common-types"; export interface IPagingParamsRequestOptions extends IRequestOptions { - paging: PagingParams; + paging: IPagingParams; } export interface IGroupIdRequestOptions extends IRequestOptions { @@ -32,7 +32,7 @@ export interface IGroupRequestOptions extends IRequestOptions { group: IGroup; } -export interface IGroupSearchRequest extends PagingParams { +export interface IGroupSearchRequest extends IPagingParams { q: string; sortField?: string; sortOrder?: string; @@ -56,7 +56,7 @@ export interface IGroupContentResult { start: number; num: number; nextStart: number; - items: Item[]; + items: IItem[]; } export interface IGroupUsersResult { diff --git a/packages/arcgis-rest-items/src/items.ts b/packages/arcgis-rest-items/src/items.ts index c52a1f6d7c..fd95f7fa7a 100644 --- a/packages/arcgis-rest-items/src/items.ts +++ b/packages/arcgis-rest-items/src/items.ts @@ -7,12 +7,12 @@ import { getPortalUrl } from "@esri/arcgis-rest-request"; -import { Extent, Item, PagingParams } from "@esri/arcgis-rest-common-types"; +import { IExtent, IItem, IPagingParams } from "@esri/arcgis-rest-common-types"; import { IUserRequestOptions } from "@esri/arcgis-rest-auth"; export interface IItemRequestOptions extends IUserRequestOptions { - item: Item; + item: IItem; } // * @param id - Item Id @@ -54,7 +54,7 @@ export interface IItemResourceRequestOptions extends IItemIdRequestOptions { } export interface IItemCrudRequestOptions extends IUserRequestOptions { - item: Item; + item: IItem; /** * Item owner username (by default authentication session will be used). */ @@ -66,7 +66,7 @@ export interface IItemCrudRequestOptions extends IUserRequestOptions { } // this interface still needs to be docced -export interface ISearchRequest extends PagingParams { +export interface ISearchRequest extends IPagingParams { q: string; [key: string]: any; // start: number; @@ -86,7 +86,7 @@ export interface ISearchResult { start: number; num: number; nextStart: number; - results: Item[]; + results: IItem[]; } /** @@ -199,7 +199,7 @@ export function addItemJsonData( export function getItem( id: string, requestOptions?: IRequestOptions -): Promise { +): Promise { const url = `${getPortalUrl(requestOptions)}/content/items/${id}`; // default to a GET request @@ -363,7 +363,7 @@ export function removeItemResource( * @param item IItem to be serialized * @returns a formatted json object to be sent to Portal */ -function serializeItem(item: Item): any { +function serializeItem(item: IItem): any { // create a clone so we're not messing with the original const clone = JSON.parse(JSON.stringify(item)); // join keywords and tags... diff --git a/packages/arcgis-rest-items/test/mocks/item.ts b/packages/arcgis-rest-items/test/mocks/item.ts index ac7e2c01dd..11377a2196 100644 --- a/packages/arcgis-rest-items/test/mocks/item.ts +++ b/packages/arcgis-rest-items/test/mocks/item.ts @@ -1,11 +1,11 @@ -import { Item } from "@esri/arcgis-rest-common-types"; +import { IItem } from "@esri/arcgis-rest-common-types"; export const ItemSuccessResponse: any = { success: true, id: "3efakeitemid0000" }; -export const ItemResponse: Item = { +export const ItemResponse: IItem = { id: "4bc", owner: "jeffvader", title: "DS Plans", diff --git a/packages/arcgis-rest-items/test/mocks/search.ts b/packages/arcgis-rest-items/test/mocks/search.ts index 687a48181b..6d91d33fd8 100644 --- a/packages/arcgis-rest-items/test/mocks/search.ts +++ b/packages/arcgis-rest-items/test/mocks/search.ts @@ -1,5 +1,5 @@ import { ISearchResult } from "../../src/items"; -import { Item } from "@esri/arcgis-rest-common-types"; +import { IItem } from "@esri/arcgis-rest-common-types"; export const SearchResponse: ISearchResult = { query: "", From 2aa7e54a3e1b7cc5faeb901752a9e28c3ef477ab Mon Sep 17 00:00:00 2001 From: john gravois Date: Thu, 22 Feb 2018 17:46:57 -0800 Subject: [PATCH 3/3] more linting fixes --- .../arcgis-rest-common-types/src/index.ts | 60 +++++++++---------- packages/arcgis-rest-geocoder/src/geocoder.ts | 2 +- packages/arcgis-rest-groups/src/groups.ts | 2 +- packages/arcgis-rest-items/src/items.ts | 3 +- packages/arcgis-rest-items/test/items.test.ts | 4 +- .../arcgis-rest-items/test/mocks/search.ts | 1 - .../src/utils/ArcGISAuthError.ts | 7 +-- .../src/utils/ArcGISRequestError.ts | 2 +- .../src/utils/get-portal.ts | 2 +- .../test/utils/get-portal-url.test.ts | 2 +- tslint.json | 2 +- 11 files changed, 40 insertions(+), 47 deletions(-) diff --git a/packages/arcgis-rest-common-types/src/index.ts b/packages/arcgis-rest-common-types/src/index.ts index c137e39d3c..08950cec95 100644 --- a/packages/arcgis-rest-common-types/src/index.ts +++ b/packages/arcgis-rest-common-types/src/index.ts @@ -102,6 +102,14 @@ export interface IExtent { spatialReference?: ISpatialReference; } +/** + * + */ +export interface IHasZM { + hasZ?: boolean; + hasM?: boolean; +} + /** * */ @@ -126,14 +134,6 @@ export interface IFont { decoration?: "line-through" | "underline" | "none"; } -/** - * - */ -export interface IHasZM { - hasZ?: boolean; - hasM?: boolean; -} - /** * Portal Item */ @@ -173,6 +173,14 @@ export interface IOldCircularArc { ]; } +/** + * + */ +export interface ISymbol { + type: SymbolType; + style?: string; +} + /** * */ @@ -197,6 +205,20 @@ export interface IPagingParams { num?: number; } +/** + * + */ +export interface IPictureSourced { + url?: string; // Relative URL for static layers and full URL for dynamic layers. Access relative URL using http:////images/ + imageData?: string; // ""; + contentType?: string; + width?: number; + height?: number; + angle?: number; + xoffset?: number; + yoffset?: number; +} + /** * */ @@ -214,20 +236,6 @@ export interface IPictureMarkerSymbol extends IMarkerSymbol, IPictureSourced { type: "esriPMS"; } -/** - * - */ -export interface IPictureSourced { - url?: string; // Relative URL for static layers and full URL for dynamic layers. Access relative URL using http:////images/ - imageData?: string; // ""; - contentType?: string; - width?: number; - height?: number; - angle?: number; - xoffset?: number; - yoffset?: number; -} - /** * A simple point geometry, with spatial reference defined. */ @@ -366,14 +374,6 @@ export interface ISpatialReference { latestWkt?: string; } -/** - * - */ -export interface ISymbol { - type: SymbolType; - style?: string; -} - /** * */ diff --git a/packages/arcgis-rest-geocoder/src/geocoder.ts b/packages/arcgis-rest-geocoder/src/geocoder.ts index bff780b61d..a724e8dee9 100644 --- a/packages/arcgis-rest-geocoder/src/geocoder.ts +++ b/packages/arcgis-rest-geocoder/src/geocoder.ts @@ -2,7 +2,7 @@ * Apache-2.0 */ import { request, IRequestOptions, IParams } from "@esri/arcgis-rest-request"; -import { IAuthenticatedRequestOptions } from "@esri/arcgis-rest-auth"; +// import { IAuthenticatedRequestOptions } from "@esri/arcgis-rest-auth"; import { IExtent, diff --git a/packages/arcgis-rest-groups/src/groups.ts b/packages/arcgis-rest-groups/src/groups.ts index 8e50040fc7..d2f70ed6d7 100644 --- a/packages/arcgis-rest-groups/src/groups.ts +++ b/packages/arcgis-rest-groups/src/groups.ts @@ -3,7 +3,7 @@ import { request, IRequestOptions, - IParams, + // IParams, getPortalUrl } from "@esri/arcgis-rest-request"; diff --git a/packages/arcgis-rest-items/src/items.ts b/packages/arcgis-rest-items/src/items.ts index fd95f7fa7a..5753d4b73f 100644 --- a/packages/arcgis-rest-items/src/items.ts +++ b/packages/arcgis-rest-items/src/items.ts @@ -3,11 +3,10 @@ import { request, IRequestOptions, - IParams, getPortalUrl } from "@esri/arcgis-rest-request"; -import { IExtent, IItem, IPagingParams } from "@esri/arcgis-rest-common-types"; +import { IItem, IPagingParams } from "@esri/arcgis-rest-common-types"; import { IUserRequestOptions } from "@esri/arcgis-rest-auth"; diff --git a/packages/arcgis-rest-items/test/items.test.ts b/packages/arcgis-rest-items/test/items.test.ts index 1704c27975..b57b39480b 100644 --- a/packages/arcgis-rest-items/test/items.test.ts +++ b/packages/arcgis-rest-items/test/items.test.ts @@ -31,8 +31,8 @@ import { RemoveItemResourceResponse } from "./mocks/resources"; -import { UserSession, IFetchTokenResponse } from "@esri/arcgis-rest-auth"; -import { TOMORROW, YESTERDAY } from "@esri/arcgis-rest-auth/test/utils"; +import { UserSession } from "@esri/arcgis-rest-auth"; +import { TOMORROW } from "@esri/arcgis-rest-auth/test/utils"; import { encodeParam } from "@esri/arcgis-rest-request"; describe("search", () => { diff --git a/packages/arcgis-rest-items/test/mocks/search.ts b/packages/arcgis-rest-items/test/mocks/search.ts index 6d91d33fd8..302ed64e79 100644 --- a/packages/arcgis-rest-items/test/mocks/search.ts +++ b/packages/arcgis-rest-items/test/mocks/search.ts @@ -1,5 +1,4 @@ import { ISearchResult } from "../../src/items"; -import { IItem } from "@esri/arcgis-rest-common-types"; export const SearchResponse: ISearchResult = { query: "", diff --git a/packages/arcgis-rest-request/src/utils/ArcGISAuthError.ts b/packages/arcgis-rest-request/src/utils/ArcGISAuthError.ts index 1b05fef459..129f08be6a 100644 --- a/packages/arcgis-rest-request/src/utils/ArcGISAuthError.ts +++ b/packages/arcgis-rest-request/src/utils/ArcGISAuthError.ts @@ -1,12 +1,7 @@ /* Copyright (c) 2017 Environmental Systems Research Institute, Inc. * Apache-2.0 */ -import { - request, - IRequestOptions, - IParams, - IAuthenticationManager -} from "../request"; +import { request, IRequestOptions, IAuthenticationManager } from "../request"; import { ArcGISRequestError } from "./ArcGISRequestError"; export type IRetryAuthError = ( diff --git a/packages/arcgis-rest-request/src/utils/ArcGISRequestError.ts b/packages/arcgis-rest-request/src/utils/ArcGISRequestError.ts index 30e56e51f0..fdd6a8dd15 100644 --- a/packages/arcgis-rest-request/src/utils/ArcGISRequestError.ts +++ b/packages/arcgis-rest-request/src/utils/ArcGISRequestError.ts @@ -1,7 +1,7 @@ /* Copyright (c) 2017 Environmental Systems Research Institute, Inc. * Apache-2.0 */ -import { IRequestOptions, IParams } from "../request"; +import { IRequestOptions } from "../request"; // TypeScript 2.1 no longer allows you to extend built in types. See https://github.com/Microsoft/TypeScript/issues/12790#issuecomment-265981442 // and https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work diff --git a/packages/arcgis-rest-request/src/utils/get-portal.ts b/packages/arcgis-rest-request/src/utils/get-portal.ts index 0850e73ae3..f985022575 100644 --- a/packages/arcgis-rest-request/src/utils/get-portal.ts +++ b/packages/arcgis-rest-request/src/utils/get-portal.ts @@ -1,7 +1,7 @@ /* Copyright (c) 2017 Environmental Systems Research Institute, Inc. * Apache-2.0 */ -import { request, IRequestOptions, IParams } from "../request"; +import { request, IRequestOptions } from "../request"; import { getPortalUrl } from "./get-portal-url"; diff --git a/packages/arcgis-rest-request/test/utils/get-portal-url.test.ts b/packages/arcgis-rest-request/test/utils/get-portal-url.test.ts index a34f211aa4..9c0ac70121 100644 --- a/packages/arcgis-rest-request/test/utils/get-portal-url.test.ts +++ b/packages/arcgis-rest-request/test/utils/get-portal-url.test.ts @@ -1,4 +1,4 @@ -import { getPortalUrl, IRequestOptions } from "../../src/index"; +import { getPortalUrl } from "../../src/index"; describe("getPortalUrl", () => { it("should default to arcgis.com", () => { diff --git a/tslint.json b/tslint.json index c9a1984eac..77a2d9fcf0 100644 --- a/tslint.json +++ b/tslint.json @@ -9,6 +9,6 @@ "ordered-imports": ["any"], "only-arrow-functions": [false], "object-literal-sort-keys": false, - "interface-name": [false, "always-prefix"] + "interface-name": [true, "always-prefix"] } }