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..08950cec95 100644 --- a/packages/arcgis-rest-common-types/src/index.ts +++ b/packages/arcgis-rest-common-types/src/index.ts @@ -2,13 +2,95 @@ * 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 IArc { + a: [ + Position, // End point: x, y, , + Position2D, // Center point: center_x, center_y + number, // minor + number, // clockwise + number, // rotation + number, // axis + number // ratio + ]; +} + +/** + * a bezier curve can be represented as a JSON curve object + */ +export interface IBezierCurve { + b: [Position, Position2D, Position2D]; +} + +/** + * a circular arc can be represented as a JSON curve object + */ +export interface ICircularArc { + c: [Position, Position2D]; +} + +/** + * + */ +export type Color = [number, number, number, number]; + +/** + * + */ +export type ElipticArc = IArc; + +/** + * a spatial entity and its corresponding properties + */ +export interface IFeature { + geometry?: IGeometry; + attributes?: any; +} + +/** + * + */ +export interface IField { + name: string; + type: string; + alias?: string; + length?: number; +} + +/** + * a building block for discrete geometries + */ +export interface IGeometry { + spatialReference?: ISpatialReference; +} + +/** + * An envelope is a rectangle defined by a range of values for each coordinate and attribute. + */ +export interface IEnvelope extends IGeometry { + xmin: number; + xmax: number; + ymin: number; + ymax: number; + + zmin?: number; + zmax?: number; + + mmin?: number; + mmax?: number; } +/** + * + */ +export type esriGeometryType = + | "esriGeometryPoint" + | "esriGeometryMultipoint" + | "esriGeometryPolyline" + | "esriGeometryPolygon" + | "esriGeometryEnvelope"; + /** * Extents are used to define rectangles and bounding boxes. */ @@ -21,20 +103,35 @@ export interface IExtent { } /** - * A simple point geometry, with spatial reference defined. + * */ -export interface IPoint { - x: number; - y: number; - spatialReference?: ISpatialReference; +export interface IHasZM { + hasZ?: boolean; + hasM?: boolean; } /** - * Params for paging operations + * */ -export interface IPagingParams { - start?: number; - num?: number; +export interface IFeatureSet extends IHasZM { + objectIdFieldName?: string; // optional + globalIdFieldName?: string; // optional + displayFieldName?: string; // optional + geometryType?: esriGeometryType; // for feature layers only + spatialReference?: ISpatialReference; // for feature layers only. + fields?: IField[]; + features: IFeature[]; +} + +/** + * + */ +export interface IFont { + family?: string; // ""; + size?: number; // ; + style?: "italic" | "normal" | "oblique"; + weight?: "bold" | "bolder" | "lighter" | "normal"; + decoration?: "line-through" | "underline" | "none"; } /** @@ -58,3 +155,240 @@ export interface IItem { url?: string; [key: string]: any; } + +/** + * + */ +export type JsonCurve = ICircularArc | IArc | IOldCircularArc | IBezierCurve; + +/** + * + */ +export interface IOldCircularArc { + a: [ + Position, // End point: x, y, , + Position2D, // Center point: center_x, center_y + number, // minor + number // clockwise + ]; +} + +/** + * + */ +export interface ISymbol { + type: SymbolType; + style?: string; +} + +/** + * + */ +export interface IMarkerSymbol extends ISymbol { + angle?: number; + xoffset?: number; + yoffset?: number; +} + +/** + * A multipoint contains an array of points. + */ +export interface IMultipoint extends IHasZM, IGeometry { + points: Position[]; +} + +/** + * Params for paging operations + */ +export interface IPagingParams { + start?: number; + 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; +} + +/** + * + */ +export interface IPictureFillSymbol extends ISymbol, IPictureSourced { + type: "esriPFS"; + outline?: ISimpleLineSymbol; // if outline has been specified + xscale?: number; + yscale?: number; +} + +/** + * + */ +export interface IPictureMarkerSymbol extends IMarkerSymbol, IPictureSourced { + type: "esriPMS"; +} + +/** + * A simple point geometry, with spatial reference defined. + */ +export interface IPoint extends IHasZM, IGeometry { + x: number; + y: number; +} + +/** + * + */ +export interface IPolyline extends IHasZM, IGeometry { + paths: Position[][]; +} + +/** + * + */ +export interface IPolylineWithCurves extends IHasZM, IGeometry { + curvePaths: Array>; +} + +/** + * + */ +export interface IPolygon extends IHasZM, IGeometry { + rings: Position[][]; +} + +/** + * + */ +export interface IPolygonWithCurves extends IHasZM, IGeometry { + 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 ISimpleFillSymbol extends ISymbol { + type: "esriSFS"; + style?: SimpleFillSymbolStyle; + color?: Color; + outline?: ISimpleLineSymbol; // if outline has been specified +} + +/** + * + */ +export interface ISimpleLineSymbol extends ISymbol { + type: "esriSLS"; + style?: SimpleLineSymbolStyle; + color?: Color; + width?: number; +} + +/** + * + */ +export interface ISimpleMarkerSymbol extends IMarkerSymbol { + type: "esriSMS"; + style?: SimpleMarkerSymbolStyle; + color?: Color; + size?: number; + outline?: ISimpleLineSymbol; +} + +/** + * Spatial reference systems define mathematical transformations and coordinate systems for displaying spatial information in 2D and 3D. + */ +export interface ISpatialReference { + wkid?: number; + latestWkid?: number; + vcsWkid?: number; + latestVcsWkid?: number; + wkt?: string; + latestWkt?: string; +} + +/** + * + */ +export interface ITextSymbol extends IMarkerSymbol { + 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?: 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 83fed054ba..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, @@ -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: IPoint; + extent: IExtent; + }) { + candidate.location.spatialReference = sr; + candidate.extent.spatialReference = sr; + }); + return response; + } + ); } /** @@ -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: 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 00df877345..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"; @@ -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 728f9c48dc..74eabc3c1d 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 589be07979..cdbbefb8a2 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 e82421a80d..77a2d9fcf0 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": [true, "always-prefix"] } }