From d820b8efeb77bfe6fff3b50da75beeaa999d0ea6 Mon Sep 17 00:00:00 2001 From: abeall Date: Sat, 7 Oct 2017 00:34:24 -0400 Subject: [PATCH 001/298] Changed TabProps.title to ReactNode not string, per docs --- types/react-bootstrap/index.d.ts | 1 + types/react-bootstrap/lib/Tab.d.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/react-bootstrap/index.d.ts b/types/react-bootstrap/index.d.ts index dcb5998f7a..8ccff26951 100644 --- a/types/react-bootstrap/index.d.ts +++ b/types/react-bootstrap/index.d.ts @@ -9,6 +9,7 @@ // Kat Busch , // Vito Samson // Karol Janyst +// Aaron Beall // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/react-bootstrap/lib/Tab.d.ts b/types/react-bootstrap/lib/Tab.d.ts index f30264a562..1c98d8c0a3 100644 --- a/types/react-bootstrap/lib/Tab.d.ts +++ b/types/react-bootstrap/lib/Tab.d.ts @@ -1,17 +1,18 @@ import * as React from 'react'; -import { TransitionCallbacks } from 'react-bootstrap'; +import { TransitionCallbacks, Omit } from 'react-bootstrap'; import * as TabContainer from './TabContainer'; import * as TabPane from './TabPane'; import * as TabContent from './TabContent'; declare namespace Tab { - export interface TabProps extends TransitionCallbacks, React.HTMLProps { + export interface TabProps extends TransitionCallbacks, Omit, "title"> { animation?: boolean; 'aria-labelledby'?: string; bsClass?: string; eventKey?: any; // TODO: Add more specific type unmountOnExit?: boolean; tabClassName?: string; + title?: React.ReactNode; // Override HTMLProps.title to allow nodes not just strings } } declare class Tab extends React.Component { From 07f707e2eb8eac55e2f05c03445d3bae680417e9 Mon Sep 17 00:00:00 2001 From: abeall Date: Mon, 9 Oct 2017 12:12:25 -0400 Subject: [PATCH 002/298] Fixed declaration of title/label as ReactNode for components, per docs --- types/react-bootstrap/lib/DropdownButton.d.ts | 1 + types/react-bootstrap/lib/Popover.d.ts | 5 +++-- types/react-bootstrap/lib/ProgressBar.d.ts | 5 +++-- types/react-bootstrap/lib/SplitButton.d.ts | 6 ++++-- .../test/react-bootstrap-individual-components-tests.tsx | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/types/react-bootstrap/lib/DropdownButton.d.ts b/types/react-bootstrap/lib/DropdownButton.d.ts index df66dd36dd..e2626e2bb7 100644 --- a/types/react-bootstrap/lib/DropdownButton.d.ts +++ b/types/react-bootstrap/lib/DropdownButton.d.ts @@ -10,6 +10,7 @@ declare namespace DropdownButton { navItem?: boolean; noCaret?: boolean; pullRight?: boolean; + title: React.ReactNode; } export type DropdownButtonProps = DropdownButtonBaseProps & React.HTMLProps; diff --git a/types/react-bootstrap/lib/Popover.d.ts b/types/react-bootstrap/lib/Popover.d.ts index 2af51da4b6..95abc38854 100644 --- a/types/react-bootstrap/lib/Popover.d.ts +++ b/types/react-bootstrap/lib/Popover.d.ts @@ -1,8 +1,8 @@ import * as React from 'react'; -import { Sizes } from 'react-bootstrap'; +import { Sizes, Omit } from 'react-bootstrap'; declare namespace Popover { - export interface PopoverProps extends React.HTMLProps { + export interface PopoverProps extends Omit, "title"> { // Optional arrowOffsetLeft?: number | string; arrowOffsetTop?: number | string; @@ -11,6 +11,7 @@ declare namespace Popover { placement?: string; positionLeft?: number | string; // String support added since v0.30.0 positionTop?: number | string; // String support added since v0.30.0 + title?: React.ReactNode; } } declare class Popover extends React.Component { } diff --git a/types/react-bootstrap/lib/ProgressBar.d.ts b/types/react-bootstrap/lib/ProgressBar.d.ts index 89b2e07cc0..8fc408ac65 100644 --- a/types/react-bootstrap/lib/ProgressBar.d.ts +++ b/types/react-bootstrap/lib/ProgressBar.d.ts @@ -1,8 +1,8 @@ import * as React from 'react'; -import { Sizes } from 'react-bootstrap'; +import { Sizes, Omit } from 'react-bootstrap'; declare namespace ProgressBar { - export interface ProgressBarProps extends React.HTMLProps { + export interface ProgressBarProps extends Omit, "label"> { // Optional active?: boolean; bsSize?: Sizes; @@ -13,6 +13,7 @@ declare namespace ProgressBar { now?: number; srOnly?: boolean; striped?: boolean; + label?: React.ReactNode; } } declare class ProgressBar extends React.Component { } diff --git a/types/react-bootstrap/lib/SplitButton.d.ts b/types/react-bootstrap/lib/SplitButton.d.ts index 7f3d9d7f30..7b824cd647 100644 --- a/types/react-bootstrap/lib/SplitButton.d.ts +++ b/types/react-bootstrap/lib/SplitButton.d.ts @@ -1,13 +1,15 @@ import * as React from 'react'; -import { Sizes } from 'react-bootstrap'; +import { Sizes, Omit } from 'react-bootstrap'; declare namespace SplitButton { - export interface SplitButtonProps extends React.HTMLProps { + export interface SplitButtonProps extends Omit, "title"> { bsStyle?: string; bsSize?: Sizes; dropdownTitle?: any; // TODO: Add more specific type dropup?: boolean; pullRight?: boolean; + title: React.ReactNode; + id: string; } } declare class SplitButton extends React.Component { } diff --git a/types/react-bootstrap/test/react-bootstrap-individual-components-tests.tsx b/types/react-bootstrap/test/react-bootstrap-individual-components-tests.tsx index 78579dc953..ff2c5b7472 100644 --- a/types/react-bootstrap/test/react-bootstrap-individual-components-tests.tsx +++ b/types/react-bootstrap/test/react-bootstrap-individual-components-tests.tsx @@ -120,7 +120,7 @@ export class ReactBootstrapIndividualComponentsTest extends React.Component { - + @@ -178,7 +178,7 @@ export class ReactBootstrapIndividualComponentsTest extends React.Component { - + From 780dcdbf69003c570e929562cdd498907a4930f5 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Mon, 6 Nov 2017 17:57:00 -0200 Subject: [PATCH 003/298] Added overload to allow the creation of a merged stream based on an array of streams --- types/merge-stream/index.d.ts | 5 +++-- types/merge-stream/merge-stream-tests.ts | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/types/merge-stream/index.d.ts b/types/merge-stream/index.d.ts index 90f91ee327..5a5493b06e 100644 --- a/types/merge-stream/index.d.ts +++ b/types/merge-stream/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for merge-stream v1.0.0 +// Type definitions for merge-stream v1.1.0 // Project: https://github.com/grncdr/merge-stream -// Definitions by: Keita Kagurazaka , Tom X. Tobin +// Definitions by: Keita Kagurazaka , Tom X. Tobin , Daniel Zazula // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -12,5 +12,6 @@ interface IMergedStream extends NodeJS.ReadWriteStream { isEmpty(): boolean; } +declare function merge(streams: T[]): IMergedStream; declare function merge(...streams: T[]): IMergedStream; export = merge; diff --git a/types/merge-stream/merge-stream-tests.ts b/types/merge-stream/merge-stream-tests.ts index 67a690e824..a12e7f9c65 100644 --- a/types/merge-stream/merge-stream-tests.ts +++ b/types/merge-stream/merge-stream-tests.ts @@ -16,3 +16,8 @@ var stream5 = new Stream(); merged.add([stream4, stream5]); merged.isEmpty(); + +var stream6 = new Stream(); +var stream7 = new Stream(); +var streamArray = [stream6, stream7]; +var merged2 = merge(streamArray); From ce92862988a2b6573b8d64d03de0a436e133a90f Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Wed, 22 Nov 2017 19:46:18 -0300 Subject: [PATCH 004/298] HapiJs v17 Typescript Definitions. Recovering the repo. --- types/hapi/v17/definitions/plugin/plugin.d.ts | 50 +++ .../hapi/v17/definitions/request/request.d.ts | 311 ++++++++++++++++++ .../definitions/response/response-object.d.ts | 305 +++++++++++++++++ .../response/response-settings.d.ts | 29 ++ .../route/route-options-access.d.ts | 75 +++++ .../route/route-options-cache.d.ts | 29 ++ .../definitions/route/route-options-cors.d.ts | 20 ++ .../route/route-options-payload.d.ts | 111 +++++++ .../route/route-options-response.d.ts | 67 ++++ .../route/route-options-secure.d.ts | 42 +++ .../route/route-options-validate.d.ts | 86 +++++ .../v17/definitions/route/route-options.d.ts | 224 +++++++++++++ .../server/server-connection-options.d.ts | 54 +++ .../server/server-options-cache.d.ts | 25 ++ .../definitions/server/server-options.d.ts | 184 +++++++++++ .../v17/definitions/server/server-realm.d.ts | 34 ++ .../server/server-state-options.d.ts | 61 ++++ types/hapi/v17/definitions/server/server.d.ts | 45 +++ .../v17/definitions/util/fail-action.d.ts | 4 + types/hapi/v17/definitions/util/util.d.ts | 10 + types/hapi/v17/hapi-tests.ts | 2 + types/hapi/v17/index.d.ts | 49 +++ types/hapi/v17/tsconfig.json | 28 ++ types/hapi/v17/tslint.json | 79 +++++ 24 files changed, 1924 insertions(+) create mode 100644 types/hapi/v17/definitions/plugin/plugin.d.ts create mode 100644 types/hapi/v17/definitions/request/request.d.ts create mode 100644 types/hapi/v17/definitions/response/response-object.d.ts create mode 100644 types/hapi/v17/definitions/response/response-settings.d.ts create mode 100644 types/hapi/v17/definitions/route/route-options-access.d.ts create mode 100644 types/hapi/v17/definitions/route/route-options-cache.d.ts create mode 100644 types/hapi/v17/definitions/route/route-options-cors.d.ts create mode 100644 types/hapi/v17/definitions/route/route-options-payload.d.ts create mode 100644 types/hapi/v17/definitions/route/route-options-response.d.ts create mode 100644 types/hapi/v17/definitions/route/route-options-secure.d.ts create mode 100644 types/hapi/v17/definitions/route/route-options-validate.d.ts create mode 100644 types/hapi/v17/definitions/route/route-options.d.ts create mode 100644 types/hapi/v17/definitions/server/server-connection-options.d.ts create mode 100644 types/hapi/v17/definitions/server/server-options-cache.d.ts create mode 100644 types/hapi/v17/definitions/server/server-options.d.ts create mode 100644 types/hapi/v17/definitions/server/server-realm.d.ts create mode 100644 types/hapi/v17/definitions/server/server-state-options.d.ts create mode 100644 types/hapi/v17/definitions/server/server.d.ts create mode 100644 types/hapi/v17/definitions/util/fail-action.d.ts create mode 100644 types/hapi/v17/definitions/util/util.d.ts create mode 100644 types/hapi/v17/hapi-tests.ts create mode 100644 types/hapi/v17/index.d.ts create mode 100644 types/hapi/v17/tsconfig.json create mode 100644 types/hapi/v17/tslint.json diff --git a/types/hapi/v17/definitions/plugin/plugin.d.ts b/types/hapi/v17/definitions/plugin/plugin.d.ts new file mode 100644 index 0000000000..f781de97bf --- /dev/null +++ b/types/hapi/v17/definitions/plugin/plugin.d.ts @@ -0,0 +1,50 @@ +import {Server} from "../server/server"; + +export interface PluginsStates { + [pluginName: string]: any; +} + +// Similar to v16, using that interface without any definition. +export interface PluginSpecificConfiguration { + +} + +/** + * Plugins provide a way to organize application code by splitting the server logic into smaller components. Each + * plugin can manipulate the server through the standard server interface, but with the added ability to sandbox + * certain properties. For example, setting a file path in one plugin doesn't affect the file path set + * in another plugin. + */ +export interface Plugin { + + /** + * (required) the registration function with the signature async function(server, options) where: + */ + register: { + /** the server object with a plugin-specific server.realm. */ + server: Server; + /** any options passed to the plugin during registration via server.register(). */ + options: any; // TODO check what kind of object is expected here. + } + + /** + * (required) the plugin name string. The name is used as a unique key. Published plugins (e.g. published in the npm + * registry) should use the same name as the name field in their 'package.json' file. Names must be + * unique within each application. + */ + name?: string; + + /** optional plugin version. The version is only used informatively to enable other plugins to find out the versions loaded. The version should be the same as the one specified in the plugin's 'package.json' file. */ + version?: string; + + /** (optional) if true, allows the plugin to be registered multiple times with the same server. Defaults to false. */ + multiple?: boolean; + + /** (optional) a string or an array of strings indicating a plugin dependency. Same as setting dependencies via server.dependency(). */ + dependencies?: string | string[]; + + /** once - (optional) if true, will only register the plugin once per server. If set, overrides the once option passed to server.register(). Defaults to no override. */ + once?: boolean; + +} + diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts new file mode 100644 index 0000000000..2da1eb27be --- /dev/null +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -0,0 +1,311 @@ +import * as stream from "stream"; +import * as url from "url"; +import * as http from "http"; +import {RouteOptions} from "../route/route-options"; +import {Server} from "../server/server"; +import {ServerRealm} from "../server/server-realm"; +import {ResponseObject} from "../response/response-object"; +import {HttpMethod, Dictionary} from "../util/util"; +import {PluginsStates} from "../plugin/plugin"; + +/** + * TODO both objects ReplyValue and _ReplyValue I found in the v16 TS definition, but I don't found it in the documentation. Need review. + * TODO I think it's not very elegant solution + */ +export type ReplyValue = _ReplyValue | Promise<_ReplyValue>; +export type _ReplyValue = null | undefined | string | number | boolean | Buffer | Error | stream.Stream | Object; // | array; + +export interface RequestAuth { + /** an artifact object received from the authentication strategy and used in authentication-related actions. */ + artifacts: any; + /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ + credentials: any; + /** the authentication error is failed and mode set to 'try'. */ + error: Error; + /** true if the request has been successfully authenticated, otherwise false. */ + isAuthenticated: boolean; + /** true is the request has been successfully authorized against the route authentication access configuration. If the route has not access rules defined or if the request failed authorization, set to false. */ + isAuthorized: boolean; + /** the route authentication mode. */ + mode: string; + /** the name of the strategy used. */ + strategy: string; +} + +export interface RequestInfo { + /** the request preferred encoding. */ + acceptEncoding: string; + /** if CORS is enabled for the route, contains the following: */ + cors: { + /** + * if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does + * not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing + * decisions are made at that point in the request lifecycle. + */ + isOriginMatch?: boolean; + }; + /** content of the HTTP 'Host' header (e.g. 'example.com:8080'). */ + host: string; + /** the hostname part of the 'Host' header (e.g. 'example.com'). */ + hostname: string; + /** request reception timestamp. */ + received: number; + /** content of the HTTP 'Referrer' (or 'Referer') header. */ + referrer: string; + /** remote client IP address. */ + remoteAddress: string; + /** + * remote client port. + * Set to string in casethey're requesting from a UNIX domain socket. + * TODO, what type does Hapi return, should this be number | string? + */ + remotePort: string; + /** request response timestamp (0 is not responded yet). */ + responded: number; +} + +export interface RequestOrig { + params: any; + query: any; + payload: any; +} + +export interface RequestRoute { + /** the route HTTP method. */ + method: HttpMethod; + /** the route path. */ + path: string; + /** the route vhost option if configured. */ + vhost?: string | string[]; + /** the active realm associated with the route.*/ + realm: ServerRealm; + /** the route options object with all defaults applied. */ + settings: RouteOptions; + /** the route internal normalized string representing the normalized path. */ + fingerprint: string; +} + +export interface Request { + + /** + Access: read / write. + Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. + */ + app: any; + + /** + Access: read only. + Authentication information: + artifacts - an artifact object received from the authentication strategy and used in authentication-related actions. + credentials - the credential object received during the authentication process. The presence of an object does not mean successful authentication. + error - the authentication error is failed and mode set to 'try'. + isAuthenticated - true if the request has been successfully authenticated, otherwise false. + isAuthorized - true is the request has been successfully authorized against the route authentication access configuration. If the route has not access rules defined or if the request failed authorization, set to false. + mode - the route authentication mode. + strategy - the name of the strategy used. + */ + auth: RequestAuth; + + /** + Access: read only and the public podium interface. + The request.events supports the following events: + 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). + 'finish' - emitted when the request payload finished reading. The event method signature is function (). + 'disconnect' - emitted when a request errors or aborts unexpectedly. + */ + events: 'peek' | 'finish' | 'disconnect'; + + /** + Access: read only. + The raw request headers (references request.raw.req.headers). + */ + headers: Dictionary; + + /** + Access: read only. + Request information: + acceptEncoding - the request preferred encoding. + cors - if CORS is enabled for the route, contains the following: + isOriginMatch - true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. + host - content of the HTTP 'Host' header (e.g. 'example.com:8080'). + hostname - the hostname part of the 'Host' header (e.g. 'example.com'). + id - a unique request identifier (using the format '{now}:{connection.info.id}:{5 digits counter}'). + received - request reception timestamp. + referrer - content of the HTTP 'Referrer' (or 'Referer') header. + remoteAddress - remote client IP address. + remotePort - remote client port. + responded - request response timestamp (0 is not responded yet). + Note that the request.info object is not meant to be modified. + */ + info: RequestInfo; + + /** + Access: read only. + An array containing the logged request events. + Note that this array will be empty if route log.collect is set to false. + */ + logs: any[]; // TODO check if type any is apropiate here. + + /** + Access: read only. + The request method in lower case (e.g. 'get', 'post'). + */ + method: HttpMethod; + + /** + Access: read only. + The parsed content-type header. Only available when payload parsing enabled and no payload error occurred. + */ + mime: string; + + /** + Access: read only. + An object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. + */ + orig: RequestOrig; + + /** + Access: read only. + An object where each key is a path parameter name with matching value as described in Path parameters. + */ + params: Dictionary; + + /** + Access: read only. + An array containing all the path params values in the order they appeared in the path. + */ + paramsArray: string[]; + + /** + Access: read only. + The request URI's pathname component. + */ + path: string; + + /** + Access: read only. + The request payload based on the route payload.output and payload.parse settings. + * TODO check this typing and add references / links. + */ + payload: stream.Readable | Buffer | any; + + /** + Access: read / write. + Plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. + */ + plugins: PluginsStates; + + /** + Access: read only. + An object where each key is the name assigned by a route pre-handler methods function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. + */ + pre: Object; + + /** + Access: read / write (see limitations below). + The response object when set. The object can be modified but must not be assigned another object. To replace the response with another from within an extension point, use reply(response) to override with a different response. Contains null when no response has been set (e.g. when a request terminates prematurely when the client disconnects). + */ + response: ResponseObject | null; + + /** + Access: read only. + Same as pre but represented as the response object created by the pre method. + */ + preResponses: Object; + + /** + Access: read only. + By default the object outputted from node's URL parse() method. Might also be set indirectly via request.setUrl in which case it may be a string (if url is set to an object with the query attribute as an unparsed string). + */ + query: any; + + /** + Access: read only. + An object containing the Node HTTP server objects. Direct interaction with these raw objects is not recommended. + req - the node request object. + res - the node response object. + */ + raw: { + req: http.IncomingMessage; + res: http.ServerResponse; + }; + + /** + Access: read only. + The request route information object, where: + method - the route HTTP method. + path - the route path. + vhost - the route vhost option if configured. + realm - the active realm associated with the route. + settings - the route options object with all defaults applied. + fingerprint - the route internal normalized string representing the normalized path. + */ + route: RequestRoute; + + /** + Access: read only and the public server interface. + The server object. + */ + server: Server; // TODO check if this server object should be right. + + /** + Access: read only. + An object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. + */ + state: Dictionary; + + /** + Access: read only. + The parsed request URI. + */ + url: url.Url; + + /** + * request.generateResponse(source, [options]) + * Returns a response which you can pass into the reply interface where: + * [See docs] (https://hapijs.com/api/17.0.1#request.generateResponse()) + * @param source - the value to set as the source of the reply interface, optional. + * @param options - options for the method, optional. + */ + generateResponse(source?: ReplyValue, options?: {marshal?: any; prepare?: any; close?: any; variety?: any}): ResponseObject; + + /** + * request.log(tags, [data]) + * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. The arguments are: + * @param tags - a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. + * @param data - (optional) an message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. + * Any logs generated by the server internally will be emitted only on the 'request-internal' channel and will include the event.internal flag set to true. + */ + log(tags: string | string[], data?: string | Object | (() => string | Object)): void; + + /** + * request.route.auth.access(request) + * [See docs] (https://hapijs.com/api/17.0.1#-requestrouteauthaccessrequest) + * Validates a request against the route's authentication access configuration, where: + * @param request - the request object. + * Return value: true if the request would have passed the route's access requirements. + * Note that the route's authentication mode and strategies are ignored. The only match is made between the request.auth.credentials scope and entity information and the route access configuration. + * If the route uses dynamic scopes, the scopes are constructed against the request.query, request.params, request.payload, and request.auth.credentials which may or may not match between the route and the request's route. If this method is called using a request that has not been authenticated (yet or not at all), it will return false if the route requires any authentication. + */ + // TODO how to implement it? It is a function inside route.auth! The v16 doesn't have this option. + + /** + * request.setMethod(method) + * Changes the request method before the router begins processing the request where: + * Can only be called from an 'onRequest' extension method. + * [See docs] (https://hapijs.com/api/17.0.1#-requestsetmethodmethod) + * @param method - is the request HTTP method (e.g. 'GET'). + */ + setMethod(method: HttpMethod): void; + + /** + * request.setUrl(url, [stripTrailingSlash] + * [See docs] (https://hapijs.com/api/17.0.1#-requestseturlurl-striptrailingslash) + * Changes the request URI before the router begins processing the request where: + * Can only be called from an 'onRequest' extension method. + * @param url - the new request URI. If url is a string, it is parsed with node's URL parse() method with parseQueryString set to true. url can also be set to an object compatible with node's URL parse() method output. + * @param stripTrailingSlash - if true, strip the trailing slash from the path. Defaults to false. + */ + setUrl(url: string | url.URL, stripTrailingSlash?: boolean): void; + +} diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/v17/definitions/response/response-object.d.ts new file mode 100644 index 0000000000..f30c98eb6e --- /dev/null +++ b/types/hapi/v17/definitions/response/response-object.d.ts @@ -0,0 +1,305 @@ +import {PluginsStates} from "../plugin/plugin"; +import {Dictionary} from "../util/util"; +import {ResponseSettings} from "./response-settings"; +import {ServerStateCookieOptions} from "../server/server-state-options"; + +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#response-object) + */ +export interface ResponseObjectHeaderOptions { + /** if true, the value is appended to any existing header value using separator. Defaults to false. */ + append?: boolean; + /** string used as separator when appending to an existing value. Defaults to ','. */ + separator?: string; + /** if false, the header value is not set if an existing value present. Defaults to true. */ + override?: boolean; + /** if false, the header value is not modified if the provided value is already included. Does not apply when append is false or if the name is 'set-cookie'. Defaults to true. */ + duplicate?: boolean; +} + +/** + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#response-object) + * The response object contains the request response value along with various HTTP headers and flags. When a lifecycle method returns a value, the value is wrapped in a response object along with some default flags (e.g. 200 status code). In order to customize a response before it is returned, the h.response() method is provided. + */ +export interface ResponseObject { + + /** + Default value: {}. + Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. + */ + app: any; + + /** + * [See docs] (https://hapijs.com/api/17.0.1#-responseevents) + * Access: read only and the public podium interface. + * The response.events object supports the following events: + * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). + * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). + */ + events: any; // TODO need to be implemented. I didn't understand yet. + + /** + Access: read only. + Default value: {}. + An object containing the response headers where each key is a header field name and the value is the string header value or array of string. + Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission. + */ + headers: Dictionary; + + /** + Access: read / write. + Default value: {}. + Plugin-specific state. Provides a place to store and pass request-level plugin data. plugins is an object where each key is a plugin name and the value is the state. + */ + plugins: PluginsStates; + + /** + Access: read only. + Object containing the response handling flags. + */ + settings: ResponseSettings; + + /** + Access: read only. + The raw value returned by the lifecycle method. + */ + source: any; // TODO need to be implemented. + + /** + Access: read only. + Default value: 200. + */ + statusCode: number; + + /** + Access: read only. + A string indicating the type of source with available values: + 'plain' - a plain response such as string, number, null, or simple object. + 'buffer' - a Buffer. + 'stream' - a Stream. + */ + variety: 'plain' | 'buffer' | 'stream'; + + /** + * response.bytes(length) + * [See docs] (https://hapijs.com/api/17.0.1#-responsebyteslength) + * Sets the HTTP 'Content-Length' header (to avoid chunked transfer encoding) where: + * @param length - the header value. Must match the actual payload size. + * @return Return value: the current response object. + */ + bytes(length: number): ResponseObject; + + /** + * response.charset(charset) + * [See docs] (https://hapijs.com/api/17.0.1#-responsecharsetcharset) + * Sets the 'Content-Type' HTTP header 'charset' property where: + * @param charset - the charset property value. + * @return Return value: the current response object. + */ + charset(charset: string): ResponseObject; + + /** + * response.code(statusCode) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsecodestatuscode) + * Sets the 'Content-Type' HTTP header 'charset' property where: + * $param charset - the charset property value. + * @return Return value: the current response object. + */ + code(statusCode: number): ResponseObject; + + /** + * response.message(httpMessage) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsemessagehttpmessage) + * Sets the HTTP status message where: + * @param httpMessage - the HTTP status message (e.g. 'Ok' for status code 200). + * @return Return value: the current response object. + */ + message(httpMessage: string): ResponseObject; + + /** + * response.created(uri) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsecreateduri) + * Sets the HTTP status code to Created (201) and the HTTP 'Location' header where: + * @param uri - an absolute or relative URI used as the 'Location' header value. + * @return Return value: the current response object. + */ + created(uri: string): ResponseObject; + + /** + * encoding(encoding) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responseencodingencoding) + * Sets the string encoding scheme used to serial data into the HTTP payload where: + * @param encoding the encoding property value (see node Buffer encoding [See docs](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings)). + * * 'ascii' - for 7-bit ASCII data only. This encoding is fast and will strip the high bit if set. + * * 'utf8' - Multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8. + * * 'utf16le' - 2 or 4 bytes, little-endian encoded Unicode characters. Surrogate pairs (U+10000 to U+10FFFF) are supported. + * * 'ucs2' - Alias of 'utf16le'. + * * 'base64' - Base64 encoding. When creating a Buffer from a string, this encoding will also correctly accept "URL and Filename Safe Alphabet" as specified in RFC4648, Section 5. + * * 'latin1' - A way of encoding the Buffer into a one-byte encoded string (as defined by the IANA in RFC1345, page 63, to be the Latin-1 supplement block and C0/C1 control codes). + * * 'binary' - Alias for 'latin1'. + * * 'hex' - Encode each byte as two hexadecimal characters. + * @return Return value: the current response object. + */ + encoding(encoding: 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex'): ResponseObject; + + /** + * response.etag(tag, options) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responseetagtag-options) + * Sets the representation entity tag where: + * @param tag - the entity tag string without the double-quote. + * @param options - (optional) settings where: + * * weak - if true, the tag will be prefixed with the 'W/' weak signifier. Weak tags will fail to match identical tags for the purpose of determining 304 response status. Defaults to false. + * * vary - if true and content encoding is set or applied to the response (e.g 'gzip' or 'deflate'), the encoding name will be automatically added to the tag at transmission time (separated by a '-' character). Ignored when weak is true. Defaults to true. + * @return Return value: the current response object. + */ + etag(tag: string, options?: {weak: boolean, vary: boolean}): ResponseObject; + + /** + * response.header(name, value, options) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responseheadername-value-options) + * Sets an HTTP header where: + * @param name - the header name. + * @param value - the header value. + * @param options - (optional) object where: + * * append - if true, the value is appended to any existing header value using separator. Defaults to false. + * * separator - string used as separator when appending to an existing value. Defaults to ','. + * * override - if false, the header value is not set if an existing value present. Defaults to true. + * * duplicate - if false, the header value is not modified if the provided value is already included. Does not apply when append is false or if the name is 'set-cookie'. Defaults to true. + * @return Return value: the current response object. + */ + header(name: string, value: string, options?: ResponseObjectHeaderOptions): ResponseObject; + + /** + * response.location(uri) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responselocationuri) + * Sets the HTTP 'Location' header where: + * @param uri - an absolute or relative URI used as the 'Location' header value. + * @return Return value: the current response object. + */ + location(uri: string): ResponseObject; + + /** + * response.redirect(uri) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responseredirecturi) + * Sets an HTTP redirection response (302) and decorates the response with additional methods, where: + * @param uri - an absolute or relative URI used to redirect the client to another resource. + * @return Return value: the current response object. + * Decorates the response object with the response.temporary(), response.permanent(), and response.rewritable() methods to easily change the default redirection code (302). + */ + redirect(uri: string): ResponseObject; + + /** + * response.replacer(method) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsereplacermethod) + * Sets the JSON.stringify() replacer argument where: + * @param method - the replacer function or array. Defaults to none. + * @return Return value: the current response object. + */ + replacer(method: any): ResponseObject; // TODO check the method object type. In v16 is a Json.StringifyReplacer + + /** + * response.spaces(count) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsespacescount) + * Sets the JSON.stringify() space argument where: + * @param count - the number of spaces to indent nested object keys. Defaults to no indentation. + * @return Return value: the current response object. + */ + spaces(count: number): ResponseObject; + + /** + * response.state(name, value, [options]) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsestatename-value-options) + * Sets an HTTP cookie where: + * @param name - the cookie name. + * @param value - the cookie value. If no options.encoding is defined, must be a string. See server.state() for supported encoding values. + * @param options - (optional) configuration. If the state was previously registered with the server using server.state(), the specified keys in options are merged with the default server definition. + * @return Return value: the current response object. + */ + state(name: string, value: string, options?: ServerStateCookieOptions): ResponseObject; + + /** + * response.suffix(suffix) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsesuffixsuffix) + * Sets a string suffix when the response is process via JSON.stringify() where: + * @param suffix - the string suffix. + * @return Return value: the current response object. + */ + suffix(suffix: string): ResponseObject; + + /** + * response.ttl(msec) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsettlmsec) + * Overrides the default route cache expiration rule for this response instance where: + * @param msec - the time-to-live value in milliseconds. + * @return Return value: the current response object. + */ + ttl(msec: number): ResponseObject; + + /** + * response.type(mimeType) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsetypemimetype) + * Sets the HTTP 'Content-Type' header where: + * @param value - is the mime type. + * @return Return value: the current response object. + * Should only be used to override the built-in default for each response type. + */ + type(mimeType: string): ResponseObject; + + /** + * unstate(name, [options]) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responseunstatename-options) + * Clears the HTTP cookie by setting an expired value where: + * @param name - the cookie name. + * @param options - (optional) configuration for expiring cookie. If the state was previously registered with the server using server.state(), the specified options are merged with the server definition. + * @return Return value: the current response object. + */ + unstate(name: string, options?: ServerStateCookieOptions): ResponseObject; + + /** + * response.vary(header) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsevaryheader) + * Adds the provided header to the list of inputs affected the response generation via the HTTP 'Vary' header where: + * @param header - the HTTP request header name. + * @return Return value: the current response object. + */ + vary(header: string): ResponseObject; + + /** + * response.takeover() + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsetakeover) + * Marks the response object as a takeover response. + * @return Return value: the current response object. + */ + takeover(): ResponseObject; + + /** + * response.temporary(isTemporary) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsetemporaryistemporary) + * Sets the status code to 302 or 307 (based on the response.rewritable() setting) where: + * @param isTemporary - if false, sets status to permanent. Defaults to true. + * @return Return value: the current response object. + * Only available after calling the response.redirect() method. + */ + temporary(isTemporary: boolean): ResponseObject; + + /** + * response.permanent(isPermanent) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsepermanentispermanent) + * Sets the status code to 301 or 308 (based on the response.rewritable() setting) where: + * @param isPermanent - if false, sets status to temporary. Defaults to true. + * @return Return value: the current response object. + * Only available after calling the response.redirect() method. + */ + permanent(isPermanent: boolean): ResponseObject; + + /** + * response.rewritable(isRewritable) + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responserewritableisrewritable) + * Sets the status code to 301/302 for rewritable (allows changing the request method from 'POST' to 'GET') or 307/308 for non-rewritable (does not allow changing the request method from 'POST' to 'GET'). Exact code based on the response.temporary() or response.permanent() setting. Arguments: + * @param isRewritable - if false, sets to non-rewritable. Defaults to true. + * @return Return value: the current response object. + * Only available after calling the response.redirect() method. + */ + rewritable(isRewritable: boolean): ResponseObject; + +} diff --git a/types/hapi/v17/definitions/response/response-settings.d.ts b/types/hapi/v17/definitions/response/response-settings.d.ts new file mode 100644 index 0000000000..f695bb7a07 --- /dev/null +++ b/types/hapi/v17/definitions/response/response-settings.d.ts @@ -0,0 +1,29 @@ +export interface ResponseSettings { + + /** + Defaults value: true. + If true and source is a Stream, copies the statusCode and headers properties of the stream object to the outbound response. + */ + passThrough: boolean; + + /** + Access: read only. + Default value: null (use route defaults). + Override the route json options used when source value requires stringification. + */ + stringify: any; // TODO need to be implemented. + + /** + Access: read only. + Default value: null (use route defaults). + If set, overrides the route cache with an expiration value in milliseconds. + */ + ttl: number; + + /** + Default value: false. + If true, a suffix will be automatically added to the 'ETag' header at transmission time (separated by a '-' character) when the HTTP 'Vary' header is present. + */ + varyEtag: boolean; + +} diff --git a/types/hapi/v17/definitions/route/route-options-access.d.ts b/types/hapi/v17/definitions/route/route-options-access.d.ts new file mode 100644 index 0000000000..99d8b0b3cf --- /dev/null +++ b/types/hapi/v17/definitions/route/route-options-access.d.ts @@ -0,0 +1,75 @@ +export enum AccessEntityEnum { + Any = 'any', + User = 'user', + App = 'app', +} + +export enum AccessModeEnum { + Required = 'required', + Optional = 'optional', + Try = 'try', +} + +export enum AccessPayloadEnum { + Required = 'required', + Optional = 'optional', +} + +/** Authentication options */ +export interface RouteOptionsAccess { + + /** + Default value: none. + An object or array of objects specifying the route access rules. Each rule is evaluated against an incoming request and access is granted if at least one of the rules matches. Each rule object must include at least one of scope or entity. + */ + access?: any | any[]; + + /** + Default value: false (no scope requirements). + The application scope required to access the route. Value can be a scope string or an array of scope strings. When authenticated, the credentials object scope property must contain at least one of the scopes defined to access the route. + If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' scope must not include 'a', must include 'b', and must include one of 'c' or 'd'. + You may also access properties on the request object (query, params, payload, and credentials) to populate a dynamic scope by using the '{' and '}' characters around the property name, such as 'user-{params.id}'. + */ + scope?: false | string | string[]; + + /** + Default value: 'any'. + The required authenticated entity type. If set, must match the entity value of the request authenticated credentials. Available values: + 'any' - the authentication can be on behalf of a user or application. + 'user' - the authentication must be on behalf of a user which is identified by the presence of a 'user' attribute in the credentials object returned by the authentication strategy. + 'app' - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. + */ + entity?: AccessEntityEnum; + + /** + Default value: 'required'. + The authentication mode. Available values: + 'required' - authentication is required. + 'optional' - authentication is optional - the request must include valid credentials or no credentials at all. + 'try' - similar to 'optional', any request credentials are attempted authentication, but if the credentials are invalid, the request proceeds regardless of the authentication error. + */ + mode?: AccessModeEnum; + + /** + Default value: false, unless the scheme requires payload authentication. + If set, the incoming request payload is authenticated after it is processed. Requires a strategy with payload authentication support (e.g. Hawk). Cannot be set to a value other than 'required' when the scheme sets the authentication options.payload to true. + Available values: + false - no payload authentication. + 'required' - payload authentication required. + 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). + */ + payload?: false | AccessPayloadEnum; + + /** + Default value: the default strategy set via server.auth.default(). + An array of string strategy names in the order they should be attempted. Cannot be used together with strategy. + */ + strategies?: string[]; + + /** + Default value: the default strategy set via server.auth.default(). + A string strategy names. Cannot be used together with strategies. + */ + strategy?: string; + +} diff --git a/types/hapi/v17/definitions/route/route-options-cache.d.ts b/types/hapi/v17/definitions/route/route-options-cache.d.ts new file mode 100644 index 0000000000..d3f10044e3 --- /dev/null +++ b/types/hapi/v17/definitions/route/route-options-cache.d.ts @@ -0,0 +1,29 @@ +/** + Default value: { privacy: 'default', statuses: [200], otherwise: 'no-cache' }. + If the route method is 'GET', the route can be configured to include HTTP caching directives in the response. Caching can be customized using an object with the following options: + privacy - determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are: + 'default' - no privacy flag. + 'public' - mark the response as suitable for public caching. + 'private' - mark the response as suitable only for private caching. + expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. + expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. + statuses - an array of HTTP response status code numbers (e.g. 200) which are allowed to include a valid caching directive. + otherwise - a string with the value of the 'Cache-Control' header when caching is disabled. + The default Cache-Control: no-cache header can be disabled by setting cache to false. + */ +export type RouteOptionsCache = { + privacy?: 'default' | 'public' | 'private'; + statuses?: number[]; + otherwise?: string; +} & ( + { + expiresIn?: number; + expiresAt?: undefined; + } | { + expiresIn?: undefined; + expiresAt?: string; + } | { + expiresIn?: undefined; + expiresAt?: undefined; + } +); diff --git a/types/hapi/v17/definitions/route/route-options-cors.d.ts b/types/hapi/v17/definitions/route/route-options-cors.d.ts new file mode 100644 index 0000000000..c85191db8e --- /dev/null +++ b/types/hapi/v17/definitions/route/route-options-cors.d.ts @@ -0,0 +1,20 @@ +/** + Default value: false (no CORS headers). + The Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. To enable, set cors to true, or to an object with the following options: + origin - an array of allowed origin servers strings ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a wildcard '*' character, or a single '*' origin string. If set to 'ignore', any incoming Origin header is ignored (present or not) and the 'Access-Control-Allow-Origin' header is set to '*'. Defaults to any origin ['*']. + maxAge - number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. Defaults to 86400 (one day). + headers - a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match']. + additionalHeaders - a strings array of additional headers to headers. Use this to keep the default headers in place. + exposedHeaders - a strings array of exposed headers ('Access-Control-Expose-Headers'). Defaults to ['WWW-Authenticate', 'Server-Authorization']. + additionalExposedHeaders - a strings array of additional headers to exposedHeaders. Use this to keep the default headers in place. + credentials - if true, allows user credentials to be sent ('Access-Control-Allow-Credentials'). Defaults to false. + */ +export interface RouteOptionsCors { + origin?: string[] | '*'| 'ignore'; + maxAge?: number; + headers?: string[]; + additionalHeaders?: string[]; + exposedHeaders?: string[]; + additionalExposedHeaders?: string[]; + credentials?: boolean; +} diff --git a/types/hapi/v17/definitions/route/route-options-payload.d.ts b/types/hapi/v17/definitions/route/route-options-payload.d.ts new file mode 100644 index 0000000000..15d1611dc9 --- /dev/null +++ b/types/hapi/v17/definitions/route/route-options-payload.d.ts @@ -0,0 +1,111 @@ +import {Dictionary} from "../util/util"; +import {FailAction} from "../util/fail-action"; + +export enum PayloadOutputEnum { + Data = 'data', + Stream = 'stream', + File = 'file' +} + +export enum PayloadMultipartOutputEnum { + // TODO not ready. The v16 definition have similar doubts: "// TODO type this?" + // https://github.com/hapijs/hapi/blob/master/API.md#route.options.payload.multipart + Data = 'data', + Stream = 'stream', + File = 'file', + Annotated = 'annotated', +} + +/**Determines how the request payload is processed.*/ +export interface RouteOptionsPayload { + + /** + Default value: allows parsing of the following mime types: + application/json + application/*+json + application/octet-stream + application/x-www-form-urlencoded + multipart/form-data + text/* + A string or an array of strings with the allowed mime types for the endpoint. Use this settings to limit the set of allowed mime types. Note that allowing additional mime types not listed above will not enable them to be parsed, and if parse is true, the request will result in an error response. + */ + allow?: string | string[]; + + /** + Default value: none. + An object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in compression. + */ + compression?: Dictionary; + + /** + Default value: 'application/json'. + The default content type if the 'Content-Type' request header is missing. + */ + defaultContentType?: string; + + /** + Default value: 'error' (return a Bad Request (400) error response). + A failAction value which determines how to handle payload parsing errors. + */ + failAction?: FailAction; + + /** + Default value: 1048576 (1MB). + Limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory. + */ + maxBytes?: number; + + /** + Default value: none. + Overrides payload processing for multipart requests. Value can be one of: + false - disable multipart processing. + an object with the following required options: + output - same as the output option with an additional value option: + annotated - wraps each multipart part in an object with the following keys: + headers - the part headers. + filename - the part file name. + payload - the processed part payload. + */ + multipart?: false | PayloadOutputEnum | PayloadMultipartOutputEnum ; + + /** + Default value: 'data'. + The processed payload format. The value must be one of: + 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, a raw Buffer is returned. + 'stream' - the incoming payload is made available via a Stream.Readable interface. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are provided as streams. File streams from a 'multipart/form-data' upload will also have a hapi property containing the filename and headers properties. Note that payload streams for multipart payloads are a synthetic interface created on top of the entire mutlipart content loaded into memory. To avoid loading large multipart payloads into memory, set parse to false and handle the multipart payload in the handler using a streaming parser (e.g. pez). + 'file' - the incoming payload is written to temporary file in the directory specified by the uploads settings. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are saved to disk. Note that it is the sole responsibility of the application to clean up the files generated by the framework. This can be done by keeping track of which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform cleanup. + */ + output?: PayloadOutputEnum; + + /** + Default value: none. + A mime type string overriding the 'Content-Type' header value received. + */ + override?: string; + + /** + Default value: true. + Determines if the incoming payload is processed or presented raw. Available values: + true - if the request 'Content-Type' matches the allowed mime types set by allow (for the whole payload as well as parts), the payload is converted into an object when possible. If the format is unknown, a Bad Request (400) error response is sent. Any known content encoding is decoded. + false - the raw payload is returned unmodified. + 'gunzip' - the raw payload is returned unmodified after any known content encoding is decoded. + */ + parse?: boolean | 'gunzip'; + + /** + Default value: to 10000 (10 seconds). + Payload reception timeout in milliseconds. Sets the maximum time allowed for the client to transmit the request payload (body) before giving up and responding with a Request Timeout (408) error response. + Set to false to disable. + */ + timeout?: false | number; + + /** + Default value: os.tmpdir(). + The directory used for writing file uploads. + */ + uploads?: string; + +} + + + diff --git a/types/hapi/v17/definitions/route/route-options-response.d.ts b/types/hapi/v17/definitions/route/route-options-response.d.ts new file mode 100644 index 0000000000..34293c9117 --- /dev/null +++ b/types/hapi/v17/definitions/route/route-options-response.d.ts @@ -0,0 +1,67 @@ +import {FailAction} from "../util/fail-action"; + +export enum EmptyStatusCode { + HTTP_200 = 200, + HTTP_204 = 204, +} + +/**Processing rules for the outgoing response.*/ +export interface RouteOptionsResponse { + + /** + Default value: 200. + The default HTTP status code when the payload is considered empty. Value can be 200 or 204. Note that a 200 status code is converted to a 204 only at the time of response transmission (the response status code will remain 200 throughout the request lifecycle unless manually set). + */ + emptyStatusCode?: EmptyStatusCode; + + /** + Default value: 'error' (return an Internal Server Error (500) error response). + A failAction value which defines what to do when a response fails payload validation. + */ + failAction?: FailAction; + + /** + Default value: false. + If true, applies the validation rule changes to the response payload. + */ + modify?: boolean; + + /** + Default value: none. + joi options object pass to the validation function. Useful to set global options such as stripUnknown or abortEarly (the complete list is available here). If a custom validation function is defined via schema or status then options can an arbitrary object that will be passed to this function as the second argument. + */ + options?: any; // TODO need to implementation. Here is JOI def. + + /** + Default value: true. + If false, payload range support is disabled. + */ + ranges?: boolean; + + /** + Default value: 100 (all responses). + The percent of response payloads validated (0 - 100). Set to 0 to disable all validation. + */ + sample?: number; + + /** + Default value: true (no validation). + The default response payload validation rules (for all non-error responses) expressed as one of: + true - any payload allowed (no validation). + false - no payload allowed. + a joi validation object. The options along with the request context ({ headers, params, query, payload, app, auth }) are passed to the validation function. + a validation function using the signature async function(value, options) where: + value - the pending response payload. + options - The options along with the request context ({ headers, params, query, payload, app, auth }). + if the function returns a value and modify is true, the value is used as the new response. If the original response is an error, the return value is used to override the original error output.payload. If an error is thrown, the error is processed according to failAction. + */ + schema?: boolean | any; // TODO need to implementation. Here is JOI and more. + + /** + Default value: none. + Validation schemas for specific HTTP status codes. Responses (excluding errors) not matching the listed status codes are validated using the default schema. + status is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. + */ + status?: any; // TODO need to implementation. + +} diff --git a/types/hapi/v17/definitions/route/route-options-secure.d.ts b/types/hapi/v17/definitions/route/route-options-secure.d.ts new file mode 100644 index 0000000000..6c2380fcc0 --- /dev/null +++ b/types/hapi/v17/definitions/route/route-options-secure.d.ts @@ -0,0 +1,42 @@ +/** + Default value: false (security headers disabled). + Sets common security headers. To enable, set security to true or to an object with the following options: + hsts - controls the 'Strict-Transport-Security' header, where: + true - the header will be set to max-age=15768000. This is the default value. + a number - the maxAge parameter will be set to the provided value. + an object with the following fields: + maxAge - the max-age portion of the header, as a number. Default is 15768000. + includeSubDomains - a boolean specifying whether to add the includeSubDomains flag to the header. + preload - a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. + xframe - controls the 'X-Frame-Options' header, where: + true - the header will be set to 'DENY'. This is the default value. + 'deny' - the headers will be set to 'DENY'. + 'sameorigin' - the headers will be set to 'SAMEORIGIN'. + an object for specifying the 'allow-from' rule, where: + rule - one of: + 'deny' + 'sameorigin' + 'allow-from' + source - when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. + xss - boolean that controls the 'X-XSS-PROTECTION' header for Internet Explorer. Defaults to true which sets the header to equal '1; mode=block'. + Note: this setting can create a security vulnerability in versions of Internet Exploere below 8, as well as unpatched versions of IE8. See here and here for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. + noOpen - boolean controlling the 'X-Download-Options' header for Internet Explorer, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. + noSniff - boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff'. + */ +export interface RouteOptionsSecureObject { + hsts?: boolean | number | { + maxAge?: number; + includeSubdomains?: boolean; + preload?: boolean; + }; + xframe?: true | 'deny' | 'sameorigin' | { + rule: 'deny' | 'sameorigin' | 'allow-from'; + source: string; + }; + xss: boolean; + noOpen?: boolean; + noSniff?: boolean; +} + + +export type RouteOptionsSecure = boolean | RouteOptionsSecureObject; diff --git a/types/hapi/v17/definitions/route/route-options-validate.d.ts b/types/hapi/v17/definitions/route/route-options-validate.d.ts new file mode 100644 index 0000000000..7b3c6afda4 --- /dev/null +++ b/types/hapi/v17/definitions/route/route-options-validate.d.ts @@ -0,0 +1,86 @@ +import {FailAction} from "../util/fail-action"; + +/** + Default value: { headers: true, params: true, query: true, payload: true, failAction: 'error' }. + Request input validation rules for various request components. + */ +export interface RouteOptionsValidate { + + /** + Default value: none. + An optional object with error fields copied into every validation error response. + */ + errorFields?: any; + + /** + Default value: 'error' (return a Bad Request (400) error response). + A failAction value which determines how to handle failed validations. When set to a function, the err argument includes the type of validation error under err.output.payload.validation.source. + */ + failAction?: FailAction; + + /** + Default value: true (no validation). + Validation rules for incoming request headers: + true - any headers allowed (no validation performed). + a joi validation object. + a validation function using the signature async function(value, options) where: + value - the request.headers object containing the request headers. + options - options. + if a value is returned, the value is used as the new request.headers value and the original value is stored in request.orig.headers. Otherwise, the headers are left unchanged. If an error is thrown, the error is handled according to failAction. + Note that all header field names must be in lowercase to match the headers normalized by node. + */ + headers?: boolean | any; // TODO need to implementation. Here is JOI and more. + + /** + Default value: none. + An options object passed to the joi rules or the custom validation methods. Used for setting global options such as stripUnknown or abortEarly (the complete list is available here). + If a custom validation function (see headers, params, query, or payload above) is defined then options can an arbitrary object that will be passed to this function as the second parameter. + The values of the other inputs (i.e. headers, query, params, payload, app, and auth) are added to the options object under the validation context (accessible in rules as Joi.ref('$query.key')). + Note that validation is performed in order (i.e. headers, params, query, and payload) and if type casting is used (e.g. converting a string to a number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. + If the validation rules for headers, params, query, and payload are defined at both the server routes level and at the route level, the individual route settings override the routes defaults (the rules are not merged). + */ + options?: any; // TODO need to be implementation + + /** + Default value: true (no validation). + Validation rules for incoming request path parameters, after matching the path against the route, extracting any parameters, and storing them in request.params, where: + true - any path parameter value allowed (no validation performed). + a joi validation object. + a validation function using the signature async function(value, options) where: + value - the request.params object containing the request path parameters. + options - options. + if a value is returned, the value is used as the new request.params value and the original value is stored in request.orig.params. Otherwise, the path parameters are left unchanged. If an error is thrown, the error is handled according to failAction. + Note that failing to match the validation rules to the route path parameters definition will cause all requests to fail. + */ + params?: boolean | any; // TODO need to implementation. Here is JOI and more. + + /** + Default value: true (no validation). + Validation rules for incoming request payload (request body), where: + true - any payload allowed (no validation performed). + false - no payload allowed. + a joi validation object. + Note that empty payloads are represented by a null value. If a validation schema is provided and empty payload are allowed, the schema must be explicitly defined by setting the rule to a joi schema with null allowed (e.g. Joi.object({ keys here }).allow(null)). + a validation function using the signature async function(value, options) where: + value - the request.query object containing the request query parameters. + options - options. + if a value is returned, the value is used as the new request.payload value and the original value is stored in request.orig.payload. Otherwise, the payload is left unchanged. If an error is thrown, the error is handled according to failAction. + Note that validating large payloads and modifying them will cause memory duplication of the payload (since the original is kept), as well as the significant performance cost of validating large amounts of data. + */ + payload?: boolean | any; // TODO need to implementation. Here is JOI and more. + + /** + Default value: true (no validation). + Validation rules for incoming request URI query component (the key-value part of the URI between '?' and '#'). The query is parsed into its individual key-value pairs, decoded, and stored in request.query prior to validation. Where: + true - any query parameter value allowed (no validation performed). + false - no query parameter value allowed. + a joi validation object. + a validation function using the signature async function(value, options) where: + value - the request.query object containing the request query parameters. + options - options. + if a value is returned, the value is used as the new request.query value and the original value is stored in request.orig.query. Otherwise, the query parameters are left unchanged. If an error is thrown, the error is handled according to failAction. + Note that changes to the query parameters will not be reflected in request.url. + */ + query?: boolean | any; // TODO need to implementation. Here is JOI and more. + +} diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/v17/definitions/route/route-options.d.ts new file mode 100644 index 0000000000..d393e25810 --- /dev/null +++ b/types/hapi/v17/definitions/route/route-options.d.ts @@ -0,0 +1,224 @@ +import {RouteOptionsAccess} from "./route-options-access"; +import {RouteOptionsCache} from "./route-options-cache"; +import {Dictionary} from "../util/util"; +import {RouteOptionsCors} from "./route-options-cors"; +import {RouteOptionsResponse} from "./route-options-response"; +import {RouteOptionsPayload} from "./route-options-payload"; +import {RouteOptionsSecure} from "./route-options-secure"; +import {FailAction} from "../util/fail-action"; +import {RouteOptionsValidate} from "./route-options-validate"; +import {PluginSpecificConfiguration} from "../plugin/plugin"; + +/** Each route can be customized to change the default behavior of the request lifecycle. */ +export interface RouteOptions { + + /** Application-specific route configuration state. Should not be used by plugins which should use options.plugins[name] instead.*/ + app?: any; + + /** + Route authentication configuration. Value can be: + false to disable authentication if a default strategy is set. + a string with the name of an authentication strategy registered with server.auth.strategy(). The strategy will be set to 'required' mode. + an authentication configuration object. + */ + auth?: false | string | RouteOptionsAccess; + + /** + Default value: null. + An object passed back to the provided handler (via this) when called. Ignored if the method is an arrow function. + */ + bind?: any; + + /** + Default value: { privacy: 'default', statuses: [200], otherwise: 'no-cache' }. + */ + cache?: false | RouteOptionsCache; + + /** + An object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in compression. + */ + compression?: Dictionary; + + /** + Default value: false (no CORS headers). + */ + cors?: false | RouteOptionsCors; + + /** + Default value: none. + Route description used for generating documentation (string). + This setting is not available when setting server route defaults using server.options.routes. + */ + description?: string; + + /** + Default value: none. + Route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the server.ext(events) event argument. + */ + ext?: any; //TODO need to review and rewrite this definition + + /** + Default value: { relativeTo: '.' }. + Defines the behavior for accessing files: + relativeTo - determines the folder relative paths are resolved against. + */ + files?: { + relativeTo: string; + } + + /** + Default value: none. + The route handler function performs the main business logic of the route and sets the respons. handler can be assigned: + a lifecycle method. + an object with a single property using the name of a handler type registred with the server.handler() method. The matching property value is passed as options to the registered handler generator. + const handler = function (request, h) { + return 'success'; + }; + Note: handlers using a fat arrow style function cannot be bound to any bind property. Instead, the bound context is available under h.context. + */ + handler?: any; //TODO need to review and rewrite this definition + + /** + Default value: none. + An optional unique identifier used to look up the route using server.lookup(). Cannot be assigned to routes added with an array of methods. + */ + id?: string; + + /** + Default value: false. + If true, the route cannot be accessed through the HTTP listener but only through the server.inject() interface with the allowInternals option set to true. Used for internal routes that should not be accessible to the outside world. + */ + isInternal?: boolean; + + /** + Default value: none. + Optional arguments passed to JSON.stringify() when converting an object or error response to a string payload or escaping it after stringification. Supports the following: + replacer - the replacer function or array. Defaults to no action. + space - number of spaces to indent nested object keys. Defaults to no indentation. + suffix - string suffix added after conversion to JSON string. Defaults to no suffix. + escape - calls Hoek.jsonEscape() after conversion to JSON string. Defaults to false. + + TODO this definition in v16 is a bit confuse for me. Need review and maybe rewrite. + */ + json?: { + replaces?: any | any[]; + space?: number | string; + suffix?: string; + escape?: boolean; // TODO boolean only? + }; + + /** + Default value: none. + Enables JSONP support by setting the value to the query parameter name containing the function name used to wrap the response payload. + For example, if the value is 'callback', a request comes in with 'callback=me', and the JSON response is '{ "a":"b" }', the payload will be 'me({ "a":"b" });'. Cannot be used with stream responses. + The 'Content-Type' response header is set to 'text/javascript' and the 'X-Content-Type-Options' response header is set to 'nosniff', and will override those headers even if explicitly set by response.type(). + */ + jsonp?: string; + + /** + Default value: { collect: false }. + Request logging options: + collect - if true, request-level logs (both internal and application) are collected and accessible via request.logs. + */ + log?: boolean; + + /** + Default value: none. + Route notes used for generating documentation (string or array of strings). + This setting is not available when setting server route defaults using server.options.routes. + */ + notes?: string | string[]; + + /** Determines how the request payload is processed. */ + payload?: RouteOptionsPayload; + + /** + Default value: {}. + Plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. + */ + plugins?: PluginSpecificConfiguration; + + /** + Default value: none. + The pre option allows defining methods for performing actions before the handler is called. These methods allow breaking the handler logic into smaller, reusable components that can be shared ascross routes, as well as provide a cleaner error handling of prerequisite operations (e.g. load required reference data from a database). + pre is assigned an ordered array of methods which are called serially in order. If the pre array contains another array of methods as one of its elements, those methods are called in parallel. Note that during parallel execution, if any of the methods error, return a takeover response, or abort signal, the other parallel methods will continue to execute but will be ignored once completed. + pre can be assigned a mixed array of: + an array containing the elements listed below, which are executed in parallel. + an object with: + method - a lifecycle method. + assign - key name used to assign the response of the method to in request.pre and request.preResponses. + failAction - A failAction value which determine what to do when a pre-handler method throws an error. If assign is specified and the failAction setting is not 'error', the error will be assigned. + a method function - same as including an object with a single method key. + Note that pre-handler methods do not behave the same way other lifecycle methods do when a value is returned. Instead of the return value becoming the new response payload, the value is used to assign the corresponding request.pre and request.preResponses properties. Otherwise, the handling of errors, takeover response response, or abort signal behave the same as any other lifecycle methods. + */ + pre?: any; // TODO is necessary come back here. In v16 we can see the definition but in this moment we don't have all the definitions for make this one. + + /** + * Processing rules for the outgoing response. + */ + response?: RouteOptionsResponse; + + /** + Default value: false (security headers disabled). + Sets common security headers. To enable, set security to true or to an object with the following options: + hsts - controls the 'Strict-Transport-Security' header, where: + true - the header will be set to max-age=15768000. This is the default value. + a number - the maxAge parameter will be set to the provided value. + an object with the following fields: + maxAge - the max-age portion of the header, as a number. Default is 15768000. + includeSubDomains - a boolean specifying whether to add the includeSubDomains flag to the header. + preload - a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. + xframe - controls the 'X-Frame-Options' header, where: + true - the header will be set to 'DENY'. This is the default value. + 'deny' - the headers will be set to 'DENY'. + 'sameorigin' - the headers will be set to 'SAMEORIGIN'. + an object for specifying the 'allow-from' rule, where: + rule - one of: + 'deny' + 'sameorigin' + 'allow-from' + source - when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. + xss - boolean that controls the 'X-XSS-PROTECTION' header for Internet Explorer. Defaults to true which sets the header to equal '1; mode=block'. + Note: this setting can create a security vulnerability in versions of Internet Exploere below 8, as well as unpatched versions of IE8. See here and here for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. + noOpen - boolean controlling the 'X-Download-Options' header for Internet Explorer, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. + noSniff - boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff'. + */ + security?: RouteOptionsSecure; + + /** + Default value: { parse: true, failAction: 'error' }. + HTTP state management (cookies) allows the server to store information on the client which is sent back to the server with every request (as defined in RFC 6265). state supports the following options: + parse - determines if incoming 'Cookie' headers are parsed and stored in the request.state object. + failAction - A failAction value which determines how to handle cookie parsing errors. Defaults to 'error' (return a Bad Request (400) error response). + */ + state?: { + parse?: boolean; + failAction?: FailAction; + } + + /** + Default value: none. + Route tags used for generating documentation (array of strings). + This setting is not available when setting server route defaults using server.options.routes. + */ + tags?: string[]; + + /** + Default value: { server: false }. + Timeouts for processing durations. + */ + timeout?: { + /** response timeout in milliseconds. Sets the maximum time allowed for the server to respond to an incoming client request before giving up and responding with a Service Unavailable (503) error response. Disabled by default (false). */ + server?: boolean | number; + /** by default, node sockets automatically timeout after 2 minutes. Use this option to override this behavior. Defaults to undefined which leaves the node default unchanged. Set to false to disable socket timeouts. */ + socket?: boolean | number; + }; + + /** + Default value: { headers: true, params: true, query: true, payload: true, failAction: 'error' }. + Request input validation rules for various request components. + */ + validate?: RouteOptionsValidate; + + +} diff --git a/types/hapi/v17/definitions/server/server-connection-options.d.ts b/types/hapi/v17/definitions/server/server-connection-options.d.ts new file mode 100644 index 0000000000..383d601dc0 --- /dev/null +++ b/types/hapi/v17/definitions/server/server-connection-options.d.ts @@ -0,0 +1,54 @@ +import {RouteOptions} from "../route/route-options"; + +/** Any connections configuration server defaults can be included to override and customize the individual connection. */ +export interface IServerConnectionOptions extends IConnectionConfigurationServerDefaults { + /** - the public hostname or IP address. Used only to set server.info.host and server.info.uri. If not configured, defaults to the operating system hostname and if not available, to 'localhost'.*/ + host?: string; + /** - sets the host name or IP address the connection will listen on.If not configured, defaults to host if present, otherwise to all available network interfaces (i.e. '0.0.0.0').Set to 127.0.0.1 or localhost to restrict connection to only those coming from the same machine.*/ + address?: string; + /** - the TCP port the connection will listen to.Defaults to an ephemeral port (0) which uses an available port when the server is started (and assigned to server.info.port).If port is a string containing a '/' character, it is used as a UNIX domain socket path and if it starts with '\.\pipe' as a Windows named pipe.*/ + port?: string | number; + /** - the full public URI without the path (e.g. 'http://example.com:8080').If present, used as the connection info.uri otherwise constructed from the connection settings.*/ + uri?: string; + /** - optional node.js HTTP (or HTTPS) http.Server object or any compatible object.If the listener needs to be manually started, set autoListen to false.If the listener uses TLS, set tls to true.*/ + listener?: any; + /** - indicates that the connection.listener will be started manually outside the framework.Cannot be specified with a port setting.Defaults to true.*/ + autoListen?: boolean; + /** caching headers configuration: */ + cache?: { + /** - an array of HTTP response status codes (e.g. 200) which are allowed to include a valid caching directive.Defaults to [200]. */ + statuses: number[]; + }; + /** - a string or string array of labels used to server.select() specific connections matching the specified labels.Defaults to an empty array [](no labels).*/ + labels?: string | string[]; + /** - used to create an HTTPS connection.The tls object is passed unchanged as options to the node.js HTTPS server as described in the node.js HTTPS documentation.Set to true when passing a listener object that has been configured to use TLS directly. */ + tls?: boolean | { key?: string; cert?: string; pfx?: string; } | Object; +} + +export interface IConnectionConfigurationServerDefaults { + /** application-specific connection configuration which can be accessed via connection.settings.app. Provides a safe place to store application configuration without potential conflicts with the framework internals. Should not be used to configure plugins which should use plugins[name]. Note the difference between connection.settings.app which is used to store configuration values and connection.app which is meant for storing run-time state. */ + app?: any; + /** if false, response content encoding is disabled. Defaults to true */ + compression?: boolean; + /** connection load limits configuration where: */ + load?: { + /** maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ + maxHeapUsedBytes?: number; + /** maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ + maxRssBytes?: number; + /** maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ + maxEventLoopDelay?: number; + }; + /** plugin-specific configuration which can later be accessed via connection.settings.plugins. Provides a place to store and pass connection-specific plugin configuration. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between connection.settings.plugins which is used to store configuration values and connection.plugins which is meant for storing run-time state. */ + plugins?: any; + /** controls how incoming request URIs are matched against the routing table: */ + router?: { + /** determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true. */ + isCaseSensitive: boolean; + /** removes trailing slashes on incoming paths. Defaults to false. */ + stripTrailingSlash: boolean; + }; + /** a route options object used to set the default configuration for every route. */ + routes?: RouteOptions; + // state?: IServerState; TODO +} diff --git a/types/hapi/v17/definitions/server/server-options-cache.d.ts b/types/hapi/v17/definitions/server/server-options-cache.d.ts new file mode 100644 index 0000000000..cd71537d85 --- /dev/null +++ b/types/hapi/v17/definitions/server/server-options-cache.d.ts @@ -0,0 +1,25 @@ +import * as Catbox from "catbox"; + +/** + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-cache) + * hapi uses catbox for its cache implementation which includes support for common storage solutions (e.g. Redis, + * MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. + */ +export interface ServerOptionsCache extends Catbox.PolicyOptions { + + /** a class, a prototype function, or a catbox engine object. */ + engine?: Catbox.EnginePrototypeOrObject; + + /** an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. */ + name?: string; + + /** if true, allows multiple cache users to share the same segment (e.g. multiple methods using the same cache storage container). Default to false. */ + shared?: boolean; + + /** (optional) string used to isolate cached data. Defaults to 'hapi-cache'. */ + partition?: string; + + /** other options passed to the catbox strategy used. Other options are only passed to catbox when engine above is a class or function and ignored if engine is a catbox engine object). */ + [s: string]: any; + +} diff --git a/types/hapi/v17/definitions/server/server-options.d.ts b/types/hapi/v17/definitions/server/server-options.d.ts new file mode 100644 index 0000000000..38af02ac44 --- /dev/null +++ b/types/hapi/v17/definitions/server/server-options.d.ts @@ -0,0 +1,184 @@ +import {ServerOptionsCache} from "./server-options-cache"; +import * as http from "http"; +import * as https from "https"; +import * as Catbox from "catbox"; +import {MimosOptions} from "mimos"; +import {PluginSpecificConfiguration, RouteOptions} from "hapi"; + + +/** + * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-server-options) + * he server options control the behavior of the server object. Note that the options object is deeply cloned + * (with the exception of listener which is shallowly copied) and should not contain any values that are unsafe to perform deep copy on. + * All options are optionals. + */ +export interface ServerOptions { + + /** + Default value: '0.0.0.0' (all available network interfaces). + Sets the hostname or IP address the server will listen on. If not configured, defaults to host if present, otherwise to all available network interfaces. Set to '127.0.0.1' or 'localhost' to restrict the server to only those coming from the same host. + */ + address?: string; + + /** + Default value: {}. + Provides application-specific configuration which can later be accessed via server.settings.app. The framework does not interact with this object. It is simply a reference made available anywhere a server reference is provided. + Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. + */ + app?: any; + + /** + Default value: true. + Used to disable the automatic initialization of the listener. When false, indicates that the listener will be started manually outside the framework. + Cannot be set to true along with a port value. + */ + autoListen?: boolean; + + /** + Default value: { engine: require('catbox-memory' }. + Sets up server-side caching providers. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and capabilities. + hapi uses catbox for its cache implementation which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. + The server cache configuration only defines the storage container itself. The configuration can be assigned one or more (array): + a class or prototype function (usually obtained by calling require() on a catbox strategy such as require('catbox-redis')). A new catbox client will be created internally using this function. + a configuration object with the following: + engine - a class, a prototype function, or a catbox engine object. + name - an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. + shared - if true, allows multiple cache users to share the same segment (e.g. multiple methods using the same cache storage container). Default to false. + partition - (optional) string used to isolate cached data. Defaults to 'hapi-cache'. + other options passed to the catbox strategy used. Other options are only passed to catbox when engine above is a class or function and ignored if engine is a catbox engine object). + */ + cache?: Catbox.EnginePrototype | ServerOptionsCache | ServerOptionsCache[]; + + /** + Default value: { minBytes: 1024 }. + Defines server handling of content encoding requests. If false, response content encoding is disabled and no compression is performed by the server. + */ + compression?: boolean; + + /** + Default value: '1024'. + Sets the minimum response payload size in bytes that is required for content encoding compression. If the payload size is under the limit, no compression is performed. + */ + minBytes?: number; + + /** + Default value: { request: ['implementation'] }. + Determines which logged events are sent to the console. This should only be used for development and does not affect which events are actually logged internally and recorded. Set to false to disable all console logging, or to an object with: + log - a string array of server log tags to be displayed via console.error() when the events are logged via server.log() as well as internally generated server logs. Defaults to no output. + request - a string array of request log tags to be displayed via console.error() when the events are logged via request.log() as well as internally generated request logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. To display all request logs, set it to '*'. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. + For example, to display all errors, set the log or request to ['error']. To turn off all output set the log or request to false. To display all server logs, set the log or request to '*'. To disable all debug information, set debug to false. + */ + debug?: false | { + log?: string[] | false; + request?: string[] | false; + }; + + /** + Default value: the operating system hostname and if not available, to 'localhost'. + The public hostname or IP address. Used to set server.info.host and server.info.uri and as address is none provided. + */ + host?: string; + + /** + Default value: none. + An optional node HTTP (or HTTPS) http.Server object (or an object with a compatible interface). + If the listener needs to be manually started, set autoListen to false. + If the listener uses TLS, set tls to true. + */ + listener?: http.Server; + + /** + Default value: { sampleInterval: 0 }. + Server excessive load handling limits where: + sampleInterval - the frequency of sampling in milliseconds. When set to 0, the other load options are ignored. Defaults to 0 (no sampling). + maxHeapUsedBytes - maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). + maxRssBytes - maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). + maxEventLoopDelay - maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). + */ + load?: { + /** the frequency of sampling in milliseconds. When set to 0, the other load options are ignored. Defaults to 0 (no sampling). */ + sampleInterval?: number; + /** maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ + maxHeapUsedBytes?: number; + /** maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).*/ + maxRssBytes?: number; + /** maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).*/ + maxEventLoopDelay?: number; + }; + + /** + Default value: none. + Options passed to the mimos module when generating the mime database used by the server (and accessed via server.mime): + override - an object hash that is merged into the built in mime information specified here. Each key value pair represents a single mime object. Each override value must contain: + key - the lower-cased mime-type string (e.g. 'application/javascript'). + value - an object following the specifications outlined here. Additional values include: + type - specify the type value of result objects, defaults to key. + predicate - method with signature function(mime) when this mime type is found in the database, this function will execute to allows customizations. + */ + mime?: MimosOptions; + + /** + Default value: {}. + Plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state. + */ + plugins?: PluginSpecificConfiguration; + + /** + Default value: 0 (an ephemeral port). + The TCP port the server will listen to. Defaults the next available port when the server is started (and assigned to server.info.port). + If port is a string containing a '/' character, it is used as a UNIX domain socket path. If it starts with '\.\pipe', it is used as a Windows named pipe. + */ + port?: number | string; + + /** + Default value: { isCaseSensitive: true, stripTrailingSlash: false }. + Controls how incoming request URIs are matched against the routing table: + isCaseSensitive - determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true. + stripTrailingSlash - removes trailing slashes on incoming paths. Defaults to false. + */ + router?: { + isCaseSensitive?: boolean; + stripTrailingSlash?: boolean; + }; + + /** + Default value: none. + A route options object used as the default configuration for every route. + */ + routes?: RouteOptions; + + /** + Default value: + { + strictHeader: true, + ignoreErrors: false, + isSecure: true, + isHttpOnly: true, + isSameSite: 'Strict', + encoding: 'none' + } + Sets the default configuration for every state (cookie) set explicitly via server.state() or implicitly (without definition) using the state configuration object. + */ + // TODO I am not sure if I need to use all the server.state() definition (like the default value) OR only the options below. The v16 use "any" here. + state?: { + strictHeader?: boolean, + ignoreErrors?: boolean, + isSecure?: boolean, + isHttpOnly?: boolean, + isSameSite?: false | 'Strict' | 'Lax', + encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron' + }; + + /** + Default value: none. + Used to create an HTTPS connection. The tls object is passed unchanged to the node HTTPS server as described in the node HTTPS documentation. + */ + tls?: true | https.RequestOptions; + + /** + Default value: constructed from runtime server information. + The full public URI without the path (e.g. 'http://example.com:8080'). If present, used as the server server.info.uri, otherwise constructed from the server settings. + */ + uri?: string; + +} diff --git a/types/hapi/v17/definitions/server/server-realm.d.ts b/types/hapi/v17/definitions/server/server-realm.d.ts new file mode 100644 index 0000000000..56b05df36e --- /dev/null +++ b/types/hapi/v17/definitions/server/server-realm.d.ts @@ -0,0 +1,34 @@ +import {PluginsStates} from "../plugin/plugin"; + +/** + Access: read only. + The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When registering a plugin or an authentication scheme, a server object reference is provided with a new server.realm container specific to that registration. It allows each plugin to maintain its own settings without leaking and affecting other plugins. + For example, a plugin can set a default file path for local resources without breaking other plugins' configured paths. When calling server.bind(), the active realm's settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). + */ +export interface ServerRealm { + /** when the server object is provided as an argument to the plugin register() method, modifiers provides the registration preferences passed the server.register() method and includes: */ + modifiers: { + /** routes preferences: */ + route: { + /** the route path prefix used by any calls to server.route() from the server. Note that if a prefix is used and the route path is set to '/', the resulting path will not include the trailing slash. */ + prefix: string; + /** the route virtual host settings used by any calls to server.route() from the server. */ + vhost: string; + } + }; + /** the realm of the parent server object, or null for the root server. */ + parent: any | null; + /** the active plugin name (empty string if at the server root). */ + plugin: string; + /** the plugin options object passed at registration. */ + pluginOptions: any; // OptionsPassedToPlugin; + /** plugin-specific state to be shared only among activities sharing the same active state. plugins is an object where each key is a plugin name and the value is the plugin state. */ + plugins: PluginsStates; + /** settings overrides */ + settings: { + files: { + relativeTo: string; + }; + bind: any; + }; +} diff --git a/types/hapi/v17/definitions/server/server-state-options.d.ts b/types/hapi/v17/definitions/server/server-state-options.d.ts new file mode 100644 index 0000000000..289507b849 --- /dev/null +++ b/types/hapi/v17/definitions/server/server-state-options.d.ts @@ -0,0 +1,61 @@ +import {Request} from "../request/request"; + +/** + * Optional cookie settings + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverstatename-options) + */ +export interface ServerStateCookieOptions { + /** time-to-live in milliseconds. Defaults to null (session time-life - cookies are deleted when the browser is closed). */ + ttl?: number | null; + /** sets the 'Secure' flag. Defaults to true. */ + isSecure?: boolean; + /** sets the 'HttpOnly' flag. Defaults to true. */ + isHttpOnly?: boolean; + /** + * sets the 'SameSite' flag. The value must be one of: + * * false - no flag. + * * 'Strict' - sets the value to 'Strict' (this is the default value). + * * 'Lax' - sets the value to 'Lax'. + */ + isSameSite?: false | 'Strict' | 'Lax'; + /** the path scope. Defaults to null (no path). */ + path?: string | null; + /** the domain scope. Defaults to null (no domain). */ + domain?: string | null; + /** + * if present and the cookie was not received from the client or explicitly set by the route handler, the + * cookie is automatically added to the response with the provided value. The value can be + * a function with signature async function(request) where: + */ + autoValue?(request: Request): void; + /** + * encoding performs on the provided value before serialization. Options are: + * * 'none' - no encoding. When used, the cookie value must be a string. This is the default value. + * * 'base64' - string value is encoded using Base64. + * * 'base64json' - object value is JSON-stringified then encoded using Base64. + * * 'form' - object value is encoded using the x-www-form-urlencoded method. + * * 'iron' - Encrypts and sign the value using iron. + */ + encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron'; + /** + * an object used to calculate an HMAC for cookie integrity validation. This does not provide privacy, only a mean to verify that the cookie value was generated by the server. Redundant when 'iron' encoding is used. Options are: + * * integrity - algorithm options. Defaults to require('iron').defaults.integrity. + * * password - password used for HMAC key generation (must be at least 32 characters long). + */ + sign?: { + integrity?: any; // TODO make iron definitions and getting typing from iron + password: string; + }; + /** password used for 'iron' encoding (must be at least 32 characters long). */ + password?: string; + /** options for 'iron' encoding. Defaults to require('iron').defaults. */ + iron?: any; // TODO make iron definitions and getting typing from iron + /** if true, errors are ignored and treated as missing cookies. */ + ignoreErrors?: boolean; + /** if true, automatically instruct the client to remove invalid cookies. Defaults to false. */ + clearInvalid?: boolean; + /** if false, allows any cookie value including values in violation of RFC 6265. Defaults to true. */ + strictHeader?: boolean; + /** used by proxy plugins (e.g. h2o2). */ + passThrough?: any; +} diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts new file mode 100644 index 0000000000..2455151678 --- /dev/null +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -0,0 +1,45 @@ +import Events = require('events'); +import {ServerOptions} from "./server-options"; +import {Dictionary} from "../util/util"; + +/** + * The server object is the main application container. The server manages all incoming requests along with all + * the facilities provided by the framework. Each server supports a single connection (e.g. listen to port 80). + */ +export class Server extends Events.EventEmitter { + + /** + Creates a new server object where: + @param options - (optional) a server configuration object. + */ + constructor(options: ServerOptions); + + /** + * Provides a safe place to store server-specific run-time application data without potential conflicts with + * the framework internals. The data can be accessed whenever the server is accessible. + * Initialized with an empty object. + */ + app?: any; + + /** + * Access: authentication strategy specific. + * An object where each key is an authentication strategy name and the value is the exposed strategy API. + * Available only when the authentication scheme exposes an API by returning an api key in the object + * returned from its implementation function. + */ + // TODO is that definition right? It's need review. The v16 is very different. + auth?: { + api: Dictionary; + } + + /** + * Access: read only. + * Contains the default authentication configuration is a default strategy was set via server.auth.default(). + */ + // TODO it needs to be implemented. I didn't understand the description yet. + + // TODO It"s not finished + + + +} diff --git a/types/hapi/v17/definitions/util/fail-action.d.ts b/types/hapi/v17/definitions/util/fail-action.d.ts new file mode 100644 index 0000000000..7b2eb4c4b8 --- /dev/null +++ b/types/hapi/v17/definitions/util/fail-action.d.ts @@ -0,0 +1,4 @@ +// TODO It should be replaced by FailAction definition (with lifecycle method) in the future. +// https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-failAction +export type FailAction = 'error' | 'log' | 'ignore' | any; + diff --git a/types/hapi/v17/definitions/util/util.d.ts b/types/hapi/v17/definitions/util/util.d.ts new file mode 100644 index 0000000000..bfe54031e8 --- /dev/null +++ b/types/hapi/v17/definitions/util/util.d.ts @@ -0,0 +1,10 @@ +export interface Dictionary { + [key: string]: T; +} + +export enum HttpMethod { + Get = "get", + Post = "post", + Put = "put", + Delete= "delete", +} diff --git a/types/hapi/v17/hapi-tests.ts b/types/hapi/v17/hapi-tests.ts new file mode 100644 index 0000000000..e0c05909c0 --- /dev/null +++ b/types/hapi/v17/hapi-tests.ts @@ -0,0 +1,2 @@ +import { Server } from "hapi"; +const server = new Server({ port: 3000, host: 'localhost' }); diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts new file mode 100644 index 0000000000..1e3403e4e1 --- /dev/null +++ b/types/hapi/v17/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for hapi 17.0 +// Project: https://github.com/hapijs/hapi +// Definitions by: Marc Bornträger +// Rafael Souza Fijalkowski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Note/Disclaimer: None. + +/// + +/** PLUGIN */ +export * from './definitions/plugin/plugin' + +/** REQUEST */ +export * from './definitions/request/request' + +/** RESPONSE */ +export * from './definitions/response/response-object' +export * from './definitions/response/response-settings' + +/** SERVER */ +export * from './definitions/server/server' +export * from './definitions/server/server-connection-options' +export * from './definitions/server/server-options' +export * from './definitions/server/server-options-cache' +export * from './definitions/server/server-realm' +export * from './definitions/server/server-state-options' + +/** ROUTE */ +export * from './definitions/route/route-options' +export * from './definitions/route/route-options-access' +export * from './definitions/route/route-options-cache' +export * from './definitions/route/route-options-cors' +export * from './definitions/route/route-options-payload' +export * from './definitions/route/route-options-response' +export * from './definitions/route/route-options-secure' +export * from './definitions/route/route-options-validate' + +/** SERVER */ +export * from './definitions/server/server' +export * from './definitions/server/server-connection-options' +export * from './definitions/server/server-options' +export * from './definitions/server/server-options-cache' +export * from './definitions/server/server-realm' +export * from './definitions/server/server-state-options' + +/** UTIL */ +export * from './definitions/util/fail-action' +export * from './definitions/util/util' diff --git a/types/hapi/v17/tsconfig.json b/types/hapi/v17/tsconfig.json new file mode 100644 index 0000000000..216332b184 --- /dev/null +++ b/types/hapi/v17/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": false, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "hapi": [ + "hapi/v17" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "hapi-tests.ts" + ] +} diff --git a/types/hapi/v17/tslint.json b/types/hapi/v17/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/hapi/v17/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} From 803f500d22b30b6ecfbd210768693ae4b5776a92 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Thu, 23 Nov 2017 01:01:00 -0300 Subject: [PATCH 005/298] More Server Definitions. --- .../v17/definitions/server/server-events.d.ts | 12 +++ .../v17/definitions/server/server-info.d.ts | 55 ++++++++++++++ types/hapi/v17/definitions/server/server.d.ts | 74 ++++++++++++++++++- 3 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 types/hapi/v17/definitions/server/server-events.d.ts create mode 100644 types/hapi/v17/definitions/server/server-info.d.ts diff --git a/types/hapi/v17/definitions/server/server-events.d.ts b/types/hapi/v17/definitions/server/server-events.d.ts new file mode 100644 index 0000000000..4aca038e7f --- /dev/null +++ b/types/hapi/v17/definitions/server/server-events.d.ts @@ -0,0 +1,12 @@ +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) + * Access: podium public interface. + * The server events emitter. Utilizes the podium with support for event criteria validation, channels, and filters. + */ +// TODO it needs to be implemented +export interface ServerEvents { + + + + +} diff --git a/types/hapi/v17/definitions/server/server-info.d.ts b/types/hapi/v17/definitions/server/server-info.d.ts new file mode 100644 index 0000000000..399543e08e --- /dev/null +++ b/types/hapi/v17/definitions/server/server-info.d.ts @@ -0,0 +1,55 @@ +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo) + * An object containing information about the server where: + */ +export interface ServerInfo { + + /** + * a unique server identifier (using the format '{hostname}:{pid}:{now base36}'). + */ + id: string; + + /** + * server creation timestamp. + */ + created: number; + + /** + * server start timestamp (0 when stopped). + */ + started: number; + + /** + * the connection [port](https://github.com/hapijs/hapi/blob/master/API.md#server.options.port) based on the following rules: + * * before the server has been started: the configured port value. + * * after the server has been started: the actual port assigned when no port is configured or was set to 0. + */ + port: number | string; + + /** + * The [host](https://github.com/hapijs/hapi/blob/master/API.md#server.options.host) configuration value. + */ + host: string; + + /** + * the active IP address the connection was bound to after starting. Set to undefined until the server has been + * started or when using a non TCP port (e.g. UNIX domain socket). + */ + address: undefined | string; + + /** + * the protocol used: + * * 'http' - HTTP. + * * 'https' - HTTPS. + * * 'socket' - UNIX domain socket or Windows named pipe. + */ + protocol: 'http' | 'https' | 'socket'; + + /** + * a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains + * the uri value if set, otherwise constructed from the available settings. If no port is configured or is set + * to 0, the uri will not include a port component until the server is started. + */ + uri: string; + +} diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 2455151678..c47fef7855 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -1,12 +1,16 @@ -import Events = require('events'); import {ServerOptions} from "./server-options"; +import {ServerInfo} from "./server-info"; import {Dictionary} from "../util/util"; +import {Request} from "../request/request"; +import * as http from "http"; +import * as events from 'events'; + /** * The server object is the main application container. The server manages all incoming requests along with all * the facilities provided by the framework. Each server supports a single connection (e.g. listen to port 80). */ -export class Server extends Events.EventEmitter { +export class Server extends events.EventEmitter { /** Creates a new server object where: @@ -28,15 +32,77 @@ export class Server extends Events.EventEmitter { * returned from its implementation function. */ // TODO is that definition right? It's need review. The v16 is very different. - auth?: { + auth: { api: Dictionary; } /** * Access: read only. - * Contains the default authentication configuration is a default strategy was set via server.auth.default(). + * Contains the default authentication configuration is a default strategy was set via [server.auth.default()](https://github.com/hapijs/hapi/blob/master/API.md#server.auth.default()). */ // TODO it needs to be implemented. I didn't understand the description yet. + //server.auth.settings.default + + + /** + * Provides access to the decorations already applied to various framework interfaces. The object must not be + * modified directly, but only through server.decorate. Contains: + * * request - decorations on the request object. + * * toolkit - decorations on the response toolkit. + * * server - decorations on the server object. + */ + decorations: { + request: Request, + toolkit: any, // TODO Request Toolkit (https://github.com/hapijs/hapi/blob/master/API.md#response-toolkit) needs to be implemented. + server: Server + } + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo) + * An object containing information about the server where: + * * id - a unique server identifier (using the format '{hostname}:{pid}:{now base36}'). + * * created - server creation timestamp. + * * started - server start timestamp (0 when stopped). + * * port - the connection port based on the following rules: + * * host - The host configuration value. + * * address - the active IP address the connection was bound to after starting. Set to undefined until the server has been started or when using a non TCP port (e.g. UNIX domain socket). + * * protocol - the protocol used: + * * 'http' - HTTP. + * * 'https' - HTTPS. + * * 'socket' - UNIX domain socket or Windows named pipe. + * * uri - a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains the uri value if set, otherwise constructed from the available settings. If no port is configured or is set to 0, the uri will not include a port component until the server is started. + */ + info: ServerInfo; + + /** + * Access: read only and listener public interface. + * The node HTTP server object. + */ + listener: http.Server; + + /** + * An object containing the process load metrics (when load.sampleInterval is enabled): + * * eventLoopDelay - event loop delay milliseconds. + * * heapUsed - V8 heap usage. + * * rss - RSS memory usage. + */ + load: { + eventLoopDelay: number; + heapUsed: number; + rss: number; + }; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethods + * Server methods are functions registered with the server and used throughout the application as a common utility. + * Their advantage is in the ability to configure them to use the built-in cache and share across multiple request + * handlers without having to create a common module. + * sever.methods is an object which provides access to the methods registered via server.method() where each + * server method name is an object property. + */ + //methods: Dictionary; + methods: any; // TODO come back here after implements the server.method() + // TODO It"s not finished From d979e41cbc3fcca1fec677e360af2c72f135305e Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Thu, 23 Nov 2017 11:49:27 -0300 Subject: [PATCH 006/298] Added more Server and Plugins definitions. --- .../definitions/plugin/plugin-registered.d.ts | 33 ++++++++ .../definitions/server/server-options.d.ts | 1 + .../v17/definitions/server/server-realm.d.ts | 1 - .../v17/definitions/server/server-state.d.ts | 29 +++++++ types/hapi/v17/definitions/server/server.d.ts | 82 +++++++++++++++++-- 5 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 types/hapi/v17/definitions/plugin/plugin-registered.d.ts create mode 100644 types/hapi/v17/definitions/server/server-state.d.ts diff --git a/types/hapi/v17/definitions/plugin/plugin-registered.d.ts b/types/hapi/v17/definitions/plugin/plugin-registered.d.ts new file mode 100644 index 0000000000..eb96b70537 --- /dev/null +++ b/types/hapi/v17/definitions/plugin/plugin-registered.d.ts @@ -0,0 +1,33 @@ +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverregistrations) + */ +export interface PluginsListRegistered { + [pluginName: string]: PluginRegistered; +} + +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverregistrations) + * An object of the currently registered plugins where each key is a registered plugin name and the value is an + * object containing: + * * version - the plugin version. + * * name - the plugin name. + * * options - (optional) options passed to the plugin during registration. + */ +export interface PluginRegistered { + + /** + * the plugin version. + */ + version: string; + + /** + * the plugin name. + */ + name: string; + + /** + * options used to register the plugin. + */ + options: any; // OptionsPassedToPlugin; + +} diff --git a/types/hapi/v17/definitions/server/server-options.d.ts b/types/hapi/v17/definitions/server/server-options.d.ts index 38af02ac44..3638531930 100644 --- a/types/hapi/v17/definitions/server/server-options.d.ts +++ b/types/hapi/v17/definitions/server/server-options.d.ts @@ -160,6 +160,7 @@ export interface ServerOptions { Sets the default configuration for every state (cookie) set explicitly via server.state() or implicitly (without definition) using the state configuration object. */ // TODO I am not sure if I need to use all the server.state() definition (like the default value) OR only the options below. The v16 use "any" here. + // state?: ServerStateCookieOptions; state?: { strictHeader?: boolean, ignoreErrors?: boolean, diff --git a/types/hapi/v17/definitions/server/server-realm.d.ts b/types/hapi/v17/definitions/server/server-realm.d.ts index 56b05df36e..289ea48018 100644 --- a/types/hapi/v17/definitions/server/server-realm.d.ts +++ b/types/hapi/v17/definitions/server/server-realm.d.ts @@ -1,7 +1,6 @@ import {PluginsStates} from "../plugin/plugin"; /** - Access: read only. The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When registering a plugin or an authentication scheme, a server object reference is provided with a new server.realm container specific to that registration. It allows each plugin to maintain its own settings without leaking and affecting other plugins. For example, a plugin can set a default file path for local resources without breaking other plugins' configured paths. When calling server.bind(), the active realm's settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). */ diff --git a/types/hapi/v17/definitions/server/server-state.d.ts b/types/hapi/v17/definitions/server/server-state.d.ts new file mode 100644 index 0000000000..796dda8cad --- /dev/null +++ b/types/hapi/v17/definitions/server/server-state.d.ts @@ -0,0 +1,29 @@ +import {ServerStateCookieOptions} from "hapi"; +import {Dictionary} from "../util/util"; + +export interface ServerState { + + /** + * The server cookies manager. + * Access: read only and statehood public interface. + */ + readonly states: any; + + /** + * The server cookies manager settings. The settings are based on the values configured in [server.options.state](https://github.com/hapijs/hapi/blob/master/API.md#server.options.state). + */ + readonly settings: ServerStateCookieOptions; + + /** + * An object containing the configuration of each cookie added via [server.state()](https://github.com/hapijs/hapi/blob/master/API.md#server.state()) where each key is the + * cookie name and value is the configuration object. + */ + readonly cookies: any; // TODO what the difference between this one and the settings above? This one should be an array? + + /** + * An array containing the names of all configued cookies. + */ + readonly names: Dictionary; + + +} diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index c47fef7855..af1bc0d160 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -1,9 +1,13 @@ import {ServerOptions} from "./server-options"; +import {ServerRealm} from "./server-realm"; import {ServerInfo} from "./server-info"; import {Dictionary} from "../util/util"; import {Request} from "../request/request"; import * as http from "http"; import * as events from 'events'; +import {PluginsListRegistered} from "../plugin/plugin-registered"; +import {ServerState} from "./server-state"; +import {MimosOptions} from "../../../../mimos/index"; /** @@ -16,7 +20,7 @@ export class Server extends events.EventEmitter { Creates a new server object where: @param options - (optional) a server configuration object. */ - constructor(options: ServerOptions); + constructor(options: ServerOptions); /** * Provides a safe place to store server-specific run-time application data without potential conflicts with @@ -41,7 +45,7 @@ export class Server extends events.EventEmitter { * Contains the default authentication configuration is a default strategy was set via [server.auth.default()](https://github.com/hapijs/hapi/blob/master/API.md#server.auth.default()). */ // TODO it needs to be implemented. I didn't understand the description yet. - //server.auth.settings.default + //readonly server.auth.settings.default /** @@ -51,7 +55,7 @@ export class Server extends events.EventEmitter { * * toolkit - decorations on the response toolkit. * * server - decorations on the server object. */ - decorations: { + readonly decorations: { request: Request, toolkit: any, // TODO Request Toolkit (https://github.com/hapijs/hapi/blob/master/API.md#response-toolkit) needs to be implemented. server: Server @@ -72,7 +76,7 @@ export class Server extends events.EventEmitter { * * 'socket' - UNIX domain socket or Windows named pipe. * * uri - a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains the uri value if set, otherwise constructed from the available settings. If no port is configured or is set to 0, the uri will not include a port component until the server is started. */ - info: ServerInfo; + readonly info: ServerInfo; /** * Access: read only and listener public interface. @@ -86,7 +90,7 @@ export class Server extends events.EventEmitter { * * heapUsed - V8 heap usage. * * rss - RSS memory usage. */ - load: { + readonly load: { eventLoopDelay: number; heapUsed: number; rss: number; @@ -101,7 +105,73 @@ export class Server extends events.EventEmitter { * server method name is an object property. */ //methods: Dictionary; - methods: any; // TODO come back here after implements the server.method() + readonly methods: any; // TODO come back here after implements the server.method() + + /** + * Provides access to the server MIME database used for setting content-type information. The object must not be + * modified directly but only through the [mime](https://github.com/hapijs/hapi/blob/master/API.md#server.options.mime) server setting. + */ + mime: MimosOptions; + + /** + * An object containing the values exposed by each registered plugin where each key is a plugin name and the values + * are the exposed properties by each plugin using server.expose(). Plugins may set the value of + * the server.plugins[name] object directly or via the server.expose() method. + */ + plugins: any; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrealm) + * The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When + * registering a plugin or an authentication scheme, a server object reference is provided with a new server.realm + * container specific to that registration. It allows each plugin to maintain its own settings without leaking + * and affecting other plugins. + * For example, a plugin can set a default file path for local resources without breaking other plugins' configured + * paths. When calling server.bind(), the active realm's settings.bind property is set which is then used by + * routes and extensions added at the same level (server root or plugin). + */ + readonly realm: ServerRealm; + + /** + * An object of the currently registered plugins where each key is a registered plugin name and the value is + * an object containing: + * * version - the plugin version. + * * name - the plugin name. + * * options - (optional) options passed to the plugin during registration. + */ + readonly registrations: PluginsListRegistered; + + /** + * The server configuration object after defaults applied. + */ + readonly settings: ServerOptions; + + /** + * The server cookies manager. + * Access: read only and statehood public interface. + */ + readonly states: ServerState; + + /** + * A string indicating the listener type where: + * * 'socket' - UNIX domain socket or Windows named pipe. + * * 'tcp' - an HTTP listener. + */ + readonly type: 'socket' | 'tcp'; + + /** + * The hapi module version number. + */ + readonly version: string; + + + + + + + + + // TODO It"s not finished From dd1526d33567a66b50bfb86af1554aaff28f78c8 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Thu, 23 Nov 2017 11:53:27 -0300 Subject: [PATCH 007/298] Updated imports with new definitions --- types/hapi/v17/index.d.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index 1e3403e4e1..c2ca44d7d4 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -10,6 +10,7 @@ /** PLUGIN */ export * from './definitions/plugin/plugin' +export * from './definitions/plugin/plugin-registered' /** REQUEST */ export * from './definitions/request/request' @@ -18,14 +19,6 @@ export * from './definitions/request/request' export * from './definitions/response/response-object' export * from './definitions/response/response-settings' -/** SERVER */ -export * from './definitions/server/server' -export * from './definitions/server/server-connection-options' -export * from './definitions/server/server-options' -export * from './definitions/server/server-options-cache' -export * from './definitions/server/server-realm' -export * from './definitions/server/server-state-options' - /** ROUTE */ export * from './definitions/route/route-options' export * from './definitions/route/route-options-access' @@ -39,9 +32,12 @@ export * from './definitions/route/route-options-validate' /** SERVER */ export * from './definitions/server/server' export * from './definitions/server/server-connection-options' +export * from './definitions/server/server-events' +export * from './definitions/server/server-info' export * from './definitions/server/server-options' export * from './definitions/server/server-options-cache' export * from './definitions/server/server-realm' +export * from './definitions/server/server-state' export * from './definitions/server/server-state-options' /** UTIL */ From a2503ea3dc27ace22bb605df48787de44caa41cb Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Thu, 23 Nov 2017 17:22:08 -0300 Subject: [PATCH 008/298] Added ResponseToolkit def. --- .../response/response-toolkit.d.ts | 130 ++++++++++++++++++ types/hapi/v17/index.d.ts | 1 + 2 files changed, 131 insertions(+) create mode 100644 types/hapi/v17/definitions/response/response-toolkit.d.ts diff --git a/types/hapi/v17/definitions/response/response-toolkit.d.ts b/types/hapi/v17/definitions/response/response-toolkit.d.ts new file mode 100644 index 0000000000..a4cabf3785 --- /dev/null +++ b/types/hapi/v17/definitions/response/response-toolkit.d.ts @@ -0,0 +1,130 @@ +import {ServerRealm, ServerStateCookieOptions} from "hapi"; +import {Request} from "../request/request"; +import {ResponseObject} from "./response-object"; + +/** + * See more about Lifecycle + * https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle + * + */ + + +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#response-toolkit) + * The response toolkit is a collection of properties and utilities passed to every [lifecycle method](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) + * It is somewhat hard to define as it provides both utilities for manipulating responses as well as other information. Since the + * toolkit is passed as a function argument, developers can name it whatever they want. For the purpose of this + * document the h notation is used. It is named in the spirit of the RethinkDB r method, with h for hapi. + */ +export interface ResponseToolkit { + + /** + * A response symbol. When returned by a lifecycle method, the request lifecycle skips to the finalizing step + * without further interaction with the node response stream. It is the developer's responsibility to write + * and end the response directly via [request.raw.res](https://github.com/hapijs/hapi/blob/master/API.md#request.raw). + */ + readonly abandon: Object; + + /** + * A response symbol. When returned by a lifecycle method, the request lifecycle skips to the finalizing step after + * calling request.raw.res.end()) to close the the node response stream. + */ + readonly close: Object; + + /** + * A response symbol. Provides access to the route or server context set via the route [bind](https://github.com/hapijs/hapi/blob/master/API.md#route.options.bind) + * option or [server.bind()](https://github.com/hapijs/hapi/blob/master/API.md#server.bind()). + */ + readonly context: Object; + + /** + * A response symbol. When returned by a lifecycle method, the request lifecycle continues without changing the response. + */ + readonly continue: Object; + + /** + * The [server realm](https://github.com/hapijs/hapi/blob/master/API.md#server.realm) associated with the matching + * route. Defaults to the root server realm in the onRequest step. + */ + readonly realm: ServerRealm; + + /** + * Access: read only and public request interface. + * The [request] object. This is a duplication of the request lifecycle method argument used by + * [toolkit decorations](https://github.com/hapijs/hapi/blob/master/API.md#server.decorate()) to access the current request. + */ + request: Request; + + /** + * Used by the [authentication] method to pass back valid credentials where: + * @param data - an object with: + * * credentials - (required) object representing the authenticated entity. + * * artifacts - (optional) authentication artifacts object specific to the authentication scheme. + * @return Return value: an internal authentication object. + */ + authenticated(data: {credentials: any, artifacts?: any}): any; + + /** + * Sets the response 'ETag' and 'Last-Modified' headers and checks for any conditional request headers to decide if + * the response is going to qualify for an HTTP 304 (Not Modified). If the entity values match the request + * conditions, h.entity() returns a response object for the lifecycle method to return as its value which will + * set a 304 response. Otherwise, it sets the provided entity headers and returns undefined. + * The method argumetns are: + * @param options - a required configuration object with: + * * etag - the ETag string. Required if modified is not present. Defaults to no header. + * * modified - the Last-Modified header value. Required if etag is not present. Defaults to no header. + * * vary - same as the response.etag() option. Defaults to true. + * @return Return value: - a response object if the response is unmodified. - undefined if the response has changed. + * If undefined is returned, the developer must return a valid lifecycle method value. If a response is returned, + * it should be used as the return value (but may be customize using the response methods). + */ + entity(options: {etag?: string, modified?: string, vary?: boolean}): ResponseObject | undefined; + + /** + * Redirects the client to the specified uri. Same as calling h.response().redirect(uri). + * @param url + * @return Returns a response object. + */ + redirect(uri: string): ResponseObject; + + /** + * Wraps the provided value and returns a response object which allows customizing the response + * (e.g. setting the HTTP status code, custom headers, etc.), where: + * @param value - (optional) return value. Defaults to null. + * @return Returns a response object. + */ + response(value?: string): ResponseObject; + + /** + * Sets a response cookie using the same arguments as response.state(). + * @param name of the cookie + * @param value of the cookie + * @param (optional) ServerStateCookieOptions object. + * @return Return value: none. + */ + state(name: string, value: string, options?: ServerStateCookieOptions): void; + + /** + * Used by the [authentication] method to indicate authentication failed and pass back the credentials received where: + * @param error - (required) the authentication error. + * @param data - (optional) an object with: + * * credentials - (required) object representing the authenticated entity. + * * artifacts - (optional) authentication artifacts object specific to the authentication scheme. + * @return void. + * The method is used to pass both the authentication error and the credentials. For example, if a request included + * expired credentials, it allows the method to pass back the user information (combined with a 'try' + * authentication mode) for error customization. + * There is no difference between throwing the error or passing it with the h.unauthenticated() method is no credentials are passed, but it might still be helpful for code clarity. + */ + unauthenticated(error: Error, data?: {credentials: any, artifacts?: any}): void; + + /** + * Clears a response cookie using the same arguments as + * [response.unstate()](https://github.com/hapijs/hapi/blob/master/API.md#response.unstate()). + * @param name of the cookie + * @param options (optional) ServerStateCookieOptions object. + * @return void. + */ + unstate(name: string, options?: ServerStateCookieOptions): void; + +} diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index c2ca44d7d4..e8ff80b1c6 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -18,6 +18,7 @@ export * from './definitions/request/request' /** RESPONSE */ export * from './definitions/response/response-object' export * from './definitions/response/response-settings' +export * from './definitions/response/response-toolkit' /** ROUTE */ export * from './definitions/route/route-options' From 5e3bbdfd3a7c9eeeb56832b2d887688d17eb5a5b Mon Sep 17 00:00:00 2001 From: rsouza Date: Fri, 24 Nov 2017 16:51:53 -0300 Subject: [PATCH 009/298] Added some events in ServerEvents interface. Not ready yet. --- .../v17/definitions/server/server-events.d.ts | 162 +++++++++++++++++- 1 file changed, 161 insertions(+), 1 deletion(-) diff --git a/types/hapi/v17/definitions/server/server-events.d.ts b/types/hapi/v17/definitions/server/server-events.d.ts index 4aca038e7f..cb86ca8245 100644 --- a/types/hapi/v17/definitions/server/server-events.d.ts +++ b/types/hapi/v17/definitions/server/server-events.d.ts @@ -1,12 +1,172 @@ +import Podium = require("../../../../podium/index"); + +/** + * an event name string. + * an event options object. + * a podium emitter object. + */ +export type ServerEventsApplication = string | ServerEventsApplicationObject | Podium; + +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents) + * Object that it will be used in Event + */ +export interface ServerEventsApplicationObject { + /** the event name string (required). */ + name: string; + /** a string or array of strings specifying the event channels available. Defaults to no channel restrictions (event updates can specify a channel or not). */ + channels?: string | string[]; + /** if true, the data object passed to server.events.emit() is cloned before it is passed to the listeners (unless an override specified by each listener). Defaults to false (data is passed as-is). */ + clone?: boolean; + /** if true, the data object passed to server.event.emit() must be an array and the listener method is called with each array element passed as a separate argument (unless an override specified by each listener). This should only be used when the emitted data structure is known and predictable. Defaults to false (data is emitted as a single argument regardless of its type). */ + spread?: boolean; + /** if true and the criteria object passed to server.event.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end. A configuration override can be set by each listener. Defaults to false. */ + tags?: boolean; + /** if true, the same event name can be registered multiple times where the second registration is ignored. Note that if the registration config is changed between registrations, only the first configuration is used. Defaults to false (a duplicate registration will throw an error). */ + shared?: boolean; +} + +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncriteria-listener) + * a criteria object with the following optional keys (unless noted otherwise): + */ +export interface ServerEventCriteria { + /** (required) the event name string. */ + name: string; + /** a string or array of strings specifying the event channels to subscribe to. If the event registration specified a list of allowed channels, the channels array must match the allowed channels. If channels are specified, event updates without any channel designation will not be included in the subscription. Defaults to no channels filter. */ + channels?: string | string[]; + /** if true, the data object passed to server.event.emit() is cloned before it is passed to the listener method. Defaults to the event registration option (which defaults to false). */ + clone?: boolean; + /** a positive integer indicating the number of times the listener can be called after which the subscription is automatically removed. A count of 1 is the same as calling server.events.once(). Defaults to no limit. */ + count?: number; + /** + * filter - the event tags (if present) to subscribe to which can be one of: + * * a tag string. + * * an array of tag strings. + * * an object with the following: + * * * tags - a tag string or array of tag strings. + * * * all - if true, all tags must be present for the event update to match the subscription. Defaults to false (at least one matching tag). + */ + filter?: string | string[] | {tags: string | string[], all?: boolean}; + /** if true, and the data object passed to server.event.emit() is an array, the listener method is called with each array element passed as a separate argument. This should only be used when the emitted data structure is known and predictable. Defaults to the event registration option (which defaults to false). */ + spread?: boolean; + /** if true and the criteria object passed to server.event.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end. Defaults to the event registration option (which defaults to false). */ + tags?: boolean; +} + /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) * Access: podium public interface. * The server events emitter. Utilizes the podium with support for event criteria validation, channels, and filters. */ -// TODO it needs to be implemented export interface ServerEvents { + /** + * Register custom application events where: + * @param events - must be one of: + * * an event name string. + * * an event options object with the following optional keys (unless noted otherwise): + * * * name - the event name string (required). + * * * channels - a string or array of strings specifying the event channels available. Defaults to no channel restrictions (event updates can specify a channel or not). + * * * clone - if true, the data object passed to server.events.emit() is cloned before it is passed to the listeners (unless an override specified by each listener). Defaults to false (data is passed as-is). + * * * spread - if true, the data object passed to server.event.emit() must be an array and the listener method is called with each array element passed as a separate argument (unless an override specified by each listener). This should only be used when the emitted data structure is known and predictable. Defaults to false (data is emitted as a single argument regardless of its type). + * * * tags - if true and the criteria object passed to server.event.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end. A configuration override can be set by each listener. Defaults to false. + * * * shared - if true, the same event name can be registered multiple times where the second registration is ignored. Note that if the registration config is changed between registrations, only the first configuration is used. Defaults to false (a duplicate registration will throw an error). + * * a podium emitter object. + * * an array containing any of the above. + * @return Return value: none. + */ + event(events: ServerEventsApplication): void; + event(events: ServerEventsApplication[]): void; + events: { + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsemitcriteria-data) + * Emits a custom application event to all the subscribed listeners where: + * @param criteria - the event update criteria which must be one of: + * * the event name string. + * * an object with the following optional keys (unless noted otherwise): + * * * name - the event name string (required). + * * * channel - the channel name string. + * * * tags - a tag string or array of tag strings. + * @param data - the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. + * @return Return value: none. + * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. + */ + emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: any): void; + + /** + *[See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncriteria-listener) + * Subscribe to an event where: + * @param criteria - the subscription criteria which must be one of: + * * event name string which can be any of the built-in server events + * * a custom application event registered with server.event(). + * * a criteria object + * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. + * @return Return value: none. + */ + on(criteria: string, listener: Function): void; + on(criteria: ServerEventsApplicationObject, listener: Function): void; + on(criteria: ServerEventCriteria, listener: Function): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) + * Same as calling [server.events.on()](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) with the count option set to 1. + * @param criteria - the subscription criteria which must be one of: + * * event name string which can be any of the built-in server events + * * a custom application event registered with server.event(). + * * a criteria object + * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. + * @return Return value: none. + */ + once(criteria: string, listener: Function): void; + once(criteria: ServerEventsApplicationObject, listener: Function): void; + once(criteria: ServerEventCriteria, listener: Function): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsoncecriteria) + * Same as calling server.events.on() with the count option set to 1. + * @param criteria - the subscription criteria which must be one of: + * * event name string which can be any of the built-in server events + * * a custom application event registered with server.event(). + * * a criteria object + * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. + * @return Return value: a promise that resolves when the event is emitted. + */ + once(criteria: string): any; + once(criteria: ServerEventsApplicationObject): any; + once(criteria: ServerEventCriteria): any; + + } + + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposekey-value) + * Used within a plugin to expose a property via server.plugins[name] where: + * @param key - the key assigned (server.plugins[name][key]). + * @param value - the value assigned. + * @return Return value: none. + */ + expose(key: string, value: any): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposeobj) + * Merges an object into to the existing content of server.plugins[name] where: + * @param obj - the object merged into the exposed properties container. + * @return Return value: none. + * Note that all the properties of obj are deeply cloned into server.plugins[name], so avoid using this method + * for exposing large objects that may be expensive to clone or singleton objects such as database client + * objects. Instead favor server.expose(key, value), which only copies a reference to value. + */ + expose(obj: Object): void; + + + + + + + // TODO not ready yet } From f863e0c6cf9b476dca1ab9ebbdb54e6b894ff417 Mon Sep 17 00:00:00 2001 From: rsouza Date: Fri, 24 Nov 2017 16:54:29 -0300 Subject: [PATCH 010/298] Removing unused param from JSDoc. --- types/hapi/v17/definitions/server/server-events.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/hapi/v17/definitions/server/server-events.d.ts b/types/hapi/v17/definitions/server/server-events.d.ts index cb86ca8245..d5920c2b3a 100644 --- a/types/hapi/v17/definitions/server/server-events.d.ts +++ b/types/hapi/v17/definitions/server/server-events.d.ts @@ -131,7 +131,6 @@ export interface ServerEvents { * * event name string which can be any of the built-in server events * * a custom application event registered with server.event(). * * a criteria object - * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. * @return Return value: a promise that resolves when the event is emitted. */ once(criteria: string): any; From b00083ac4342de05a53c36c669fa502fd53de506 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 26 Nov 2017 12:52:56 -0300 Subject: [PATCH 011/298] Added more Server definitions. Moved the events from ServerEvents.d.ts to Server.d.ts. --- .../route/route-options-payload.d.ts | 7 +- .../v17/definitions/server/server-events.d.ts | 116 --------- types/hapi/v17/definitions/server/server.d.ts | 236 ++++++++++++++++++ 3 files changed, 242 insertions(+), 117 deletions(-) diff --git a/types/hapi/v17/definitions/route/route-options-payload.d.ts b/types/hapi/v17/definitions/route/route-options-payload.d.ts index 15d1611dc9..fc5a7b10c4 100644 --- a/types/hapi/v17/definitions/route/route-options-payload.d.ts +++ b/types/hapi/v17/definitions/route/route-options-payload.d.ts @@ -16,6 +16,11 @@ export enum PayloadMultipartOutputEnum { Annotated = 'annotated', } +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) + */ +export type PayloadCompressionDecoderSettings = any; + /**Determines how the request payload is processed.*/ export interface RouteOptionsPayload { @@ -35,7 +40,7 @@ export interface RouteOptionsPayload { Default value: none. An object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in compression. */ - compression?: Dictionary; + compression?: Dictionary; /** Default value: 'application/json'. diff --git a/types/hapi/v17/definitions/server/server-events.d.ts b/types/hapi/v17/definitions/server/server-events.d.ts index d5920c2b3a..c08bf4057a 100644 --- a/types/hapi/v17/definitions/server/server-events.d.ts +++ b/types/hapi/v17/definitions/server/server-events.d.ts @@ -53,119 +53,3 @@ export interface ServerEventCriteria { /** if true and the criteria object passed to server.event.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end. Defaults to the event registration option (which defaults to false). */ tags?: boolean; } - -/** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) - * Access: podium public interface. - * The server events emitter. Utilizes the podium with support for event criteria validation, channels, and filters. - */ -export interface ServerEvents { - - /** - * Register custom application events where: - * @param events - must be one of: - * * an event name string. - * * an event options object with the following optional keys (unless noted otherwise): - * * * name - the event name string (required). - * * * channels - a string or array of strings specifying the event channels available. Defaults to no channel restrictions (event updates can specify a channel or not). - * * * clone - if true, the data object passed to server.events.emit() is cloned before it is passed to the listeners (unless an override specified by each listener). Defaults to false (data is passed as-is). - * * * spread - if true, the data object passed to server.event.emit() must be an array and the listener method is called with each array element passed as a separate argument (unless an override specified by each listener). This should only be used when the emitted data structure is known and predictable. Defaults to false (data is emitted as a single argument regardless of its type). - * * * tags - if true and the criteria object passed to server.event.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end. A configuration override can be set by each listener. Defaults to false. - * * * shared - if true, the same event name can be registered multiple times where the second registration is ignored. Note that if the registration config is changed between registrations, only the first configuration is used. Defaults to false (a duplicate registration will throw an error). - * * a podium emitter object. - * * an array containing any of the above. - * @return Return value: none. - */ - event(events: ServerEventsApplication): void; - event(events: ServerEventsApplication[]): void; - - events: { - - /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsemitcriteria-data) - * Emits a custom application event to all the subscribed listeners where: - * @param criteria - the event update criteria which must be one of: - * * the event name string. - * * an object with the following optional keys (unless noted otherwise): - * * * name - the event name string (required). - * * * channel - the channel name string. - * * * tags - a tag string or array of tag strings. - * @param data - the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. - * @return Return value: none. - * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. - */ - emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: any): void; - - /** - *[See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncriteria-listener) - * Subscribe to an event where: - * @param criteria - the subscription criteria which must be one of: - * * event name string which can be any of the built-in server events - * * a custom application event registered with server.event(). - * * a criteria object - * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. - * @return Return value: none. - */ - on(criteria: string, listener: Function): void; - on(criteria: ServerEventsApplicationObject, listener: Function): void; - on(criteria: ServerEventCriteria, listener: Function): void; - - /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) - * Same as calling [server.events.on()](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) with the count option set to 1. - * @param criteria - the subscription criteria which must be one of: - * * event name string which can be any of the built-in server events - * * a custom application event registered with server.event(). - * * a criteria object - * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. - * @return Return value: none. - */ - once(criteria: string, listener: Function): void; - once(criteria: ServerEventsApplicationObject, listener: Function): void; - once(criteria: ServerEventCriteria, listener: Function): void; - - /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsoncecriteria) - * Same as calling server.events.on() with the count option set to 1. - * @param criteria - the subscription criteria which must be one of: - * * event name string which can be any of the built-in server events - * * a custom application event registered with server.event(). - * * a criteria object - * @return Return value: a promise that resolves when the event is emitted. - */ - once(criteria: string): any; - once(criteria: ServerEventsApplicationObject): any; - once(criteria: ServerEventCriteria): any; - - } - - - /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposekey-value) - * Used within a plugin to expose a property via server.plugins[name] where: - * @param key - the key assigned (server.plugins[name][key]). - * @param value - the value assigned. - * @return Return value: none. - */ - expose(key: string, value: any): void; - - /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposeobj) - * Merges an object into to the existing content of server.plugins[name] where: - * @param obj - the object merged into the exposed properties container. - * @return Return value: none. - * Note that all the properties of obj are deeply cloned into server.plugins[name], so avoid using this method - * for exposing large objects that may be expensive to clone or singleton objects such as database client - * objects. Instead favor server.expose(key, value), which only copies a reference to value. - */ - expose(obj: Object): void; - - - - - - - // TODO not ready yet - - -} diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index af1bc0d160..6ad62c63b6 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -5,9 +5,15 @@ import {Dictionary} from "../util/util"; import {Request} from "../request/request"; import * as http from "http"; import * as events from 'events'; +import * as catbox from "catbox"; +import * as zlib from "zlib"; import {PluginsListRegistered} from "../plugin/plugin-registered"; import {ServerState} from "./server-state"; import {MimosOptions} from "../../../../mimos/index"; +import { + ServerOptionsCache, ServerEventCriteria, ServerEventsApplication, ServerEventsApplicationObject, + PayloadCompressionDecoderSettings +} from "hapi"; /** @@ -61,6 +67,172 @@ export class Server extends events.EventEmitter { server: Server } + /** + * Register custom application events where: + * @param events - must be one of: + * * an event name string. + * * an event options object with the following optional keys (unless noted otherwise): + * * * name - the event name string (required). + * * * channels - a string or array of strings specifying the event channels available. Defaults to no channel restrictions (event updates can specify a channel or not). + * * * clone - if true, the data object passed to server.events.emit() is cloned before it is passed to the listeners (unless an override specified by each listener). Defaults to false (data is passed as-is). + * * * spread - if true, the data object passed to server.event.emit() must be an array and the listener method is called with each array element passed as a separate argument (unless an override specified by each listener). This should only be used when the emitted data structure is known and predictable. Defaults to false (data is emitted as a single argument regardless of its type). + * * * tags - if true and the criteria object passed to server.event.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end. A configuration override can be set by each listener. Defaults to false. + * * * shared - if true, the same event name can be registered multiple times where the second registration is ignored. Note that if the registration config is changed between registrations, only the first configuration is used. Defaults to false (a duplicate registration will throw an error). + * * a podium emitter object. + * * an array containing any of the above. + * @return Return value: none. + */ + event(events: ServerEventsApplication): void; + event(events: ServerEventsApplication[]): void; + + events: { + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsemitcriteria-data) + * Emits a custom application event to all the subscribed listeners where: + * @param criteria - the event update criteria which must be one of: + * * the event name string. + * * an object with the following optional keys (unless noted otherwise): + * * * name - the event name string (required). + * * * channel - the channel name string. + * * * tags - a tag string or array of tag strings. + * @param data - the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. + * @return Return value: none. + * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. + */ + emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: any): void; + + /** + *[See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncriteria-listener) + * Subscribe to an event where: + * @param criteria - the subscription criteria which must be one of: + * * event name string which can be any of the built-in server events + * * a custom application event registered with server.event(). + * * a criteria object + * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. + * @return Return value: none. + */ + on(criteria: string, listener: Function): void; + on(criteria: ServerEventsApplicationObject, listener: Function): void; + on(criteria: ServerEventCriteria, listener: Function): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) + * Same as calling [server.events.on()](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) with the count option set to 1. + * @param criteria - the subscription criteria which must be one of: + * * event name string which can be any of the built-in server events + * * a custom application event registered with server.event(). + * * a criteria object + * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. + * @return Return value: none. + */ + once(criteria: string, listener: Function): void; + once(criteria: ServerEventsApplicationObject, listener: Function): void; + once(criteria: ServerEventCriteria, listener: Function): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsoncecriteria) + * Same as calling server.events.on() with the count option set to 1. + * @param criteria - the subscription criteria which must be one of: + * * event name string which can be any of the built-in server events + * * a custom application event registered with server.event(). + * * a criteria object + * @return Return value: a promise that resolves when the event is emitted. + */ + once(criteria: string): any; + once(criteria: ServerEventsApplicationObject): any; + once(criteria: ServerEventCriteria): any; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) + * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumremovelistenername-listener) + */ + removeListener(name: string, listener: Function): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) + * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumremovealllistenersname) + */ + removeAllListeners(name: string): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) + * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumhaslistenersname) + */ + hasListeners(name: string): boolean; + + /** + * The 'log' event type emits internal server events generated by the framework as well as application events + * logged with server.log(). + * The 'log' event handler uses the function signature function(event, tags) where: + * @param event - an object with the following properties: + * * timestamp - the event timestamp. + * * tags - an array of tags identifying the event (e.g. ['error', 'http']). + * * channel - set to 'internal' for internally generated events, otherwise 'app' for events generated by server.log(). + * * data - event-specific information. Available when event data was provided and is not an error. Errors are passed via error. + * * error - the error object related to the event if applicable. Cannot appear together with data. + * @param tags - an object where each event.tag is a key and the value is true. Useful for quick identification of events. + * + */ + + + // TODO not ready yet + + + + } + + + + + + + + + + + + + + + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposekey-value) + * Used within a plugin to expose a property via server.plugins[name] where: + * @param key - the key assigned (server.plugins[name][key]). + * @param value - the value assigned. + * @return Return value: none. + */ + expose(key: string, value: any): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposeobj) + * Merges an object into to the existing content of server.plugins[name] where: + * @param obj - the object merged into the exposed properties container. + * @return Return value: none. + * Note that all the properties of obj are deeply cloned into server.plugins[name], so avoid using this method + * for exposing large objects that may be expensive to clone or singleton objects such as database client + * objects. Instead favor server.expose(key, value), which only copies a reference to value. + */ + expose(obj: Object): void; + + + + + + + + + + + + + + + + + + /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo) * An object containing information about the server where: @@ -168,6 +340,70 @@ export class Server extends events.EventEmitter { + // TODO Put SERVER AUTH here + + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverbindcontext) + * Sets a global context used as the default bind object when adding a route or an extension where: + * @param context - the object used to bind this in lifecycle methods such as the route handler and extension methods. The context is also made available as h.context. + * @return Return value: none. + * When setting a context inside a plugin, the context is applied only to methods set up by the plugin. Note that the context applies only to routes and extensions added after it has been set. Ignored if the method being bound is an arrow function. + */ + bind(context: any): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) + */ + cache: { + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) + * Provisions a cache segment within the server cache facility where: + * @param options - [catbox policy](https://github.com/hapijs/catbox#policy) configuration where: + * * expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. + * * expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records expire. Uses local time. Cannot be used together with expiresIn. + * * generateFunc - a function used to generate a new cache item if one is not found in the cache when calling get(). The method's signature is async function(id, flags) where: + * - `id` - the `id` string or object provided to the `get()` method. + * - `flags` - an object used to pass back additional flags to the cache where: + *- `ttl` - the cache ttl value in milliseconds. Set to `0` to skip storing in the cache. Defaults to the cache global policy. + * * staleIn - number of milliseconds to mark an item stored in cache as stale and attempt to regenerate it when generateFunc is provided. Must be less than expiresIn. + * * staleTimeout - number of milliseconds to wait before checking if an item is stale. + * * generateTimeout - number of milliseconds to wait before returning a timeout error when the generateFunc function takes too long to return a value. When the value is eventually returned, it is stored in the cache for future requests. Required if generateFunc is present. Set to false to disable timeouts which may cause all get() requests to get stuck forever. + * * generateOnReadError - if false, an upstream cache read error will stop the cache.get() method from calling the generate function and will instead pass back the cache error. Defaults to true. + * * generateIgnoreWriteError - if false, an upstream cache write error when calling cache.get() will be passed back with the generated value when calling. Defaults to true. + * * dropOnError - if true, an error or timeout in the generateFunc causes the stale value to be evicted from the cache. Defaults to true. + * * pendingGenerateTimeout - number of milliseconds while generateFunc call is in progress for a given id, before a subsequent generateFunc call is allowed. Defaults to 0 (no blocking of concurrent generateFunc calls beyond staleTimeout). + * * cache - the cache name configured in server.cache. Defaults to the default cache. + * * segment - string segment name, used to isolate cached items within the cache partition. When called within a plugin, defaults to '!name' where 'name' is the plugin name. When called within a server method, defaults to '#name' where 'name' is the server method name. Required when called outside of a plugin. + * * shared - if true, allows multiple cache provisions to share the same segment. Default to false. + * @return Catbox Policy. + */ + (options: catbox.PolicyOptions): catbox.Policy; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions) + * Provisions a server cache as described in server.cache where: + * @param options - same as the server cache configuration options. + * @return Return value: none. + * Note that if the server has been initialized or started, the cache will be automatically started to match the state of any other provisioned server cache. + */ + provision(options: ServerOptionsCache): void; + + } + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoderencoding-decoder) + * Registers a custom content decoding compressor to extend the built-in support for 'gzip' and 'deflate' where: + * @param encoding - the decoder name string. + * @param decoder - a function using the signature function(options) where options are the encoding specific options configured in the route payload.compression configuration option, and the return value is an object compatible with the output of node's zlib.createGunzip(). + * @return Return value: none. + */ + decoder(encoding: string, decoder: ((options: PayloadCompressionDecoderSettings) => zlib.Gunzip)): void; + + + + From c6edf56209d507e738150b31eaef1acc28060743 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 26 Nov 2017 18:10:44 -0300 Subject: [PATCH 012/298] Removed legacy definitions. --- .../server/server-connection-options.d.ts | 54 ------------------- types/hapi/v17/index.d.ts | 1 - 2 files changed, 55 deletions(-) delete mode 100644 types/hapi/v17/definitions/server/server-connection-options.d.ts diff --git a/types/hapi/v17/definitions/server/server-connection-options.d.ts b/types/hapi/v17/definitions/server/server-connection-options.d.ts deleted file mode 100644 index 383d601dc0..0000000000 --- a/types/hapi/v17/definitions/server/server-connection-options.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -import {RouteOptions} from "../route/route-options"; - -/** Any connections configuration server defaults can be included to override and customize the individual connection. */ -export interface IServerConnectionOptions extends IConnectionConfigurationServerDefaults { - /** - the public hostname or IP address. Used only to set server.info.host and server.info.uri. If not configured, defaults to the operating system hostname and if not available, to 'localhost'.*/ - host?: string; - /** - sets the host name or IP address the connection will listen on.If not configured, defaults to host if present, otherwise to all available network interfaces (i.e. '0.0.0.0').Set to 127.0.0.1 or localhost to restrict connection to only those coming from the same machine.*/ - address?: string; - /** - the TCP port the connection will listen to.Defaults to an ephemeral port (0) which uses an available port when the server is started (and assigned to server.info.port).If port is a string containing a '/' character, it is used as a UNIX domain socket path and if it starts with '\.\pipe' as a Windows named pipe.*/ - port?: string | number; - /** - the full public URI without the path (e.g. 'http://example.com:8080').If present, used as the connection info.uri otherwise constructed from the connection settings.*/ - uri?: string; - /** - optional node.js HTTP (or HTTPS) http.Server object or any compatible object.If the listener needs to be manually started, set autoListen to false.If the listener uses TLS, set tls to true.*/ - listener?: any; - /** - indicates that the connection.listener will be started manually outside the framework.Cannot be specified with a port setting.Defaults to true.*/ - autoListen?: boolean; - /** caching headers configuration: */ - cache?: { - /** - an array of HTTP response status codes (e.g. 200) which are allowed to include a valid caching directive.Defaults to [200]. */ - statuses: number[]; - }; - /** - a string or string array of labels used to server.select() specific connections matching the specified labels.Defaults to an empty array [](no labels).*/ - labels?: string | string[]; - /** - used to create an HTTPS connection.The tls object is passed unchanged as options to the node.js HTTPS server as described in the node.js HTTPS documentation.Set to true when passing a listener object that has been configured to use TLS directly. */ - tls?: boolean | { key?: string; cert?: string; pfx?: string; } | Object; -} - -export interface IConnectionConfigurationServerDefaults { - /** application-specific connection configuration which can be accessed via connection.settings.app. Provides a safe place to store application configuration without potential conflicts with the framework internals. Should not be used to configure plugins which should use plugins[name]. Note the difference between connection.settings.app which is used to store configuration values and connection.app which is meant for storing run-time state. */ - app?: any; - /** if false, response content encoding is disabled. Defaults to true */ - compression?: boolean; - /** connection load limits configuration where: */ - load?: { - /** maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ - maxHeapUsedBytes?: number; - /** maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ - maxRssBytes?: number; - /** maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ - maxEventLoopDelay?: number; - }; - /** plugin-specific configuration which can later be accessed via connection.settings.plugins. Provides a place to store and pass connection-specific plugin configuration. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between connection.settings.plugins which is used to store configuration values and connection.plugins which is meant for storing run-time state. */ - plugins?: any; - /** controls how incoming request URIs are matched against the routing table: */ - router?: { - /** determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true. */ - isCaseSensitive: boolean; - /** removes trailing slashes on incoming paths. Defaults to false. */ - stripTrailingSlash: boolean; - }; - /** a route options object used to set the default configuration for every route. */ - routes?: RouteOptions; - // state?: IServerState; TODO -} diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index e8ff80b1c6..9efde0895d 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -32,7 +32,6 @@ export * from './definitions/route/route-options-validate' /** SERVER */ export * from './definitions/server/server' -export * from './definitions/server/server-connection-options' export * from './definitions/server/server-events' export * from './definitions/server/server-info' export * from './definitions/server/server-options' From 42fbf80a213f1865234ffe77405995c40b784dfa Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 26 Nov 2017 18:50:39 -0300 Subject: [PATCH 013/298] Replaced enum HttpMethod to types like v16. Not very elegant solution but works easily with lower/upper case :) --- types/hapi/v17/definitions/util/util.d.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/types/hapi/v17/definitions/util/util.d.ts b/types/hapi/v17/definitions/util/util.d.ts index bfe54031e8..f1c6d0c39e 100644 --- a/types/hapi/v17/definitions/util/util.d.ts +++ b/types/hapi/v17/definitions/util/util.d.ts @@ -2,9 +2,6 @@ export interface Dictionary { [key: string]: T; } -export enum HttpMethod { - Get = "get", - Post = "post", - Put = "put", - Delete= "delete", -} +export type HTTP_METHODS_PARTIAL_LOWERCASE = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; +export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_LOWERCASE; +export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; From 0f1dbd0f9d77c1d95296f697ce4978d6ff646a36 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 26 Nov 2017 18:52:44 -0300 Subject: [PATCH 014/298] Separating request auth, server and route in different files to better understanding. --- .../v17/definitions/request/request-auth.d.ts | 20 +++++ .../v17/definitions/request/request-info.d.ts | 35 ++++++++ .../definitions/request/request-route.d.ts | 20 +++++ .../hapi/v17/definitions/request/request.d.ts | 81 +++---------------- 4 files changed, 84 insertions(+), 72 deletions(-) create mode 100644 types/hapi/v17/definitions/request/request-auth.d.ts create mode 100644 types/hapi/v17/definitions/request/request-info.d.ts create mode 100644 types/hapi/v17/definitions/request/request-route.d.ts diff --git a/types/hapi/v17/definitions/request/request-auth.d.ts b/types/hapi/v17/definitions/request/request-auth.d.ts new file mode 100644 index 0000000000..cc5fe1ec0a --- /dev/null +++ b/types/hapi/v17/definitions/request/request-auth.d.ts @@ -0,0 +1,20 @@ +/** + * Authentication information + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestauth) + */ +export interface RequestAuth { + /** an artifact object received from the authentication strategy and used in authentication-related actions. */ + artifacts: any; + /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ + credentials: any; + /** the authentication error is failed and mode set to 'try'. */ + error: Error; + /** true if the request has been successfully authenticated, otherwise false. */ + isAuthenticated: boolean; + /** true is the request has been successfully authorized against the route authentication access configuration. If the route has not access rules defined or if the request failed authorization, set to false. */ + isAuthorized: boolean; + /** the route authentication mode. */ + mode: string; + /** the name of the strategy used. */ + strategy: string; +} diff --git a/types/hapi/v17/definitions/request/request-info.d.ts b/types/hapi/v17/definitions/request/request-info.d.ts new file mode 100644 index 0000000000..035b36cba0 --- /dev/null +++ b/types/hapi/v17/definitions/request/request-info.d.ts @@ -0,0 +1,35 @@ +/** + * Request information + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestinfo) + */ +export interface RequestInfo { + /** the request preferred encoding. */ + acceptEncoding: string; + /** if CORS is enabled for the route, contains the following: */ + cors: { + /** + * if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does + * not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing + * decisions are made at that point in the request lifecycle. + */ + isOriginMatch?: boolean; + }; + /** content of the HTTP 'Host' header (e.g. 'example.com:8080'). */ + host: string; + /** the hostname part of the 'Host' header (e.g. 'example.com'). */ + hostname: string; + /** request reception timestamp. */ + received: number; + /** content of the HTTP 'Referrer' (or 'Referer') header. */ + referrer: string; + /** remote client IP address. */ + remoteAddress: string; + /** + * remote client port. + * Set to string in casethey're requesting from a UNIX domain socket. + * TODO, what type does Hapi return, should this be number | string? + */ + remotePort: string; + /** request response timestamp (0 is not responded yet). */ + responded: number; +} diff --git a/types/hapi/v17/definitions/request/request-route.d.ts b/types/hapi/v17/definitions/request/request-route.d.ts new file mode 100644 index 0000000000..1b5e79d03b --- /dev/null +++ b/types/hapi/v17/definitions/request/request-route.d.ts @@ -0,0 +1,20 @@ +import {RouteOptions, ServerRealm, HTTP_METHODS_PARTIAL} from "hapi"; + +/** + * The request route information object + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestroute) + */ +export interface RequestRoute { + /** the route HTTP method. */ + method: HTTP_METHODS_PARTIAL; + /** the route path. */ + path: string; + /** the route vhost option if configured. */ + vhost?: string | string[]; + /** the active realm associated with the route.*/ + realm: ServerRealm; + /** the route options object with all defaults applied. */ + settings: RouteOptions; + /** the route internal normalized string representing the normalized path. */ + fingerprint: string; +} diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index 2da1eb27be..84212bfacf 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -1,12 +1,13 @@ import * as stream from "stream"; import * as url from "url"; import * as http from "http"; -import {RouteOptions} from "../route/route-options"; import {Server} from "../server/server"; -import {ServerRealm} from "../server/server-realm"; import {ResponseObject} from "../response/response-object"; -import {HttpMethod, Dictionary} from "../util/util"; +import {Dictionary, HTTP_METHODS_PARTIAL, HTTP_METHODS_PARTIAL_LOWERCASE} from "../util/util"; import {PluginsStates} from "../plugin/plugin"; +import {RequestRoute} from "./request-route"; +import {RequestAuth} from "./request-auth"; +import {RequestInfo} from "./request-info"; /** * TODO both objects ReplyValue and _ReplyValue I found in the v16 TS definition, but I don't found it in the documentation. Need review. @@ -15,76 +16,12 @@ import {PluginsStates} from "../plugin/plugin"; export type ReplyValue = _ReplyValue | Promise<_ReplyValue>; export type _ReplyValue = null | undefined | string | number | boolean | Buffer | Error | stream.Stream | Object; // | array; -export interface RequestAuth { - /** an artifact object received from the authentication strategy and used in authentication-related actions. */ - artifacts: any; - /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ - credentials: any; - /** the authentication error is failed and mode set to 'try'. */ - error: Error; - /** true if the request has been successfully authenticated, otherwise false. */ - isAuthenticated: boolean; - /** true is the request has been successfully authorized against the route authentication access configuration. If the route has not access rules defined or if the request failed authorization, set to false. */ - isAuthorized: boolean; - /** the route authentication mode. */ - mode: string; - /** the name of the strategy used. */ - strategy: string; -} - -export interface RequestInfo { - /** the request preferred encoding. */ - acceptEncoding: string; - /** if CORS is enabled for the route, contains the following: */ - cors: { - /** - * if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does - * not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing - * decisions are made at that point in the request lifecycle. - */ - isOriginMatch?: boolean; - }; - /** content of the HTTP 'Host' header (e.g. 'example.com:8080'). */ - host: string; - /** the hostname part of the 'Host' header (e.g. 'example.com'). */ - hostname: string; - /** request reception timestamp. */ - received: number; - /** content of the HTTP 'Referrer' (or 'Referer') header. */ - referrer: string; - /** remote client IP address. */ - remoteAddress: string; - /** - * remote client port. - * Set to string in casethey're requesting from a UNIX domain socket. - * TODO, what type does Hapi return, should this be number | string? - */ - remotePort: string; - /** request response timestamp (0 is not responded yet). */ - responded: number; -} - export interface RequestOrig { params: any; query: any; payload: any; } -export interface RequestRoute { - /** the route HTTP method. */ - method: HttpMethod; - /** the route path. */ - path: string; - /** the route vhost option if configured. */ - vhost?: string | string[]; - /** the active realm associated with the route.*/ - realm: ServerRealm; - /** the route options object with all defaults applied. */ - settings: RouteOptions; - /** the route internal normalized string representing the normalized path. */ - fingerprint: string; -} - export interface Request { /** @@ -104,7 +41,7 @@ export interface Request { mode - the route authentication mode. strategy - the name of the strategy used. */ - auth: RequestAuth; + readonly auth: RequestAuth; /** Access: read only and the public podium interface. @@ -137,7 +74,7 @@ export interface Request { responded - request response timestamp (0 is not responded yet). Note that the request.info object is not meant to be modified. */ - info: RequestInfo; + readonly info: RequestInfo; /** Access: read only. @@ -150,7 +87,7 @@ export interface Request { Access: read only. The request method in lower case (e.g. 'get', 'post'). */ - method: HttpMethod; + method: HTTP_METHODS_PARTIAL_LOWERCASE; /** Access: read only. @@ -292,11 +229,11 @@ export interface Request { /** * request.setMethod(method) * Changes the request method before the router begins processing the request where: + * @param method - is the request HTTP method (e.g. 'GET'). * Can only be called from an 'onRequest' extension method. * [See docs] (https://hapijs.com/api/17.0.1#-requestsetmethodmethod) - * @param method - is the request HTTP method (e.g. 'GET'). */ - setMethod(method: HttpMethod): void; + setMethod(method: HTTP_METHODS_PARTIAL): void; /** * request.setUrl(url, [stripTrailingSlash] From 0e0de0dc95301e00d24443ecbea67d213c0a3bff Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 26 Nov 2017 18:55:26 -0300 Subject: [PATCH 015/298] Added more Server definitions: ServerExt, ServerInject and others. --- .../v17/definitions/server/server-ext.d.ts | 97 ++++++++ .../v17/definitions/server/server-inject.d.ts | 50 ++++ types/hapi/v17/definitions/server/server.d.ts | 230 ++++++++++++++---- 3 files changed, 324 insertions(+), 53 deletions(-) create mode 100644 types/hapi/v17/definitions/server/server-ext.d.ts create mode 100644 types/hapi/v17/definitions/server/server-inject.d.ts diff --git a/types/hapi/v17/definitions/server/server-ext.d.ts b/types/hapi/v17/definitions/server/server-ext.d.ts new file mode 100644 index 0000000000..960a342998 --- /dev/null +++ b/types/hapi/v17/definitions/server/server-ext.d.ts @@ -0,0 +1,97 @@ +import {Server, Request, ResponseToolkit} from "hapi"; + +/** + * The extension point event name. The available extension points include the request extension points as well as the following server extension points: + * 'onPreStart' - called before the connection listeners are started. + * 'onPostStart' - called after the connection listeners are started. + * 'onPreStop' - called before the connection listeners are stopped. + * 'onPostStop' - called after the connection listeners are stopped. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) + */ +export type ServerExtType = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; + +/** + * The extension point event name for Request + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) + */ +export type ServerExtRequestType = 'onRequest'; + +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) + * Registers an extension function in one of the request lifecycle extension points where: + * @param events - an object or array of objects with the following: + * * type - (required) the extension point event name. The available extension points include the request extension points as well as the following server extension points: + * * * 'onPreStart' - called before the connection listeners are started. + * * * 'onPostStart' - called after the connection listeners are started. + * * * 'onPreStop' - called before the connection listeners are stopped. + * * * 'onPostStop' - called after the connection listeners are stopped. + * * method - (required) a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is: + * * * server extension points: async function(server) where: + * * * * server - the server object. + * * * * this - the object provided via options.bind or the current active context set with server.bind(). + * * * request extension points: a lifecycle method. + * * options - (optional) an object with the following: + * * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. + * * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. + * * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. + * * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. + * @return void + */ +export interface ServerExtEventsObject { + type: ServerExtType; + method: ServerExtPointFunction | ServerExtPointFunction[]; + options?: ServerExtOptions; +} + +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) + * Registers an extension function in one of the request lifecycle extension points where: + * @param events - an object or array of objects with the following: + * * type - (required) the extension point event name. The available extension points include the request extension points as well as the following server extension points: + * * * 'onPreStart' - called before the connection listeners are started. + * * * 'onPostStart' - called after the connection listeners are started. + * * * 'onPreStop' - called before the connection listeners are stopped. + * * * 'onPostStop' - called after the connection listeners are stopped. + * * method - (required) a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is: + * * * server extension points: async function(server) where: + * * * * server - the server object. + * * * * this - the object provided via options.bind or the current active context set with server.bind(). + * * * request extension points: a lifecycle method. + * * options - (optional) an object with the following: + * * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. + * * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. + * * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. + * * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. + * @return void + */ +export interface ServerExtEventsRequestObject { + type: ServerExtRequestType; + method: RequestExtPointFunction | RequestExtPointFunction[]; + options?: ServerExtOptions; +} + +export interface ServerExtPointFunction { + (server: Server): void; +} + +export interface RequestExtPointFunction { + (request: Request, h: ResponseToolkit): void; +} + +/** + * An object with the following: + * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. + * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. + * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. + * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) + */ +export interface ServerExtOptions { + before: string | string[]; + after: string | string[]; + bind: any; + sandbox?: 'server' | 'plugin'; +} + diff --git a/types/hapi/v17/definitions/server/server-inject.d.ts b/types/hapi/v17/definitions/server/server-inject.d.ts new file mode 100644 index 0000000000..cb04ba3aab --- /dev/null +++ b/types/hapi/v17/definitions/server/server-inject.d.ts @@ -0,0 +1,50 @@ +import {Request, PluginsStates} from "hapi"; +import * as Shot from "shot"; + +/** + * An object with: + * * method - (optional) the request HTTP method (e.g. 'POST'). Defaults to 'GET'. + * * url - (required) the request URL. If the URI includes an authority (e.g. 'example.com:8080'), it is used to automatically set an HTTP 'Host' header, unless one was specified in headers. + * * headers - (optional) an object with optional request headers where each key is the header name and the value is the header content. Defaults to no additions to the default shot headers. + * * payload - (optional) an string, buffer or object containing the request payload. In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided. + * * credentials - (optional) an credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials. + * * artifacts - (optional) an artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts. + * * app - (optional) sets the initial value of request.app, defaults to {}. + * * plugins - (optional) sets the initial value of request.plugins, defaults to {}. + * * allowInternals - (optional) allows access to routes with config.isInternal set to true. Defaults to false. + * * remoteAddress - (optional) sets the remote address for the incoming connection. + * * simulate - (optional) an object with options used to simulate client request stream conditions for testing: + * * error - if true, emits an 'error' event after payload transmission (if any). Defaults to false. + * * close - if true, emits a 'close' event after payload transmission (if any). Defaults to false. + * * end - if false, does not end the stream. Defaults to true. + * * split - indicates whether the request payload will be split into chunks. Defaults to undefined, meaning payload will not be chunked. + * * validate - (optional) if false, the options inputs are not validated. This is recommended for run-time usage of inject() to make it perform faster where input validation can be tested separately. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions) + * For context [Shot module](https://github.com/hapijs/shot) + */ +export interface ServerInjectOptions extends Shot.RequestOptions { + credentials?: any; + artifacts?: any; + app?: any; + plugins?: PluginsStates; + allowInternals?: boolean; +} + +/** + * A response object with the following properties: + * * statusCode - the HTTP status code. + * * headers - an object containing the headers set. + * * payload - the response payload string. + * * rawPayload - the raw response payload buffer. + * * raw - an object with the injection request and response objects: + * * req - the simulated node request object. + * * res - the simulated node response object. + * * result - the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the internal objects returned (instead of parsing the response string). + * * request - the request object. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions) + * For context [Shot module](https://github.com/hapijs/shot) + */ +export interface ServerInjectResponse extends Shot.ResponseObject { + result: any; + request: Request; +} diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 6ad62c63b6..741279629b 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -12,9 +12,14 @@ import {ServerState} from "./server-state"; import {MimosOptions} from "../../../../mimos/index"; import { ServerOptionsCache, ServerEventCriteria, ServerEventsApplication, ServerEventsApplicationObject, - PayloadCompressionDecoderSettings + PayloadCompressionDecoderSettings, RouteCompressionEncoderSettings, HTTP_METHODS } from "hapi"; - +import { + RequestExtPointFunction, ServerExtEventsObject, ServerExtEventsRequestObject, ServerExtOptions, + ServerExtPointFunction, ServerExtRequestType, ServerExtType +} from "./server-ext"; +import {ServerInjectOptions, ServerInjectResponse} from "./server-inject"; +import {RequestRoute} from "../request/request-route"; /** * The server object is the main application container. The server manages all incoming requests along with all @@ -182,57 +187,6 @@ export class Server extends events.EventEmitter { } - - - - - - - - - - - - - - - /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposekey-value) - * Used within a plugin to expose a property via server.plugins[name] where: - * @param key - the key assigned (server.plugins[name][key]). - * @param value - the value assigned. - * @return Return value: none. - */ - expose(key: string, value: any): void; - - /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposeobj) - * Merges an object into to the existing content of server.plugins[name] where: - * @param obj - the object merged into the exposed properties container. - * @return Return value: none. - * Note that all the properties of obj are deeply cloned into server.plugins[name], so avoid using this method - * for exposing large objects that may be expensive to clone or singleton objects such as database client - * objects. Instead favor server.expose(key, value), which only copies a reference to value. - */ - expose(obj: Object): void; - - - - - - - - - - - - - - - - - - /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo) * An object containing information about the server where: @@ -401,6 +355,176 @@ export class Server extends events.EventEmitter { */ decoder(encoding: string, decoder: ((options: PayloadCompressionDecoderSettings) => zlib.Gunzip)): void; + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options) + * Extends various framework interfaces with custom methods where: + * @param type - the interface being decorated. Supported types: + * 'handler' - adds a new handler type to be used in routes handlers. + * 'request' - adds methods to the Request object. + * 'server' - adds methods to the Server object. + * 'toolkit' - adds methods to the response toolkit. + * @param property - the object decoration key name. + * @param method - the extension function or other value. + * @param options - (optional) supports the following optional settings: + * apply - when the type is 'request', if true, the method function is invoked using the signature function(request) where request is the current request object and the returned value is assigned as the decoration. + * extend - if true, overrides an existing decoration. The method must be a function with the signature function(existing) where: + * existing - is the previously set decoration method value. + * must return the new decoration function or value. + * cannot be used to extend handler decorations. + * @return void; + */ + decorate(type: 'request', property: string, method: ((request: Request) => Function), options?: {apply: true; extend: false} ): void; + decorate(type: 'handler' | 'request' | 'reply' | 'server', property: string, method: Function, options?: {apply: boolean; extend: boolean} ): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdependencydependencies-after) + * Used within a plugin to declare a required dependency on other plugins where: + * @param dependencies - a single string or an array of plugin name strings which must be registered in order for this plugin to operate. Plugins listed must be registered before the server is initialized or started. + * @param after - (optional) a function that is called after all the specified dependencies have been registered and before the server starts. The function is only called if the server is initialized or started. The function signature is async function(server) where: + * server - the server the dependency() method was called on. + * @return Return value: none. + * The after method is identical to setting a server extension point on 'onPreStart'. + * If a circular dependency is detected, an exception is thrown (e.g. two plugins each has an after function to be called after the other). + * The method does not provide version dependency which should be implemented using npm peer dependencies. + */ + dependency(dependencies: string | string[], after?: ((server: Server) => Function)): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder) + * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' where: + * @param encoding - the encoder name string. + * @param encoder - a function using the signature function(options) where options are the encoding specific options configured in the route compression option, and the return value is an object compatible with the output of node's zlib.createGzip(). + * @return Return value: none. + */ + encoder(encoding: string, encoder: ((options: RouteCompressionEncoderSettings) => zlib.Gzip)): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposekey-value) + * Used within a plugin to expose a property via server.plugins[name] where: + * @param key - the key assigned (server.plugins[name][key]). + * @param value - the value assigned. + * @return Return value: none. + */ + expose(key: string, value: any): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposeobj) + * Merges an object into to the existing content of server.plugins[name] where: + * @param obj - the object merged into the exposed properties container. + * @return Return value: none. + * Note that all the properties of obj are deeply cloned into server.plugins[name], so avoid using this method + * for exposing large objects that may be expensive to clone or singleton objects such as database client + * objects. Instead favor server.expose(key, value), which only copies a reference to value. + */ + expose(obj: Object): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) + * Registers an extension function in one of the request lifecycle extension points where: + * @param events - an object or array of objects with the following: + * * type - (required) the extension point event name. The available extension points include the request extension points as well as the following server extension points: + * * * 'onPreStart' - called before the connection listeners are started. + * * * 'onPostStart' - called after the connection listeners are started. + * * * 'onPreStop' - called before the connection listeners are stopped. + * * * 'onPostStop' - called after the connection listeners are stopped. + * * method - (required) a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is: + * * * server extension points: async function(server) where: + * * * * server - the server object. + * * * * this - the object provided via options.bind or the current active context set with server.bind(). + * * * request extension points: a lifecycle method. + * * options - (optional) an object with the following: + * * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. + * * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. + * * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. + * * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. + * @return void + */ + ext(events: ServerExtEventsObject | ServerExtEventsObject[]): void; + ext(events: ServerExtEventsRequestObject | ServerExtEventsRequestObject[]): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options) + * Registers a single extension event using the same properties as used in server.ext(events), but passed as arguments. + * @return Return value: none. + */ + ext(event: ServerExtType, method: ServerExtPointFunction, options?: ServerExtOptions): void; + ext(event: ServerExtRequestType, method: RequestExtPointFunction, options?: ServerExtOptions): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinitialize) + * Initializes the server (starts the caches, finalizes plugin registration) but does not start listening on the connection port. + * @return Return value: none. + * Note that if the method fails and throws an error, the server is considered to be in an undefined state and + * should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and + * other event listeners will get confused by repeated attempts to start the server or make assumptions about the + * healthy state of the environment. It is recommended to abort the process when the server fails to start properly. + * If you must try to resume after an error, call server.stop() first to reset the server state. + */ + initialize(): void; + + /** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions) + * Injects a request into the server simulating an incoming HTTP request without making an actual socket connection. Injection is useful for testing purposes as well as for invoking routing logic internally without the overhead and limitations of the network stack. + * The method utilizes the shot module for performing injections, with some additional options and response properties: + * @param options - can be assigned a string with the requested URI, or an object with: + * * method - (optional) the request HTTP method (e.g. 'POST'). Defaults to 'GET'. + * * url - (required) the request URL. If the URI includes an authority (e.g. 'example.com:8080'), it is used to automatically set an HTTP 'Host' header, unless one was specified in headers. + * * headers - (optional) an object with optional request headers where each key is the header name and the value is the header content. Defaults to no additions to the default shot headers. + * * payload - (optional) an string, buffer or object containing the request payload. In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided. + * * credentials - (optional) an credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials. + * * artifacts - (optional) an artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts. + * * app - (optional) sets the initial value of request.app, defaults to {}. + * * plugins - (optional) sets the initial value of request.plugins, defaults to {}. + * * allowInternals - (optional) allows access to routes with config.isInternal set to true. Defaults to false. + * * remoteAddress - (optional) sets the remote address for the incoming connection. + * * simulate - (optional) an object with options used to simulate client request stream conditions for testing: + * * error - if true, emits an 'error' event after payload transmission (if any). Defaults to false. + * * close - if true, emits a 'close' event after payload transmission (if any). Defaults to false. + * * end - if false, does not end the stream. Defaults to true. + * * split - indicates whether the request payload will be split into chunks. Defaults to undefined, meaning payload will not be chunked. + * * validate - (optional) if false, the options inputs are not validated. This is recommended for run-time usage of inject() to make it perform faster where input validation can be tested separately. + * @return Return value: a response object with the following properties: + * * statusCode - the HTTP status code. + * * headers - an object containing the headers set. + * * payload - the response payload string. + * * rawPayload - the raw response payload buffer. + * * raw - an object with the injection request and response objects: + * * req - the simulated node request object. + * * res - the simulated node response object. + * * result - the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the internal objects returned (instead of parsing the response string). + * * request - the request object. + */ + inject(options: string | ServerInjectOptions): ServerInjectResponse; + + /** + * Logs server events that cannot be associated with a specific request. When called the server emits a 'log' event which can be used by other listeners or plugins to record the information or output to the console. The arguments are: + * @param tags - (required) a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. Any logs generated by the server internally include the 'hapi' tag along with event-specific information. + * @param data - (optional) an message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. + * @param timestamp - (optional) an timestamp expressed in milliseconds. Defaults to Date.now() (now). + * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverlogtags-data-timestamp) + */ + log(tags: string | string[], data?: string | Object | (() => Function), timestamp?: number): void; + + /** + * Looks up a route configuration where: + * @param id - the route identifier. + * @return Return value: the route information if found, otherwise null. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverlookupid) + */ + lookup(id: string): RequestRoute | null; + + /** + * Looks up a route configuration where: + * @param method - the HTTP method (e.g. 'GET', 'POST'). + * @param path - the requested path (must begin with '/'). + * @param host - (optional) hostname (to match against routes with vhost). + * @return Return value: the route information if found, otherwise null. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermatchmethod-path-host) + */ + match(method: HTTP_METHODS, path: string, host?: string): RequestRoute | null; + + From 6a2a84d017a422109d2352067d7a3b01b7780b1a Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 26 Nov 2017 18:56:34 -0300 Subject: [PATCH 016/298] Replaced "any" type to "RouteCompressionEncoderSettings" type to better understanding because is shared with other interface. --- types/hapi/v17/definitions/route/route-options.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/v17/definitions/route/route-options.d.ts index d393e25810..db012ed3ce 100644 --- a/types/hapi/v17/definitions/route/route-options.d.ts +++ b/types/hapi/v17/definitions/route/route-options.d.ts @@ -9,6 +9,12 @@ import {FailAction} from "../util/fail-action"; import {RouteOptionsValidate} from "./route-options-validate"; import {PluginSpecificConfiguration} from "../plugin/plugin"; +/** + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression) + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder) + */ +export type RouteCompressionEncoderSettings = any; + /** Each route can be customized to change the default behavior of the request lifecycle. */ export interface RouteOptions { @@ -37,7 +43,7 @@ export interface RouteOptions { /** An object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in compression. */ - compression?: Dictionary; + compression?: Dictionary; /** Default value: false (no CORS headers). From a03205797eee83cb76a682b3add2c2faacd50d96 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 26 Nov 2017 19:04:41 -0300 Subject: [PATCH 017/298] Updated index with last file definitions. --- types/hapi/v17/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index 9efde0895d..98f8377102 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -14,6 +14,9 @@ export * from './definitions/plugin/plugin-registered' /** REQUEST */ export * from './definitions/request/request' +export * from './definitions/request/request-auth' +export * from './definitions/request/request-info' +export * from './definitions/request/request-route' /** RESPONSE */ export * from './definitions/response/response-object' @@ -33,7 +36,9 @@ export * from './definitions/route/route-options-validate' /** SERVER */ export * from './definitions/server/server' export * from './definitions/server/server-events' +export * from './definitions/server/server-ext' export * from './definitions/server/server-info' +export * from './definitions/server/server-inject' export * from './definitions/server/server-options' export * from './definitions/server/server-options-cache' export * from './definitions/server/server-realm' From 544cf39a2d424612d51e1dbc8b90caf0b86cb98b Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 26 Nov 2017 23:18:12 -0300 Subject: [PATCH 018/298] Added generic LifeCycle interfaces. --- .../hapi/v17/definitions/util/lifecycle.d.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 types/hapi/v17/definitions/util/lifecycle.d.ts diff --git a/types/hapi/v17/definitions/util/lifecycle.d.ts b/types/hapi/v17/definitions/util/lifecycle.d.ts new file mode 100644 index 0000000000..9dba7980d4 --- /dev/null +++ b/types/hapi/v17/definitions/util/lifecycle.d.ts @@ -0,0 +1,28 @@ +/** + * Lifecycle methods are the interface between the framework and the application. Many of the request lifecycle steps: + * extensions, authentication, handlers, pre-handler methods, and failAction function values are lifecyle methods + * provided by the developer and executed by the framework. + * Each lifecycle method is a function with the signature await function(request, h, [err]) where: + * * request - the request object. + * * h - the response toolkit the handler must call to set a response and return control back to the framework. + * * err - an error object availble only when the method is used as a failAction value. + */ +export interface LifecycleMethod { + + // TODO need to be implemented. Ideally with Generics types. + +} + +/** + * Each lifecycle method must return a value or a promise that resolves into a value. If a lifecycle method returns + * without a value or resolves to an undefined value, an Internal Server Error (500) error response is sent. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) + */ +export interface LifecycleReturnValue { + + + +} + + + From 1d687c3144c2285fff960071128afaf544f1e437 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 26 Nov 2017 23:19:58 -0300 Subject: [PATCH 019/298] Added Server Auth definitions. --- .../server/server-auth-scheme.d.ts | 71 ++++++++++++++ .../v17/definitions/server/server-auth.d.ts | 95 +++++++++++++++++++ types/hapi/v17/definitions/server/server.d.ts | 27 +----- 3 files changed, 169 insertions(+), 24 deletions(-) create mode 100644 types/hapi/v17/definitions/server/server-auth-scheme.d.ts create mode 100644 types/hapi/v17/definitions/server/server-auth.d.ts diff --git a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts new file mode 100644 index 0000000000..db21ed6111 --- /dev/null +++ b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts @@ -0,0 +1,71 @@ +import {Server} from "./server"; +import {LifecycleReturnValue} from "../util/lifecycle"; +import {ResponseToolkit} from "../response/response-toolkit"; +import {Request} from "../request/request"; + +/** + * The scheme options argument passed to server.auth.strategy() when instantiation a strategy. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme) + */ +export type ServerAuthSchemeOptions = any; + +/** + * the method implementing the scheme with signature function(server, options) where: + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme) + * @param server - a reference to the server object the scheme is added to. + * @param options - (optional) the scheme options argument passed to server.auth.strategy() when instantiation a strategy. + */ +export interface ServerAuthScheme { + (server: Server, options?: ServerAuthSchemeOptions): ServerAuthSchemeObject; +} + +/** + * The scheme method must return an object with the following + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#authentication-scheme) + */ +export interface ServerAuthSchemeObject { + + /** + * optional object which is exposed via the [server.auth.api](https://github.com/hapijs/hapi/blob/master/API.md#server.auth.api) object. + */ + api?: any; + + /** + * A lifecycle method function called for each incoming request configured with the authentication scheme. The + * method is provided with two special toolkit methods for returning an authenticated or an unauthenticate result: + * * h.authenticated() - indicate request authenticated successfully. + * * h.unauthenticated() - indicate request failed to authenticate. + * @param request the request object. + * @param h the ResponseToolkit + * @return the LifecycleReturnValue + */ + authenticate(request: Request, h: ResponseToolkit): LifecycleReturnValue; + + /** + * A lifecycle method to authenticate the request payload. + * When the scheme payload() method returns an error with a message, it means payload validation failed due to bad + * payload. If the error has no message but includes a scheme name (e.g. Boom.unauthorized(null, 'Custom')), + * authentication may still be successful if the route auth.payload configuration is set to 'optional'. + * @param request the request object. + * @param h the ResponseToolkit + * @return the LifecycleReturnValue + */ + payload?(request: Request, h: ResponseToolkit): LifecycleReturnValue; + + /** + * A lifecycle method to decorate the response with authentication headers before the response headers or payload is written. + * @param request the request object. + * @param h the ResponseToolkit + * @return the LifecycleReturnValue + */ + response?(request: Request, h: ResponseToolkit): LifecycleReturnValue; + + /** + * An object with the following keys: + * * payload - if true, requires payload validation as part of the scheme and forbids routes from disabling payload auth validation. Defaults to false. + */ + options?: { + payload?: boolean; + }; + +} diff --git a/types/hapi/v17/definitions/server/server-auth.d.ts b/types/hapi/v17/definitions/server/server-auth.d.ts new file mode 100644 index 0000000000..370e16be6b --- /dev/null +++ b/types/hapi/v17/definitions/server/server-auth.d.ts @@ -0,0 +1,95 @@ +import {ServerAuthScheme} from "./server-auth-scheme"; +import {Request} from "../request/request"; +import {RouteOptionsAccess} from "hapi"; +import {Dictionary} from "../util/util"; + +/** + * The authentication credentials object + * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverauthteststrategy-request) + */ +export interface ServerAuthenticatedCredentials { + +} + +/** + * An authentication configuration object using the same format as the route auth handler options. + * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions) + */ +export interface ServerAuthConfig extends RouteOptionsAccess { + +} + +export interface ServerAuth { + + /** + * An object where each key is an authentication strategy name and the value is the exposed strategy API. + * Available only when the authentication scheme exposes an API by returning an api key in the object + * returned from its implementation function. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi) + */ + api: Dictionary; + + /** + * Contains the default authentication configuration is a default strategy was set via + * [server.auth.default()](https://github.com/hapijs/hapi/blob/master/API.md#server.auth.default()). + */ + readonly settings: { + default: ServerAuthConfig; + } + + /** + * server.auth.default + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions) + * Sets a default strategy which is applied to every route where: + * @param options - one of: + * * a string with the default strategy name + * * an authentication configuration object using the same format as the route auth handler options. + * @return void. + * The default does not apply when a route config specifies auth as false, or has an authentication strategy + * configured (contains the strategy or strategies authentication settings). Otherwise, the route authentication + * config is applied to the defaults. + * Note that if the route has authentication configured, the default only applies at the time of adding the route, + * not at runtime. This means that calling server.auth.default() after adding a route with some authentication + * config will have no impact on the routes added prior. However, the default will apply to routes added + * before server.auth.default() is called if those routes lack any authentication config. + * The default auth strategy configuration can be accessed via server.auth.settings.default. To obtain the active + * authentication configuration of a route, use server.auth.lookup(request.route). + */ + default(options: string | ServerAuthConfig): void; + + /** + * server.auth.scheme + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme) + * Registers an authentication scheme where: + * @param name the scheme name. + * @param scheme - the method implementing the scheme with signature function(server, options) where: + * * server - a reference to the server object the scheme is added to. + * * options - (optional) the scheme options argument passed to server.auth.strategy() when instantiation a strategy. + * @return void. + */ + scheme(name: string, scheme: ServerAuthScheme): void; + + /** + * Registers an authentication strategy where: + * @param name - the strategy name. + * @param scheme - the scheme name (must be previously registered using server.auth.scheme()). + * @param options - scheme options based on the scheme requirements. + * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthstrategyname-scheme-options) + */ + strategy(name: string, scheme: string, options?: any): void; + + /** + * Tests a request against an authentication strategy where: + * @param strategy - the strategy name registered with server.auth.strategy(). + * @param request - the request object. + * @return Return value: the authentication credentials object if authentication was successful, otherwise throws an error. + * Note that the test() method does not take into account the route authentication configuration. It also does not + * perform payload authentication. It is limited to the basic strategy authentication execution. It does not + * include verifying scope, entity, or other route properties. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverauthteststrategy-request) + */ + test(strategy: string, request: Request): ServerAuthenticatedCredentials; + +} + diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 741279629b..92fc4ac961 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -1,7 +1,6 @@ import {ServerOptions} from "./server-options"; import {ServerRealm} from "./server-realm"; import {ServerInfo} from "./server-info"; -import {Dictionary} from "../util/util"; import {Request} from "../request/request"; import * as http from "http"; import * as events from 'events'; @@ -20,6 +19,7 @@ import { } from "./server-ext"; import {ServerInjectOptions, ServerInjectResponse} from "./server-inject"; import {RequestRoute} from "../request/request-route"; +import {ServerAuth, ServerAuthConfig} from "./server-auth"; /** * The server object is the main application container. The server manages all incoming requests along with all @@ -41,23 +41,9 @@ export class Server extends events.EventEmitter { app?: any; /** - * Access: authentication strategy specific. - * An object where each key is an authentication strategy name and the value is the exposed strategy API. - * Available only when the authentication scheme exposes an API by returning an api key in the object - * returned from its implementation function. + * Server Auth: properties and methods */ - // TODO is that definition right? It's need review. The v16 is very different. - auth: { - api: Dictionary; - } - - /** - * Access: read only. - * Contains the default authentication configuration is a default strategy was set via [server.auth.default()](https://github.com/hapijs/hapi/blob/master/API.md#server.auth.default()). - */ - // TODO it needs to be implemented. I didn't understand the description yet. - //readonly server.auth.settings.default - + auth: ServerAuth; /** * Provides access to the decorations already applied to various framework interfaces. The object must not be @@ -290,13 +276,6 @@ export class Server extends events.EventEmitter { */ readonly version: string; - - - - - // TODO Put SERVER AUTH here - - /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverbindcontext) * Sets a global context used as the default bind object when adding a route or an extension where: From c4d48d6542ae324a9f47bc3c482e17dee6542870 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 26 Nov 2017 23:21:04 -0300 Subject: [PATCH 020/298] Updated index with last file definitions. --- types/hapi/v17/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index 98f8377102..fa8569c974 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -35,6 +35,8 @@ export * from './definitions/route/route-options-validate' /** SERVER */ export * from './definitions/server/server' +export * from './definitions/server/server-auth' +export * from './definitions/server/server-auth-scheme' export * from './definitions/server/server-events' export * from './definitions/server/server-ext' export * from './definitions/server/server-info' @@ -47,4 +49,5 @@ export * from './definitions/server/server-state-options' /** UTIL */ export * from './definitions/util/fail-action' +export * from './definitions/util/lifecycle' export * from './definitions/util/util' From 6799c6506dda1f95148616fd5009fab60d573228 Mon Sep 17 00:00:00 2001 From: rsouza Date: Mon, 27 Nov 2017 13:12:09 -0300 Subject: [PATCH 021/298] Added more Server definitions. --- types/hapi/v17/definitions/server/server.d.ts | 34 +++++++++++++++++-- types/hapi/v17/hapi-tests.ts | 14 ++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 92fc4ac961..89169e0e2e 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -21,6 +21,10 @@ import {ServerInjectOptions, ServerInjectResponse} from "./server-inject"; import {RequestRoute} from "../request/request-route"; import {ServerAuth, ServerAuthConfig} from "./server-auth"; +export interface ServerMethod { + // (...args: any[], ttl?: number): any; +} + /** * The server object is the main application container. The server manages all incoming requests along with all * the facilities provided by the framework. Each server supports a single connection (e.g. listen to port 80). @@ -31,6 +35,7 @@ export class Server extends events.EventEmitter { Creates a new server object where: @param options - (optional) a server configuration object. */ + constructor(); constructor(options: ServerOptions); /** @@ -503,8 +508,23 @@ export class Server extends events.EventEmitter { */ match(method: HTTP_METHODS, path: string, host?: string): RequestRoute | null; - - + /** + * Registers a server method where: + * @param name - a unique method name used to invoke the method via server.methods[name]. + * @param method - the method function with a signature async function(...args, [flags]) where: + * * ...args - the method function arguments (can be any number of arguments or none). + * * flags - when caching is enabled, an object used to set optional method result flags: + * * * ttl - 0 if result is valid but cannot be cached. Defaults to cache policy. + * @param options - (optional) configuration object: + * * bind - a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. Ignored if the method is an arrow function. + * * cache - the same cache configuration used in server.cache(). The generateTimeout option is required. + * * generateKey - a function used to generate a unique key (for caching) from the arguments passed to the method function (the flags argument is not passed as input). The server will automatically generate a unique key if the function's arguments are all of types 'string', 'number', or 'boolean'. However if the method uses other types of arguments, a key generation function must be provided which takes the same arguments as the function and returns a unique string (or null if no key can be generated). + * @return Return value: none. + * Method names can be nested (e.g. utils.users.get) which will automatically create the full path under server.methods (e.g. accessed via server.methods.utils.users.get). + * When configured with caching enabled, server.methods[name].cache is assigned an object with the following properties and methods: - await drop(...args) - a function that can be used to clear the cache for a given key. - stats - an object with cache statistics, see catbox for stats documentation. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) + */ + // method(name: string, method: Function, options?: any): void; @@ -516,5 +536,15 @@ export class Server extends events.EventEmitter { // TODO It"s not finished + /** + * Starts the server by listening for incoming requests on the configured port (unless the connection was configured with autoListen set to false). + * @return Return value: none. + * Note that if the method fails and throws an error, the server is considered to be in an undefined state and should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and other event listeners will get confused by repeated attempts to start the server or make assumptions about the healthy state of the environment. It is recommended to abort the process when the server fails to start properly. If you must try to resume after an error, call server.stop() first to reset the server state. + * If a started server is started again, the second call to server.start() is ignored. No events will be emitted and no extension points invoked. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstart) + */ + start(): void; + + } diff --git a/types/hapi/v17/hapi-tests.ts b/types/hapi/v17/hapi-tests.ts index e0c05909c0..06e2cdf175 100644 --- a/types/hapi/v17/hapi-tests.ts +++ b/types/hapi/v17/hapi-tests.ts @@ -1,2 +1,12 @@ -import { Server } from "hapi"; -const server = new Server({ port: 3000, host: 'localhost' }); +import {Server, ServerOptions} from "hapi"; + +const options:ServerOptions = { + port: 8000 +} + +const server = new Server(options); +server.start(); + +console.log('Server started at: ' + server.info.uri); + + From 3907d25ab74bf09b890e32c7e85ed188848eb23a Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Mon, 27 Nov 2017 20:58:46 -0300 Subject: [PATCH 022/298] Added more Server types --- types/hapi/v17/definitions/plugin/plugin.d.ts | 3 +- .../v17/definitions/server/server-method.d.ts | 51 +++++++++++++ .../definitions/server/server-options.d.ts | 4 +- .../definitions/server/server-register.d.ts | 36 ++++++++++ types/hapi/v17/definitions/server/server.d.ts | 71 ++++++++++++++++--- types/hapi/v17/index.d.ts | 2 + 6 files changed, 155 insertions(+), 12 deletions(-) create mode 100644 types/hapi/v17/definitions/server/server-method.d.ts create mode 100644 types/hapi/v17/definitions/server/server-register.d.ts diff --git a/types/hapi/v17/definitions/plugin/plugin.d.ts b/types/hapi/v17/definitions/plugin/plugin.d.ts index f781de97bf..df31c2c449 100644 --- a/types/hapi/v17/definitions/plugin/plugin.d.ts +++ b/types/hapi/v17/definitions/plugin/plugin.d.ts @@ -4,7 +4,6 @@ export interface PluginsStates { [pluginName: string]: any; } -// Similar to v16, using that interface without any definition. export interface PluginSpecificConfiguration { } @@ -32,7 +31,7 @@ export interface Plugin { * registry) should use the same name as the name field in their 'package.json' file. Names must be * unique within each application. */ - name?: string; + name: string; /** optional plugin version. The version is only used informatively to enable other plugins to find out the versions loaded. The version should be the same as the one specified in the plugin's 'package.json' file. */ version?: string; diff --git a/types/hapi/v17/definitions/server/server-method.d.ts b/types/hapi/v17/definitions/server/server-method.d.ts new file mode 100644 index 0000000000..216fd6ce6f --- /dev/null +++ b/types/hapi/v17/definitions/server/server-method.d.ts @@ -0,0 +1,51 @@ +import * as catbox from "catbox"; + +/** + * The method function with a signature async function(...args, [flags]) where: + * * ...args - the method function arguments (can be any number of arguments or none). + * * flags - when caching is enabled, an object used to set optional method result flags: + * * * ttl - 0 if result is valid but cannot be cached. Defaults to cache policy. + * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) + */ +export interface ServerMethod { + (args: any[], flags: {ttl?: number}): any; +} + +/** + * The same cache configuration used in server.cache(). + * The generateTimeout option is required. + * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) + * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) + */ +export interface ServerMethodCache extends catbox.PolicyOptions { + /** + * Required + */ + generateTimeout: number | false; +} + +/** + * Configuration object: + * * bind - a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. Ignored if the method is an arrow function. + * * cache - the same cache configuration used in server.cache(). The generateTimeout option is required. + * * generateKey - a function used to generate a unique key (for caching) from the arguments passed to the method function (the flags argument is not passed as input). The server will automatically generate a unique key if the function's arguments are all of types 'string', 'number', or 'boolean'. However if the method uses other types of arguments, a key generation function must be provided which takes the same arguments as the function and returns a unique string (or null if no key can be generated). + * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) + */ +export interface ServerMethodOptions { + bind: any; + cache: ServerMethodCache; + generateKey: Function; +} + +/** + * An object or an array of objects where each one contains: + * * name - the method name. + * * method - the method function. + * * options - (optional) settings. + * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodmethods) + */ +export interface ServerMethodConfigurationObject { + name: string; + method: ServerMethod; + options?: ServerMethodOptions; +} diff --git a/types/hapi/v17/definitions/server/server-options.d.ts b/types/hapi/v17/definitions/server/server-options.d.ts index 3638531930..5b2b364f8c 100644 --- a/types/hapi/v17/definitions/server/server-options.d.ts +++ b/types/hapi/v17/definitions/server/server-options.d.ts @@ -1,7 +1,7 @@ import {ServerOptionsCache} from "./server-options-cache"; import * as http from "http"; import * as https from "https"; -import * as Catbox from "catbox"; +import * as catbox from "catbox"; import {MimosOptions} from "mimos"; import {PluginSpecificConfiguration, RouteOptions} from "hapi"; @@ -47,7 +47,7 @@ export interface ServerOptions { partition - (optional) string used to isolate cached data. Defaults to 'hapi-cache'. other options passed to the catbox strategy used. Other options are only passed to catbox when engine above is a class or function and ignored if engine is a catbox engine object). */ - cache?: Catbox.EnginePrototype | ServerOptionsCache | ServerOptionsCache[]; + cache?: catbox.EnginePrototype | ServerOptionsCache | ServerOptionsCache[]; /** Default value: { minBytes: 1024 }. diff --git a/types/hapi/v17/definitions/server/server-register.d.ts b/types/hapi/v17/definitions/server/server-register.d.ts new file mode 100644 index 0000000000..34685cbde2 --- /dev/null +++ b/types/hapi/v17/definitions/server/server-register.d.ts @@ -0,0 +1,36 @@ +import {Plugin} from "hapi"; + +/** + * Registration options (different from the options passed to the registration function): + * * once - if true, subsequent registrations of the same plugin are skipped without error. Cannot be used with plugin options. Defaults to false. If not set to true, an error will be thrown the second time a plugin is registered on the server. + * * routes - modifiers applied to each route added by the plugin: + * * * prefix - string added as prefix to any route path (must begin with '/'). If a plugin registers a child plugin the prefix is passed on to the child or is added in front of the child-specific prefix. + * * * vhost - virtual host string (or array of strings) applied to every route. The outer-most vhost overrides the any nested configuration. + * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options) + */ +export interface ServerRegisterOptions { + + once?: boolean; + routes?: { + prefix: string; + vhost: string | string[]; + }; + +} + +/** + * An object with the following: + * * plugin - a plugin object. + * * options - (optional) options passed to the plugin during registration. + * * once - if true, subsequent registrations of the same plugin are skipped without error. Cannot be used with plugin options. Defaults to false. If not set to true, an error will be thrown the second time a plugin is registered on the server. + * * routes - modifiers applied to each route added by the plugin: + * * * prefix - string added as prefix to any route path (must begin with '/'). If a plugin registers a child plugin the prefix is passed on to the child or is added in front of the child-specific prefix. + * * * vhost - virtual host string (or array of strings) applied to every route. The outer-most vhost overrides the any nested configuration. + * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options) + */ +export interface ServerRegisterPluginObject extends ServerRegisterOptions { + + plugin: Plugin; + options?: any; + +} diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 89169e0e2e..0866db9f6f 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -11,7 +11,9 @@ import {ServerState} from "./server-state"; import {MimosOptions} from "../../../../mimos/index"; import { ServerOptionsCache, ServerEventCriteria, ServerEventsApplication, ServerEventsApplicationObject, - PayloadCompressionDecoderSettings, RouteCompressionEncoderSettings, HTTP_METHODS + PayloadCompressionDecoderSettings, RouteCompressionEncoderSettings, HTTP_METHODS, ServerMethodOptions, ServerMethod, + ServerMethodConfigurationObject, + Plugin, } from "hapi"; import { RequestExtPointFunction, ServerExtEventsObject, ServerExtEventsRequestObject, ServerExtOptions, @@ -20,10 +22,7 @@ import { import {ServerInjectOptions, ServerInjectResponse} from "./server-inject"; import {RequestRoute} from "../request/request-route"; import {ServerAuth, ServerAuthConfig} from "./server-auth"; - -export interface ServerMethod { - // (...args: any[], ttl?: number): any; -} +import {ServerRegisterPluginObject, ServerRegisterOptions} from "./server-register"; /** * The server object is the main application container. The server manages all incoming requests along with all @@ -524,7 +523,65 @@ export class Server extends events.EventEmitter { * When configured with caching enabled, server.methods[name].cache is assigned an object with the following properties and methods: - await drop(...args) - a function that can be used to clear the cache for a given key. - stats - an object with cache statistics, see catbox for stats documentation. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) */ - // method(name: string, method: Function, options?: any): void; + method(name: string, method: ServerMethod, options?: ServerMethodOptions): void; + + /** + * Registers a server method function as described in server.method() using a configuration object where: + * @param methods - an object or an array of objects where each one contains: + * * name - the method name. + * * method - the method function. + * * options - (optional) settings. + * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodmethods) + */ + method(methods: ServerMethodConfigurationObject): void; + method(methods: ServerMethodConfigurationObject[]): void; + + /** + * Sets the path prefix used to locate static resources (files and view templates) when relative paths are used where: + * @param relativeTo - the path prefix added to any relative file path starting with '.'. + * @return Return value: none. + * Note that setting a path within a plugin only applies to resources accessed by plugin methods. If no path is set, the server default route configuration files.relativeTo settings is used. The path only applies to routes added after it has been set. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverpathrelativeto) + */ + path(relativeTo: string): void; + + /** + * Registers a plugin where: + * @param plugins - one or an array of: + * * a plugin object. + * * an object with the following: + * * * plugin - a plugin object. + * * * options - (optional) options passed to the plugin during registration. + * * * once, routes - (optional) plugin-specific registration options as defined below. + * @paramoptions - (optional) registration options (different from the options passed to the registration function): + * * once - if true, subsequent registrations of the same plugin are skipped without error. Cannot be used with plugin options. Defaults to false. If not set to true, an error will be thrown the second time a plugin is registered on the server. + * * routes - modifiers applied to each route added by the plugin: + * * * prefix - string added as prefix to any route path (must begin with '/'). If a plugin registers a child plugin the prefix is passed on to the child or is added in front of the child-specific prefix. + * * * vhost - virtual host string (or array of strings) applied to every route. The outer-most vhost overrides the any nested configuration. + * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options) + */ + register(plugins: Plugin | ServerRegisterPluginObject): void; + register(plugins: Plugin | ServerRegisterPluginObject, options: ServerRegisterOptions): void; + register(plugins: Plugin[] | ServerRegisterPluginObject[]): void; + register(plugins: Plugin[] | ServerRegisterPluginObject[], options: ServerRegisterOptions): void; + + /** + * Adds a route where: + * @param route - a route configuration object or an array of configuration objects where each object contains: + * * path - (required) the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the server's router configuration. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. + * * method - (required) the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. + * * vhost - (optional) a domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. + * * handler - (required when handler is not set) the route handler function called to generate the response after successful authentication and validation. + * * options - additional route options. The options value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. + * * rules - route custom rules object. The object is passed to each rules processor registered with server.rules(). Cannot be used if route.options.rules is defined. + * @return Return value: none. + * Note that the options object is deeply cloned (with the exception of bind which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrouteroute) + */ + route(route: any): void; // TODO needs to be implemented. Depends of the route options TODO as well. + @@ -545,6 +602,4 @@ export class Server extends events.EventEmitter { */ start(): void; - - } diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index fa8569c974..e6ec85e659 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -41,9 +41,11 @@ export * from './definitions/server/server-events' export * from './definitions/server/server-ext' export * from './definitions/server/server-info' export * from './definitions/server/server-inject' +export * from './definitions/server/server-method' export * from './definitions/server/server-options' export * from './definitions/server/server-options-cache' export * from './definitions/server/server-realm' +export * from './definitions/server/server-register' export * from './definitions/server/server-state' export * from './definitions/server/server-state-options' From 08bc4cb219984cbb6e62dc16062251469fb8541a Mon Sep 17 00:00:00 2001 From: Sam Nau Date: Tue, 28 Nov 2017 15:30:25 -0600 Subject: [PATCH 023/298] **@types/siema : Trying to address missing configuration options in the definition file interfaces** * changed `onInit` to optional so that standard javascript objects could be used for Siema configration without having `onInit` defined * According to the Siema documentation, `perPage` can be either a number or a object with breakpoint values as keys and number of slides as values: * https://github.com/pawelgrzybek/siema * https://codepen.io/pawelgrzybek/pen/dWbGyZ --- types/siema/index.d.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/types/siema/index.d.ts b/types/siema/index.d.ts index 682c0e907e..834184a41e 100644 --- a/types/siema/index.d.ts +++ b/types/siema/index.d.ts @@ -17,17 +17,21 @@ declare class Siema { destroy(restoreMarkup: boolean, callback?: () => void): void; } +interface perPageInterface { + [key : number] : number; +} + interface SiemaOptions { selector?: string; duration?: number; easing?: string; - perPage?: number; + perPage?: number | perPageInterface; startIndex?: number; draggable?: boolean; multipleDrag?: boolean; threshold?: number; loop?: boolean; - onInit(): void; + onInit?(): void; onChange?(): void; } From df2aca6c8dc0ab48b3c2a12039bcf81c7288ba82 Mon Sep 17 00:00:00 2001 From: Sam Nau Date: Tue, 28 Nov 2017 15:59:58 -0600 Subject: [PATCH 024/298] fixing whitespace linting errors --- types/siema/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/siema/index.d.ts b/types/siema/index.d.ts index 834184a41e..d1b2c0d604 100644 --- a/types/siema/index.d.ts +++ b/types/siema/index.d.ts @@ -18,7 +18,7 @@ declare class Siema { } interface perPageInterface { - [key : number] : number; + [key: number]: number; } interface SiemaOptions { From 55e66bcf7d8eb112071087ced4f60cf145b88989 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 28 Nov 2017 21:44:54 -0300 Subject: [PATCH 025/298] Creating namespace Lifecycle and moving FailAction to inside. --- .../v17/definitions/util/fail-action.d.ts | 4 -- .../hapi/v17/definitions/util/lifecycle.d.ts | 63 ++++++++++++------- 2 files changed, 39 insertions(+), 28 deletions(-) delete mode 100644 types/hapi/v17/definitions/util/fail-action.d.ts diff --git a/types/hapi/v17/definitions/util/fail-action.d.ts b/types/hapi/v17/definitions/util/fail-action.d.ts deleted file mode 100644 index 7b2eb4c4b8..0000000000 --- a/types/hapi/v17/definitions/util/fail-action.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -// TODO It should be replaced by FailAction definition (with lifecycle method) in the future. -// https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-failAction -export type FailAction = 'error' | 'log' | 'ignore' | any; - diff --git a/types/hapi/v17/definitions/util/lifecycle.d.ts b/types/hapi/v17/definitions/util/lifecycle.d.ts index 9dba7980d4..41864a6bdf 100644 --- a/types/hapi/v17/definitions/util/lifecycle.d.ts +++ b/types/hapi/v17/definitions/util/lifecycle.d.ts @@ -1,28 +1,43 @@ -/** - * Lifecycle methods are the interface between the framework and the application. Many of the request lifecycle steps: - * extensions, authentication, handlers, pre-handler methods, and failAction function values are lifecyle methods - * provided by the developer and executed by the framework. - * Each lifecycle method is a function with the signature await function(request, h, [err]) where: - * * request - the request object. - * * h - the response toolkit the handler must call to set a response and return control back to the framework. - * * err - an error object availble only when the method is used as a failAction value. - */ -export interface LifecycleMethod { +export namespace Lifecycle { - // TODO need to be implemented. Ideally with Generics types. + /** + * Lifecycle methods are the interface between the framework and the application. Many of the request lifecycle steps: + * extensions, authentication, handlers, pre-handler methods, and failAction function values are lifecyle methods + * provided by the developer and executed by the framework. + * Each lifecycle method is a function with the signature await function(request, h, [err]) where: + * * request - the request object. + * * h - the response toolkit the handler must call to set a response and return control back to the framework. + * * err - an error object availble only when the method is used as a failAction value. + */ + export interface LifecycleMethod { + + // TODO needs to be implemented. + + } + + /** + * Each lifecycle method must return a value or a promise that resolves into a value. If a lifecycle method returns + * without a value or resolves to an undefined value, an Internal Server Error (500) error response is sent. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) + */ + export interface LifecycleReturnValue { + + // TODO needs to be implemented. + + } + + /** + * Various configuration options allows defining how errors are handled. For example, when invalid payload is received or malformed cookie, instead of returning an error, the framework can be configured to perform another action. When supported the failAction option supports the following values: + * * 'error' - return the error object as the response. + * * 'log' - report the error but continue processing the request. + * * 'ignore' - take no action and continue processing the request. + * * a lifecycle method with the signature async function(request, h, err) where: + * * * request - the request object. + * * * h - the response toolkit. + * * * err - the error object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-failaction-configuration) + */ + export type FailAction = 'error' | 'log' | 'ignore' | LifecycleMethod; } -/** - * Each lifecycle method must return a value or a promise that resolves into a value. If a lifecycle method returns - * without a value or resolves to an undefined value, an Internal Server Error (500) error response is sent. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) - */ -export interface LifecycleReturnValue { - - - -} - - - From c26417bb5955ef013ea43efe5e21fb27b6d1743c Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 28 Nov 2017 21:46:35 -0300 Subject: [PATCH 026/298] Reviewing Route types and getting better. Not finished yet. --- .../route/route-options-access-scope.d.ts | 28 +++ .../route/route-options-access.d.ts | 98 +++++---- .../route/route-options-cache.d.ts | 20 +- .../definitions/route/route-options-cors.d.ts | 19 +- .../route/route-options-payload.d.ts | 136 +++++++------ .../definitions/route/route-options-pre.d.ts | 26 +++ .../route/route-options-response.d.ts | 75 ++++--- .../route/route-options-validate.d.ts | 4 +- .../v17/definitions/route/route-options.d.ts | 192 +++++++++++------- 9 files changed, 370 insertions(+), 228 deletions(-) create mode 100644 types/hapi/v17/definitions/route/route-options-access-scope.d.ts create mode 100644 types/hapi/v17/definitions/route/route-options-pre.d.ts diff --git a/types/hapi/v17/definitions/route/route-options-access-scope.d.ts b/types/hapi/v17/definitions/route/route-options-access-scope.d.ts new file mode 100644 index 0000000000..4ed76fe9c6 --- /dev/null +++ b/types/hapi/v17/definitions/route/route-options-access-scope.d.ts @@ -0,0 +1,28 @@ +import {RouteOptionsAccessEntity} from "hapi"; + +/** + * Each rule is evaluated against an incoming request and access is granted if at least one of the rules matches. + * Each rule object must include at least one of [scope](https://github.com/hapijs/hapi/blob/master/API.md#route.options.auth.access.scope) or [entity](https://github.com/hapijs/hapi/blob/master/API.md#route.options.auth.access.entity). + */ +export interface RouteOptionsAccessObject { + + /** + * Default value: false (no scope requirements). + * The application scope required to access the route. Value can be a scope string or an array of scope strings. When authenticated, the credentials object scope property must contain at least one of the scopes defined to access the route. + * If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' scope must not include 'a', must include 'b', and must include one of 'c' or 'd'. + * You may also access properties on the request object (query, params, payload, and credentials) to populate a dynamic scope by using the '{' and '}' characters around the property name, such as 'user-{params.id}'. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessscope) + */ + scope?: false | string | string[]; + + /** + * Default value: 'any'. + * The required authenticated entity type. If set, must match the entity value of the request authenticated credentials. Available values: + * * 'any' - the authentication can be on behalf of a user or application. + * * 'user' - the authentication must be on behalf of a user which is identified by the presence of a 'user' attribute in the credentials object returned by the authentication strategy. + * * 'app' - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessentity) + */ + entity?: RouteOptionsAccessEntity; + +} diff --git a/types/hapi/v17/definitions/route/route-options-access.d.ts b/types/hapi/v17/definitions/route/route-options-access.d.ts index 99d8b0b3cf..8bc175b10a 100644 --- a/types/hapi/v17/definitions/route/route-options-access.d.ts +++ b/types/hapi/v17/definitions/route/route-options-access.d.ts @@ -1,74 +1,104 @@ -export enum AccessEntityEnum { +/** + * The required authenticated entity type. If set, must match the entity value of the request authenticated credentials. Available values: + * * 'any' - the authentication can be on behalf of a user or application. + * * 'user' - the authentication must be on behalf of a user which is identified by the presence of a 'user' attribute in the credentials object returned by the authentication strategy. + * * 'app' - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessentity) + */ +export enum RouteOptionsAccessEntity { Any = 'any', User = 'user', - App = 'app', + App = 'app' } -export enum AccessModeEnum { +/** + * The authentication mode. Available values: + * * 'required' - authentication is required. + * * 'optional' - authentication is optional - the request must include valid credentials or no credentials at all. + * * 'try' - similar to 'optional', any request credentials are attempted authentication, but if the credentials are invalid, the request proceeds regardless of the authentication error. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthmode) + */ +export enum RouteOptionsAccessMode { Required = 'required', Optional = 'optional', Try = 'try', } -export enum AccessPayloadEnum { +/** + * Available values: + * * false - no payload authentication. + * * 'required' - payload authentication required. + * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthpayload) + */ +export enum RouteOptionsAccessPayload { Required = 'required', Optional = 'optional', } -/** Authentication options */ +/** + * Route Authentication Options + */ export interface RouteOptionsAccess { /** - Default value: none. - An object or array of objects specifying the route access rules. Each rule is evaluated against an incoming request and access is granted if at least one of the rules matches. Each rule object must include at least one of scope or entity. + * Default value: none. + * An object or array of objects specifying the route access rules. Each rule is evaluated against an incoming request and access is granted if at least one of the rules matches. Each rule object must include at least one of scope or entity. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccess) */ access?: any | any[]; /** - Default value: false (no scope requirements). - The application scope required to access the route. Value can be a scope string or an array of scope strings. When authenticated, the credentials object scope property must contain at least one of the scopes defined to access the route. - If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' scope must not include 'a', must include 'b', and must include one of 'c' or 'd'. - You may also access properties on the request object (query, params, payload, and credentials) to populate a dynamic scope by using the '{' and '}' characters around the property name, such as 'user-{params.id}'. + * Default value: false (no scope requirements). + * The application scope required to access the route. Value can be a scope string or an array of scope strings. When authenticated, the credentials object scope property must contain at least one of the scopes defined to access the route. + * If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' scope must not include 'a', must include 'b', and must include one of 'c' or 'd'. + * You may also access properties on the request object (query, params, payload, and credentials) to populate a dynamic scope by using the '{' and '}' characters around the property name, such as 'user-{params.id}'. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessscope) */ scope?: false | string | string[]; /** - Default value: 'any'. - The required authenticated entity type. If set, must match the entity value of the request authenticated credentials. Available values: - 'any' - the authentication can be on behalf of a user or application. - 'user' - the authentication must be on behalf of a user which is identified by the presence of a 'user' attribute in the credentials object returned by the authentication strategy. - 'app' - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. + * Default value: 'any'. + * The required authenticated entity type. If set, must match the entity value of the request authenticated credentials. Available values: + * * 'any' - the authentication can be on behalf of a user or application. + * * 'user' - the authentication must be on behalf of a user which is identified by the presence of a 'user' attribute in the credentials object returned by the authentication strategy. + * * 'app' - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessentity) */ - entity?: AccessEntityEnum; + entity?: RouteOptionsAccessEntity; /** - Default value: 'required'. - The authentication mode. Available values: - 'required' - authentication is required. - 'optional' - authentication is optional - the request must include valid credentials or no credentials at all. - 'try' - similar to 'optional', any request credentials are attempted authentication, but if the credentials are invalid, the request proceeds regardless of the authentication error. + * Default value: 'required'. + * The authentication mode. Available values: + * * 'required' - authentication is required. + * * 'optional' - authentication is optional - the request must include valid credentials or no credentials at all. + * * 'try' - similar to 'optional', any request credentials are attempted authentication, but if the credentials are invalid, the request proceeds regardless of the authentication error. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthmode) */ - mode?: AccessModeEnum; + mode?: RouteOptionsAccessMode; /** - Default value: false, unless the scheme requires payload authentication. - If set, the incoming request payload is authenticated after it is processed. Requires a strategy with payload authentication support (e.g. Hawk). Cannot be set to a value other than 'required' when the scheme sets the authentication options.payload to true. - Available values: - false - no payload authentication. - 'required' - payload authentication required. - 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). + * Default value: false, unless the scheme requires payload authentication. + * If set, the incoming request payload is authenticated after it is processed. Requires a strategy with payload authentication support (e.g. Hawk). Cannot be set to a value other than 'required' when the scheme sets the authentication options.payload to true. + * Available values: + * * false - no payload authentication. + * * 'required' - payload authentication required. + * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthpayload) */ - payload?: false | AccessPayloadEnum; + payload?: false | RouteOptionsAccessPayload; /** - Default value: the default strategy set via server.auth.default(). - An array of string strategy names in the order they should be attempted. Cannot be used together with strategy. + * Default value: the default strategy set via server.auth.default(). + * An array of string strategy names in the order they should be attempted. Cannot be used together with strategy. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthstrategies) */ strategies?: string[]; /** - Default value: the default strategy set via server.auth.default(). - A string strategy names. Cannot be used together with strategies. + * Default value: the default strategy set via server.auth.default(). + * A string strategy names. Cannot be used together with strategies. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthstrategy) */ strategy?: string; diff --git a/types/hapi/v17/definitions/route/route-options-cache.d.ts b/types/hapi/v17/definitions/route/route-options-cache.d.ts index d3f10044e3..91df550ad4 100644 --- a/types/hapi/v17/definitions/route/route-options-cache.d.ts +++ b/types/hapi/v17/definitions/route/route-options-cache.d.ts @@ -1,15 +1,13 @@ /** - Default value: { privacy: 'default', statuses: [200], otherwise: 'no-cache' }. - If the route method is 'GET', the route can be configured to include HTTP caching directives in the response. Caching can be customized using an object with the following options: - privacy - determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are: - 'default' - no privacy flag. - 'public' - mark the response as suitable for public caching. - 'private' - mark the response as suitable only for private caching. - expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. - expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. - statuses - an array of HTTP response status code numbers (e.g. 200) which are allowed to include a valid caching directive. - otherwise - a string with the value of the 'Cache-Control' header when caching is disabled. - The default Cache-Control: no-cache header can be disabled by setting cache to false. + * Values are: + * * * 'default' - no privacy flag. + * * * 'public' - mark the response as suitable for public caching. + * * * 'private' - mark the response as suitable only for private caching. + * * expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. + * * expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. + * * statuses - an array of HTTP response status code numbers (e.g. 200) which are allowed to include a valid caching directive. + * * otherwise - a string with the value of the 'Cache-Control' header when caching is disabled. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscache) */ export type RouteOptionsCache = { privacy?: 'default' | 'public' | 'private'; diff --git a/types/hapi/v17/definitions/route/route-options-cors.d.ts b/types/hapi/v17/definitions/route/route-options-cors.d.ts index c85191db8e..d19e6a5774 100644 --- a/types/hapi/v17/definitions/route/route-options-cors.d.ts +++ b/types/hapi/v17/definitions/route/route-options-cors.d.ts @@ -1,13 +1,14 @@ /** - Default value: false (no CORS headers). - The Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. To enable, set cors to true, or to an object with the following options: - origin - an array of allowed origin servers strings ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a wildcard '*' character, or a single '*' origin string. If set to 'ignore', any incoming Origin header is ignored (present or not) and the 'Access-Control-Allow-Origin' header is set to '*'. Defaults to any origin ['*']. - maxAge - number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. Defaults to 86400 (one day). - headers - a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match']. - additionalHeaders - a strings array of additional headers to headers. Use this to keep the default headers in place. - exposedHeaders - a strings array of exposed headers ('Access-Control-Expose-Headers'). Defaults to ['WWW-Authenticate', 'Server-Authorization']. - additionalExposedHeaders - a strings array of additional headers to exposedHeaders. Use this to keep the default headers in place. - credentials - if true, allows user credentials to be sent ('Access-Control-Allow-Credentials'). Defaults to false. + * Default value: false (no CORS headers). + * The Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. To enable, set cors to true, or to an object with the following options: + * * origin - an array of allowed origin servers strings ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a wildcard '*' character, or a single '*' origin string. If set to 'ignore', any incoming Origin header is ignored (present or not) and the 'Access-Control-Allow-Origin' header is set to '*'. Defaults to any origin ['*']. + * * maxAge - number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. Defaults to 86400 (one day). + * * headers - a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match']. + * * additionalHeaders - a strings array of additional headers to headers. Use this to keep the default headers in place. + * * exposedHeaders - a strings array of exposed headers ('Access-Control-Expose-Headers'). Defaults to ['WWW-Authenticate', 'Server-Authorization']. + * * additionalExposedHeaders - a strings array of additional headers to exposedHeaders. Use this to keep the default headers in place. + * * credentials - if true, allows user credentials to be sent ('Access-Control-Allow-Credentials'). Defaults to false. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscors) */ export interface RouteOptionsCors { origin?: string[] | '*'| 'ignore'; diff --git a/types/hapi/v17/definitions/route/route-options-payload.d.ts b/types/hapi/v17/definitions/route/route-options-payload.d.ts index fc5a7b10c4..b7baaac182 100644 --- a/types/hapi/v17/definitions/route/route-options-payload.d.ts +++ b/types/hapi/v17/definitions/route/route-options-payload.d.ts @@ -1,116 +1,122 @@ -import {Dictionary} from "../util/util"; -import {FailAction} from "../util/fail-action"; +import {Dictionary, Lifecycle} from "hapi"; -export enum PayloadOutputEnum { - Data = 'data', - Stream = 'stream', - File = 'file' -} - -export enum PayloadMultipartOutputEnum { - // TODO not ready. The v16 definition have similar doubts: "// TODO type this?" - // https://github.com/hapijs/hapi/blob/master/API.md#route.options.payload.multipart - Data = 'data', - Stream = 'stream', - File = 'file', - Annotated = 'annotated', -} +/** + * The value must be one of: + * * 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, a raw Buffer is returned. + * * 'stream' - the incoming payload is made available via a Stream.Readable interface. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are provided as streams. File streams from a 'multipart/form-data' upload will also have a hapi property containing the filename and headers properties. Note that payload streams for multipart payloads are a synthetic interface created on top of the entire mutlipart content loaded into memory. To avoid loading large multipart payloads into memory, set parse to false and handle the multipart payload in the handler using a streaming parser (e.g. pez). + * * 'file' - the incoming payload is written to temporary file in the directory specified by the uploads settings. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are saved to disk. Note that it is the sole responsibility of the application to clean up the files generated by the framework. This can be done by keeping track of which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform cleanup. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadoutput) + */ +export type PayloadOutput = 'data' | 'stream' | 'file'; /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) */ export type PayloadCompressionDecoderSettings = any; -/**Determines how the request payload is processed.*/ +/** + * Determines how the request payload is processed. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayload) + */ export interface RouteOptionsPayload { /** - Default value: allows parsing of the following mime types: - application/json - application/*+json - application/octet-stream - application/x-www-form-urlencoded - multipart/form-data - text/* - A string or an array of strings with the allowed mime types for the endpoint. Use this settings to limit the set of allowed mime types. Note that allowing additional mime types not listed above will not enable them to be parsed, and if parse is true, the request will result in an error response. + * Default value: allows parsing of the following mime types: + * * application/json + * * application/*+json + * * application/octet-stream + * * application/x-www-form-urlencoded + * * multipart/form-data + * * text/* + * A string or an array of strings with the allowed mime types for the endpoint. Use this settings to limit the set of allowed mime types. Note that allowing additional mime types not listed above will not enable them to be parsed, and if parse is true, the request will result in an error response. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadallow) */ allow?: string | string[]; /** - Default value: none. - An object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in compression. + * Default value: none. + * An object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in compression. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) */ compression?: Dictionary; /** - Default value: 'application/json'. - The default content type if the 'Content-Type' request header is missing. + * Default value: 'application/json'. + * The default content type if the 'Content-Type' request header is missing. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloaddefaultcontenttype) */ defaultContentType?: string; /** - Default value: 'error' (return a Bad Request (400) error response). - A failAction value which determines how to handle payload parsing errors. + * Default value: 'error' (return a Bad Request (400) error response). + * A failAction value which determines how to handle payload parsing errors. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadfailaction) */ - failAction?: FailAction; + failAction?: Lifecycle.FailAction; /** - Default value: 1048576 (1MB). - Limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory. + * Default value: 1048576 (1MB). + * Limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadmaxbytes) */ maxBytes?: number; /** - Default value: none. - Overrides payload processing for multipart requests. Value can be one of: - false - disable multipart processing. - an object with the following required options: - output - same as the output option with an additional value option: - annotated - wraps each multipart part in an object with the following keys: - headers - the part headers. - filename - the part file name. - payload - the processed part payload. + * Default value: none. + * Overrides payload processing for multipart requests. Value can be one of: + * * false - disable multipart processing. + * an object with the following required options: + * * output - same as the output option with an additional value option: + * * * annotated - wraps each multipart part in an object with the following keys: // TODO type this? + * * * * headers - the part headers. + * * * * filename - the part file name. + * * * * payload - the processed part payload. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadmultipart) */ - multipart?: false | PayloadOutputEnum | PayloadMultipartOutputEnum ; + multipart?: false | { + output: PayloadOutput | 'annotated'; + }; /** - Default value: 'data'. - The processed payload format. The value must be one of: - 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, a raw Buffer is returned. - 'stream' - the incoming payload is made available via a Stream.Readable interface. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are provided as streams. File streams from a 'multipart/form-data' upload will also have a hapi property containing the filename and headers properties. Note that payload streams for multipart payloads are a synthetic interface created on top of the entire mutlipart content loaded into memory. To avoid loading large multipart payloads into memory, set parse to false and handle the multipart payload in the handler using a streaming parser (e.g. pez). - 'file' - the incoming payload is written to temporary file in the directory specified by the uploads settings. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are saved to disk. Note that it is the sole responsibility of the application to clean up the files generated by the framework. This can be done by keeping track of which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform cleanup. + * Default value: 'data'. + * The processed payload format. The value must be one of: + * * 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, a raw Buffer is returned. + * * 'stream' - the incoming payload is made available via a Stream.Readable interface. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are provided as streams. File streams from a 'multipart/form-data' upload will also have a hapi property containing the filename and headers properties. Note that payload streams for multipart payloads are a synthetic interface created on top of the entire mutlipart content loaded into memory. To avoid loading large multipart payloads into memory, set parse to false and handle the multipart payload in the handler using a streaming parser (e.g. pez). + * * 'file' - the incoming payload is written to temporary file in the directory specified by the uploads settings. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are saved to disk. Note that it is the sole responsibility of the application to clean up the files generated by the framework. This can be done by keeping track of which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform cleanup. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadoutput) */ - output?: PayloadOutputEnum; + output?: PayloadOutput; /** - Default value: none. - A mime type string overriding the 'Content-Type' header value received. + * Default value: none. + * A mime type string overriding the 'Content-Type' header value received. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadoverride) */ override?: string; /** - Default value: true. - Determines if the incoming payload is processed or presented raw. Available values: - true - if the request 'Content-Type' matches the allowed mime types set by allow (for the whole payload as well as parts), the payload is converted into an object when possible. If the format is unknown, a Bad Request (400) error response is sent. Any known content encoding is decoded. - false - the raw payload is returned unmodified. - 'gunzip' - the raw payload is returned unmodified after any known content encoding is decoded. + * Default value: true. + * Determines if the incoming payload is processed or presented raw. Available values: + * * true - if the request 'Content-Type' matches the allowed mime types set by allow (for the whole payload as well as parts), the payload is converted into an object when possible. If the format is unknown, a Bad Request (400) error response is sent. Any known content encoding is decoded. + * * false - the raw payload is returned unmodified. + * * 'gunzip' - the raw payload is returned unmodified after any known content encoding is decoded. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadparse) */ parse?: boolean | 'gunzip'; /** - Default value: to 10000 (10 seconds). - Payload reception timeout in milliseconds. Sets the maximum time allowed for the client to transmit the request payload (body) before giving up and responding with a Request Timeout (408) error response. - Set to false to disable. + * Default value: to 10000 (10 seconds). + * Payload reception timeout in milliseconds. Sets the maximum time allowed for the client to transmit the request payload (body) before giving up and responding with a Request Timeout (408) error response. + * Set to false to disable. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadtimeout) */ timeout?: false | number; /** - Default value: os.tmpdir(). - The directory used for writing file uploads. + * Default value: os.tmpdir(). + * The directory used for writing file uploads. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloaduploads) */ uploads?: string; } - - - diff --git a/types/hapi/v17/definitions/route/route-options-pre.d.ts b/types/hapi/v17/definitions/route/route-options-pre.d.ts new file mode 100644 index 0000000000..95b458d490 --- /dev/null +++ b/types/hapi/v17/definitions/route/route-options-pre.d.ts @@ -0,0 +1,26 @@ +import {Lifecycle} from "hapi"; + +/** + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre) + */ +export type RouteOptionsPreArray = RouteOptionsPreAllOptions[]; + +/** + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre) + */ +export type RouteOptionsPreAllOptions = RouteOptionsPreObject | RouteOptionsPreObject[] | Lifecycle.LifecycleMethod; + +/** + * An object with: + * * method - a lifecycle method. + * * assign - key name used to assign the response of the method to in request.pre and request.preResponses. + * * failAction - A failAction value which determine what to do when a pre-handler method throws an error. If assign is specified and the failAction setting is not 'error', the error will be assigned. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre) + */ +export interface RouteOptionsPreObject { + method: Lifecycle.LifecycleMethod; + assign: string; + failAction?: Lifecycle.FailAction; +} + + diff --git a/types/hapi/v17/definitions/route/route-options-response.d.ts b/types/hapi/v17/definitions/route/route-options-response.d.ts index 34293c9117..39db5e4574 100644 --- a/types/hapi/v17/definitions/route/route-options-response.d.ts +++ b/types/hapi/v17/definitions/route/route-options-response.d.ts @@ -1,67 +1,82 @@ -import {FailAction} from "../util/fail-action"; +import {Lifecycle, Dictionary} from "hapi"; +import {ValidationOptions} from "joi"; +/** + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseemptystatuscode) + */ export enum EmptyStatusCode { HTTP_200 = 200, HTTP_204 = 204, } -/**Processing rules for the outgoing response.*/ +/** + * Processing rules for the outgoing response. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponse) + */ export interface RouteOptionsResponse { /** - Default value: 200. - The default HTTP status code when the payload is considered empty. Value can be 200 or 204. Note that a 200 status code is converted to a 204 only at the time of response transmission (the response status code will remain 200 throughout the request lifecycle unless manually set). + * Default value: 200. + * The default HTTP status code when the payload is considered empty. Value can be 200 or 204. Note that a 200 status code is converted to a 204 only at the time of response transmission (the response status code will remain 200 throughout the request lifecycle unless manually set). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseemptystatuscode) */ emptyStatusCode?: EmptyStatusCode; /** - Default value: 'error' (return an Internal Server Error (500) error response). - A failAction value which defines what to do when a response fails payload validation. + * Default value: 'error' (return an Internal Server Error (500) error response). + * A failAction value which defines what to do when a response fails payload validation. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsefailaction) */ - failAction?: FailAction; + failAction?: Lifecycle.FailAction; /** - Default value: false. - If true, applies the validation rule changes to the response payload. + * Default value: false. + * If true, applies the validation rule changes to the response payload. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsemodify) */ modify?: boolean; /** - Default value: none. - joi options object pass to the validation function. Useful to set global options such as stripUnknown or abortEarly (the complete list is available here). If a custom validation function is defined via schema or status then options can an arbitrary object that will be passed to this function as the second argument. + * Default value: none. + * [joi](http://github.com/hapijs/joi) options object pass to the validation function. Useful to set global options such as stripUnknown or abortEarly (the complete list is available here). If a custom validation function is defined via schema or status then options can an arbitrary object that will be passed to this function as the second argument. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseoptions) */ - options?: any; // TODO need to implementation. Here is JOI def. + options?: ValidationOptions; // TODO needs validation /** - Default value: true. - If false, payload range support is disabled. + * Default value: true. + * If false, payload range support is disabled. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseranges) */ ranges?: boolean; /** - Default value: 100 (all responses). - The percent of response payloads validated (0 - 100). Set to 0 to disable all validation. + * Default value: 100 (all responses). + * The percent of response payloads validated (0 - 100). Set to 0 to disable all validation. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsesample) */ sample?: number; /** - Default value: true (no validation). - The default response payload validation rules (for all non-error responses) expressed as one of: - true - any payload allowed (no validation). - false - no payload allowed. - a joi validation object. The options along with the request context ({ headers, params, query, payload, app, auth }) are passed to the validation function. - a validation function using the signature async function(value, options) where: - value - the pending response payload. - options - The options along with the request context ({ headers, params, query, payload, app, auth }). - if the function returns a value and modify is true, the value is used as the new response. If the original response is an error, the return value is used to override the original error output.payload. If an error is thrown, the error is processed according to failAction. + * Default value: true (no validation). + * The default response payload validation rules (for all non-error responses) expressed as one of: + * * true - any payload allowed (no validation). + * * false - no payload allowed. + * * a joi validation object. The options along with the request context ({ headers, params, query, payload, app, auth }) are passed to the validation function. + * * a validation function using the signature async function(value, options) where: + * * * value - the pending response payload. + * * * options - The options along with the request context ({ headers, params, query, payload, app, auth }). + * * * if the function returns a value and modify is true, the value is used as the new response. If the original response is an error, the return value is used to override the original error output.payload. If an error is thrown, the error is processed according to failAction. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseschema) */ - schema?: boolean | any; // TODO need to implementation. Here is JOI and more. + schema?: boolean | ValidationOptions | ((value: any, options: any) => Function); // TODO it must be better /** - Default value: none. - Validation schemas for specific HTTP status codes. Responses (excluding errors) not matching the listed status codes are validated using the default schema. - status is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. + * Default value: none. + * Validation schemas for specific HTTP status codes. Responses (excluding errors) not matching the listed status codes are validated using the default schema. + * status is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsestatus) */ - status?: any; // TODO need to implementation. + status?: Dictionary; // TODO it must be better } diff --git a/types/hapi/v17/definitions/route/route-options-validate.d.ts b/types/hapi/v17/definitions/route/route-options-validate.d.ts index 7b3c6afda4..4e4a8351cd 100644 --- a/types/hapi/v17/definitions/route/route-options-validate.d.ts +++ b/types/hapi/v17/definitions/route/route-options-validate.d.ts @@ -1,4 +1,4 @@ -import {FailAction} from "../util/fail-action"; +import {Lifecycle} from "hapi"; /** Default value: { headers: true, params: true, query: true, payload: true, failAction: 'error' }. @@ -16,7 +16,7 @@ export interface RouteOptionsValidate { Default value: 'error' (return a Bad Request (400) error response). A failAction value which determines how to handle failed validations. When set to a function, the err argument includes the type of validation error under err.output.payload.validation.source. */ - failAction?: FailAction; + failAction?: Lifecycle.FailAction; /** Default value: true (no validation). diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/v17/definitions/route/route-options.d.ts index db012ed3ce..7b62764f0f 100644 --- a/types/hapi/v17/definitions/route/route-options.d.ts +++ b/types/hapi/v17/definitions/route/route-options.d.ts @@ -5,9 +5,11 @@ import {RouteOptionsCors} from "./route-options-cors"; import {RouteOptionsResponse} from "./route-options-response"; import {RouteOptionsPayload} from "./route-options-payload"; import {RouteOptionsSecure} from "./route-options-secure"; -import {FailAction} from "../util/fail-action"; import {RouteOptionsValidate} from "./route-options-validate"; import {PluginSpecificConfiguration} from "../plugin/plugin"; +import {Json} from "../util/util"; +import {RouteOptionsPreArray} from "./route-options-pre"; +import {Lifecycle} from "hapi"; /** * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression) @@ -15,152 +17,189 @@ import {PluginSpecificConfiguration} from "../plugin/plugin"; */ export type RouteCompressionEncoderSettings = any; -/** Each route can be customized to change the default behavior of the request lifecycle. */ +/** + * Each route can be customized to change the default behavior of the request lifecycle. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#route-options) + */ export interface RouteOptions { - /** Application-specific route configuration state. Should not be used by plugins which should use options.plugins[name] instead.*/ + /** + * Application-specific route configuration state. Should not be used by plugins which should use options.plugins[name] instead. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsapp) + */ app?: any; /** - Route authentication configuration. Value can be: - false to disable authentication if a default strategy is set. - a string with the name of an authentication strategy registered with server.auth.strategy(). The strategy will be set to 'required' mode. - an authentication configuration object. + * Route authentication configuration. Value can be: + * false to disable authentication if a default strategy is set. + * a string with the name of an authentication strategy registered with server.auth.strategy(). The strategy will be set to 'required' mode. + * an authentication configuration object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsapp) */ auth?: false | string | RouteOptionsAccess; /** - Default value: null. - An object passed back to the provided handler (via this) when called. Ignored if the method is an arrow function. + * Default value: null. + * An object passed back to the provided handler (via this) when called. Ignored if the method is an arrow function. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsbind) */ bind?: any; /** - Default value: { privacy: 'default', statuses: [200], otherwise: 'no-cache' }. + * Default value: { privacy: 'default', statuses: [200], otherwise: 'no-cache' }. + * If the route method is 'GET', the route can be configured to include HTTP caching directives in the response. Caching can be customized using an object with the following options: + * privacy - determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are: + * * * 'default' - no privacy flag. + * * * 'public' - mark the response as suitable for public caching. + * * * 'private' - mark the response as suitable only for private caching. + * * expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. + * * expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. + * * statuses - an array of HTTP response status code numbers (e.g. 200) which are allowed to include a valid caching directive. + * * otherwise - a string with the value of the 'Cache-Control' header when caching is disabled. + * The default Cache-Control: no-cache header can be disabled by setting cache to false. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscache) */ cache?: false | RouteOptionsCache; /** - An object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in compression. + * An object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in compression. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression) */ compression?: Dictionary; /** - Default value: false (no CORS headers). + * Default value: false (no CORS headers). + * The Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. To enable, set cors to true, or to an object with the following options: + * * origin - an array of allowed origin servers strings ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a wildcard '*' character, or a single '*' origin string. If set to 'ignore', any incoming Origin header is ignored (present or not) and the 'Access-Control-Allow-Origin' header is set to '*'. Defaults to any origin ['*']. + * * maxAge - number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. Defaults to 86400 (one day). + * * headers - a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match']. + * * additionalHeaders - a strings array of additional headers to headers. Use this to keep the default headers in place. + * * exposedHeaders - a strings array of exposed headers ('Access-Control-Expose-Headers'). Defaults to ['WWW-Authenticate', 'Server-Authorization']. + * * additionalExposedHeaders - a strings array of additional headers to exposedHeaders. Use this to keep the default headers in place. + * * credentials - if true, allows user credentials to be sent ('Access-Control-Allow-Credentials'). Defaults to false. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscors) */ cors?: false | RouteOptionsCors; /** - Default value: none. - Route description used for generating documentation (string). - This setting is not available when setting server route defaults using server.options.routes. + * Default value: none. + * Route description used for generating documentation (string). + * This setting is not available when setting server route defaults using server.options.routes. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsdescription) */ description?: string; /** - Default value: none. - Route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the server.ext(events) event argument. + * Default value: none. + * Route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the server.ext(events) event argument. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsext) */ - ext?: any; //TODO need to review and rewrite this definition + ext?: any; //TODO need to review and rewrite this definition // I saw again and I keep not understanding. /** - Default value: { relativeTo: '.' }. - Defines the behavior for accessing files: - relativeTo - determines the folder relative paths are resolved against. + * Default value: { relativeTo: '.' }. + * Defines the behavior for accessing files: + * * relativeTo - determines the folder relative paths are resolved against. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsfiles) */ files?: { relativeTo: string; } /** - Default value: none. - The route handler function performs the main business logic of the route and sets the respons. handler can be assigned: - a lifecycle method. - an object with a single property using the name of a handler type registred with the server.handler() method. The matching property value is passed as options to the registered handler generator. - const handler = function (request, h) { - return 'success'; - }; - Note: handlers using a fat arrow style function cannot be bound to any bind property. Instead, the bound context is available under h.context. + * Default value: none. + * The route handler function performs the main business logic of the route and sets the response. handler can be assigned: + * * a lifecycle method. + * * an object with a single property using the name of a handler type registred with the server.handler() method. The matching property value is passed as options to the registered handler generator. + * Note: handlers using a fat arrow style function cannot be bound to any bind property. Instead, the bound context is available under h.context. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionshandler) */ - handler?: any; //TODO need to review and rewrite this definition + handler?: Lifecycle.LifecycleMethod | Object; //TODO need to review /** - Default value: none. - An optional unique identifier used to look up the route using server.lookup(). Cannot be assigned to routes added with an array of methods. + * Default value: none. + * An optional unique identifier used to look up the route using server.lookup(). Cannot be assigned to routes added with an array of methods. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsid) */ id?: string; /** - Default value: false. - If true, the route cannot be accessed through the HTTP listener but only through the server.inject() interface with the allowInternals option set to true. Used for internal routes that should not be accessible to the outside world. + * Default value: false. + * If true, the route cannot be accessed through the HTTP listener but only through the server.inject() interface with the allowInternals option set to true. Used for internal routes that should not be accessible to the outside world. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsisinternal) */ isInternal?: boolean; /** - Default value: none. - Optional arguments passed to JSON.stringify() when converting an object or error response to a string payload or escaping it after stringification. Supports the following: - replacer - the replacer function or array. Defaults to no action. - space - number of spaces to indent nested object keys. Defaults to no indentation. - suffix - string suffix added after conversion to JSON string. Defaults to no suffix. - escape - calls Hoek.jsonEscape() after conversion to JSON string. Defaults to false. - - TODO this definition in v16 is a bit confuse for me. Need review and maybe rewrite. + * Default value: none. + * Optional arguments passed to JSON.stringify() when converting an object or error response to a string payload or escaping it after stringification. Supports the following: + * * replacer - the replacer function or array. Defaults to no action. + * * space - number of spaces to indent nested object keys. Defaults to no indentation. + * * suffix - string suffix added after conversion to JSON string. Defaults to no suffix. + * * escape - calls Hoek.jsonEscape() after conversion to JSON string. Defaults to false. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsjson) */ - json?: { - replaces?: any | any[]; - space?: number | string; - suffix?: string; - escape?: boolean; // TODO boolean only? - }; + json?: Json.StringifyArguments; /** - Default value: none. - Enables JSONP support by setting the value to the query parameter name containing the function name used to wrap the response payload. - For example, if the value is 'callback', a request comes in with 'callback=me', and the JSON response is '{ "a":"b" }', the payload will be 'me({ "a":"b" });'. Cannot be used with stream responses. - The 'Content-Type' response header is set to 'text/javascript' and the 'X-Content-Type-Options' response header is set to 'nosniff', and will override those headers even if explicitly set by response.type(). + * Default value: none. + * Enables JSONP support by setting the value to the query parameter name containing the function name used to wrap the response payload. + * For example, if the value is 'callback', a request comes in with 'callback=me', and the JSON response is '{ "a":"b" }', the payload will be 'me({ "a":"b" });'. Cannot be used with stream responses. + * The 'Content-Type' response header is set to 'text/javascript' and the 'X-Content-Type-Options' response header is set to 'nosniff', and will override those headers even if explicitly set by response.type(). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsjsonp) */ jsonp?: string; /** - Default value: { collect: false }. - Request logging options: - collect - if true, request-level logs (both internal and application) are collected and accessible via request.logs. + * Default value: { collect: false }. + * Request logging options: + * collect - if true, request-level logs (both internal and application) are collected and accessible via request.logs. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionslog) */ - log?: boolean; + log?: { + collect: boolean; + } /** - Default value: none. - Route notes used for generating documentation (string or array of strings). - This setting is not available when setting server route defaults using server.options.routes. + * Default value: none. + * Route notes used for generating documentation (string or array of strings). + * This setting is not available when setting server route defaults using server.options.routes. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsnotes) */ notes?: string | string[]; - /** Determines how the request payload is processed. */ + /** + * Determines how the request payload is processed. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayload) + */ payload?: RouteOptionsPayload; /** - Default value: {}. - Plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. + * Default value: {}. + * Plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsplugins) */ - plugins?: PluginSpecificConfiguration; + plugins?: Dictionary; /** - Default value: none. - The pre option allows defining methods for performing actions before the handler is called. These methods allow breaking the handler logic into smaller, reusable components that can be shared ascross routes, as well as provide a cleaner error handling of prerequisite operations (e.g. load required reference data from a database). - pre is assigned an ordered array of methods which are called serially in order. If the pre array contains another array of methods as one of its elements, those methods are called in parallel. Note that during parallel execution, if any of the methods error, return a takeover response, or abort signal, the other parallel methods will continue to execute but will be ignored once completed. - pre can be assigned a mixed array of: - an array containing the elements listed below, which are executed in parallel. - an object with: - method - a lifecycle method. - assign - key name used to assign the response of the method to in request.pre and request.preResponses. - failAction - A failAction value which determine what to do when a pre-handler method throws an error. If assign is specified and the failAction setting is not 'error', the error will be assigned. - a method function - same as including an object with a single method key. - Note that pre-handler methods do not behave the same way other lifecycle methods do when a value is returned. Instead of the return value becoming the new response payload, the value is used to assign the corresponding request.pre and request.preResponses properties. Otherwise, the handling of errors, takeover response response, or abort signal behave the same as any other lifecycle methods. + * Default value: none. + * The pre option allows defining methods for performing actions before the handler is called. These methods allow breaking the handler logic into smaller, reusable components that can be shared ascross routes, as well as provide a cleaner error handling of prerequisite operations (e.g. load required reference data from a database). + * pre is assigned an ordered array of methods which are called serially in order. If the pre array contains another array of methods as one of its elements, those methods are called in parallel. Note that during parallel execution, if any of the methods error, return a takeover response, or abort signal, the other parallel methods will continue to execute but will be ignored once completed. + * pre can be assigned a mixed array of: + * * an array containing the elements listed below, which are executed in parallel. + * * an object with: + * * * method - a lifecycle method. + * * * assign - key name used to assign the response of the method to in request.pre and request.preResponses. + * * * failAction - A failAction value which determine what to do when a pre-handler method throws an error. If assign is specified and the failAction setting is not 'error', the error will be assigned. + * * a method function - same as including an object with a single method key. + * Note that pre-handler methods do not behave the same way other lifecycle methods do when a value is returned. Instead of the return value becoming the new response payload, the value is used to assign the corresponding request.pre and request.preResponses properties. Otherwise, the handling of errors, takeover response response, or abort signal behave the same as any other lifecycle methods. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre) */ - pre?: any; // TODO is necessary come back here. In v16 we can see the definition but in this moment we don't have all the definitions for make this one. + pre?: RouteOptionsPreArray; /** * Processing rules for the outgoing response. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponse) */ response?: RouteOptionsResponse; @@ -199,7 +238,7 @@ export interface RouteOptions { */ state?: { parse?: boolean; - failAction?: FailAction; + failAction?: Lifecycle.FailAction; } /** @@ -226,5 +265,4 @@ export interface RouteOptions { */ validate?: RouteOptionsValidate; - } From 00b0f483af93b7234fafe9b5cc355114f3e6dbe1 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 28 Nov 2017 21:48:32 -0300 Subject: [PATCH 027/298] Added Json namespace. Cloned to v16 types. --- types/hapi/v17/definitions/util/util.d.ts | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/types/hapi/v17/definitions/util/util.d.ts b/types/hapi/v17/definitions/util/util.d.ts index f1c6d0c39e..ae473d89ac 100644 --- a/types/hapi/v17/definitions/util/util.d.ts +++ b/types/hapi/v17/definitions/util/util.d.ts @@ -5,3 +5,34 @@ export interface Dictionary { export type HTTP_METHODS_PARTIAL_LOWERCASE = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_LOWERCASE; export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; + +/** + * Json properties + */ +export namespace Json { + + /** + * @see {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter} + */ + export type StringifyReplacer = ((key: string, value: any) => any) | (string | number)[] | undefined; + + /** + * Any value greater than 10 is truncated. + */ + export type StringifySpace = number | string; + + /** + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsjson) + */ + export interface StringifyArguments { + /** the replacer function or array. Defaults to no action. */ + replacer?: StringifyReplacer; + /** number of spaces to indent nested object keys. Defaults to no indentation. */ + space?: StringifySpace; + /** tring suffix added after conversion to JSON string. Defaults to no suffix. **/ + suffix?: string; + /** calls Hoek.jsonEscape() after conversion to JSON string. Defaults to false. **/ + escape?: boolean; + } + +} From d75c57e480257aac4fd000d2772b292ea4531c81 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 28 Nov 2017 21:49:02 -0300 Subject: [PATCH 028/298] Using new Lifecycle namespace. --- types/hapi/v17/definitions/server/server-auth-scheme.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts index db21ed6111..ea0b7817d0 100644 --- a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts +++ b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts @@ -1,7 +1,7 @@ import {Server} from "./server"; -import {LifecycleReturnValue} from "../util/lifecycle"; import {ResponseToolkit} from "../response/response-toolkit"; import {Request} from "../request/request"; +import {Lifecycle} from "hapi"; /** * The scheme options argument passed to server.auth.strategy() when instantiation a strategy. @@ -39,7 +39,7 @@ export interface ServerAuthSchemeObject { * @param h the ResponseToolkit * @return the LifecycleReturnValue */ - authenticate(request: Request, h: ResponseToolkit): LifecycleReturnValue; + authenticate(request: Request, h: ResponseToolkit): Lifecycle.LifecycleReturnValue; /** * A lifecycle method to authenticate the request payload. @@ -50,7 +50,7 @@ export interface ServerAuthSchemeObject { * @param h the ResponseToolkit * @return the LifecycleReturnValue */ - payload?(request: Request, h: ResponseToolkit): LifecycleReturnValue; + payload?(request: Request, h: ResponseToolkit): Lifecycle.LifecycleReturnValue; /** * A lifecycle method to decorate the response with authentication headers before the response headers or payload is written. @@ -58,7 +58,7 @@ export interface ServerAuthSchemeObject { * @param h the ResponseToolkit * @return the LifecycleReturnValue */ - response?(request: Request, h: ResponseToolkit): LifecycleReturnValue; + response?(request: Request, h: ResponseToolkit): Lifecycle.LifecycleReturnValue; /** * An object with the following keys: From 81b7abd1d49ce724540e4bec913fcf6149875385 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 28 Nov 2017 21:49:37 -0300 Subject: [PATCH 029/298] Solved some TODO's --- types/hapi/v17/definitions/server/server.d.ts | 46 ++++++++----------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 0866db9f6f..abe6d8c313 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -13,7 +13,7 @@ import { ServerOptionsCache, ServerEventCriteria, ServerEventsApplication, ServerEventsApplicationObject, PayloadCompressionDecoderSettings, RouteCompressionEncoderSettings, HTTP_METHODS, ServerMethodOptions, ServerMethod, ServerMethodConfigurationObject, - Plugin, + Plugin, ResponseToolkit, Dictionary, } from "hapi"; import { RequestExtPointFunction, ServerExtEventsObject, ServerExtEventsRequestObject, ServerExtOptions, @@ -32,9 +32,13 @@ export class Server extends events.EventEmitter { /** Creates a new server object where: - @param options - (optional) a server configuration object. */ constructor(); + + /** + Creates a new server object where: + @param options server configuration object. + */ constructor(options: ServerOptions); /** @@ -58,9 +62,9 @@ export class Server extends events.EventEmitter { */ readonly decorations: { request: Request, - toolkit: any, // TODO Request Toolkit (https://github.com/hapijs/hapi/blob/master/API.md#response-toolkit) needs to be implemented. + toolkit: ResponseToolkit, server: Server - } + }; /** * Register custom application events where: @@ -98,7 +102,6 @@ export class Server extends events.EventEmitter { emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: any): void; /** - *[See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncriteria-listener) * Subscribe to an event where: * @param criteria - the subscription criteria which must be one of: * * event name string which can be any of the built-in server events @@ -106,6 +109,13 @@ export class Server extends events.EventEmitter { * * a criteria object * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncriteria-listener) + * See ['log' event](https://github.com/hapijs/hapi/blob/master/API.md#-log-event) + * See ['request' event](https://github.com/hapijs/hapi/blob/master/API.md#-request-event) + * See ['response' event](https://github.com/hapijs/hapi/blob/master/API.md#-response-event) + * See ['route' event](https://github.com/hapijs/hapi/blob/master/API.md#-route-event) + * See ['start' event](https://github.com/hapijs/hapi/blob/master/API.md#-start-event) + * See ['stop' event](https://github.com/hapijs/hapi/blob/master/API.md#-stop-event) */ on(criteria: string, listener: Function): void; on(criteria: ServerEventsApplicationObject, listener: Function): void; @@ -156,26 +166,7 @@ export class Server extends events.EventEmitter { */ hasListeners(name: string): boolean; - /** - * The 'log' event type emits internal server events generated by the framework as well as application events - * logged with server.log(). - * The 'log' event handler uses the function signature function(event, tags) where: - * @param event - an object with the following properties: - * * timestamp - the event timestamp. - * * tags - an array of tags identifying the event (e.g. ['error', 'http']). - * * channel - set to 'internal' for internally generated events, otherwise 'app' for events generated by server.log(). - * * data - event-specific information. Available when event data was provided and is not an error. Errors are passed via error. - * * error - the error object related to the event if applicable. Cannot appear together with data. - * @param tags - an object where each event.tag is a key and the value is true. Useful for quick identification of events. - * - */ - - - // TODO not ready yet - - - - } + }; /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo) @@ -220,8 +211,7 @@ export class Server extends events.EventEmitter { * sever.methods is an object which provides access to the methods registered via server.method() where each * server method name is an object property. */ - //methods: Dictionary; - readonly methods: any; // TODO come back here after implements the server.method() + readonly methods: Dictionary; /** * Provides access to the server MIME database used for setting content-type information. The object must not be @@ -327,7 +317,7 @@ export class Server extends events.EventEmitter { */ provision(options: ServerOptionsCache): void; - } + }; /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoderencoding-decoder) From 4098227016919c35cd7ae8fa7705f088dcbade61 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 28 Nov 2017 21:50:00 -0300 Subject: [PATCH 030/298] Updated with new types. --- types/hapi/v17/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index e6ec85e659..fa2e6cac25 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -26,9 +26,11 @@ export * from './definitions/response/response-toolkit' /** ROUTE */ export * from './definitions/route/route-options' export * from './definitions/route/route-options-access' +export * from './definitions/route/route-options-access-scope' export * from './definitions/route/route-options-cache' export * from './definitions/route/route-options-cors' export * from './definitions/route/route-options-payload' +export * from './definitions/route/route-options-pre' export * from './definitions/route/route-options-response' export * from './definitions/route/route-options-secure' export * from './definitions/route/route-options-validate' @@ -50,6 +52,5 @@ export * from './definitions/server/server-state' export * from './definitions/server/server-state-options' /** UTIL */ -export * from './definitions/util/fail-action' export * from './definitions/util/lifecycle' export * from './definitions/util/util' From 9a5c7a31040a2a74f278bb3c205a5e3c4ae9ec8a Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 28 Nov 2017 21:57:18 -0300 Subject: [PATCH 031/298] Renamed Lifecycle methods for better understanding. --- .../v17/definitions/route/route-options-pre.d.ts | 4 ++-- types/hapi/v17/definitions/route/route-options.d.ts | 2 +- .../v17/definitions/server/server-auth-scheme.d.ts | 12 ++++++------ types/hapi/v17/definitions/util/lifecycle.d.ts | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/types/hapi/v17/definitions/route/route-options-pre.d.ts b/types/hapi/v17/definitions/route/route-options-pre.d.ts index 95b458d490..1cd980fc16 100644 --- a/types/hapi/v17/definitions/route/route-options-pre.d.ts +++ b/types/hapi/v17/definitions/route/route-options-pre.d.ts @@ -8,7 +8,7 @@ export type RouteOptionsPreArray = RouteOptionsPreAllOptions[]; /** * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre) */ -export type RouteOptionsPreAllOptions = RouteOptionsPreObject | RouteOptionsPreObject[] | Lifecycle.LifecycleMethod; +export type RouteOptionsPreAllOptions = RouteOptionsPreObject | RouteOptionsPreObject[] | Lifecycle.Method; /** * An object with: @@ -18,7 +18,7 @@ export type RouteOptionsPreAllOptions = RouteOptionsPreObject | RouteOptionsPreO * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre) */ export interface RouteOptionsPreObject { - method: Lifecycle.LifecycleMethod; + method: Lifecycle.Method; assign: string; failAction?: Lifecycle.FailAction; } diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/v17/definitions/route/route-options.d.ts index 7b62764f0f..c1fc5267a8 100644 --- a/types/hapi/v17/definitions/route/route-options.d.ts +++ b/types/hapi/v17/definitions/route/route-options.d.ts @@ -114,7 +114,7 @@ export interface RouteOptions { * Note: handlers using a fat arrow style function cannot be bound to any bind property. Instead, the bound context is available under h.context. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionshandler) */ - handler?: Lifecycle.LifecycleMethod | Object; //TODO need to review + handler?: Lifecycle.Method | Object; //TODO need to review /** * Default value: none. diff --git a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts index ea0b7817d0..52a7b732a3 100644 --- a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts +++ b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts @@ -37,9 +37,9 @@ export interface ServerAuthSchemeObject { * * h.unauthenticated() - indicate request failed to authenticate. * @param request the request object. * @param h the ResponseToolkit - * @return the LifecycleReturnValue + * @return the Lifecycle.ReturnValue */ - authenticate(request: Request, h: ResponseToolkit): Lifecycle.LifecycleReturnValue; + authenticate(request: Request, h: ResponseToolkit): Lifecycle.ReturnValue; /** * A lifecycle method to authenticate the request payload. @@ -48,17 +48,17 @@ export interface ServerAuthSchemeObject { * authentication may still be successful if the route auth.payload configuration is set to 'optional'. * @param request the request object. * @param h the ResponseToolkit - * @return the LifecycleReturnValue + * @return the Lifecycle.ReturnValue */ - payload?(request: Request, h: ResponseToolkit): Lifecycle.LifecycleReturnValue; + payload?(request: Request, h: ResponseToolkit): Lifecycle.ReturnValue; /** * A lifecycle method to decorate the response with authentication headers before the response headers or payload is written. * @param request the request object. * @param h the ResponseToolkit - * @return the LifecycleReturnValue + * @return the Lifecycle.ReturnValue */ - response?(request: Request, h: ResponseToolkit): Lifecycle.LifecycleReturnValue; + response?(request: Request, h: ResponseToolkit): Lifecycle.ReturnValue; /** * An object with the following keys: diff --git a/types/hapi/v17/definitions/util/lifecycle.d.ts b/types/hapi/v17/definitions/util/lifecycle.d.ts index 41864a6bdf..6501e8edd1 100644 --- a/types/hapi/v17/definitions/util/lifecycle.d.ts +++ b/types/hapi/v17/definitions/util/lifecycle.d.ts @@ -9,7 +9,7 @@ export namespace Lifecycle { * * h - the response toolkit the handler must call to set a response and return control back to the framework. * * err - an error object availble only when the method is used as a failAction value. */ - export interface LifecycleMethod { + export interface Method { // TODO needs to be implemented. @@ -20,7 +20,7 @@ export namespace Lifecycle { * without a value or resolves to an undefined value, an Internal Server Error (500) error response is sent. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) */ - export interface LifecycleReturnValue { + export interface ReturnValue { // TODO needs to be implemented. @@ -37,7 +37,7 @@ export namespace Lifecycle { * * * err - the error object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-failaction-configuration) */ - export type FailAction = 'error' | 'log' | 'ignore' | LifecycleMethod; + export type FailAction = 'error' | 'log' | 'ignore' | Method; } From c8874b4a152f701f098151c0b04509856e87f5eb Mon Sep 17 00:00:00 2001 From: rsouza Date: Wed, 29 Nov 2017 15:23:43 -0300 Subject: [PATCH 032/298] Reviewing Routes type implementation. --- .../route/route-options-secure.d.ts | 53 ++++---- .../route/route-options-validate.d.ts | 118 +++++++++--------- .../v17/definitions/route/route-options.d.ts | 85 +++++++------ 3 files changed, 138 insertions(+), 118 deletions(-) diff --git a/types/hapi/v17/definitions/route/route-options-secure.d.ts b/types/hapi/v17/definitions/route/route-options-secure.d.ts index 6c2380fcc0..8c68f25dfe 100644 --- a/types/hapi/v17/definitions/route/route-options-secure.d.ts +++ b/types/hapi/v17/definitions/route/route-options-secure.d.ts @@ -1,33 +1,34 @@ /** - Default value: false (security headers disabled). - Sets common security headers. To enable, set security to true or to an object with the following options: - hsts - controls the 'Strict-Transport-Security' header, where: - true - the header will be set to max-age=15768000. This is the default value. - a number - the maxAge parameter will be set to the provided value. - an object with the following fields: - maxAge - the max-age portion of the header, as a number. Default is 15768000. - includeSubDomains - a boolean specifying whether to add the includeSubDomains flag to the header. - preload - a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. - xframe - controls the 'X-Frame-Options' header, where: - true - the header will be set to 'DENY'. This is the default value. - 'deny' - the headers will be set to 'DENY'. - 'sameorigin' - the headers will be set to 'SAMEORIGIN'. - an object for specifying the 'allow-from' rule, where: - rule - one of: - 'deny' - 'sameorigin' - 'allow-from' - source - when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. - xss - boolean that controls the 'X-XSS-PROTECTION' header for Internet Explorer. Defaults to true which sets the header to equal '1; mode=block'. - Note: this setting can create a security vulnerability in versions of Internet Exploere below 8, as well as unpatched versions of IE8. See here and here for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. - noOpen - boolean controlling the 'X-Download-Options' header for Internet Explorer, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. - noSniff - boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff'. + * Default value: false (security headers disabled). + * Sets common security headers. To enable, set security to true or to an object with the following options: + * * hsts - controls the 'Strict-Transport-Security' header, where: + * * * true - the header will be set to max-age=15768000. This is the default value. + * * * a number - the maxAge parameter will be set to the provided value. + * * * an object with the following fields: + * * * * maxAge - the max-age portion of the header, as a number. Default is 15768000. + * * * * includeSubDomains - a boolean specifying whether to add the includeSubDomains flag to the header. + * * * * preload - a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. + * * xframe - controls the 'X-Frame-Options' header, where: + * * * true - the header will be set to 'DENY'. This is the default value. + * * * 'deny' - the headers will be set to 'DENY'. + * * * 'sameorigin' - the headers will be set to 'SAMEORIGIN'. + * * * an object for specifying the 'allow-from' rule, where: + * * * * rule - one of: + * * * * * 'deny' + * * * * * 'sameorigin' + * * * * * 'allow-from' + * * * * source - when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. + * * xss - boolean that controls the 'X-XSS-PROTECTION' header for Internet Explorer. Defaults to true which sets the header to equal '1; mode=block'. + * Note: this setting can create a security vulnerability in versions of Internet Exploere below 8, as well as unpatched versions of IE8. See here and here for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. + * * noOpen - boolean controlling the 'X-Download-Options' header for Internet Explorer, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. + * * noSniff - boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff'. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionssecurity) */ export interface RouteOptionsSecureObject { hsts?: boolean | number | { - maxAge?: number; - includeSubdomains?: boolean; - preload?: boolean; + maxAge: number; + includeSubdomains: boolean; + preload: boolean; }; xframe?: true | 'deny' | 'sameorigin' | { rule: 'deny' | 'sameorigin' | 'allow-from'; diff --git a/types/hapi/v17/definitions/route/route-options-validate.d.ts b/types/hapi/v17/definitions/route/route-options-validate.d.ts index 4e4a8351cd..6fba5dfc67 100644 --- a/types/hapi/v17/definitions/route/route-options-validate.d.ts +++ b/types/hapi/v17/definitions/route/route-options-validate.d.ts @@ -1,86 +1,92 @@ import {Lifecycle} from "hapi"; +import {ValidationOptions} from "joi"; /** - Default value: { headers: true, params: true, query: true, payload: true, failAction: 'error' }. - Request input validation rules for various request components. + * Default value: { headers: true, params: true, query: true, payload: true, failAction: 'error' }. + * Request input validation rules for various request components. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidate) */ export interface RouteOptionsValidate { /** - Default value: none. - An optional object with error fields copied into every validation error response. + * Default value: none. + * An optional object with error fields copied into every validation error response. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateerrorfields) */ errorFields?: any; /** - Default value: 'error' (return a Bad Request (400) error response). - A failAction value which determines how to handle failed validations. When set to a function, the err argument includes the type of validation error under err.output.payload.validation.source. + * Default value: 'error' (return a Bad Request (400) error response). + * A failAction value which determines how to handle failed validations. When set to a function, the err argument includes the type of validation error under err.output.payload.validation.source. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidatefailaction) */ failAction?: Lifecycle.FailAction; /** - Default value: true (no validation). - Validation rules for incoming request headers: - true - any headers allowed (no validation performed). - a joi validation object. - a validation function using the signature async function(value, options) where: - value - the request.headers object containing the request headers. - options - options. - if a value is returned, the value is used as the new request.headers value and the original value is stored in request.orig.headers. Otherwise, the headers are left unchanged. If an error is thrown, the error is handled according to failAction. - Note that all header field names must be in lowercase to match the headers normalized by node. + * Default value: true (no validation). + * Validation rules for incoming request headers: + * * true - any headers allowed (no validation performed). + * * a joi validation object. + * * a validation function using the signature async function(value, options) where: + * * * value - the request.headers object containing the request headers. + * * * options - options. + * * * if a value is returned, the value is used as the new request.headers value and the original value is stored in request.orig.headers. Otherwise, the headers are left unchanged. If an error is thrown, the error is handled according to failAction. + * Note that all header field names must be in lowercase to match the headers normalized by node. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateheaders) */ - headers?: boolean | any; // TODO need to implementation. Here is JOI and more. + headers?: boolean | ValidationOptions | ((value: any, option: any) => Function); /** - Default value: none. - An options object passed to the joi rules or the custom validation methods. Used for setting global options such as stripUnknown or abortEarly (the complete list is available here). - If a custom validation function (see headers, params, query, or payload above) is defined then options can an arbitrary object that will be passed to this function as the second parameter. - The values of the other inputs (i.e. headers, query, params, payload, app, and auth) are added to the options object under the validation context (accessible in rules as Joi.ref('$query.key')). - Note that validation is performed in order (i.e. headers, params, query, and payload) and if type casting is used (e.g. converting a string to a number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. - If the validation rules for headers, params, query, and payload are defined at both the server routes level and at the route level, the individual route settings override the routes defaults (the rules are not merged). + * Default value: none. + * An options object passed to the joi rules or the custom validation methods. Used for setting global options such as stripUnknown or abortEarly (the complete list is available here). + * If a custom validation function (see headers, params, query, or payload above) is defined then options can an arbitrary object that will be passed to this function as the second parameter. + * The values of the other inputs (i.e. headers, query, params, payload, app, and auth) are added to the options object under the validation context (accessible in rules as Joi.ref('$query.key')). + * Note that validation is performed in order (i.e. headers, params, query, and payload) and if type casting is used (e.g. converting a string to a number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. + * If the validation rules for headers, params, query, and payload are defined at both the server routes level and at the route level, the individual route settings override the routes defaults (the rules are not merged). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateparams) */ - options?: any; // TODO need to be implementation + options?: ValidationOptions | Object; // TODO need review /** - Default value: true (no validation). - Validation rules for incoming request path parameters, after matching the path against the route, extracting any parameters, and storing them in request.params, where: - true - any path parameter value allowed (no validation performed). - a joi validation object. - a validation function using the signature async function(value, options) where: - value - the request.params object containing the request path parameters. - options - options. - if a value is returned, the value is used as the new request.params value and the original value is stored in request.orig.params. Otherwise, the path parameters are left unchanged. If an error is thrown, the error is handled according to failAction. - Note that failing to match the validation rules to the route path parameters definition will cause all requests to fail. + * Default value: true (no validation). + * Validation rules for incoming request path parameters, after matching the path against the route, extracting any parameters, and storing them in request.params, where: + * * true - any path parameter value allowed (no validation performed). + * * a joi validation object. + * * a validation function using the signature async function(value, options) where: + * * * value - the request.params object containing the request path parameters. + * * * options - options. + * if a value is returned, the value is used as the new request.params value and the original value is stored in request.orig.params. Otherwise, the path parameters are left unchanged. If an error is thrown, the error is handled according to failAction. + * Note that failing to match the validation rules to the route path parameters definition will cause all requests to fail. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateparams) */ - params?: boolean | any; // TODO need to implementation. Here is JOI and more. + params?: boolean | ValidationOptions | ((value: any, option: any) => Function); // TODO need review /** - Default value: true (no validation). - Validation rules for incoming request payload (request body), where: - true - any payload allowed (no validation performed). - false - no payload allowed. - a joi validation object. - Note that empty payloads are represented by a null value. If a validation schema is provided and empty payload are allowed, the schema must be explicitly defined by setting the rule to a joi schema with null allowed (e.g. Joi.object({ keys here }).allow(null)). - a validation function using the signature async function(value, options) where: - value - the request.query object containing the request query parameters. - options - options. - if a value is returned, the value is used as the new request.payload value and the original value is stored in request.orig.payload. Otherwise, the payload is left unchanged. If an error is thrown, the error is handled according to failAction. - Note that validating large payloads and modifying them will cause memory duplication of the payload (since the original is kept), as well as the significant performance cost of validating large amounts of data. + * Default value: true (no validation). + * Validation rules for incoming request payload (request body), where: + * * true - any payload allowed (no validation performed). false - no payload allowed. + * * a joi validation object. Note that empty payloads are represented by a null value. If a validation schema is provided and empty payload are allowed, the schema must be explicitly defined by setting the rule to a joi schema with null allowed (e.g. Joi.object({ keys here }).allow(null)). + * * a validation function using the signature async function(value, options) where: + * * * value - the request.query object containing the request query parameters. + * * * options - options. + * if a value is returned, the value is used as the new request.payload value and the original value is stored in request.orig.payload. Otherwise, the payload is left unchanged. If an error is thrown, the error is handled according to failAction. + * Note that validating large payloads and modifying them will cause memory duplication of the payload (since the original is kept), as well as the significant performance cost of validating large amounts of data. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidatepayload) */ - payload?: boolean | any; // TODO need to implementation. Here is JOI and more. + payload?: boolean | ValidationOptions | ((value: any, option: any) => Function); // TODO need review /** - Default value: true (no validation). - Validation rules for incoming request URI query component (the key-value part of the URI between '?' and '#'). The query is parsed into its individual key-value pairs, decoded, and stored in request.query prior to validation. Where: - true - any query parameter value allowed (no validation performed). - false - no query parameter value allowed. - a joi validation object. - a validation function using the signature async function(value, options) where: - value - the request.query object containing the request query parameters. - options - options. - if a value is returned, the value is used as the new request.query value and the original value is stored in request.orig.query. Otherwise, the query parameters are left unchanged. If an error is thrown, the error is handled according to failAction. - Note that changes to the query parameters will not be reflected in request.url. + * Default value: true (no validation). + * Validation rules for incoming request URI query component (the key-value part of the URI between '?' and '#'). The query is parsed into its individual key-value pairs, decoded, and stored in request.query prior to validation. Where: + * * true - any query parameter value allowed (no validation performed). false - no query parameter value allowed. + * * a joi validation object. + * * a validation function using the signature async function(value, options) where: + * * * value - the request.query object containing the request query parameters. + * * * options - options. + * if a value is returned, the value is used as the new request.query value and the original value is stored in request.orig.query. Otherwise, the query parameters are left unchanged. If an error is thrown, the error is handled according to failAction. + * Note that changes to the query parameters will not be reflected in request.url. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidatequery) */ - query?: boolean | any; // TODO need to implementation. Here is JOI and more. + query?: boolean | ValidationOptions | ((value: any, option: any) => Function); // TODO need review } diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/v17/definitions/route/route-options.d.ts index c1fc5267a8..e01d1a4cd3 100644 --- a/types/hapi/v17/definitions/route/route-options.d.ts +++ b/types/hapi/v17/definitions/route/route-options.d.ts @@ -204,37 +204,39 @@ export interface RouteOptions { response?: RouteOptionsResponse; /** - Default value: false (security headers disabled). - Sets common security headers. To enable, set security to true or to an object with the following options: - hsts - controls the 'Strict-Transport-Security' header, where: - true - the header will be set to max-age=15768000. This is the default value. - a number - the maxAge parameter will be set to the provided value. - an object with the following fields: - maxAge - the max-age portion of the header, as a number. Default is 15768000. - includeSubDomains - a boolean specifying whether to add the includeSubDomains flag to the header. - preload - a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. - xframe - controls the 'X-Frame-Options' header, where: - true - the header will be set to 'DENY'. This is the default value. - 'deny' - the headers will be set to 'DENY'. - 'sameorigin' - the headers will be set to 'SAMEORIGIN'. - an object for specifying the 'allow-from' rule, where: - rule - one of: - 'deny' - 'sameorigin' - 'allow-from' - source - when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. - xss - boolean that controls the 'X-XSS-PROTECTION' header for Internet Explorer. Defaults to true which sets the header to equal '1; mode=block'. - Note: this setting can create a security vulnerability in versions of Internet Exploere below 8, as well as unpatched versions of IE8. See here and here for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. - noOpen - boolean controlling the 'X-Download-Options' header for Internet Explorer, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. - noSniff - boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff'. + * Default value: false (security headers disabled). + * Sets common security headers. To enable, set security to true or to an object with the following options: + * * hsts - controls the 'Strict-Transport-Security' header, where: + * * * true - the header will be set to max-age=15768000. This is the default value. + * * * a number - the maxAge parameter will be set to the provided value. + * * * an object with the following fields: + * * * * maxAge - the max-age portion of the header, as a number. Default is 15768000. + * * * * includeSubDomains - a boolean specifying whether to add the includeSubDomains flag to the header. + * * * * preload - a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. + * * xframe - controls the 'X-Frame-Options' header, where: + * * * true - the header will be set to 'DENY'. This is the default value. + * * * 'deny' - the headers will be set to 'DENY'. + * * * 'sameorigin' - the headers will be set to 'SAMEORIGIN'. + * * * an object for specifying the 'allow-from' rule, where: + * * * * rule - one of: + * * * * * 'deny' + * * * * * 'sameorigin' + * * * * * 'allow-from' + * * * * source - when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. + * * xss - boolean that controls the 'X-XSS-PROTECTION' header for Internet Explorer. Defaults to true which sets the header to equal '1; mode=block'. + * Note: this setting can create a security vulnerability in versions of Internet Exploere below 8, as well as unpatched versions of IE8. See here and here for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. + * * noOpen - boolean controlling the 'X-Download-Options' header for Internet Explorer, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. + * * noSniff - boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff'. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionssecurity) */ security?: RouteOptionsSecure; /** - Default value: { parse: true, failAction: 'error' }. - HTTP state management (cookies) allows the server to store information on the client which is sent back to the server with every request (as defined in RFC 6265). state supports the following options: - parse - determines if incoming 'Cookie' headers are parsed and stored in the request.state object. - failAction - A failAction value which determines how to handle cookie parsing errors. Defaults to 'error' (return a Bad Request (400) error response). + * Default value: { parse: true, failAction: 'error' }. + * HTTP state management (cookies) allows the server to store information on the client which is sent back to the server with every request (as defined in RFC 6265). state supports the following options: + * parse - determines if incoming 'Cookie' headers are parsed and stored in the request.state object. + * failAction - A failAction value which determines how to handle cookie parsing errors. Defaults to 'error' (return a Bad Request (400) error response). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsstate) */ state?: { parse?: boolean; @@ -242,26 +244,37 @@ export interface RouteOptions { } /** - Default value: none. - Route tags used for generating documentation (array of strings). - This setting is not available when setting server route defaults using server.options.routes. + * Default value: none. + * Route tags used for generating documentation (array of strings). + * This setting is not available when setting server route defaults using server.options.routes. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionstags) */ tags?: string[]; /** - Default value: { server: false }. - Timeouts for processing durations. + * Default value: { server: false }. + * Timeouts for processing durations. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionstimeout) */ timeout?: { - /** response timeout in milliseconds. Sets the maximum time allowed for the server to respond to an incoming client request before giving up and responding with a Service Unavailable (503) error response. Disabled by default (false). */ + + /** + * Response timeout in milliseconds. Sets the maximum time allowed for the server to respond to an incoming request before giving up and responding with a Service Unavailable (503) error response. + */ server?: boolean | number; - /** by default, node sockets automatically timeout after 2 minutes. Use this option to override this behavior. Defaults to undefined which leaves the node default unchanged. Set to false to disable socket timeouts. */ + + /** + * Default value: none (use node default of 2 minutes). + * By default, node sockets automatically timeout after 2 minutes. Use this option to override this behavior. Set to false to disable socket timeouts. + */ socket?: boolean | number; + }; /** - Default value: { headers: true, params: true, query: true, payload: true, failAction: 'error' }. - Request input validation rules for various request components. + * Default value: { headers: true, params: true, query: true, payload: true, failAction: 'error' }. + * Request input validation rules for various request components. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidate) */ validate?: RouteOptionsValidate; From 12d64487d41076f45d1b3181561ff40765731397 Mon Sep 17 00:00:00 2001 From: rsouza Date: Wed, 29 Nov 2017 16:33:59 -0300 Subject: [PATCH 033/298] Added some Lifecycle definitions. --- .../hapi/v17/definitions/util/lifecycle.d.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/types/hapi/v17/definitions/util/lifecycle.d.ts b/types/hapi/v17/definitions/util/lifecycle.d.ts index 6501e8edd1..3cf2840199 100644 --- a/types/hapi/v17/definitions/util/lifecycle.d.ts +++ b/types/hapi/v17/definitions/util/lifecycle.d.ts @@ -1,3 +1,8 @@ +import * as Boom from "../../../../boom/index"; +import * as stream from "stream"; +import {ResponseToolkit, Request} from "hapi"; + + export namespace Lifecycle { /** @@ -10,9 +15,8 @@ export namespace Lifecycle { * * err - an error object availble only when the method is used as a failAction value. */ export interface Method { - - // TODO needs to be implemented. - + (request: Request, h: ResponseToolkit): void; + (request: Request, h: ResponseToolkit, err: Error): void; } /** @@ -20,11 +24,16 @@ export namespace Lifecycle { * without a value or resolves to an undefined value, an Internal Server Error (500) error response is sent. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) */ - export interface ReturnValue { - - // TODO needs to be implemented. - - } + export type ReturnValue = ReturnValueTypes | (Promise); + export type ReturnValueTypes = + (null | undefined | string | number | boolean) | + (Buffer) | + (Error | Boom.BoomError) | + (stream.Stream) | + (Object | Object[]) | + // a toolkit signal: + // a toolkit method response: + any; // TODO need review /** * Various configuration options allows defining how errors are handled. For example, when invalid payload is received or malformed cookie, instead of returning an error, the framework can be configured to perform another action. When supported the failAction option supports the following values: From 3eb657d0308fa679dd189bab11f615ab6bb035e3 Mon Sep 17 00:00:00 2001 From: rsouza Date: Wed, 29 Nov 2017 16:37:04 -0300 Subject: [PATCH 034/298] Fix. Each lifecycle method must return a value or a promise. --- types/hapi/v17/definitions/util/lifecycle.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/hapi/v17/definitions/util/lifecycle.d.ts b/types/hapi/v17/definitions/util/lifecycle.d.ts index 3cf2840199..568b45b181 100644 --- a/types/hapi/v17/definitions/util/lifecycle.d.ts +++ b/types/hapi/v17/definitions/util/lifecycle.d.ts @@ -15,8 +15,8 @@ export namespace Lifecycle { * * err - an error object availble only when the method is used as a failAction value. */ export interface Method { - (request: Request, h: ResponseToolkit): void; - (request: Request, h: ResponseToolkit, err: Error): void; + (request: Request, h: ResponseToolkit): ReturnValue; + (request: Request, h: ResponseToolkit, err: Error): ReturnValue; } /** From bf99493e116329b2cc8f2ed4a898467b328bcf29 Mon Sep 17 00:00:00 2001 From: simonxca Date: Wed, 29 Nov 2017 22:13:11 -0800 Subject: [PATCH 035/298] Allow overriding id attribute --- types/mongoose/index.d.ts | 2 +- types/mongoose/mongoose-tests.ts | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index f86dea4f8a..311d2d298f 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -1144,7 +1144,7 @@ declare module "mongoose" { interface MongooseDocumentOptionals { /** The string version of this documents _id. */ - id?: string; + id?: any; } interface DocumentToObjectOptions { diff --git a/types/mongoose/mongoose-tests.ts b/types/mongoose/mongoose-tests.ts index 9fe20cd8ad..57c98fcbbf 100644 --- a/types/mongoose/mongoose-tests.ts +++ b/types/mongoose/mongoose-tests.ts @@ -503,6 +503,25 @@ doc.populate(cb); doc.populate({path: 'hello'}).execPopulate().catch(cb); doc.update({$inc: {wheels:1}}, { w: 1 }, cb); +const ImageSchema = new mongoose.Schema({ + name: {type: String, required: true}, + id: {type: Number, unique: true, required: true, index: true}, +}, { id: false }); + +interface ImageDoc extends mongoose.Document { + name: string, + id: number +} + +const ImageModel = mongoose.model('image', ImageSchema); + +ImageModel.findOne({}, function(err, doc) { + if (doc) { + doc.name; + doc.id; + } +}); + /* * section types/subdocument.js * http://mongoosejs.com/docs/api.html#types-subdocument-js @@ -1277,6 +1296,7 @@ mongoModel.remove(function (err, product) { if (err) throw(err); MongoModel.findById(product._id, function (err, product) { if (product) { + product.id.toLowerCase(); product.remove(); } }); From 304bf7ff45113d70fc07dc2c85ac3f1b43d69fbe Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Thu, 30 Nov 2017 11:26:55 -0300 Subject: [PATCH 036/298] Reviewed Response declarations. --- .../definitions/response/response-object.d.ts | 157 +++++++++--------- .../response/response-settings.d.ts | 30 ++-- .../response/response-toolkit.d.ts | 25 ++- 3 files changed, 108 insertions(+), 104 deletions(-) diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/v17/definitions/response/response-object.d.ts index f30c98eb6e..b913237571 100644 --- a/types/hapi/v17/definitions/response/response-object.d.ts +++ b/types/hapi/v17/definitions/response/response-object.d.ts @@ -2,132 +2,134 @@ import {PluginsStates} from "../plugin/plugin"; import {Dictionary} from "../util/util"; import {ResponseSettings} from "./response-settings"; import {ServerStateCookieOptions} from "../server/server-state-options"; +import * as Podium from "podium"; +import {Json, Lifecycle} from "hapi"; /** + * Object where: + * * append - if true, the value is appended to any existing header value using separator. Defaults to false. + * * separator - string used as separator when appending to an existing value. Defaults to ','. + * * override - if false, the header value is not set if an existing value present. Defaults to true. + * * duplicate - if false, the header value is not modified if the provided value is already included. Does not apply when append is false or if the name is 'set-cookie'. Defaults to true. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheadername-value-options) * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#response-object) */ export interface ResponseObjectHeaderOptions { - /** if true, the value is appended to any existing header value using separator. Defaults to false. */ append?: boolean; - /** string used as separator when appending to an existing value. Defaults to ','. */ separator?: string; - /** if false, the header value is not set if an existing value present. Defaults to true. */ override?: boolean; - /** if false, the header value is not modified if the provided value is already included. Does not apply when append is false or if the name is 'set-cookie'. Defaults to true. */ duplicate?: boolean; } /** - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#response-object) - * The response object contains the request response value along with various HTTP headers and flags. When a lifecycle method returns a value, the value is wrapped in a response object along with some default flags (e.g. 200 status code). In order to customize a response before it is returned, the h.response() method is provided. + * The response object contains the request response value along with various HTTP headers and flags. When a lifecycle + * method returns a value, the value is wrapped in a response object along with some default flags (e.g. 200 status + * code). In order to customize a response before it is returned, the h.response() method is provided. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#response-object) + * TODO, check extending from Podium is correct. Extending because of "The response object supports the following events" [See docs](https://hapijs.com/api/17.0.1#-responseevents) */ -export interface ResponseObject { +export interface ResponseObject extends Podium { /** - Default value: {}. - Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. + * Default value: {}. + * Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseapp) */ app: any; /** - * [See docs] (https://hapijs.com/api/17.0.1#-responseevents) * Access: read only and the public podium interface. * The response.events object supports the following events: * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). + * [See docs](https://hapijs.com/api/17.0.1#-responseevents) */ - events: any; // TODO need to be implemented. I didn't understand yet. + readonly events: any; // TODO need to be implemented. I didn't understand yet. /** - Access: read only. - Default value: {}. - An object containing the response headers where each key is a header field name and the value is the string header value or array of string. - Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission. + * Default value: {}. + * An object containing the response headers where each key is a header field name and the value is the string header value or array of string. + * Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheaders) */ - headers: Dictionary; + readonly headers: Dictionary; /** - Access: read / write. - Default value: {}. - Plugin-specific state. Provides a place to store and pass request-level plugin data. plugins is an object where each key is a plugin name and the value is the state. + * Default value: {}. + * Plugin-specific state. Provides a place to store and pass request-level plugin data. plugins is an object where each key is a plugin name and the value is the state. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseplugins) */ plugins: PluginsStates; /** - Access: read only. - Object containing the response handling flags. + * Object containing the response handling flags. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsesettings) */ - settings: ResponseSettings; + readonly settings: ResponseSettings; /** - Access: read only. - The raw value returned by the lifecycle method. + * The raw value returned by the lifecycle method. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsesource) */ - source: any; // TODO need to be implemented. + readonly source: Lifecycle.ReturnValue; /** - Access: read only. - Default value: 200. + * Default value: 200. + * The HTTP response status code. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsestatuscode) */ - statusCode: number; + readonly statusCode: number; /** - Access: read only. - A string indicating the type of source with available values: - 'plain' - a plain response such as string, number, null, or simple object. - 'buffer' - a Buffer. - 'stream' - a Stream. + * A string indicating the type of source with available values: + * * 'plain' - a plain response such as string, number, null, or simple object. + * * 'buffer' - a Buffer. + * * 'stream' - a Stream. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsevariety) */ - variety: 'plain' | 'buffer' | 'stream'; + readonly variety: 'plain' | 'buffer' | 'stream'; /** - * response.bytes(length) - * [See docs] (https://hapijs.com/api/17.0.1#-responsebyteslength) * Sets the HTTP 'Content-Length' header (to avoid chunked transfer encoding) where: * @param length - the header value. Must match the actual payload size. * @return Return value: the current response object. + * [See docs](https://hapijs.com/api/17.0.1#-responsebyteslength) */ bytes(length: number): ResponseObject; /** - * response.charset(charset) - * [See docs] (https://hapijs.com/api/17.0.1#-responsecharsetcharset) * Sets the 'Content-Type' HTTP header 'charset' property where: * @param charset - the charset property value. * @return Return value: the current response object. + * [See docs](https://hapijs.com/api/17.0.1#-responsecharsetcharset) */ charset(charset: string): ResponseObject; /** - * response.code(statusCode) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsecodestatuscode) * Sets the 'Content-Type' HTTP header 'charset' property where: * $param charset - the charset property value. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsecodestatuscode) */ code(statusCode: number): ResponseObject; /** - * response.message(httpMessage) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsemessagehttpmessage) * Sets the HTTP status message where: * @param httpMessage - the HTTP status message (e.g. 'Ok' for status code 200). * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsemessagehttpmessage) */ message(httpMessage: string): ResponseObject; /** - * response.created(uri) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsecreateduri) * Sets the HTTP status code to Created (201) and the HTTP 'Location' header where: * @param uri - an absolute or relative URI used as the 'Location' header value. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsecreateduri) */ created(uri: string): ResponseObject; /** - * encoding(encoding) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responseencodingencoding) * Sets the string encoding scheme used to serial data into the HTTP payload where: * @param encoding the encoding property value (see node Buffer encoding [See docs](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings)). * * 'ascii' - for 7-bit ASCII data only. This encoding is fast and will strip the high bit if set. @@ -139,24 +141,23 @@ export interface ResponseObject { * * 'binary' - Alias for 'latin1'. * * 'hex' - Encode each byte as two hexadecimal characters. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseencodingencoding) */ encoding(encoding: 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex'): ResponseObject; /** - * response.etag(tag, options) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responseetagtag-options) * Sets the representation entity tag where: * @param tag - the entity tag string without the double-quote. * @param options - (optional) settings where: * * weak - if true, the tag will be prefixed with the 'W/' weak signifier. Weak tags will fail to match identical tags for the purpose of determining 304 response status. Defaults to false. * * vary - if true and content encoding is set or applied to the response (e.g 'gzip' or 'deflate'), the encoding name will be automatically added to the tag at transmission time (separated by a '-' character). Ignored when weak is true. Defaults to true. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseetagtag-options) */ - etag(tag: string, options?: {weak: boolean, vary: boolean}): ResponseObject; + etag(tag: string): ResponseObject; + etag(tag: string, options: {weak: boolean, vary: boolean}): ResponseObject; /** - * response.header(name, value, options) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responseheadername-value-options) * Sets an HTTP header where: * @param name - the header name. * @param value - the header value. @@ -166,139 +167,129 @@ export interface ResponseObject { * * override - if false, the header value is not set if an existing value present. Defaults to true. * * duplicate - if false, the header value is not modified if the provided value is already included. Does not apply when append is false or if the name is 'set-cookie'. Defaults to true. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheadername-value-options) */ - header(name: string, value: string, options?: ResponseObjectHeaderOptions): ResponseObject; + header(name: string, value: string): ResponseObject; + header(name: string, value: string, options: ResponseObjectHeaderOptions): ResponseObject; /** - * response.location(uri) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responselocationuri) * Sets the HTTP 'Location' header where: * @param uri - an absolute or relative URI used as the 'Location' header value. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responselocationuri) */ location(uri: string): ResponseObject; /** - * response.redirect(uri) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responseredirecturi) * Sets an HTTP redirection response (302) and decorates the response with additional methods, where: * @param uri - an absolute or relative URI used to redirect the client to another resource. * @return Return value: the current response object. * Decorates the response object with the response.temporary(), response.permanent(), and response.rewritable() methods to easily change the default redirection code (302). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseredirecturi) */ redirect(uri: string): ResponseObject; /** - * response.replacer(method) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsereplacermethod) * Sets the JSON.stringify() replacer argument where: * @param method - the replacer function or array. Defaults to none. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsereplacermethod) */ - replacer(method: any): ResponseObject; // TODO check the method object type. In v16 is a Json.StringifyReplacer + replacer(method: Json.StringifyReplacer): ResponseObject; /** - * response.spaces(count) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsespacescount) * Sets the JSON.stringify() space argument where: * @param count - the number of spaces to indent nested object keys. Defaults to no indentation. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsespacescount) */ spaces(count: number): ResponseObject; /** - * response.state(name, value, [options]) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsestatename-value-options) * Sets an HTTP cookie where: * @param name - the cookie name. * @param value - the cookie value. If no options.encoding is defined, must be a string. See server.state() for supported encoding values. * @param options - (optional) configuration. If the state was previously registered with the server using server.state(), the specified keys in options are merged with the default server definition. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsestatename-value-options) */ - state(name: string, value: string, options?: ServerStateCookieOptions): ResponseObject; + state(name: string, value: string): ResponseObject; + state(name: string, value: string, options: ServerStateCookieOptions): ResponseObject; /** - * response.suffix(suffix) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsesuffixsuffix) * Sets a string suffix when the response is process via JSON.stringify() where: * @param suffix - the string suffix. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsesuffixsuffix) */ suffix(suffix: string): ResponseObject; /** - * response.ttl(msec) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsettlmsec) * Overrides the default route cache expiration rule for this response instance where: * @param msec - the time-to-live value in milliseconds. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsettlmsec) */ ttl(msec: number): ResponseObject; /** - * response.type(mimeType) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsetypemimetype) * Sets the HTTP 'Content-Type' header where: * @param value - is the mime type. * @return Return value: the current response object. * Should only be used to override the built-in default for each response type. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsetypemimetype) */ type(mimeType: string): ResponseObject; /** - * unstate(name, [options]) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responseunstatename-options) * Clears the HTTP cookie by setting an expired value where: * @param name - the cookie name. * @param options - (optional) configuration for expiring cookie. If the state was previously registered with the server using server.state(), the specified options are merged with the server definition. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseunstatename-options) */ - unstate(name: string, options?: ServerStateCookieOptions): ResponseObject; + unstate(name: string): ResponseObject; + unstate(name: string, options: ServerStateCookieOptions): ResponseObject; /** - * response.vary(header) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsevaryheader) * Adds the provided header to the list of inputs affected the response generation via the HTTP 'Vary' header where: * @param header - the HTTP request header name. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsevaryheader) */ vary(header: string): ResponseObject; /** - * response.takeover() - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsetakeover) * Marks the response object as a takeover response. * @return Return value: the current response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsetakeover) */ takeover(): ResponseObject; /** - * response.temporary(isTemporary) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsetemporaryistemporary) * Sets the status code to 302 or 307 (based on the response.rewritable() setting) where: * @param isTemporary - if false, sets status to permanent. Defaults to true. * @return Return value: the current response object. * Only available after calling the response.redirect() method. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsetemporaryistemporary) */ temporary(isTemporary: boolean): ResponseObject; /** - * response.permanent(isPermanent) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responsepermanentispermanent) * Sets the status code to 301 or 308 (based on the response.rewritable() setting) where: * @param isPermanent - if false, sets status to temporary. Defaults to true. * @return Return value: the current response object. * Only available after calling the response.redirect() method. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsepermanentispermanent) */ permanent(isPermanent: boolean): ResponseObject; /** - * response.rewritable(isRewritable) - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-responserewritableisrewritable) * Sets the status code to 301/302 for rewritable (allows changing the request method from 'POST' to 'GET') or 307/308 for non-rewritable (does not allow changing the request method from 'POST' to 'GET'). Exact code based on the response.temporary() or response.permanent() setting. Arguments: * @param isRewritable - if false, sets to non-rewritable. Defaults to true. * @return Return value: the current response object. * Only available after calling the response.redirect() method. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responserewritableisrewritable) */ rewritable(isRewritable: boolean): ResponseObject; diff --git a/types/hapi/v17/definitions/response/response-settings.d.ts b/types/hapi/v17/definitions/response/response-settings.d.ts index f695bb7a07..0926878d1c 100644 --- a/types/hapi/v17/definitions/response/response-settings.d.ts +++ b/types/hapi/v17/definitions/response/response-settings.d.ts @@ -1,28 +1,32 @@ +import {Json} from "hapi"; + +/** + * Object containing the response handling flags. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsesettings) + */ export interface ResponseSettings { /** - Defaults value: true. - If true and source is a Stream, copies the statusCode and headers properties of the stream object to the outbound response. + * Defaults value: true. + * If true and source is a Stream, copies the statusCode and headers properties of the stream object to the outbound response. */ - passThrough: boolean; + readonly passThrough: boolean; /** - Access: read only. - Default value: null (use route defaults). - Override the route json options used when source value requires stringification. + * Default value: null (use route defaults). + * Override the route json options used when source value requires stringification. */ - stringify: any; // TODO need to be implemented. + readonly stringify: Json.StringifyArguments; /** - Access: read only. - Default value: null (use route defaults). - If set, overrides the route cache with an expiration value in milliseconds. + * Default value: null (use route defaults). + * If set, overrides the route cache with an expiration value in milliseconds. */ - ttl: number; + readonly ttl: number; /** - Default value: false. - If true, a suffix will be automatically added to the 'ETag' header at transmission time (separated by a '-' character) when the HTTP 'Vary' header is present. + * Default value: false. + * If true, a suffix will be automatically added to the 'ETag' header at transmission time (separated by a '-' character) when the HTTP 'Vary' header is present. */ varyEtag: boolean; diff --git a/types/hapi/v17/definitions/response/response-toolkit.d.ts b/types/hapi/v17/definitions/response/response-toolkit.d.ts index a4cabf3785..a421f7c1a1 100644 --- a/types/hapi/v17/definitions/response/response-toolkit.d.ts +++ b/types/hapi/v17/definitions/response/response-toolkit.d.ts @@ -1,5 +1,4 @@ import {ServerRealm, ServerStateCookieOptions} from "hapi"; -import {Request} from "../request/request"; import {ResponseObject} from "./response-object"; /** @@ -10,11 +9,11 @@ import {ResponseObject} from "./response-object"; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#response-toolkit) * The response toolkit is a collection of properties and utilities passed to every [lifecycle method](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) * It is somewhat hard to define as it provides both utilities for manipulating responses as well as other information. Since the * toolkit is passed as a function argument, developers can name it whatever they want. For the purpose of this * document the h notation is used. It is named in the spirit of the RethinkDB r method, with h for hapi. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#response-toolkit) */ export interface ResponseToolkit { @@ -53,7 +52,7 @@ export interface ResponseToolkit { * The [request] object. This is a duplication of the request lifecycle method argument used by * [toolkit decorations](https://github.com/hapijs/hapi/blob/master/API.md#server.decorate()) to access the current request. */ - request: Request; + request: any; // TODO needs review /** * Used by the [authentication] method to pass back valid credentials where: @@ -77,13 +76,16 @@ export interface ResponseToolkit { * @return Return value: - a response object if the response is unmodified. - undefined if the response has changed. * If undefined is returned, the developer must return a valid lifecycle method value. If a response is returned, * it should be used as the return value (but may be customize using the response methods). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hentityoptions) */ + entity(): ResponseObject | undefined; entity(options: {etag?: string, modified?: string, vary?: boolean}): ResponseObject | undefined; /** * Redirects the client to the specified uri. Same as calling h.response().redirect(uri). * @param url * @return Returns a response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hredirecturi) */ redirect(uri: string): ResponseObject; @@ -92,8 +94,10 @@ export interface ResponseToolkit { * (e.g. setting the HTTP status code, custom headers, etc.), where: * @param value - (optional) return value. Defaults to null. * @return Returns a response object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hresponsevalue) */ - response(value?: string): ResponseObject; + response(): ResponseObject; + response(value: string): ResponseObject; /** * Sets a response cookie using the same arguments as response.state(). @@ -101,8 +105,10 @@ export interface ResponseToolkit { * @param value of the cookie * @param (optional) ServerStateCookieOptions object. * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hstatename-value-options) */ - state(name: string, value: string, options?: ServerStateCookieOptions): void; + state(name: string, value: string): void; + state(name: string, value: string, options: ServerStateCookieOptions): void; /** * Used by the [authentication] method to indicate authentication failed and pass back the credentials received where: @@ -115,16 +121,19 @@ export interface ResponseToolkit { * expired credentials, it allows the method to pass back the user information (combined with a 'try' * authentication mode) for error customization. * There is no difference between throwing the error or passing it with the h.unauthenticated() method is no credentials are passed, but it might still be helpful for code clarity. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hunauthenticatederror-data) */ - unauthenticated(error: Error, data?: {credentials: any, artifacts?: any}): void; + unauthenticated(error: Error): void; + unauthenticated(error: Error, data: {credentials: any, artifacts?: any}): void; /** * Clears a response cookie using the same arguments as - * [response.unstate()](https://github.com/hapijs/hapi/blob/master/API.md#response.unstate()). * @param name of the cookie * @param options (optional) ServerStateCookieOptions object. * @return void. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hunstatename-options) */ - unstate(name: string, options?: ServerStateCookieOptions): void; + unstate(name: string): void; + unstate(name: string, options: ServerStateCookieOptions): void; } From 7d6c5756865f2f52040d4554077887b47946afd0 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Thu, 30 Nov 2017 15:15:14 -0300 Subject: [PATCH 037/298] Reviewed Request declarations. --- .../v17/definitions/request/request-auth.d.ts | 11 +- .../v17/definitions/request/request-info.d.ts | 24 +- .../definitions/request/request-route.d.ts | 8 +- .../hapi/v17/definitions/request/request.d.ts | 208 +++++++++--------- 4 files changed, 133 insertions(+), 118 deletions(-) diff --git a/types/hapi/v17/definitions/request/request-auth.d.ts b/types/hapi/v17/definitions/request/request-auth.d.ts index cc5fe1ec0a..2382697da0 100644 --- a/types/hapi/v17/definitions/request/request-auth.d.ts +++ b/types/hapi/v17/definitions/request/request-auth.d.ts @@ -1,6 +1,13 @@ /** - * Authentication information - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestauth) + * Authentication information: + * * artifacts - an artifact object received from the authentication strategy and used in authentication-related actions. + * * credentials - the credential object received during the authentication process. The presence of an object does not mean successful authentication. + * * error - the authentication error is failed and mode set to 'try'. + * * isAuthenticated - true if the request has been successfully authenticated, otherwise false. + * * isAuthorized - true is the request has been successfully authorized against the route authentication access configuration. If the route has not access rules defined or if the request failed authorization, set to false. + * * mode - the route authentication mode. + * * strategy - the name of the strategy used. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestauth) */ export interface RequestAuth { /** an artifact object received from the authentication strategy and used in authentication-related actions. */ diff --git a/types/hapi/v17/definitions/request/request-info.d.ts b/types/hapi/v17/definitions/request/request-info.d.ts index 035b36cba0..a4892438a2 100644 --- a/types/hapi/v17/definitions/request/request-info.d.ts +++ b/types/hapi/v17/definitions/request/request-info.d.ts @@ -1,5 +1,17 @@ /** - * Request information + * Request information: + * * acceptEncoding - the request preferred encoding. + * * cors - if CORS is enabled for the route, contains the following: + * * isOriginMatch - true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. + * * host - content of the HTTP 'Host' header (e.g. 'example.com:8080'). + * * hostname - the hostname part of the 'Host' header (e.g. 'example.com'). + * * id - a unique request identifier (using the format '{now}:{connection.info.id}:{5 digits counter}'). + * * received - request reception timestamp. + * * referrer - content of the HTTP 'Referrer' (or 'Referer') header. + * * remoteAddress - remote client IP address. + * * remotePort - remote client port. + * * responded - request response timestamp (0 is not responded yet). + * Note that the request.info object is not meant to be modified. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestinfo) */ export interface RequestInfo { @@ -8,9 +20,7 @@ export interface RequestInfo { /** if CORS is enabled for the route, contains the following: */ cors: { /** - * if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does - * not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing - * decisions are made at that point in the request lifecycle. + * true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. */ isOriginMatch?: boolean; }; @@ -24,11 +34,7 @@ export interface RequestInfo { referrer: string; /** remote client IP address. */ remoteAddress: string; - /** - * remote client port. - * Set to string in casethey're requesting from a UNIX domain socket. - * TODO, what type does Hapi return, should this be number | string? - */ + /** remote client port. */ remotePort: string; /** request response timestamp (0 is not responded yet). */ responded: number; diff --git a/types/hapi/v17/definitions/request/request-route.d.ts b/types/hapi/v17/definitions/request/request-route.d.ts index 1b5e79d03b..b93132e66c 100644 --- a/types/hapi/v17/definitions/request/request-route.d.ts +++ b/types/hapi/v17/definitions/request/request-route.d.ts @@ -1,7 +1,13 @@ import {RouteOptions, ServerRealm, HTTP_METHODS_PARTIAL} from "hapi"; /** - * The request route information object + * The request route information object, where: + * * method - the route HTTP method. + * * path - the route path. + * * vhost - the route vhost option if configured. + * * realm - the active realm associated with the route. + * * settings - the route options object with all defaults applied. + * * fingerprint - the route internal normalized string representing the normalized path. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestroute) */ export interface RequestRoute { diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index 84212bfacf..4eff44dea0 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -8,6 +8,7 @@ import {PluginsStates} from "../plugin/plugin"; import {RequestRoute} from "./request-route"; import {RequestAuth} from "./request-auth"; import {RequestInfo} from "./request-info"; +import * as Podium from "podium"; /** * TODO both objects ReplyValue and _ReplyValue I found in the v16 TS definition, but I don't found it in the documentation. Need review. @@ -16,232 +17,227 @@ import {RequestInfo} from "./request-info"; export type ReplyValue = _ReplyValue | Promise<_ReplyValue>; export type _ReplyValue = null | undefined | string | number | boolean | Buffer | Error | stream.Stream | Object; // | array; +/** + * An object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestorig) + */ export interface RequestOrig { params: any; query: any; payload: any; } -export interface Request { +/** + * The request object is created internally for each incoming request. It is not the same object received from the node + * HTTP server callback (which is available via [request.raw.req](https://github.com/hapijs/hapi/blob/master/API.md#request.raw)). The request properties change throughout + * the request [lifecycle](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle). + */ +export interface Request extends Podium { /** - Access: read / write. - Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. + * Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestapp) */ app: any; /** - Access: read only. - Authentication information: - artifacts - an artifact object received from the authentication strategy and used in authentication-related actions. - credentials - the credential object received during the authentication process. The presence of an object does not mean successful authentication. - error - the authentication error is failed and mode set to 'try'. - isAuthenticated - true if the request has been successfully authenticated, otherwise false. - isAuthorized - true is the request has been successfully authorized against the route authentication access configuration. If the route has not access rules defined or if the request failed authorization, set to false. - mode - the route authentication mode. - strategy - the name of the strategy used. + * Authentication information: + * * artifacts - an artifact object received from the authentication strategy and used in authentication-related actions. + * * credentials - the credential object received during the authentication process. The presence of an object does not mean successful authentication. + * * error - the authentication error is failed and mode set to 'try'. + * * isAuthenticated - true if the request has been successfully authenticated, otherwise false. + * * isAuthorized - true is the request has been successfully authorized against the route authentication access configuration. If the route has not access rules defined or if the request failed authorization, set to false. + * * mode - the route authentication mode. + * * strategy - the name of the strategy used. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestauth) */ readonly auth: RequestAuth; /** - Access: read only and the public podium interface. - The request.events supports the following events: - 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). - 'finish' - emitted when the request payload finished reading. The event method signature is function (). - 'disconnect' - emitted when a request errors or aborts unexpectedly. + * Access: read only and the public podium interface. + * The request.events supports the following events: + * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). + * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). + * * 'disconnect' - emitted when a request errors or aborts unexpectedly. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) */ - events: 'peek' | 'finish' | 'disconnect'; + events: 'peek' | 'finish' | 'disconnect'; // TODO I think it's wrong. Maybe is events.on(' ', ' '). It needs revision. /** - Access: read only. - The raw request headers (references request.raw.req.headers). + * The raw request headers (references request.raw.req.headers). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestheaders) */ - headers: Dictionary; + readonly headers: Dictionary; /** - Access: read only. - Request information: - acceptEncoding - the request preferred encoding. - cors - if CORS is enabled for the route, contains the following: - isOriginMatch - true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. - host - content of the HTTP 'Host' header (e.g. 'example.com:8080'). - hostname - the hostname part of the 'Host' header (e.g. 'example.com'). - id - a unique request identifier (using the format '{now}:{connection.info.id}:{5 digits counter}'). - received - request reception timestamp. - referrer - content of the HTTP 'Referrer' (or 'Referer') header. - remoteAddress - remote client IP address. - remotePort - remote client port. - responded - request response timestamp (0 is not responded yet). - Note that the request.info object is not meant to be modified. + * Request information: + * * acceptEncoding - the request preferred encoding. + * * cors - if CORS is enabled for the route, contains the following: + * * isOriginMatch - true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. + * * host - content of the HTTP 'Host' header (e.g. 'example.com:8080'). + * * hostname - the hostname part of the 'Host' header (e.g. 'example.com'). + * * id - a unique request identifier (using the format '{now}:{connection.info.id}:{5 digits counter}'). + * * received - request reception timestamp. + * * referrer - content of the HTTP 'Referrer' (or 'Referer') header. + * * remoteAddress - remote client IP address. + * * remotePort - remote client port. + * * responded - request response timestamp (0 is not responded yet). + * Note that the request.info object is not meant to be modified. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestinfo) */ readonly info: RequestInfo; /** - Access: read only. - An array containing the logged request events. - Note that this array will be empty if route log.collect is set to false. + * An array containing the logged request events. + * Note that this array will be empty if route log.collect is set to false. */ - logs: any[]; // TODO check if type any is apropiate here. + readonly logs: any[]; /** - Access: read only. - The request method in lower case (e.g. 'get', 'post'). + * The request method in lower case (e.g. 'get', 'post'). */ - method: HTTP_METHODS_PARTIAL_LOWERCASE; + readonly method: HTTP_METHODS_PARTIAL_LOWERCASE; /** - Access: read only. - The parsed content-type header. Only available when payload parsing enabled and no payload error occurred. + * The parsed content-type header. Only available when payload parsing enabled and no payload error occurred. */ - mime: string; + readonly mime: string; /** - Access: read only. - An object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. + * An object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. */ - orig: RequestOrig; + readonly orig: RequestOrig; /** - Access: read only. - An object where each key is a path parameter name with matching value as described in Path parameters. + * An object where each key is a path parameter name with matching value as described in [Path parameters](https://github.com/hapijs/hapi/blob/master/API.md#path-parameters). */ - params: Dictionary; + readonly params: Dictionary; /** - Access: read only. - An array containing all the path params values in the order they appeared in the path. + * An array containing all the path params values in the order they appeared in the path. */ - paramsArray: string[]; + readonly paramsArray: string[]; /** - Access: read only. - The request URI's pathname component. + * The request URI's pathname component. */ - path: string; + readonly path: string; /** - Access: read only. - The request payload based on the route payload.output and payload.parse settings. + * The request payload based on the route payload.output and payload.parse settings. * TODO check this typing and add references / links. */ - payload: stream.Readable | Buffer | any; + readonly payload: stream.Readable | Buffer | any; /** - Access: read / write. - Plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. + * Plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. */ plugins: PluginsStates; /** - Access: read only. - An object where each key is the name assigned by a route pre-handler methods function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. + * An object where each key is the name assigned by a route pre-handler methods function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. */ - pre: Object; + readonly pre: Object; /** - Access: read / write (see limitations below). - The response object when set. The object can be modified but must not be assigned another object. To replace the response with another from within an extension point, use reply(response) to override with a different response. Contains null when no response has been set (e.g. when a request terminates prematurely when the client disconnects). + * Access: read / write (see limitations below). + * The response object when set. The object can be modified but must not be assigned another object. To replace the response with another from within an extension point, use reply(response) to override with a different response. Contains null when no response has been set (e.g. when a request terminates prematurely when the client disconnects). */ response: ResponseObject | null; /** - Access: read only. - Same as pre but represented as the response object created by the pre method. + * Same as pre but represented as the response object created by the pre method. */ - preResponses: Object; + readonly preResponses: Object; /** - Access: read only. - By default the object outputted from node's URL parse() method. Might also be set indirectly via request.setUrl in which case it may be a string (if url is set to an object with the query attribute as an unparsed string). + * By default the object outputted from node's URL parse() method. Might also be set indirectly via request.setUrl in which case it may be a string (if url is set to an object with the query attribute as an unparsed string). */ - query: any; + readonly query: any; /** - Access: read only. - An object containing the Node HTTP server objects. Direct interaction with these raw objects is not recommended. - req - the node request object. - res - the node response object. + * An object containing the Node HTTP server objects. Direct interaction with these raw objects is not recommended. + * * req - the node request object. + * * res - the node response object. */ - raw: { + readonly raw: { req: http.IncomingMessage; res: http.ServerResponse; }; /** - Access: read only. - The request route information object, where: - method - the route HTTP method. - path - the route path. - vhost - the route vhost option if configured. - realm - the active realm associated with the route. - settings - the route options object with all defaults applied. - fingerprint - the route internal normalized string representing the normalized path. + * The request route information object, where: + * * method - the route HTTP method. + * * path - the route path. + * * vhost - the route vhost option if configured. + * * realm - the active realm associated with the route. + * * settings - the route options object with all defaults applied. + * * fingerprint - the route internal normalized string representing the normalized path. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestroute) */ - route: RequestRoute; + readonly route: RequestRoute; /** - Access: read only and the public server interface. - The server object. + * Access: read only and the public server interface. + * The server object. */ - server: Server; // TODO check if this server object should be right. + server: Server; /** - Access: read only. - An object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. + * An object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. */ - state: Dictionary; + readonly state: Dictionary; /** - Access: read only. - The parsed request URI. + * The parsed request URI. */ - url: url.Url; + readonly url: url.Url; /** - * request.generateResponse(source, [options]) * Returns a response which you can pass into the reply interface where: - * [See docs] (https://hapijs.com/api/17.0.1#request.generateResponse()) * @param source - the value to set as the source of the reply interface, optional. * @param options - options for the method, optional. + * @return ResponseObject + * [See docs] (https://hapijs.com/api/17.0.1#request.generateResponse()) */ generateResponse(source?: ReplyValue, options?: {marshal?: any; prepare?: any; close?: any; variety?: any}): ResponseObject; /** - * request.log(tags, [data]) * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. The arguments are: * @param tags - a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. * @param data - (optional) an message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. * Any logs generated by the server internally will be emitted only on the 'request-internal' channel and will include the event.internal flag set to true. + * @return void + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data) */ log(tags: string | string[], data?: string | Object | (() => string | Object)): void; /** - * request.route.auth.access(request) - * [See docs] (https://hapijs.com/api/17.0.1#-requestrouteauthaccessrequest) * Validates a request against the route's authentication access configuration, where: * @param request - the request object. - * Return value: true if the request would have passed the route's access requirements. + * @return Return value: true if the request would have passed the route's access requirements. * Note that the route's authentication mode and strategies are ignored. The only match is made between the request.auth.credentials scope and entity information and the route access configuration. * If the route uses dynamic scopes, the scopes are constructed against the request.query, request.params, request.payload, and request.auth.credentials which may or may not match between the route and the request's route. If this method is called using a request that has not been authenticated (yet or not at all), it will return false if the route requires any authentication. + * [See docs] (https://hapijs.com/api/17.0.1#-requestrouteauthaccessrequest) */ - // TODO how to implement it? It is a function inside route.auth! The v16 doesn't have this option. + // TODO how to implement it? It is a function inside route.auth! We have another "route" properti in this file. (The v16 doesn't have this option) /** - * request.setMethod(method) * Changes the request method before the router begins processing the request where: * @param method - is the request HTTP method (e.g. 'GET'). + * @return void * Can only be called from an 'onRequest' extension method. * [See docs] (https://hapijs.com/api/17.0.1#-requestsetmethodmethod) */ setMethod(method: HTTP_METHODS_PARTIAL): void; /** - * request.setUrl(url, [stripTrailingSlash] - * [See docs] (https://hapijs.com/api/17.0.1#-requestseturlurl-striptrailingslash) * Changes the request URI before the router begins processing the request where: * Can only be called from an 'onRequest' extension method. * @param url - the new request URI. If url is a string, it is parsed with node's URL parse() method with parseQueryString set to true. url can also be set to an object compatible with node's URL parse() method output. * @param stripTrailingSlash - if true, strip the trailing slash from the path. Defaults to false. + * @return void + * [See docs] (https://hapijs.com/api/17.0.1#-requestseturlurl-striptrailingslash) */ setUrl(url: string | url.URL, stripTrailingSlash?: boolean): void; From b5a3441be2339cf610916d181c840cfa9e3fb15c Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Thu, 30 Nov 2017 20:25:27 -0300 Subject: [PATCH 038/298] Fix in JsDocs. --- types/hapi/v17/definitions/plugin/plugin-registered.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/hapi/v17/definitions/plugin/plugin-registered.d.ts b/types/hapi/v17/definitions/plugin/plugin-registered.d.ts index eb96b70537..9ee3987a10 100644 --- a/types/hapi/v17/definitions/plugin/plugin-registered.d.ts +++ b/types/hapi/v17/definitions/plugin/plugin-registered.d.ts @@ -6,12 +6,12 @@ export interface PluginsListRegistered { } /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverregistrations) * An object of the currently registered plugins where each key is a registered plugin name and the value is an * object containing: * * version - the plugin version. * * name - the plugin name. * * options - (optional) options passed to the plugin during registration. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverregistrations) */ export interface PluginRegistered { From 6bc069990613c44263d74f98880f7e005d88517e Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Thu, 30 Nov 2017 20:26:11 -0300 Subject: [PATCH 039/298] Solved TODO about plugin, --- types/hapi/v17/definitions/plugin/plugin.d.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/types/hapi/v17/definitions/plugin/plugin.d.ts b/types/hapi/v17/definitions/plugin/plugin.d.ts index df31c2c449..cda5c37f4a 100644 --- a/types/hapi/v17/definitions/plugin/plugin.d.ts +++ b/types/hapi/v17/definitions/plugin/plugin.d.ts @@ -1,4 +1,5 @@ import {Server} from "../server/server"; +import {ServerRegisterOptions} from "hapi"; export interface PluginsStates { [pluginName: string]: any; @@ -13,18 +14,16 @@ export interface PluginSpecificConfiguration { * plugin can manipulate the server through the standard server interface, but with the added ability to sandbox * certain properties. For example, setting a file path in one plugin doesn't affect the file path set * in another plugin. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#plugins) */ export interface Plugin { /** * (required) the registration function with the signature async function(server, options) where: + * * server - the server object with a plugin-specific server.realm. + * * options - any options passed to the plugin during registration via server.register(). */ - register: { - /** the server object with a plugin-specific server.realm. */ - server: Server; - /** any options passed to the plugin during registration via server.register(). */ - options: any; // TODO check what kind of object is expected here. - } + register: (server: Server, options: ServerRegisterOptions) => Function; /** * (required) the plugin name string. The name is used as a unique key. Published plugins (e.g. published in the npm From 84cd35512e25cbe528812cb064d2cc2b605593e4 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Thu, 30 Nov 2017 20:26:37 -0300 Subject: [PATCH 040/298] Fix in JsDocs. --- types/hapi/v17/definitions/request/request.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index 4eff44dea0..87d53c73a3 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -198,7 +198,7 @@ export interface Request extends Podium { * @param source - the value to set as the source of the reply interface, optional. * @param options - options for the method, optional. * @return ResponseObject - * [See docs] (https://hapijs.com/api/17.0.1#request.generateResponse()) + * [See docs](https://hapijs.com/api/17.0.1#request.generateResponse()) */ generateResponse(source?: ReplyValue, options?: {marshal?: any; prepare?: any; close?: any; variety?: any}): ResponseObject; @@ -218,7 +218,7 @@ export interface Request extends Podium { * @return Return value: true if the request would have passed the route's access requirements. * Note that the route's authentication mode and strategies are ignored. The only match is made between the request.auth.credentials scope and entity information and the route access configuration. * If the route uses dynamic scopes, the scopes are constructed against the request.query, request.params, request.payload, and request.auth.credentials which may or may not match between the route and the request's route. If this method is called using a request that has not been authenticated (yet or not at all), it will return false if the route requires any authentication. - * [See docs] (https://hapijs.com/api/17.0.1#-requestrouteauthaccessrequest) + * [See docs](https://hapijs.com/api/17.0.1#-requestrouteauthaccessrequest) */ // TODO how to implement it? It is a function inside route.auth! We have another "route" properti in this file. (The v16 doesn't have this option) @@ -227,7 +227,7 @@ export interface Request extends Podium { * @param method - is the request HTTP method (e.g. 'GET'). * @return void * Can only be called from an 'onRequest' extension method. - * [See docs] (https://hapijs.com/api/17.0.1#-requestsetmethodmethod) + * [See docs](https://hapijs.com/api/17.0.1#-requestsetmethodmethod) */ setMethod(method: HTTP_METHODS_PARTIAL): void; @@ -237,7 +237,7 @@ export interface Request extends Podium { * @param url - the new request URI. If url is a string, it is parsed with node's URL parse() method with parseQueryString set to true. url can also be set to an object compatible with node's URL parse() method output. * @param stripTrailingSlash - if true, strip the trailing slash from the path. Defaults to false. * @return void - * [See docs] (https://hapijs.com/api/17.0.1#-requestseturlurl-striptrailingslash) + * [See docs](https://hapijs.com/api/17.0.1#-requestseturlurl-striptrailingslash) */ setUrl(url: string | url.URL, stripTrailingSlash?: boolean): void; From 4d8024908f6ede582b212c04884935669af1587d Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Thu, 30 Nov 2017 20:28:35 -0300 Subject: [PATCH 041/298] Added more Server types. --- .../server/server-options-cache.d.ts | 2 +- .../definitions/server/server-options.d.ts | 2 +- .../definitions/server/server-register.d.ts | 4 -- .../v17/definitions/server/server-route.d.ts | 47 +++++++++++++ .../v17/definitions/server/server-state.d.ts | 45 ++++++++++++- types/hapi/v17/definitions/server/server.d.ts | 67 +++++++++++++++---- types/hapi/v17/index.d.ts | 1 + 7 files changed, 149 insertions(+), 19 deletions(-) create mode 100644 types/hapi/v17/definitions/server/server-route.d.ts diff --git a/types/hapi/v17/definitions/server/server-options-cache.d.ts b/types/hapi/v17/definitions/server/server-options-cache.d.ts index cd71537d85..13b4df499a 100644 --- a/types/hapi/v17/definitions/server/server-options-cache.d.ts +++ b/types/hapi/v17/definitions/server/server-options-cache.d.ts @@ -1,7 +1,7 @@ import * as Catbox from "catbox"; /** - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-cache) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-cache) * hapi uses catbox for its cache implementation which includes support for common storage solutions (e.g. Redis, * MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. */ diff --git a/types/hapi/v17/definitions/server/server-options.d.ts b/types/hapi/v17/definitions/server/server-options.d.ts index 5b2b364f8c..41b21e01fd 100644 --- a/types/hapi/v17/definitions/server/server-options.d.ts +++ b/types/hapi/v17/definitions/server/server-options.d.ts @@ -7,7 +7,7 @@ import {PluginSpecificConfiguration, RouteOptions} from "hapi"; /** - * [See docs] (https://github.com/hapijs/hapi/blob/master/API.md#-server-options) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-server-options) * he server options control the behavior of the server object. Note that the options object is deeply cloned * (with the exception of listener which is shallowly copied) and should not contain any values that are unsafe to perform deep copy on. * All options are optionals. diff --git a/types/hapi/v17/definitions/server/server-register.d.ts b/types/hapi/v17/definitions/server/server-register.d.ts index 34685cbde2..14746bc85a 100644 --- a/types/hapi/v17/definitions/server/server-register.d.ts +++ b/types/hapi/v17/definitions/server/server-register.d.ts @@ -9,13 +9,11 @@ import {Plugin} from "hapi"; * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options) */ export interface ServerRegisterOptions { - once?: boolean; routes?: { prefix: string; vhost: string | string[]; }; - } /** @@ -29,8 +27,6 @@ export interface ServerRegisterOptions { * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options) */ export interface ServerRegisterPluginObject extends ServerRegisterOptions { - plugin: Plugin; options?: any; - } diff --git a/types/hapi/v17/definitions/server/server-route.d.ts b/types/hapi/v17/definitions/server/server-route.d.ts new file mode 100644 index 0000000000..0a6fce8ed0 --- /dev/null +++ b/types/hapi/v17/definitions/server/server-route.d.ts @@ -0,0 +1,47 @@ +import {HTTP_METHODS_PARTIAL, Lifecycle, Server} from "hapi"; + +/** + * A route configuration object or an array of configuration objects where each object contains: + * * path - (required) the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the server's router configuration. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. + * * method - (required) the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. + * * vhost - (optional) a domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. + * * handler - (required when handler is not set) the route handler function called to generate the response after successful authentication and validation. + * * options - additional route options. The options value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. + * * rules - route custom rules object. The object is passed to each rules processor registered with server.rules(). Cannot be used if route.options.rules is defined. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrouteroute) + */ +export interface ServerRoute { + + /** + * (required) the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the server's router configuration. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrouteroute) + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#path-parameters) + */ + path: string; + + /** + * (required) the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. + */ + method: HTTP_METHODS_PARTIAL | HTTP_METHODS_PARTIAL[] | string | string[]; + + /** + * (optional) a domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. + */ + vhost?: string | string[]; + + /** + * (required when handler is not set) the route handler function called to generate the response after successful authentication and validation. + */ + handler?: Lifecycle.Method; + + /** + * additional route options. The options value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. + */ + options?: Object | ((server: Server) => Function); + + /** + * route custom rules object. The object is passed to each rules processor registered with server.rules(). Cannot be used if route.options.rules is defined. + */ + rules?: any; + +} diff --git a/types/hapi/v17/definitions/server/server-state.d.ts b/types/hapi/v17/definitions/server/server-state.d.ts index 796dda8cad..4b8a234718 100644 --- a/types/hapi/v17/definitions/server/server-state.d.ts +++ b/types/hapi/v17/definitions/server/server-state.d.ts @@ -1,6 +1,22 @@ import {ServerStateCookieOptions} from "hapi"; -import {Dictionary} from "../util/util"; +import {Dictionary} from "hapi"; +/** + * A single object or an array of object where each contains: + * * name - the cookie name. + * * value - the cookie value. + * * options - cookie configuration to override the server settings. + */ +export interface ServerStateFormat { + name: string; + value: string; + options: ServerStateCookieOptions; +} + +/** + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverstatename-options) + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsstate) + */ export interface ServerState { /** @@ -25,5 +41,32 @@ export interface ServerState { */ readonly names: Dictionary; + /** + * Same as calling [server.state()](https://github.com/hapijs/hapi/blob/master/API.md#server.state()). + */ + add(name: string): void; + add(name: string, options: ServerStateCookieOptions): void; + + /** + * Formats an HTTP 'Set-Cookie' header based on the server.options.state where: + * @param cookies - a single object or an array of object where each contains: + * * name - the cookie name. + * * value - the cookie value. + * * options - cookie configuration to override the server settings. + * @return Return value: a header string. + * Note that this utility uses the server configuration but does not change the server state. It is provided for manual cookie formating (e.g. when headers are set manually). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-async-serverstatesformatcookies) + */ + format(cookies: ServerStateFormat): string; + format(cookies: ServerStateFormat[]): string; + + /** + * Parses an HTTP 'Cookies' header based on the server.options.state where: + * @param header - the HTTP header. + * @return Return value: an object where each key is a cookie name and value is the parsed cookie. + * Note that this utility uses the server configuration but does not change the server state. It is provided for manual cookie parsing (e.g. when server parsing is disabled). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-async-serverstatesparseheader) + */ + parse(header: string): Dictionary; } diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index abe6d8c313..849d1b15b4 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -13,7 +13,7 @@ import { ServerOptionsCache, ServerEventCriteria, ServerEventsApplication, ServerEventsApplicationObject, PayloadCompressionDecoderSettings, RouteCompressionEncoderSettings, HTTP_METHODS, ServerMethodOptions, ServerMethod, ServerMethodConfigurationObject, - Plugin, ResponseToolkit, Dictionary, + Plugin, ResponseToolkit, Dictionary, ServerStateCookieOptions, HTTP_METHODS_PARTIAL_LOWERCASE, } from "hapi"; import { RequestExtPointFunction, ServerExtEventsObject, ServerExtEventsRequestObject, ServerExtOptions, @@ -23,6 +23,7 @@ import {ServerInjectOptions, ServerInjectResponse} from "./server-inject"; import {RequestRoute} from "../request/request-route"; import {ServerAuth, ServerAuthConfig} from "./server-auth"; import {ServerRegisterPluginObject, ServerRegisterOptions} from "./server-register"; +import {ServerRoute} from "./server-route"; /** * The server object is the main application container. The server manages all incoming requests along with all @@ -570,18 +571,27 @@ export class Server extends events.EventEmitter { * Note that the options object is deeply cloned (with the exception of bind which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrouteroute) */ - route(route: any): void; // TODO needs to be implemented. Depends of the route options TODO as well. - - - - - - - - - - // TODO It"s not finished + route(route: ServerRoute | ServerRoute[]): void; + /** + * Defines a route rules processor for converting route rules object into route configuration where: + * @param processor - a function using the signature function(rules, info) where: + * * rules - + * * info - an object with the following properties: + * * * method - the route method. + * * * path - the route path. + * * *vhost - the route virtual host (if any defined). + * * returns a route config object. + * @param options - optional settings: + * * validate - rules object validation: + * * * schema - joi schema. + * * * options - optional joi validation options. Defaults to { allowUnknown: true }. + * Note that the root server and each plugin server instance can only register one rules processor. If a route is added after the rules are configured, it will not include the rules config. Routes added by plugins apply the rules to each of the parent realms' rules from the root to the route's realm. This means the processor defined by the plugin override the config generated by the root processor if they overlap. The route config overrides the rules config if the overlap. + * @return void + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrulesprocessor-options) + */ + rules(processor: (rules: any, info: {method: string, path: string, vhost?: string}) => Function): void; + rules(processor: (rules: any, info: {method: string, path: string, vhost?: string}) => Function, options: {validate: any}): void; // TODO needs implementation /** * Starts the server by listening for incoming requests on the configured port (unless the connection was configured with autoListen set to false). @@ -592,4 +602,37 @@ export class Server extends events.EventEmitter { */ start(): void; + /** + * HTTP state management uses client cookies to persist a state across multiple requests. + * @param name - the cookie name string. + * @param options - are the optional cookie settings + * @return Return value: none. + * State defaults can be modified via the server default state configuration option. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverstatename-options) + */ + state(name: string): void; + state(name: string, options: ServerStateCookieOptions): void; + + /** + * Stops the server's listener by refusing to accept any new connections or requests (existing connections will continue until closed or timeout), where: + * @param options - (optional) object with: + * * timeout - overrides the timeout in millisecond before forcefully terminating a connection. Defaults to 5000 (5 seconds). + * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstopoptions) + */ + stop(): void; + stop(options: {timeout: number}): void; + + /** + * Returns a copy of the routing table where: + * @param host - (optional) host to filter routes matching a specific virtual host. Defaults to all virtual hosts. + * @return Return value: an array of routes where each route contains: + * * settings - the route config with defaults applied. + * * method - the HTTP method in lower case. + * * path - the route path. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost) + */ + table(): {settings: ServerRoute; method: HTTP_METHODS_PARTIAL_LOWERCASE, path: string}[]; // TODO I am not sure if the ServerRoute is the object expected here + table(host: string): {settings: ServerRoute; method: HTTP_METHODS_PARTIAL_LOWERCASE, path: string}[]; + } diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index fa2e6cac25..3e890253c4 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -48,6 +48,7 @@ export * from './definitions/server/server-options' export * from './definitions/server/server-options-cache' export * from './definitions/server/server-realm' export * from './definitions/server/server-register' +export * from './definitions/server/server-route' export * from './definitions/server/server-state' export * from './definitions/server/server-state-options' From c424efdbe7181553efc8c9d952965287268cf24c Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 3 Dec 2017 10:27:26 -0300 Subject: [PATCH 042/298] Reviewed and added sonme Function Overloading to follow best practices: http://definitelytyped.org/guides/best-practices.html --- types/hapi/v17/definitions/server/server.d.ts | 81 ++++++++++++------- 1 file changed, 52 insertions(+), 29 deletions(-) diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 849d1b15b4..a18fcb7dc7 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -28,17 +28,19 @@ import {ServerRoute} from "./server-route"; /** * The server object is the main application container. The server manages all incoming requests along with all * the facilities provided by the framework. Each server supports a single connection (e.g. listen to port 80). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#server) */ export class Server extends events.EventEmitter { /** - Creates a new server object where: + Creates a new server object */ constructor(); /** - Creates a new server object where: - @param options server configuration object. + * Creates a new server object where: + * @param options server configuration object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptions) */ constructor(options: ServerOptions); @@ -46,6 +48,7 @@ export class Server extends events.EventEmitter { * Provides a safe place to store server-specific run-time application data without potential conflicts with * the framework internals. The data can be accessed whenever the server is accessible. * Initialized with an empty object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverapp) */ app?: any; @@ -60,6 +63,7 @@ export class Server extends events.EventEmitter { * * request - decorations on the request object. * * toolkit - decorations on the response toolkit. * * server - decorations on the server object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecorations) */ readonly decorations: { request: Request, @@ -81,6 +85,7 @@ export class Server extends events.EventEmitter { * * a podium emitter object. * * an array containing any of the above. * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) */ event(events: ServerEventsApplication): void; event(events: ServerEventsApplication[]): void; @@ -170,7 +175,6 @@ export class Server extends events.EventEmitter { }; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo) * An object containing information about the server where: * * id - a unique server identifier (using the format '{hostname}:{pid}:{now base36}'). * * created - server creation timestamp. @@ -183,12 +187,14 @@ export class Server extends events.EventEmitter { * * 'https' - HTTPS. * * 'socket' - UNIX domain socket or Windows named pipe. * * uri - a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains the uri value if set, otherwise constructed from the available settings. If no port is configured or is set to 0, the uri will not include a port component until the server is started. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo) */ readonly info: ServerInfo; /** * Access: read only and listener public interface. * The node HTTP server object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverlistener) */ listener: http.Server; @@ -197,6 +203,7 @@ export class Server extends events.EventEmitter { * * eventLoopDelay - event loop delay milliseconds. * * heapUsed - V8 heap usage. * * rss - RSS memory usage. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverload) */ readonly load: { eventLoopDelay: number; @@ -205,18 +212,19 @@ export class Server extends events.EventEmitter { }; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethods * Server methods are functions registered with the server and used throughout the application as a common utility. * Their advantage is in the ability to configure them to use the built-in cache and share across multiple request * handlers without having to create a common module. * sever.methods is an object which provides access to the methods registered via server.method() where each * server method name is an object property. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethods */ readonly methods: Dictionary; /** * Provides access to the server MIME database used for setting content-type information. The object must not be * modified directly but only through the [mime](https://github.com/hapijs/hapi/blob/master/API.md#server.options.mime) server setting. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermime) */ mime: MimosOptions; @@ -224,11 +232,11 @@ export class Server extends events.EventEmitter { * An object containing the values exposed by each registered plugin where each key is a plugin name and the values * are the exposed properties by each plugin using server.expose(). Plugins may set the value of * the server.plugins[name] object directly or via the server.expose() method. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins) */ plugins: any; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrealm) * The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When * registering a plugin or an authentication scheme, a server object reference is provided with a new server.realm * container specific to that registration. It allows each plugin to maintain its own settings without leaking @@ -236,6 +244,7 @@ export class Server extends events.EventEmitter { * For example, a plugin can set a default file path for local resources without breaking other plugins' configured * paths. When calling server.bind(), the active realm's settings.bind property is set which is then used by * routes and extensions added at the same level (server root or plugin). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrealm) */ readonly realm: ServerRealm; @@ -245,17 +254,20 @@ export class Server extends events.EventEmitter { * * version - the plugin version. * * name - the plugin name. * * options - (optional) options passed to the plugin during registration. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverregistrations) */ readonly registrations: PluginsListRegistered; /** * The server configuration object after defaults applied. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serversettings) */ readonly settings: ServerOptions; /** * The server cookies manager. * Access: read only and statehood public interface. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverstates) */ readonly states: ServerState; @@ -272,11 +284,11 @@ export class Server extends events.EventEmitter { readonly version: string; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverbindcontext) * Sets a global context used as the default bind object when adding a route or an extension where: * @param context - the object used to bind this in lifecycle methods such as the route handler and extension methods. The context is also made available as h.context. * @return Return value: none. * When setting a context inside a plugin, the context is applied only to methods set up by the plugin. Note that the context applies only to routes and extensions added after it has been set. Ignored if the method being bound is an arrow function. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverbindcontext) */ bind(context: any): void; @@ -286,7 +298,6 @@ export class Server extends events.EventEmitter { cache: { /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) * Provisions a cache segment within the server cache facility where: * @param options - [catbox policy](https://github.com/hapijs/catbox#policy) configuration where: * * expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. @@ -294,7 +305,7 @@ export class Server extends events.EventEmitter { * * generateFunc - a function used to generate a new cache item if one is not found in the cache when calling get(). The method's signature is async function(id, flags) where: * - `id` - the `id` string or object provided to the `get()` method. * - `flags` - an object used to pass back additional flags to the cache where: - *- `ttl` - the cache ttl value in milliseconds. Set to `0` to skip storing in the cache. Defaults to the cache global policy. + * - `ttl` - the cache ttl value in milliseconds. Set to `0` to skip storing in the cache. Defaults to the cache global policy. * * staleIn - number of milliseconds to mark an item stored in cache as stale and attempt to regenerate it when generateFunc is provided. Must be less than expiresIn. * * staleTimeout - number of milliseconds to wait before checking if an item is stale. * * generateTimeout - number of milliseconds to wait before returning a timeout error when the generateFunc function takes too long to return a value. When the value is eventually returned, it is stored in the cache for future requests. Required if generateFunc is present. Set to false to disable timeouts which may cause all get() requests to get stuck forever. @@ -306,31 +317,31 @@ export class Server extends events.EventEmitter { * * segment - string segment name, used to isolate cached items within the cache partition. When called within a plugin, defaults to '!name' where 'name' is the plugin name. When called within a server method, defaults to '#name' where 'name' is the server method name. Required when called outside of a plugin. * * shared - if true, allows multiple cache provisions to share the same segment. Default to false. * @return Catbox Policy. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) */ (options: catbox.PolicyOptions): catbox.Policy; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions) * Provisions a server cache as described in server.cache where: * @param options - same as the server cache configuration options. * @return Return value: none. * Note that if the server has been initialized or started, the cache will be automatically started to match the state of any other provisioned server cache. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions) */ provision(options: ServerOptionsCache): void; }; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoderencoding-decoder) * Registers a custom content decoding compressor to extend the built-in support for 'gzip' and 'deflate' where: * @param encoding - the decoder name string. * @param decoder - a function using the signature function(options) where options are the encoding specific options configured in the route payload.compression configuration option, and the return value is an object compatible with the output of node's zlib.createGunzip(). * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoderencoding-decoder) */ decoder(encoding: string, decoder: ((options: PayloadCompressionDecoderSettings) => zlib.Gunzip)): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options) * Extends various framework interfaces with custom methods where: * @param type - the interface being decorated. Supported types: * 'handler' - adds a new handler type to be used in routes handlers. @@ -346,12 +357,12 @@ export class Server extends events.EventEmitter { * must return the new decoration function or value. * cannot be used to extend handler decorations. * @return void; + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options) */ decorate(type: 'request', property: string, method: ((request: Request) => Function), options?: {apply: true; extend: false} ): void; decorate(type: 'handler' | 'request' | 'reply' | 'server', property: string, method: Function, options?: {apply: boolean; extend: boolean} ): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdependencydependencies-after) * Used within a plugin to declare a required dependency on other plugins where: * @param dependencies - a single string or an array of plugin name strings which must be registered in order for this plugin to operate. Plugins listed must be registered before the server is initialized or started. * @param after - (optional) a function that is called after all the specified dependencies have been registered and before the server starts. The function is only called if the server is initialized or started. The function signature is async function(server) where: @@ -360,40 +371,43 @@ export class Server extends events.EventEmitter { * The after method is identical to setting a server extension point on 'onPreStart'. * If a circular dependency is detected, an exception is thrown (e.g. two plugins each has an after function to be called after the other). * The method does not provide version dependency which should be implemented using npm peer dependencies. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdependencydependencies-after) */ - dependency(dependencies: string | string[], after?: ((server: Server) => Function)): void; + dependency(dependencies: string): void; + dependency(dependencies: string, after: ((server: Server) => Function)): void; + dependency(dependencies: string[]): void; + dependency(dependencies: string[], after: ((server: Server) => Function)): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder) * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' where: * @param encoding - the encoder name string. * @param encoder - a function using the signature function(options) where options are the encoding specific options configured in the route compression option, and the return value is an object compatible with the output of node's zlib.createGzip(). * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder) */ encoder(encoding: string, encoder: ((options: RouteCompressionEncoderSettings) => zlib.Gzip)): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposekey-value) * Used within a plugin to expose a property via server.plugins[name] where: * @param key - the key assigned (server.plugins[name][key]). * @param value - the value assigned. * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposekey-value) */ expose(key: string, value: any): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposeobj) * Merges an object into to the existing content of server.plugins[name] where: * @param obj - the object merged into the exposed properties container. * @return Return value: none. * Note that all the properties of obj are deeply cloned into server.plugins[name], so avoid using this method * for exposing large objects that may be expensive to clone or singleton objects such as database client * objects. Instead favor server.expose(key, value), which only copies a reference to value. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposeobj) */ expose(obj: Object): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) * Registers an extension function in one of the request lifecycle extension points where: * @param events - an object or array of objects with the following: * * type - (required) the extension point event name. The available extension points include the request extension points as well as the following server extension points: @@ -412,20 +426,24 @@ export class Server extends events.EventEmitter { * * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. * * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. * @return void + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) */ - ext(events: ServerExtEventsObject | ServerExtEventsObject[]): void; - ext(events: ServerExtEventsRequestObject | ServerExtEventsRequestObject[]): void; + ext(events: ServerExtEventsObject): void; + ext(events: ServerExtEventsObject[]): void; + ext(events: ServerExtEventsRequestObject): void; + ext(events: ServerExtEventsRequestObject[]): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options) * Registers a single extension event using the same properties as used in server.ext(events), but passed as arguments. * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options) */ - ext(event: ServerExtType, method: ServerExtPointFunction, options?: ServerExtOptions): void; - ext(event: ServerExtRequestType, method: RequestExtPointFunction, options?: ServerExtOptions): void; + ext(event: ServerExtType, method: ServerExtPointFunction): void; + ext(event: ServerExtType, method: ServerExtPointFunction, options: ServerExtOptions): void; + ext(event: ServerExtRequestType, method: RequestExtPointFunction): void; + ext(event: ServerExtRequestType, method: RequestExtPointFunction, options: ServerExtOptions): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinitialize) * Initializes the server (starts the caches, finalizes plugin registration) but does not start listening on the connection port. * @return Return value: none. * Note that if the method fails and throws an error, the server is considered to be in an undefined state and @@ -433,11 +451,11 @@ export class Server extends events.EventEmitter { * other event listeners will get confused by repeated attempts to start the server or make assumptions about the * healthy state of the environment. It is recommended to abort the process when the server fails to start properly. * If you must try to resume after an error, call server.stop() first to reset the server state. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinitialize) */ initialize(): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions) * Injects a request into the server simulating an incoming HTTP request without making an actual socket connection. Injection is useful for testing purposes as well as for invoking routing logic internally without the overhead and limitations of the network stack. * The method utilizes the shot module for performing injections, with some additional options and response properties: * @param options - can be assigned a string with the requested URI, or an object with: @@ -467,8 +485,10 @@ export class Server extends events.EventEmitter { * * res - the simulated node response object. * * result - the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the internal objects returned (instead of parsing the response string). * * request - the request object. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions) */ - inject(options: string | ServerInjectOptions): ServerInjectResponse; + inject(options: string): ServerInjectResponse; + inject(options: ServerInjectOptions): ServerInjectResponse; /** * Logs server events that cannot be associated with a specific request. When called the server emits a 'log' event which can be used by other listeners or plugins to record the information or output to the console. The arguments are: @@ -496,7 +516,8 @@ export class Server extends events.EventEmitter { * @return Return value: the route information if found, otherwise null. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermatchmethod-path-host) */ - match(method: HTTP_METHODS, path: string, host?: string): RequestRoute | null; + match(method: HTTP_METHODS, path: string): RequestRoute | null; + match(method: HTTP_METHODS, path: string, host: string): RequestRoute | null; /** * Registers a server method where: @@ -514,7 +535,8 @@ export class Server extends events.EventEmitter { * When configured with caching enabled, server.methods[name].cache is assigned an object with the following properties and methods: - await drop(...args) - a function that can be used to clear the cache for a given key. - stats - an object with cache statistics, see catbox for stats documentation. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) */ - method(name: string, method: ServerMethod, options?: ServerMethodOptions): void; + method(name: string, method: ServerMethod): void; + method(name: string, method: ServerMethod, options: ServerMethodOptions): void; /** * Registers a server method function as described in server.method() using a configuration object where: @@ -571,7 +593,8 @@ export class Server extends events.EventEmitter { * Note that the options object is deeply cloned (with the exception of bind which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrouteroute) */ - route(route: ServerRoute | ServerRoute[]): void; + route(route: ServerRoute): void; + route(route: ServerRoute[]): void; /** * Defines a route rules processor for converting route rules object into route configuration where: From f7e3fc1e8d42dab607bb4fec24c0fb0f921e92f2 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 3 Dec 2017 15:57:40 -0300 Subject: [PATCH 043/298] Reviewed some server types. --- .../v17/definitions/server/server-auth.d.ts | 12 +- .../v17/definitions/server/server-method.d.ts | 3 - .../server/server-options-cache.d.ts | 2 +- .../definitions/server/server-options.d.ts | 132 +++++++++--------- types/hapi/v17/definitions/server/server.d.ts | 26 ++-- 5 files changed, 83 insertions(+), 92 deletions(-) diff --git a/types/hapi/v17/definitions/server/server-auth.d.ts b/types/hapi/v17/definitions/server/server-auth.d.ts index 370e16be6b..6b86c0e8a4 100644 --- a/types/hapi/v17/definitions/server/server-auth.d.ts +++ b/types/hapi/v17/definitions/server/server-auth.d.ts @@ -38,8 +38,6 @@ export interface ServerAuth { } /** - * server.auth.default - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions) * Sets a default strategy which is applied to every route where: * @param options - one of: * * a string with the default strategy name @@ -54,18 +52,19 @@ export interface ServerAuth { * before server.auth.default() is called if those routes lack any authentication config. * The default auth strategy configuration can be accessed via server.auth.settings.default. To obtain the active * authentication configuration of a route, use server.auth.lookup(request.route). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions) */ - default(options: string | ServerAuthConfig): void; + default(options: string): void; + default(options: ServerAuthConfig): void; /** - * server.auth.scheme - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme) * Registers an authentication scheme where: * @param name the scheme name. * @param scheme - the method implementing the scheme with signature function(server, options) where: * * server - a reference to the server object the scheme is added to. * * options - (optional) the scheme options argument passed to server.auth.strategy() when instantiation a strategy. * @return void. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme) */ scheme(name: string, scheme: ServerAuthScheme): void; @@ -77,7 +76,8 @@ export interface ServerAuth { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthstrategyname-scheme-options) */ - strategy(name: string, scheme: string, options?: any): void; + strategy(name: string, scheme: string): void; + strategy(name: string, scheme: string, options: any): void; /** * Tests a request against an authentication strategy where: diff --git a/types/hapi/v17/definitions/server/server-method.d.ts b/types/hapi/v17/definitions/server/server-method.d.ts index 216fd6ce6f..9806ffc5cb 100644 --- a/types/hapi/v17/definitions/server/server-method.d.ts +++ b/types/hapi/v17/definitions/server/server-method.d.ts @@ -18,9 +18,6 @@ export interface ServerMethod { * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) */ export interface ServerMethodCache extends catbox.PolicyOptions { - /** - * Required - */ generateTimeout: number | false; } diff --git a/types/hapi/v17/definitions/server/server-options-cache.d.ts b/types/hapi/v17/definitions/server/server-options-cache.d.ts index 13b4df499a..1e75ebe857 100644 --- a/types/hapi/v17/definitions/server/server-options-cache.d.ts +++ b/types/hapi/v17/definitions/server/server-options-cache.d.ts @@ -1,9 +1,9 @@ import * as Catbox from "catbox"; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-cache) * hapi uses catbox for its cache implementation which includes support for common storage solutions (e.g. Redis, * MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-cache) */ export interface ServerOptionsCache extends Catbox.PolicyOptions { diff --git a/types/hapi/v17/definitions/server/server-options.d.ts b/types/hapi/v17/definitions/server/server-options.d.ts index 41b21e01fd..4273a01988 100644 --- a/types/hapi/v17/definitions/server/server-options.d.ts +++ b/types/hapi/v17/definitions/server/server-options.d.ts @@ -5,68 +5,71 @@ import * as catbox from "catbox"; import {MimosOptions} from "mimos"; import {PluginSpecificConfiguration, RouteOptions} from "hapi"; - /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-server-options) * he server options control the behavior of the server object. Note that the options object is deeply cloned * (with the exception of listener which is shallowly copied) and should not contain any values that are unsafe to perform deep copy on. * All options are optionals. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-server-options) */ export interface ServerOptions { /** - Default value: '0.0.0.0' (all available network interfaces). - Sets the hostname or IP address the server will listen on. If not configured, defaults to host if present, otherwise to all available network interfaces. Set to '127.0.0.1' or 'localhost' to restrict the server to only those coming from the same host. + * Default value: '0.0.0.0' (all available network interfaces). + * Sets the hostname or IP address the server will listen on. If not configured, defaults to host if present, otherwise to all available network interfaces. Set to '127.0.0.1' or 'localhost' to restrict the server to only those coming from the same host. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsaddress) */ address?: string; /** - Default value: {}. - Provides application-specific configuration which can later be accessed via server.settings.app. The framework does not interact with this object. It is simply a reference made available anywhere a server reference is provided. - Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. + * Default value: {}. + * Provides application-specific configuration which can later be accessed via server.settings.app. The framework does not interact with this object. It is simply a reference made available anywhere a server reference is provided. + * Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsapp) */ app?: any; /** - Default value: true. - Used to disable the automatic initialization of the listener. When false, indicates that the listener will be started manually outside the framework. - Cannot be set to true along with a port value. + * Default value: true. + * Used to disable the automatic initialization of the listener. When false, indicates that the listener will be started manually outside the framework. + * Cannot be set to true along with a port value. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsautolisten) */ autoListen?: boolean; /** - Default value: { engine: require('catbox-memory' }. - Sets up server-side caching providers. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and capabilities. - hapi uses catbox for its cache implementation which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. - The server cache configuration only defines the storage container itself. The configuration can be assigned one or more (array): - a class or prototype function (usually obtained by calling require() on a catbox strategy such as require('catbox-redis')). A new catbox client will be created internally using this function. - a configuration object with the following: - engine - a class, a prototype function, or a catbox engine object. - name - an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. - shared - if true, allows multiple cache users to share the same segment (e.g. multiple methods using the same cache storage container). Default to false. - partition - (optional) string used to isolate cached data. Defaults to 'hapi-cache'. - other options passed to the catbox strategy used. Other options are only passed to catbox when engine above is a class or function and ignored if engine is a catbox engine object). + * Default value: { engine: require('catbox-memory' }. + * Sets up server-side caching providers. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and capabilities. + * hapi uses catbox for its cache implementation which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. + * The server cache configuration only defines the storage container itself. The configuration can be assigned one or more (array): + * * a class or prototype function (usually obtained by calling require() on a catbox strategy such as require('catbox-redis')). A new catbox client will be created internally using this function. + * * a configuration object with the following: + * * * engine - a class, a prototype function, or a catbox engine object. + * * * name - an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. + * * * shared - if true, allows multiple cache users to share the same segment (e.g. multiple methods using the same cache storage container). Default to false. + * * * partition - (optional) string used to isolate cached data. Defaults to 'hapi-cache'. + * * * other options passed to the catbox strategy used. Other options are only passed to catbox when engine above is a class or function and ignored if engine is a catbox engine object). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionscache) */ cache?: catbox.EnginePrototype | ServerOptionsCache | ServerOptionsCache[]; /** - Default value: { minBytes: 1024 }. - Defines server handling of content encoding requests. If false, response content encoding is disabled and no compression is performed by the server. + * Default value: { minBytes: 1024 }. + * Defines server handling of content encoding requests. If false, response content encoding is disabled and no compression is performed by the server. */ compression?: boolean; /** - Default value: '1024'. - Sets the minimum response payload size in bytes that is required for content encoding compression. If the payload size is under the limit, no compression is performed. + * Default value: '1024'. + * Sets the minimum response payload size in bytes that is required for content encoding compression. If the payload size is under the limit, no compression is performed. */ minBytes?: number; /** - Default value: { request: ['implementation'] }. - Determines which logged events are sent to the console. This should only be used for development and does not affect which events are actually logged internally and recorded. Set to false to disable all console logging, or to an object with: - log - a string array of server log tags to be displayed via console.error() when the events are logged via server.log() as well as internally generated server logs. Defaults to no output. - request - a string array of request log tags to be displayed via console.error() when the events are logged via request.log() as well as internally generated request logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. To display all request logs, set it to '*'. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. - For example, to display all errors, set the log or request to ['error']. To turn off all output set the log or request to false. To display all server logs, set the log or request to '*'. To disable all debug information, set debug to false. + * Default value: { request: ['implementation'] }. + * Determines which logged events are sent to the console. This should only be used for development and does not affect which events are actually logged internally and recorded. Set to false to disable all console logging, or to an object with: + * * log - a string array of server log tags to be displayed via console.error() when the events are logged via server.log() as well as internally generated server logs. Defaults to no output. + * * request - a string array of request log tags to be displayed via console.error() when the events are logged via request.log() as well as internally generated request logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. To display all request logs, set it to '*'. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. + * For example, to display all errors, set the log or request to ['error']. To turn off all output set the log or request to false. To display all server logs, set the log or request to '*'. To disable all debug information, set debug to false. */ debug?: false | { log?: string[] | false; @@ -74,26 +77,26 @@ export interface ServerOptions { }; /** - Default value: the operating system hostname and if not available, to 'localhost'. - The public hostname or IP address. Used to set server.info.host and server.info.uri and as address is none provided. + * Default value: the operating system hostname and if not available, to 'localhost'. + * The public hostname or IP address. Used to set server.info.host and server.info.uri and as address is none provided. */ host?: string; /** - Default value: none. - An optional node HTTP (or HTTPS) http.Server object (or an object with a compatible interface). - If the listener needs to be manually started, set autoListen to false. - If the listener uses TLS, set tls to true. + * Default value: none. + * An optional node HTTP (or HTTPS) http.Server object (or an object with a compatible interface). + * If the listener needs to be manually started, set autoListen to false. + * If the listener uses TLS, set tls to true. */ listener?: http.Server; /** - Default value: { sampleInterval: 0 }. - Server excessive load handling limits where: - sampleInterval - the frequency of sampling in milliseconds. When set to 0, the other load options are ignored. Defaults to 0 (no sampling). - maxHeapUsedBytes - maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). - maxRssBytes - maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). - maxEventLoopDelay - maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). + * Default value: { sampleInterval: 0 }. + * Server excessive load handling limits where: + * * sampleInterval - the frequency of sampling in milliseconds. When set to 0, the other load options are ignored. Defaults to 0 (no sampling). + * * maxHeapUsedBytes - maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). + * * maxRssBytes - maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). + * * maxEventLoopDelay - maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ load?: { /** the frequency of sampling in milliseconds. When set to 0, the other load options are ignored. Defaults to 0 (no sampling). */ @@ -107,34 +110,35 @@ export interface ServerOptions { }; /** - Default value: none. - Options passed to the mimos module when generating the mime database used by the server (and accessed via server.mime): - override - an object hash that is merged into the built in mime information specified here. Each key value pair represents a single mime object. Each override value must contain: - key - the lower-cased mime-type string (e.g. 'application/javascript'). - value - an object following the specifications outlined here. Additional values include: - type - specify the type value of result objects, defaults to key. - predicate - method with signature function(mime) when this mime type is found in the database, this function will execute to allows customizations. + * Default value: none. + * Options passed to the mimos module when generating the mime database used by the server (and accessed via server.mime): + * * override - an object hash that is merged into the built in mime information specified here. Each key value pair represents a single mime object. Each override value must contain: + * * key - the lower-cased mime-type string (e.g. 'application/javascript'). + * * value - an object following the specifications outlined here. Additional values include: + * * * type - specify the type value of result objects, defaults to key. + * * * predicate - method with signature function(mime) when this mime type is found in the database, this function will execute to allows customizations. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsmime) */ mime?: MimosOptions; /** - Default value: {}. - Plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state. + * Default value: {}. + * Plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state. */ plugins?: PluginSpecificConfiguration; /** - Default value: 0 (an ephemeral port). - The TCP port the server will listen to. Defaults the next available port when the server is started (and assigned to server.info.port). - If port is a string containing a '/' character, it is used as a UNIX domain socket path. If it starts with '\.\pipe', it is used as a Windows named pipe. + * Default value: 0 (an ephemeral port). + * The TCP port the server will listen to. Defaults the next available port when the server is started (and assigned to server.info.port). + * If port is a string containing a '/' character, it is used as a UNIX domain socket path. If it starts with '\.\pipe', it is used as a Windows named pipe. */ port?: number | string; /** - Default value: { isCaseSensitive: true, stripTrailingSlash: false }. - Controls how incoming request URIs are matched against the routing table: - isCaseSensitive - determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true. - stripTrailingSlash - removes trailing slashes on incoming paths. Defaults to false. + * Default value: { isCaseSensitive: true, stripTrailingSlash: false }. + * Controls how incoming request URIs are matched against the routing table: + * * isCaseSensitive - determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true. + * * stripTrailingSlash - removes trailing slashes on incoming paths. Defaults to false. */ router?: { isCaseSensitive?: boolean; @@ -142,8 +146,8 @@ export interface ServerOptions { }; /** - Default value: none. - A route options object used as the default configuration for every route. + * Default value: none. + * A route options object used as the default configuration for every route. */ routes?: RouteOptions; @@ -171,14 +175,14 @@ export interface ServerOptions { }; /** - Default value: none. - Used to create an HTTPS connection. The tls object is passed unchanged to the node HTTPS server as described in the node HTTPS documentation. + * Default value: none. + * Used to create an HTTPS connection. The tls object is passed unchanged to the node HTTPS server as described in the node HTTPS documentation. */ tls?: true | https.RequestOptions; /** - Default value: constructed from runtime server information. - The full public URI without the path (e.g. 'http://example.com:8080'). If present, used as the server server.info.uri, otherwise constructed from the server settings. + * Default value: constructed from runtime server information. + * The full public URI without the path (e.g. 'http://example.com:8080'). If present, used as the server server.info.uri, otherwise constructed from the server settings. */ uri?: string; diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index a18fcb7dc7..8045317d37 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -1,36 +1,26 @@ -import {ServerOptions} from "./server-options"; -import {ServerRealm} from "./server-realm"; -import {ServerInfo} from "./server-info"; -import {Request} from "../request/request"; import * as http from "http"; -import * as events from 'events'; import * as catbox from "catbox"; import * as zlib from "zlib"; -import {PluginsListRegistered} from "../plugin/plugin-registered"; -import {ServerState} from "./server-state"; -import {MimosOptions} from "../../../../mimos/index"; +import * as Podium from "podium"; +import {MimosOptions} from "mimos"; import { + ServerOptions, ServerRealm, ServerInfo, Request, PluginsListRegistered, ServerState, ServerOptionsCache, ServerEventCriteria, ServerEventsApplication, ServerEventsApplicationObject, PayloadCompressionDecoderSettings, RouteCompressionEncoderSettings, HTTP_METHODS, ServerMethodOptions, ServerMethod, ServerMethodConfigurationObject, + RequestExtPointFunction, ServerExtEventsObject, ServerExtEventsRequestObject, ServerExtOptions, + ServerExtPointFunction, ServerExtRequestType, ServerExtType, + ServerInjectOptions, ServerInjectResponse, + RequestRoute, ServerAuth, ServerRegisterPluginObject, ServerRegisterOptions, ServerRoute, Plugin, ResponseToolkit, Dictionary, ServerStateCookieOptions, HTTP_METHODS_PARTIAL_LOWERCASE, } from "hapi"; -import { - RequestExtPointFunction, ServerExtEventsObject, ServerExtEventsRequestObject, ServerExtOptions, - ServerExtPointFunction, ServerExtRequestType, ServerExtType -} from "./server-ext"; -import {ServerInjectOptions, ServerInjectResponse} from "./server-inject"; -import {RequestRoute} from "../request/request-route"; -import {ServerAuth, ServerAuthConfig} from "./server-auth"; -import {ServerRegisterPluginObject, ServerRegisterOptions} from "./server-register"; -import {ServerRoute} from "./server-route"; /** * The server object is the main application container. The server manages all incoming requests along with all * the facilities provided by the framework. Each server supports a single connection (e.g. listen to port 80). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#server) */ -export class Server extends events.EventEmitter { +export class Server extends Podium { /** Creates a new server object From 4b5b1390fd8ba1fbabf8ef7983548f2c5b01cd1c Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 3 Dec 2017 16:09:52 -0300 Subject: [PATCH 044/298] Refactored Json and Util namespaces. --- .../definitions/request/request-route.d.ts | 4 +- .../hapi/v17/definitions/request/request.d.ts | 12 +++--- .../definitions/response/response-object.d.ts | 4 +- .../route/route-options-payload.d.ts | 4 +- .../route/route-options-response.d.ts | 4 +- .../v17/definitions/route/route-options.d.ts | 8 ++-- .../v17/definitions/server/server-auth.d.ts | 4 +- .../v17/definitions/server/server-route.d.ts | 4 +- .../v17/definitions/server/server-state.d.ts | 6 +-- types/hapi/v17/definitions/server/server.d.ts | 14 +++---- types/hapi/v17/definitions/util/json.d.ts | 27 ++++++++++++ .../hapi/v17/definitions/util/lifecycle.d.ts | 1 - types/hapi/v17/definitions/util/util.d.ts | 41 ++++--------------- types/hapi/v17/index.d.ts | 1 + 14 files changed, 67 insertions(+), 67 deletions(-) create mode 100644 types/hapi/v17/definitions/util/json.d.ts diff --git a/types/hapi/v17/definitions/request/request-route.d.ts b/types/hapi/v17/definitions/request/request-route.d.ts index b93132e66c..531b60f796 100644 --- a/types/hapi/v17/definitions/request/request-route.d.ts +++ b/types/hapi/v17/definitions/request/request-route.d.ts @@ -1,4 +1,4 @@ -import {RouteOptions, ServerRealm, HTTP_METHODS_PARTIAL} from "hapi"; +import {RouteOptions, ServerRealm, Util} from "hapi"; /** * The request route information object, where: @@ -12,7 +12,7 @@ import {RouteOptions, ServerRealm, HTTP_METHODS_PARTIAL} from "hapi"; */ export interface RequestRoute { /** the route HTTP method. */ - method: HTTP_METHODS_PARTIAL; + method: Util.HTTP_METHODS_PARTIAL; /** the route path. */ path: string; /** the route vhost option if configured. */ diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index 87d53c73a3..c77614ee9d 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -3,7 +3,7 @@ import * as url from "url"; import * as http from "http"; import {Server} from "../server/server"; import {ResponseObject} from "../response/response-object"; -import {Dictionary, HTTP_METHODS_PARTIAL, HTTP_METHODS_PARTIAL_LOWERCASE} from "../util/util"; +import {Util} from "../util/util"; import {PluginsStates} from "../plugin/plugin"; import {RequestRoute} from "./request-route"; import {RequestAuth} from "./request-auth"; @@ -67,7 +67,7 @@ export interface Request extends Podium { * The raw request headers (references request.raw.req.headers). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestheaders) */ - readonly headers: Dictionary; + readonly headers: Util.Dictionary; /** * Request information: @@ -96,7 +96,7 @@ export interface Request extends Podium { /** * The request method in lower case (e.g. 'get', 'post'). */ - readonly method: HTTP_METHODS_PARTIAL_LOWERCASE; + readonly method: Util.HTTP_METHODS_PARTIAL_LOWERCASE; /** * The parsed content-type header. Only available when payload parsing enabled and no payload error occurred. @@ -111,7 +111,7 @@ export interface Request extends Podium { /** * An object where each key is a path parameter name with matching value as described in [Path parameters](https://github.com/hapijs/hapi/blob/master/API.md#path-parameters). */ - readonly params: Dictionary; + readonly params: Util.Dictionary; /** * An array containing all the path params values in the order they appeared in the path. @@ -186,7 +186,7 @@ export interface Request extends Podium { /** * An object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. */ - readonly state: Dictionary; + readonly state: Util.Dictionary; /** * The parsed request URI. @@ -229,7 +229,7 @@ export interface Request extends Podium { * Can only be called from an 'onRequest' extension method. * [See docs](https://hapijs.com/api/17.0.1#-requestsetmethodmethod) */ - setMethod(method: HTTP_METHODS_PARTIAL): void; + setMethod(method: Util.HTTP_METHODS_PARTIAL): void; /** * Changes the request URI before the router begins processing the request where: diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/v17/definitions/response/response-object.d.ts index b913237571..a0f7abdf97 100644 --- a/types/hapi/v17/definitions/response/response-object.d.ts +++ b/types/hapi/v17/definitions/response/response-object.d.ts @@ -1,5 +1,5 @@ import {PluginsStates} from "../plugin/plugin"; -import {Dictionary} from "../util/util"; +import {Util} from "../util/util"; import {ResponseSettings} from "./response-settings"; import {ServerStateCookieOptions} from "../server/server-state-options"; import * as Podium from "podium"; @@ -52,7 +52,7 @@ export interface ResponseObject extends Podium { * Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheaders) */ - readonly headers: Dictionary; + readonly headers: Util.Dictionary; /** * Default value: {}. diff --git a/types/hapi/v17/definitions/route/route-options-payload.d.ts b/types/hapi/v17/definitions/route/route-options-payload.d.ts index b7baaac182..c07bf45fd4 100644 --- a/types/hapi/v17/definitions/route/route-options-payload.d.ts +++ b/types/hapi/v17/definitions/route/route-options-payload.d.ts @@ -1,4 +1,4 @@ -import {Dictionary, Lifecycle} from "hapi"; +import {Util, Lifecycle} from "hapi"; /** * The value must be one of: @@ -38,7 +38,7 @@ export interface RouteOptionsPayload { * An object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in compression. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) */ - compression?: Dictionary; + compression?: Util.Dictionary; /** * Default value: 'application/json'. diff --git a/types/hapi/v17/definitions/route/route-options-response.d.ts b/types/hapi/v17/definitions/route/route-options-response.d.ts index 39db5e4574..cbf389e862 100644 --- a/types/hapi/v17/definitions/route/route-options-response.d.ts +++ b/types/hapi/v17/definitions/route/route-options-response.d.ts @@ -1,4 +1,4 @@ -import {Lifecycle, Dictionary} from "hapi"; +import {Lifecycle, Util} from "hapi"; import {ValidationOptions} from "joi"; /** @@ -77,6 +77,6 @@ export interface RouteOptionsResponse { * status is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsestatus) */ - status?: Dictionary; // TODO it must be better + status?: Util.Dictionary; // TODO it must be better } diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/v17/definitions/route/route-options.d.ts index e01d1a4cd3..5f8523b322 100644 --- a/types/hapi/v17/definitions/route/route-options.d.ts +++ b/types/hapi/v17/definitions/route/route-options.d.ts @@ -1,13 +1,13 @@ import {RouteOptionsAccess} from "./route-options-access"; import {RouteOptionsCache} from "./route-options-cache"; -import {Dictionary} from "../util/util"; +import {Util} from "../util/util"; import {RouteOptionsCors} from "./route-options-cors"; import {RouteOptionsResponse} from "./route-options-response"; import {RouteOptionsPayload} from "./route-options-payload"; import {RouteOptionsSecure} from "./route-options-secure"; import {RouteOptionsValidate} from "./route-options-validate"; import {PluginSpecificConfiguration} from "../plugin/plugin"; -import {Json} from "../util/util"; +import {Json} from "../util/json"; import {RouteOptionsPreArray} from "./route-options-pre"; import {Lifecycle} from "hapi"; @@ -65,7 +65,7 @@ export interface RouteOptions { * An object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in compression. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression) */ - compression?: Dictionary; + compression?: Util.Dictionary; /** * Default value: false (no CORS headers). @@ -179,7 +179,7 @@ export interface RouteOptions { * Plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsplugins) */ - plugins?: Dictionary; + plugins?: Util.Dictionary; /** * Default value: none. diff --git a/types/hapi/v17/definitions/server/server-auth.d.ts b/types/hapi/v17/definitions/server/server-auth.d.ts index 6b86c0e8a4..785cee3a9d 100644 --- a/types/hapi/v17/definitions/server/server-auth.d.ts +++ b/types/hapi/v17/definitions/server/server-auth.d.ts @@ -1,7 +1,7 @@ import {ServerAuthScheme} from "./server-auth-scheme"; import {Request} from "../request/request"; import {RouteOptionsAccess} from "hapi"; -import {Dictionary} from "../util/util"; +import {Util} from "../util/util"; /** * The authentication credentials object @@ -27,7 +27,7 @@ export interface ServerAuth { * returned from its implementation function. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi) */ - api: Dictionary; + api: Util.Dictionary; /** * Contains the default authentication configuration is a default strategy was set via diff --git a/types/hapi/v17/definitions/server/server-route.d.ts b/types/hapi/v17/definitions/server/server-route.d.ts index 0a6fce8ed0..70e0bf1d34 100644 --- a/types/hapi/v17/definitions/server/server-route.d.ts +++ b/types/hapi/v17/definitions/server/server-route.d.ts @@ -1,4 +1,4 @@ -import {HTTP_METHODS_PARTIAL, Lifecycle, Server} from "hapi"; +import {Util, Lifecycle, Server} from "hapi"; /** * A route configuration object or an array of configuration objects where each object contains: @@ -22,7 +22,7 @@ export interface ServerRoute { /** * (required) the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. */ - method: HTTP_METHODS_PARTIAL | HTTP_METHODS_PARTIAL[] | string | string[]; + method: Util.HTTP_METHODS_PARTIAL | Util.HTTP_METHODS_PARTIAL[] | string | string[]; /** * (optional) a domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. diff --git a/types/hapi/v17/definitions/server/server-state.d.ts b/types/hapi/v17/definitions/server/server-state.d.ts index 4b8a234718..1331d32e4a 100644 --- a/types/hapi/v17/definitions/server/server-state.d.ts +++ b/types/hapi/v17/definitions/server/server-state.d.ts @@ -1,5 +1,5 @@ import {ServerStateCookieOptions} from "hapi"; -import {Dictionary} from "hapi"; +import {Util} from "hapi"; /** * A single object or an array of object where each contains: @@ -39,7 +39,7 @@ export interface ServerState { /** * An array containing the names of all configued cookies. */ - readonly names: Dictionary; + readonly names: Util.Dictionary; /** * Same as calling [server.state()](https://github.com/hapijs/hapi/blob/master/API.md#server.state()). @@ -67,6 +67,6 @@ export interface ServerState { * Note that this utility uses the server configuration but does not change the server state. It is provided for manual cookie parsing (e.g. when server parsing is disabled). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-async-serverstatesparseheader) */ - parse(header: string): Dictionary; + parse(header: string): Util.Dictionary; } diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 8045317d37..1d765d425b 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -6,13 +6,13 @@ import {MimosOptions} from "mimos"; import { ServerOptions, ServerRealm, ServerInfo, Request, PluginsListRegistered, ServerState, ServerOptionsCache, ServerEventCriteria, ServerEventsApplication, ServerEventsApplicationObject, - PayloadCompressionDecoderSettings, RouteCompressionEncoderSettings, HTTP_METHODS, ServerMethodOptions, ServerMethod, + PayloadCompressionDecoderSettings, RouteCompressionEncoderSettings, ServerMethodOptions, ServerMethod, ServerMethodConfigurationObject, RequestExtPointFunction, ServerExtEventsObject, ServerExtEventsRequestObject, ServerExtOptions, ServerExtPointFunction, ServerExtRequestType, ServerExtType, ServerInjectOptions, ServerInjectResponse, RequestRoute, ServerAuth, ServerRegisterPluginObject, ServerRegisterOptions, ServerRoute, - Plugin, ResponseToolkit, Dictionary, ServerStateCookieOptions, HTTP_METHODS_PARTIAL_LOWERCASE, + Plugin, ResponseToolkit, Util, ServerStateCookieOptions, } from "hapi"; /** @@ -209,7 +209,7 @@ export class Server extends Podium { * server method name is an object property. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethods */ - readonly methods: Dictionary; + readonly methods: Util.Dictionary; /** * Provides access to the server MIME database used for setting content-type information. The object must not be @@ -506,8 +506,8 @@ export class Server extends Podium { * @return Return value: the route information if found, otherwise null. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermatchmethod-path-host) */ - match(method: HTTP_METHODS, path: string): RequestRoute | null; - match(method: HTTP_METHODS, path: string, host: string): RequestRoute | null; + match(method: Util.HTTP_METHODS, path: string): RequestRoute | null; + match(method: Util.HTTP_METHODS, path: string, host: string): RequestRoute | null; /** * Registers a server method where: @@ -645,7 +645,7 @@ export class Server extends Podium { * * path - the route path. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost) */ - table(): {settings: ServerRoute; method: HTTP_METHODS_PARTIAL_LOWERCASE, path: string}[]; // TODO I am not sure if the ServerRoute is the object expected here - table(host: string): {settings: ServerRoute; method: HTTP_METHODS_PARTIAL_LOWERCASE, path: string}[]; + table(): {settings: ServerRoute; method: Util.HTTP_METHODS_PARTIAL_LOWERCASE, path: string}[]; // TODO I am not sure if the ServerRoute is the object expected here + table(host: string): {settings: ServerRoute; method: Util.HTTP_METHODS_PARTIAL_LOWERCASE, path: string}[]; } diff --git a/types/hapi/v17/definitions/util/json.d.ts b/types/hapi/v17/definitions/util/json.d.ts new file mode 100644 index 0000000000..116f6bdf9a --- /dev/null +++ b/types/hapi/v17/definitions/util/json.d.ts @@ -0,0 +1,27 @@ +export namespace Json { + + /** + * @see {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter} + */ + export type StringifyReplacer = ((key: string, value: any) => any) | (string | number)[] | undefined; + + /** + * Any value greater than 10 is truncated. + */ + export type StringifySpace = number | string; + + /** + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsjson) + */ + export interface StringifyArguments { + /** the replacer function or array. Defaults to no action. */ + replacer?: StringifyReplacer; + /** number of spaces to indent nested object keys. Defaults to no indentation. */ + space?: StringifySpace; + /** tring suffix added after conversion to JSON string. Defaults to no suffix. **/ + suffix?: string; + /** calls Hoek.jsonEscape() after conversion to JSON string. Defaults to false. **/ + escape?: boolean; + } + +} diff --git a/types/hapi/v17/definitions/util/lifecycle.d.ts b/types/hapi/v17/definitions/util/lifecycle.d.ts index 568b45b181..583fdf3c28 100644 --- a/types/hapi/v17/definitions/util/lifecycle.d.ts +++ b/types/hapi/v17/definitions/util/lifecycle.d.ts @@ -2,7 +2,6 @@ import * as Boom from "../../../../boom/index"; import * as stream from "stream"; import {ResponseToolkit, Request} from "hapi"; - export namespace Lifecycle { /** diff --git a/types/hapi/v17/definitions/util/util.d.ts b/types/hapi/v17/definitions/util/util.d.ts index ae473d89ac..f92b23bb4d 100644 --- a/types/hapi/v17/definitions/util/util.d.ts +++ b/types/hapi/v17/definitions/util/util.d.ts @@ -1,38 +1,11 @@ -export interface Dictionary { - [key: string]: T; -} +export namespace Util { -export type HTTP_METHODS_PARTIAL_LOWERCASE = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; -export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_LOWERCASE; -export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; - -/** - * Json properties - */ -export namespace Json { - - /** - * @see {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter} - */ - export type StringifyReplacer = ((key: string, value: any) => any) | (string | number)[] | undefined; - - /** - * Any value greater than 10 is truncated. - */ - export type StringifySpace = number | string; - - /** - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsjson) - */ - export interface StringifyArguments { - /** the replacer function or array. Defaults to no action. */ - replacer?: StringifyReplacer; - /** number of spaces to indent nested object keys. Defaults to no indentation. */ - space?: StringifySpace; - /** tring suffix added after conversion to JSON string. Defaults to no suffix. **/ - suffix?: string; - /** calls Hoek.jsonEscape() after conversion to JSON string. Defaults to false. **/ - escape?: boolean; + export interface Dictionary { + [key: string]: T; } + export type HTTP_METHODS_PARTIAL_LOWERCASE = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; + export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_LOWERCASE; + export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; + } diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index 3e890253c4..de0cb95cca 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -53,5 +53,6 @@ export * from './definitions/server/server-state' export * from './definitions/server/server-state-options' /** UTIL */ +export * from './definitions/util/json' export * from './definitions/util/lifecycle' export * from './definitions/util/util' From cb083b4d692c3bd7541e751324b28cfc21703c5a Mon Sep 17 00:00:00 2001 From: Cameron Taggart Date: Sun, 3 Dec 2017 18:26:13 -0300 Subject: [PATCH 045/298] examples replacing any with object --- types/hapi/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index a97a9f1edb..5eff9b7e9b 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -231,7 +231,7 @@ export class Server extends Podium { * @param data the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. * @param callback an optional callback method invoked when all subscribers have been notified using the signature function(). The callback is called only after all the listeners have been notified, including any event updates emitted earlier (the order of event updates are guaranteed to be in the order they were emitted). */ - emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: any, callback?: () => void): void; + emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: object, callback?: () => void): void; /** * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' * [See docs](https://hapijs.com/api/16.1.1#serverencoderencoding-encoder) @@ -489,7 +489,7 @@ export interface PluginSpecificConfiguration {} */ export interface ServerOptions { /** app - application-specific configuration which can later be accessed via server.settings.app. Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. Defaults to {}. */ - app?: any; + app?: object; /** * cache - sets up server-side caching. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and capabilities. hapi uses catbox for its cache which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. The server cache configuration only defines the storage container itself. cache can be assigned: * * a prototype function (usually obtained by calling require() on a catbox strategy such as require('catbox-redis')). A new catbox client will be created internally using this function. @@ -533,7 +533,7 @@ export interface ServerEventObject { /** an array of tags (e.g. ['error', 'http']). */ tags: string[]; /** optional event-specific information. */ - data: any; + data?: object; /** true if the event was generated internally by the framework. */ internal: boolean; } From 6cb3917140ff947da500e3d6a1194270fe028b9c Mon Sep 17 00:00:00 2001 From: Michael Mclaughlin Date: Mon, 4 Dec 2017 06:48:31 +0000 Subject: [PATCH 046/298] Remove decimal.js typings --- notNeededPackages.json | 6 + types/decimal.js/decimal.js-tests.ts | 401 -------------- types/decimal.js/index.d.ts | 767 --------------------------- types/decimal.js/tsconfig.json | 23 - types/decimal.js/tslint.json | 79 --- 5 files changed, 6 insertions(+), 1270 deletions(-) delete mode 100644 types/decimal.js/decimal.js-tests.ts delete mode 100644 types/decimal.js/index.d.ts delete mode 100644 types/decimal.js/tsconfig.json delete mode 100644 types/decimal.js/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 0e5f946e07..e076cba36b 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -156,6 +156,12 @@ "sourceRepoURL": "https://github.com/date-fns/date-fns", "asOfVersion": "2.6.0" }, + { + "libraryName": "decimal.js", + "typingsPackageName": "decimal.js", + "sourceRepoURL": "https://github.com/MikeMcl/decimal.js", + "asOfVersion": "7.4.0" + }, { "libraryName": "DevExtreme", "typingsPackageName": "devextreme", diff --git a/types/decimal.js/decimal.js-tests.ts b/types/decimal.js/decimal.js-tests.ts deleted file mode 100644 index f05434a72f..0000000000 --- a/types/decimal.js/decimal.js-tests.ts +++ /dev/null @@ -1,401 +0,0 @@ - -var x = new Decimal(9) -var y = new Decimal(x) - -Decimal(435.345) - -new Decimal('5032485723458348569331745.33434346346912144534543') -new Decimal('4.321e+4') -new Decimal('-735.0918e-430') -new Decimal('5.6700000') -new Decimal(Infinity) -new Decimal(NaN) -new Decimal('.5') -new Decimal('+2') -new Decimal(-10110100.1, 2) -new Decimal('123412421.234324', 5) -new Decimal('ff.8', 16) - -Decimal.config({ precision: 5 }) -new Decimal(1.23456789) -new Decimal(1.23456789, 10) - - -Decimal.config({ - precision: 20, - rounding: 4, - toExpNeg: -7, - toExpPos: 21, - minE: -9e15, - maxE: 9e15, - errors: true, - crypto: false, - modulo: 1, - format: { - decimalSeparator: '.', - groupSeparator: ',', - groupSize: 3, - secondaryGroupSize: 0, - fractionGroupSeparator: '\xA0', - fractionGroupSize: 0 - } -}); - -Decimal.config({ - format: { - - decimalSeparator: '.', - - groupSeparator: ',', - - groupSize: 3, - - secondaryGroupSize: 0, - - fractionGroupSeparator: ' ', - - fractionGroupSize: 0 - } -}); -Decimal.config({ rounding: Decimal.ROUND_CEIL }) -Decimal.config({ rounding: 2 }) -Decimal.rounding - -x = new Decimal(1.3) -x.ceil() -y = new Decimal(-1.8) -y.ceil() - -x.comparedTo(y) -x.comparedTo(x.minus(1)) -y.cmp(NaN) -y.cmp('110', 2) - -x.decimalPlaces() -y.dp() - -x.dividedBy(y) -x.div(5) -x.div(47, 16) - -x.dividedToIntegerBy(y) -x.divToInt(0.7) -x.divToInt('0.f', 16) - -x.equals('1e-324') -new Decimal(-0).eq(x) -new Decimal(255).eq('ff', 16) - -y = new Decimal(NaN) -y.equals(NaN) - -x = new Decimal(1) -x.exponential() -y = new Decimal(2) -y.exp() - -x = new Decimal(1.8) -x.floor() -y = new Decimal(-1.3) -y.floor() - -x.greaterThan(Decimal(0.3).minus(0.2)) -new Decimal(0).gt(x) -new Decimal(11, 3).gt(11.1, 2) - - -x = new Decimal(0.3).minus(0.2) -x.greaterThanOrEqualTo(0.1) -new Decimal(1).gte(x) -new Decimal(10, 18).gte('i', 36) - -x = new Decimal(1) -x.isFinite() -y = new Decimal(Infinity) -y.isFinite() - -x = new Decimal(1) -x.isInteger() -y = new Decimal(123.456) -y.isInt() - -x = new Decimal(NaN) -x.isNaN() -y = new Decimal('Infinity') -y.isNaN() - -x = new Decimal(-0) -x.isNegative() -y = new Decimal(2) -y.isNeg - -x = new Decimal(-0) -x.isZero() && x.isNeg() -y = new Decimal(Infinity) -y.isZero() - -x.lessThan(0.1) -new Decimal(0).lt(x) -new Decimal(11.1, 2).lt(11, 3) - -x.lessThan(0.1) -new Decimal(0).lt(x) -new Decimal(11.1, 2).lt(11, 3) - -x = new Decimal(0.1) -x.lessThanOrEqualTo(Decimal(0.3).minus(0.2)) -new Decimal(-1).lte(x) -new Decimal(10, 18).lte('i', 36) - -x = new Decimal(1000) -x.logarithm() -y = new Decimal(256) -y.log(2) - -x = new Decimal(0.3) -x.minus(0.1) -x.minus(0.6, 20) - -x = new Decimal(1) -x.modulo(0.9) - -y = new Decimal(33) -y.mod('a', 33) - -x = new Decimal(8) -y = new Decimal(-3) -Decimal.modulo = 1 -x.mod(y) -Decimal.modulo = 3 -x.mod(y) - -x = new Decimal(10) -x.naturalLogarithm() -y = new Decimal('1.23e+30') -y.ln() - -x = new Decimal(1.8) -x.negated() -y = new Decimal(-1.3) -y.neg() - -x = new Decimal(0.1) -y = x.plus(0.2) -new Decimal(0.7).plus(x).plus(y) -x.plus('0.1', 8) - -x = new Decimal(1.234) -x.precision() -y = new Decimal(987000) -y.sd() -y.sd(true) - -Decimal.config({ rounding: 4 }) -x.round() - -Decimal.rounding = Decimal.ROUND_DOWN -x.round() -x - -x = new Decimal(16) -x.squareRoot() -y = new Decimal(3) -y.sqrt() -y.sqrt().eq(y.pow(0.5)) - -x = new Decimal(0.6) -y = x.times(3) -new Decimal('7e+500').times(y) -x.times('-a', 16) - -x = new Decimal(12.24567) -x.toDecimalPlaces(0) -x.toDecimalPlaces(1, 0) - -y = new Decimal(9876.54321) -y.toDP(3) -y.toDP(1, 0) -y.toDP(1, Decimal.ROUND_DOWN) - -y = new Decimal(x) -x.toExponential() -y.toExponential() -x.toExponential(0) -y.toExponential(0) -x.toExponential(1) -y.toExponential(1) -y.toExponential(1, 1) -x.toExponential(3) -y.toExponential(3) - -y = new Decimal(x) -x.toFixed() -y.toFixed() -y.toFixed(0) -x.toFixed(2) -y.toFixed(2) -y.toFixed(2, 1) -x.toFixed(5) -y.toFixed(5) - -Decimal.config({ - format: { - decimalSeparator: '.', - groupSeparator: ',', - groupSize: 3, - secondaryGroupSize: 0, - fractionGroupSeparator: ' ', - fractionGroupSize: 0 - } -}); - -x = new Decimal('123456789.123456789') -x.toFormat() -x.toFormat(1) - - -Decimal.format.groupSeparator = ' '; -Decimal.format.fractionGroupSize = 5; -x.toFormat() - - -Decimal.format = { - decimalSeparator: ',', - groupSeparator: '.', - groupSize: 3, - secondaryGroupSize: 2 -} - -x.toFormat() - -x.toFraction() - -var pi = new Decimal('3.14159265358') -pi.toFraction() -pi.toFraction(100000) -pi.toFraction(10000) -pi.toFraction(100) -pi.toFraction(10) -pi.toFraction(1) - - - -x = new Decimal('177.7e+457') -y = new Decimal(235.4325) -var z = new Decimal('0.0098074') - -// Serialize an array of three Decimals -var str = JSON.stringify([x, y, z]) -// "["1.777e+459","235.4325","0.0098074"]" - -// Return an array of three Decimals -JSON.parse(str, function(key, val) { - return key === '' ? val : new Decimal(val) -}) - -x = new Decimal(1.39) -x.toNearest(0.25) - -y = new Decimal(0.75) -y.toNearest(0.5, 0) -y.toNearest(0.5, 1) - -x = new Decimal(456.789) -x.toNumber() - -y = new Decimal('45987349857634085409857349856430985') -y.toNumber() - -z = new Decimal(-0) -1 / +z -1 / z.toNumber() - -Math.pow(0.7, 2) -x = new Decimal(0.7) -x.toPower(2) -new Decimal(3).pow(-2) - -new Decimal(1217652.23).pow('98765.489305603941') -y = new Decimal(x) -x.toPrecision() -y.toPrecision() -x.toPrecision(1) -y.toPrecision(1) -y.toPrecision(2, 0) -y.toPrecision(2, 1) -x.toPrecision(5) -y.toPrecision(5) - -Decimal.config({ precision: 5, rounding: 4 }) -x = new Decimal(9876.54321) - -x.toSignificantDigits() -x.toSignificantDigits(6) -x.toSignificantDigits(6, Decimal.ROUND_UP) -x.toSD(2) -x.toSD(2, 1) - -x = new Decimal(750000) -x.toString() -Decimal.config({ toExpPos: 5 }) -x.toString() - -y = new Decimal(362.875) -y.toString(2) -y.toString(9) -y.toString(32) - -Decimal.config({ precision: 4 }); -z = new Decimal('1.23456789') -z.toString() -z.toString(10) - -x = new Decimal(123.456) -x.truncated() -y = new Decimal(-12.3) -y.trunc() - -x = new Decimal('1.777e+457') -x.valueOf() - -x = Decimal.exp(3) -y = new Decimal(3).exp() -x.equals(y) - -x = Decimal.ln(4.321) -y = new Decimal(4.321).ln() -x.equals(y) - -x = Decimal.log(100, 2.5) -y = new Decimal(100).log(2.5) -x.equals(y) - -x = new Decimal('3257869345.0378653') -Decimal.max(4e9, x, '123456789.9') - -var arr = [12, '13', new Decimal(14)] -Decimal.max(arr) - -x = new Decimal('3257869345.0378653') -Decimal.min(4e9, x, '123456789.9') - -arr = [2, new Decimal(-14), '-15.9999', -12] -Decimal.min(arr) - -x = new Decimal(2) -var D = Decimal.noConflict() -Decimal -y = new D(3) - -x = Decimal.pow(3257.4, 17.01) -y = new Decimal(3257.4).pow(17.01) -x.equals(y) - -Decimal.config({ precision: 10 }) -Decimal.random() - -Decimal.random(20) - -x = Decimal.sqrt('987654321.123456789') -y = new Decimal('987654321.123456789').sqrt() -x.equals(y) diff --git a/types/decimal.js/index.d.ts b/types/decimal.js/index.d.ts deleted file mode 100644 index 27f4213612..0000000000 --- a/types/decimal.js/index.d.ts +++ /dev/null @@ -1,767 +0,0 @@ -// Type definitions for decimal.js -// Project: http://mikemcl.github.io/decimal.js -// Definitions by: Joseph Rossi -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare var Decimal: decimal.IDecimalStatic; - -// Support AMD require -declare module 'decimal.js' { - export = Decimal; -} - -declare namespace decimal { - - enum RoundingMode { - /** - * Rounds away from zero - */ - ROUND_UP = 0, - - /** - * Rounds towards zero - */ - ROUND_DOWN = 1, - - /** - * Rounds towards Infinity - */ - ROUND_CEIL = 2, - - /** - * Rounds towards -Infinity - */ - ROUND_FLOOR = 3, - - /** - * Rounds towards nearest neighbour. - * If equidistant, rounds away from zero - */ - ROUND_HALF_UP = 4, - - /** - * Rounds towards nearest neighbour. - * If equidistant, rounds towards zero - */ - ROUND_HALF_DOWN = 5, - - /** - * Rounds towards nearest neighbour. - * If equidistant, rounds towards even neighbour - */ - ROUND_HALF_EVEN = 6, - - /** - * Rounds towards nearest neighbour. - * If equidistant, rounds towards Infinity - */ - ROUND_HALF_CEIL = 7, - - /** - * Rounds towards nearest neighbour. - * If equidistant, rounds towards -Infinity - */ - ROUND_HALF_FLOOR = 8, - - /** - * Not a rounding mode, see modulo - */ - EUCLID = 9, - } - - interface IFormatConfig { - decimalSeparator?: string; - groupSeparator?: string; - groupSize?: number; - secondaryGroupSize?: number; - fractionGroupSeparator?: string; - fractionGroupSize?: number; - } - - interface IDecimalConfig { - /** - * number: integer, 1 to 1e+9 inclusive - * Default value: 20 - * - * The maximum number of significant digits of the result of a calculation or base conversion. - * - * All methods which return a Decimal will round the return value to precision significant digits except absoluteValue, ceil, floor, negated, round, toDecimalPlaces, toNearest and truncated. - * - * A Decimal constructor will also not round to precision unless a base is specified. - */ - precision?: number; - - /** - * number: integer, 0 to 8 inclusive - * Default value: 4 (ROUND_HALF_UP) - * - * The default rounding mode used when rounding the result of a calculation or base conversion to precision significant digits, and when rounding the return value of the round, toDecimalPlaces, toExponential, toFixed, toFormat, toNearest, toPrecision and toSignificantDigits methods. - * - * The rounding modes are available as enumerated properties of the constructor. - */ - rounding?: RoundingMode; - - /** - * number: integer, -9e15 to 0 inclusive - * Default value: -7 - * - * The negative exponent value at and below which toString returns exponential notation. - * @type {[type]} - */ - toExpNeg?: number; - - /** - * number: integer, 0 to 9e15 inclusive - * Default value: 20 - * - * The positive exponent value at and above which toString returns exponential notation. - */ - toExpPos?: number; - - /** - * number: integer, -9e15 to 0 inclusive - * Default value: -9e15 - * - * The negative exponent limit, i.e. the exponent value below which underflow to zero occurs. - * - * If the Decimal to be returned by a calculation would have an exponent lower than minE then its value becomes zero. - * - * JavaScript numbers underflow to zero for exponents below -324. - */ - minE?: number; - - /** - * number: integer, 0 to 9e15 inclusive - * Default value: 9e15 - * - * The positive exponent limit, i.e. the exponent value above which overflow to Infinity occurs. - * - * If the Decimal to be returned by a calculation would have an exponent higher than maxE then its value becomes Infinity. - * - * JavaScript numbers overflow to Infinity for exponents above 308. - */ - maxE?: number; - - /** - * boolean/number: true, false, 1 or 0 - * Default value: true - * - * The value that determines whether Decimal Errors are thrown. If errors is false, this library will not throw errors. - */ - errors?: boolean | number; - - /** - * boolean/number: true, false, 1 or 0 - * Default value: false - * - * The value that determines whether cryptographically-secure pseudo-random number generation is used. - * - * If crypto is truthy then the random method will generate random digits using crypto.getRandomValues in browsers that support it, or crypto.randomBytes if using a version of Node.js that supports it. - * - * If neither function is supported by the host environment or if crypto is falsey then the source of randomness will be Math.random. If the crypto property is set directly (i.e. without using config) to true, then at the time the random method is called, if errors is true, an error will be thrown if the crypto methods are unavailable. - */ - crypto?: boolean | number; - - /** - * number: integer, 0 to 9 inclusive - * Default value: 1 (ROUND_DOWN) - * - * The modulo mode used when calculating the modulus: a mod n. - * - * The quotient, q = a / n, is calculated according to the rounding mode that corresponds to the chosen modulo mode. - * - * The remainder, r, is calculated as: r = a - n * q. - * - * The modes that are most commonly used for the modulus/remainder operation are ROUND_UP, ROUND_DOWN, ROUND_FLOOR, ROUND_HALF_EVEN, and EUCLID. Although the other rounding modes can be used, they may not give useful results. - */ - modulo?: RoundingMode; - - /** - * The format object configures the format of the string returned by the toFormat method. - * - * The example below shows the properties of the format object that are recognised, and their default values. - * - * Unlike setting other properties using config, the values of the properties of the format object will not be checked for validity. The existing format object will simply be replaced by the object that is passed in. Only the toFormat method ever references a Decimal constructor's format object property. - * - * See toFormat for examples of usage, and of setting format properties individually and directly without using config. - */ - format?: IFormatConfig; - } - - interface IDecimalStatic extends IDecimalConfig { - default: IDecimalStatic; - - (value: number | string | Decimal, base?: number): Decimal; - - new(value: number | string | Decimal, base?: number): Decimal; - - /** - * Configures the 'global' settings for this particular Decimal constructor. - * - * Returns this Decimal constructor. - */ - config(object: IDecimalConfig): IDecimalStatic; - - /** - * Returns a new independent Decimal constructor with configuration settings as described by object - */ - constructor(object: IDecimalConfig): IDecimalStatic; - - /** - * Returns a new Decimal whose value is the base e (Euler's number, the base of the natural logarithm) exponential of the value of this Decimal, rounded to precision significant digits using rounding mode rounding. - */ - exp(n: number | string | Decimal): Decimal; - - /** - * Returns a new Decimal whose value is the natural logarithm of the value of this Decimal, rounded to precision significant digits using rounding mode rounding. - * - * The natual logarithm is the inverse of the exponential function. - */ - ln(n: number | string | Decimal): Decimal; - - /** - * Returns a new Decimal whose value is the base n logarithm of the value of this Decimal, rounded to precision significant digits using rounding mode rounding. - * - * If n is null or undefined, then the base 10 logarithm of the value of this Decimal will be returned. - */ - log(n: number | string | Decimal, base?: number): Decimal; - - /** - * Returns a new Decimal whose value is the maximum of arg1, arg2,... . - */ - max(...args: any[]): Decimal; - - /** - * Returns a new Decimal whose value is the minimum of arg1, arg2,... . - */ - min(...args: any[]): Decimal; - - /** - * Reverts the Decimal variable to the value it had before this library was loaded and returns a reference to the original Decimal constructor so it can be assigned to a variable with a different name. - */ - noConflict(): IDecimalStatic; - - /** - * Returns a new Decimal whose value is the value of this Decimal raised to the power n, rounded to precision significant digits using rounding mode rounding. - * - * The performance of this method degrades exponentially with increasing digits. For non-integer exponents in particular, the performance of this method may not be adequate. - */ - pow(base: number | string | Decimal, exponent: number | string | Decimal): Decimal; - - /** - * Returns a new Decimal with a pseudo-random value equal to or greater than 0 and less than 1. The return value will have dp decimal places (or less if trailing zeros are produced). If dp is omitted then the number of decimal places will default to the current precision setting. - * - * Depending on the value of a Decimal constructor's crypto property and the support for the crypto object in the host environment, the random digits of the return value are generated by either Math.random (fastest), crypto.getRandomValues (Web Cryptography API in recent browsers) or crypto.randomBytes (Node.js). - * - * If crypto is true, i.e. one of the crypto methods is to be used, the value of a returned Decimal should be cryptographically-secure and statistically indistinguishable from a random value. - */ - random(dp?: number): Decimal; - - /** - * The return value will be correctly rounded, i.e. rounded as if the result was first calculated to an infinite number of correct digits before rounding. - * - * This method is much faster than using the toPower method with an exponent of 0.5. - */ - sqrt(arg: number | string | Decimal): Decimal; - - /** - * A Decimal instance with value one. - */ - ONE: number; - - /** - * Rounds away from zero - */ - ROUND_UP: number; - - /** - * Rounds towards zero - */ - ROUND_DOWN: number; - - /** - * Rounds towards Infinity - */ - ROUND_CEIL: number; - - /** - * Rounds towards -Infinity - */ - ROUND_FLOOR: number; - - /** - * Rounds towards nearest neighbour. - * If equidistant, rounds away from zero - */ - ROUND_HALF_UP: number; - - /** - * Rounds towards nearest neighbour. - * If equidistant, rounds towards zero - */ - ROUND_HALF_DOWN: number; - - /** - * Rounds towards nearest neighbour. - * If equidistant, rounds towards even neighbour - */ - ROUND_HALF_EVEN: number; - - /** - * Rounds towards nearest neighbour. - * If equidistant, rounds towards Infinity - */ - ROUND_HALF_CEIL: number; - - /** - * Rounds towards nearest neighbour. - * If equidistant, rounds towards -Infinity - */ - ROUND_HALF_FLOOR: number; - - /** - * Not a rounding mode, see modulo - */ - EUCLID: number; - } - - interface Decimal { - - /** - * Returns a new Decimal whose value is the absolute value, i.e. the magnitude, of the value of this Decimal. - * - * The return value is not rounded. - */ - absoluteValue(): Decimal; - - /** - * Returns a new Decimal whose value is the absolute value, i.e. the magnitude, of the value of this Decimal. - * - * The return value is not rounded. - */ - abs(): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal rounded to a whole number in the direction of positive Infinity. - * - * The return value is not rounded to precision. - */ - ceil(): Decimal; - - /** - * @return 1, -1, 0, or null - * 1 If the value of this Decimal is greater than the - * value of n - * -1 If the value of this Decimal is less than the value - * of n - * 0 If this Decimal and n have the same value - * null If the value of either this Decimal or n is NaN - */ - comparedTo(n: number | string | Decimal, base?: number): number; - - /** - * Returns 1, -1, 0, or null - * 1 If the value of this Decimal is greater than the value - * of n - * -1 If the value of this Decimal is less than the value - * of n - * 0 If this Decimal and n have the same value - * null If the value of either this Decimal or n is NaN - */ - cmp(n: number | string | Decimal, base?: number): number; - - /** - * Returns the number of decimal places, i.e. the number of digits after the decimal point, of the value of this Decimal. - */ - decimalPlaces(): number; - - /** - * Returns the number of decimal places, i.e. the number of digits after the decimal point, of the value of this Decimal. - */ - dp(): number; - - /** - * Returns a new Decimal whose value is the value of this Decimal divided by n, rounded to precision significant digits using rounding mode rounding. - */ - dividedBy(n: number | string | Decimal, base?: number): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal divided by n, rounded to precision significant digits using rounding mode rounding. - */ - div(n: number | string | Decimal, base?: number): Decimal; - - /** - * Return a new Decimal whose value is the integer part of dividing this Decimal by n, rounded to precision significant digits using rounding mode rounding. - */ - dividedToIntegerBy(n: number | string| Decimal, base?: number): Decimal; - - /** - * Return a new Decimal whose value is the integer part of dividing this Decimal by n, rounded to precision significant digits using rounding mode rounding. - */ - divToInt(n: number | string| Decimal, base?: number): Decimal; - - /** - * Returns true if the value of this Decimal equals the value of n, otherwise returns false. - * - * As with JavaScript, NaN does not equal NaN. - * - * Note: This method uses the cmp method internally. - */ - equals(n: number | string | Decimal, base?: number): boolean; - - /** - * Returns true if the value of this Decimal equals the value of n, otherwise returns false. - * - * As with JavaScript, NaN does not equal NaN. - * - * Note: This method uses the cmp method internally. - */ - eq(n: number | string | Decimal, base?: number): boolean; - - /** - * Returns a new Decimal whose value is the base e (Euler's number, the base of the natural logarithm) exponential of the value of this Decimal, rounded to precision significant digits using rounding mode rounding. - */ - exponential(): Decimal; - - /** - * Returns a new Decimal whose value is the base e (Euler's number, the base of the natural logarithm) exponential of the value of this Decimal, rounded to precision significant digits using rounding mode rounding. - */ - exp(): Decimal; - - /** - * The return value is not rounded to precision. - */ - floor(): Decimal; - - - /** - * Note: This method uses cmp method internally. - */ - greaterThan(n: number | string | Decimal, base?: number): boolean; - - /** - * Note: This method uses cmp method internally. - */ - gt(n: number | string | Decimal, base?: number): boolean; - - /** - * Note: This method uses cmp method internally. - */ - greaterThanOrEqualTo(n: number | string | Decimal, base?: number): boolean; - - /** - * Note: This method uses cmp method internally. - */ - gte(n: number | string | Decimal, base?: number): boolean; - - /** - * The only possible non-finite values of a Decimal are NaN, Infinity and -Infinity. - */ - isFinite(): boolean; - - isInteger(): boolean; - - isInt(): boolean; - - isNaN(): boolean; - - isNegative(): boolean; - - isNeg(): boolean; - - isZero(): boolean; - - /** - * Note: This method uses cmp method internally. - */ - lessThan(n: number | string | Decimal, base?: number): boolean; - - /** - * Note: This method uses cmp method internally. - */ - lt(n: number | string | Decimal, base?: number): boolean; - - /** - * Note: This method uses cmp method internally. - */ - lessThanOrEqualTo(n: number | string | Decimal, base?: number): boolean; - - /** - * Note: This method uses cmp method internally. - */ - lte(n: number | string | Decimal, base?: number): boolean; - - /** - * Returns a new Decimal whose value is the base n logarithm of the value of this Decimal, rounded to precision significant digits using rounding mode rounding. - * - * If n is null or undefined, then the base 10 logarithm of the value of this Decimal will be returned. - */ - logarithm(n?: number | string | Decimal, base?: number): Decimal; - - /** - * Returns a new Decimal whose value is the base n logarithm of the value of this Decimal, rounded to precision significant digits using rounding mode rounding. - * - * If n is null or undefined, then the base 10 logarithm of the value of this Decimal will be returned. - */ - log(n?: number | string | Decimal, base?: number): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal minus n, rounded to precision significant digits using rounding mode rounding. - */ - minus(n: number | string | Decimal, base?: number): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal modulo n, rounded to precision significant digits using rounding mode rounding. - * - * The value returned, and in particular its sign, is dependent on the value of the modulo property of this Decimal's constructor. If it is 1 (default value), the result will have the same sign as this Decimal, and it will match that of Javascript's % operator (within the limits of double precision) and BigDecimal's remainder method. - */ - modulo(n: number | string | Decimal, base?: number): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal modulo n, rounded to precision significant digits using rounding mode rounding. - * - * The value returned, and in particular its sign, is dependent on the value of the modulo property of this Decimal's constructor. If it is 1 (default value), the result will have the same sign as this Decimal, and it will match that of Javascript's % operator (within the limits of double precision) and BigDecimal's remainder method. - */ - mod(n: number | string | Decimal, base?: number): Decimal; - - /** - * Returns a new Decimal whose value is the natural logarithm of the value of this Decimal, rounded to precision significant digits using rounding mode rounding. - * - * The natual logarithm is the inverse of the exponential function. - */ - naturalLogarithm(): Decimal; - - /** - * Returns a new Decimal whose value is the natural logarithm of the value of this Decimal, rounded to precision significant digits using rounding mode rounding. - * - * The natual logarithm is the inverse of the exponential function. - */ - ln(): Decimal; - - /** - * The return value is not rounded. - */ - negated(): Decimal; - - /** - * The return value is not rounded. - */ - neg(): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal plus n, rounded to precision significant digits using rounding mode rounding. - */ - plus(n: number | string | Decimal, base?: number): Decimal; - - /** - * If include_zeros is true or 1 then any trailing zeros of the integer part of a number are counted as significant digits, otherwise they are not. - */ - precision(include_leading_zeros?: boolean | number): number; - - /** - * If include_zeros is true or 1 then any trailing zeros of the integer part of a number are counted as significant digits, otherwise they are not. - */ - sd(include_leading_zeros?: boolean | number): number; - - round(): Decimal; - - /** - * The return value will be correctly rounded, i.e. rounded as if the result was first calculated to an infinite number of correct digits before rounding. - * - * This method is much faster than using the toPower method with an exponent of 0.5. - */ - squareRoot(): Decimal; - - /** - * The return value will be correctly rounded, i.e. rounded as if the result was first calculated to an infinite number of correct digits before rounding. - * - * This method is much faster than using the toPower method with an exponent of 0.5. - */ - sqrt(): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal times n, rounded to precision significant digits using rounding mode rounding. - */ - times(n: number | string | Decimal, base?: number): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal rounded to dp decimal places using rounding mode rm. - * - * If dp is omitted or is null or undefined, the return value will have the same value as this Decimal. - * - * If rm is omitted or is null or undefined, rounding mode rounding is used. - */ - toDecimalPlaces(dp?: number, rm?: RoundingMode): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal rounded to dp decimal places using rounding mode rm. - * - * If dp is omitted or is null or undefined, the return value will have the same value as this Decimal. - * - * If rm is omitted or is null or undefined, rounding mode rounding is used. - */ - toDP(dp?: number, rm?: RoundingMode): Decimal; - - /** - * Returns a string representing the value of this Decimal in exponential notation rounded using rounding mode rm to dp decimal places, i.e with one digit before the decimal point and dp digits after it. - * - * If the value of this Decimal in exponential notation has fewer than dp fraction digits, the return value will be appended with zeros accordingly. - * - * If dp is omitted, or is null or undefined, the number of digits after the decimal point defaults to the minimum number of digits necessary to represent the value exactly. - * - * If rm is omitted or is null or undefined, rounding mode rounding is used. - */ - toExponential(dp?: number, rm?: RoundingMode): string; - - /** - * Returns a string representing the value of this Decimal in normal (fixed-point) notation rounded to dp decimal places using rounding mode rm. - * - * If the value of this Decimal in normal notation has fewer than dp fraction digits , the return value will be appended with zeros accordingly. - * - * Unlike Number.prototype.toFixed, which returns exponential notation if a number is greater or equal to 1021, this method will always return normal notation. - * - * If dp is omitted or is null or undefined, then the return value will be unrounded and in normal notation. This is unlike Number.prototype.toFixed, which returns the value to zero decimal places, but is useful when because of the current toExpNeg or toExpNeg values, toString returns exponential notation - * - * if rm is omitted or is null or undefined, rounding mode rounding is used. - */ - toFixed(dp?: number, rm?: RoundingMode): string; - - /** - * Returns a string representing the value of this Decimal in fixed-point notation rounded to dp decimal places using rounding mode rm (as toFixed), and formatted according to the properties of this Decimal's constructor's format object property. - * - * See the examples below for the properties of the format object, their types and their usage. - * - * If dp is omitted or is null or undefined, then the return value is not rounded to a fixed number of decimal places. - * - * if rm is omitted or is null or undefined, rounding mode rounding is used. - */ - toFormat(dp?: number, rm?: RoundingMode): string; - - /** - * Returns a string array representing the value of this Decimal as a simple fraction with an integer numerator and an integer denominator. The denominator will be a positive non-zero value less than or equal to max_denominator. - * - * If a maximum denominator is not specified, or is null or undefined, the denominator will be the lowest value necessary to represent the number exactly. - */ - toFraction(max_denominator?: number | string | Decimal): string[]; - - toJSON(): string; - - /** - * Returns a new Decimal whose value is the nearest multiple of n to the value of this Decimal. - * - * If the value of this Decimal is equidistant from two multiples of n, the rounding mode rm, or rounding if rm is omitted or is null or undefined, determines the direction of the nearest. - * - * In this context, rounding mode ROUND_HALF_UP is interpreted the same as rounding mode ROUND_UP, and so on. I.e. the rounding is either up, own, to ceil, to floor or to even. - * - * The return value will always have the same sign as this Decimal, unless either this Decimal or n is NaN, in which case the return value will be also be NaN. - * - * The return value is not rounded to precision. - */ - toNearest(n: number | string | Decimal, rm?: RoundingMode): Decimal; - - /** - * Returns the value of this Decimal converted to a number primitive. - * - * Type coercion with, for example, JavaScript's unary plus operator will also work, except that a Decimal with the value minus zero will convert to positive zero. - */ - toNumber(): number; - - /** - * Returns a new Decimal whose value is the value of this Decimal raised to the power n, rounded to precision significant digits using rounding mode rounding. - * - * The performance of this method degrades exponentially with increasing digits. For non-integer exponents in particular, the performance of this method may not be adequate. - */ - toPower(n: number | string | Decimal, base?: number): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal raised to the power n, rounded to precision significant digits using rounding mode rounding. - * - * The performance of this method degrades exponentially with increasing digits. For non-integer exponents in particular, the performance of this method may not be adequate. - */ - pow(n: number | string | Decimal, base?: number): Decimal; - - /** - * Returns a string representing the value of this Decimal rounded to sd significant digits using rounding mode rm. - * - * If sd is less than the number of digits necessary to represent the integer part of the value in normal (fixed-point) notation, then exponential notation is used. - * - * If sd is omitted or is null or undefined, then the return value is the same as toString. - * - * if rm is omitted or is null or undefined, rounding mode rounding is used. - */ - toPrecision(sd?: number, rm?: RoundingMode): string; - - /** - * Returns a new Decimal whose value is the value of this Decimal rounded to sd significant digits using rounding mode rm. - * - * If sd is omitted or is null or undefined, the return value will be rounded to precision significant digits. - * - * if rm is omitted or is null or undefined, rounding mode rounding will be used. - */ - toSignificantDigits(sd?: number, rm?: RoundingMode): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal rounded to sd significant digits using rounding mode rm. - * - * If sd is omitted or is null or undefined, the return value will be rounded to precision significant digits. - * - * if rm is omitted or is null or undefined, rounding mode rounding will be used. - */ - toSD(sd?: number, rm?: RoundingMode): Decimal; - - /** - * base: number: integer, 2 to 64 inclusive - * - * Returns a string representing the value of this Decimal in the specified base, or base 10 if base is omitted or is null or undefined. - * - * For bases above 10, values from 10 to 35 are represented by a-z (as with Number.prototype.toString), 36 to 61 by A-Z, and 62 and 63 by $ and _ respectively. - * - * If a base is specified the value is rounded to precision significant digits using rounding mode rounding. - * - * If a base is not specified and this Decimal has a positive exponent that is equal to or greater than toExpPos, or a negative exponent equal to or less than toExpNeg, then exponential notation is returned. - * - * If base is null or undefined it is ignored. - */ - toString(base?: number): string; - - /** - * Returns a new Decimal whose value is the value of this Decimal truncated to a whole number. - * - * The return value is not rounded to precision. - */ - truncated(): Decimal; - - /** - * Returns a new Decimal whose value is the value of this Decimal truncated to a whole number. - * - * The return value is not rounded to precision. - */ - trunc(): Decimal; - - /** - * As toString, but does not accept a base argument. - */ - valueOf(): string; - - /** - * coefficient - * - * Array of integers, each 0 - 1e7 - */ - c: number[]; - - /** - * exponent - * - * Integer, -9e15 to 9e15 inclusive - */ - e: number; - - /** - * sign - * - * -1 or 1 - */ - s: number; - } -} diff --git a/types/decimal.js/tsconfig.json b/types/decimal.js/tsconfig.json deleted file mode 100644 index e2474fecd5..0000000000 --- a/types/decimal.js/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "decimal.js-tests.ts" - ] -} \ No newline at end of file diff --git a/types/decimal.js/tslint.json b/types/decimal.js/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/decimal.js/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From cb5d8da22f4db19d4fd0c3c205dbc9d6bd3019f3 Mon Sep 17 00:00:00 2001 From: BorntraegerMarc Date: Mon, 4 Dec 2017 09:34:47 +0100 Subject: [PATCH 047/298] Added first hapi TS tests --- types/hapi/v17/hapi-tests.ts | 12 ------------ .../v17/test/getting-started/01-creating-a-server.ts | 11 +++++++++++ types/hapi/v17/test/index.test.d.ts | 12 ++++++++++++ types/hapi/v17/tsconfig.json | 2 +- 4 files changed, 24 insertions(+), 13 deletions(-) delete mode 100644 types/hapi/v17/hapi-tests.ts create mode 100644 types/hapi/v17/test/getting-started/01-creating-a-server.ts create mode 100644 types/hapi/v17/test/index.test.d.ts diff --git a/types/hapi/v17/hapi-tests.ts b/types/hapi/v17/hapi-tests.ts deleted file mode 100644 index 06e2cdf175..0000000000 --- a/types/hapi/v17/hapi-tests.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {Server, ServerOptions} from "hapi"; - -const options:ServerOptions = { - port: 8000 -} - -const server = new Server(options); -server.start(); - -console.log('Server started at: ' + server.info.uri); - - diff --git a/types/hapi/v17/test/getting-started/01-creating-a-server.ts b/types/hapi/v17/test/getting-started/01-creating-a-server.ts new file mode 100644 index 0000000000..b45aca4564 --- /dev/null +++ b/types/hapi/v17/test/getting-started/01-creating-a-server.ts @@ -0,0 +1,11 @@ +// From https://hapijs.com/tutorials/getting-started#creating-a-server +import { Server, ServerOptions } from 'hapi'; + +const options: ServerOptions = { + port: 8000, +}; + +const server = new Server(options); +server.start(); + +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/index.test.d.ts new file mode 100644 index 0000000000..ce156ebbdb --- /dev/null +++ b/types/hapi/v17/test/index.test.d.ts @@ -0,0 +1,12 @@ +// Type definitions for hapi 17.0 +// Project: https://github.com/hapijs/hapi +// Definitions by: Marc Bornträger +// Rafael Souza Fijalkowski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// Note/Disclaimer: None. + +/// + +/** Getting Started */ +export * from './getting-started/01-creating-a-server'; diff --git a/types/hapi/v17/tsconfig.json b/types/hapi/v17/tsconfig.json index 216332b184..8ce2562c61 100644 --- a/types/hapi/v17/tsconfig.json +++ b/types/hapi/v17/tsconfig.json @@ -23,6 +23,6 @@ }, "files": [ "index.d.ts", - "hapi-tests.ts" + "test/index.test.d.ts" ] } From c0337babb663374cc72862bcc6cb69309240043b Mon Sep 17 00:00:00 2001 From: rsouza Date: Mon, 4 Dec 2017 15:53:37 -0300 Subject: [PATCH 048/298] Revert "examples replacing any with object" This reverts commit cb083b4 It was my mistake. The example code is outside of v17 folder. --- types/hapi/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 5eff9b7e9b..a97a9f1edb 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -231,7 +231,7 @@ export class Server extends Podium { * @param data the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. * @param callback an optional callback method invoked when all subscribers have been notified using the signature function(). The callback is called only after all the listeners have been notified, including any event updates emitted earlier (the order of event updates are guaranteed to be in the order they were emitted). */ - emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: object, callback?: () => void): void; + emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: any, callback?: () => void): void; /** * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' * [See docs](https://hapijs.com/api/16.1.1#serverencoderencoding-encoder) @@ -489,7 +489,7 @@ export interface PluginSpecificConfiguration {} */ export interface ServerOptions { /** app - application-specific configuration which can later be accessed via server.settings.app. Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. Defaults to {}. */ - app?: object; + app?: any; /** * cache - sets up server-side caching. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and capabilities. hapi uses catbox for its cache which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. The server cache configuration only defines the storage container itself. cache can be assigned: * * a prototype function (usually obtained by calling require() on a catbox strategy such as require('catbox-redis')). A new catbox client will be created internally using this function. @@ -533,7 +533,7 @@ export interface ServerEventObject { /** an array of tags (e.g. ['error', 'http']). */ tags: string[]; /** optional event-specific information. */ - data?: object; + data: any; /** true if the event was generated internally by the framework. */ internal: boolean; } From 5334e6bf7e19a5f92318789f9129b7ce41fe4af7 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Mon, 4 Dec 2017 20:22:31 -0300 Subject: [PATCH 049/298] Reviewed some server types. --- .../v17/definitions/server/server-events.d.ts | 5 +- types/hapi/v17/definitions/server/server.d.ts | 63 +++++++++++++------ 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/types/hapi/v17/definitions/server/server-events.d.ts b/types/hapi/v17/definitions/server/server-events.d.ts index c08bf4057a..7d0d600e6b 100644 --- a/types/hapi/v17/definitions/server/server-events.d.ts +++ b/types/hapi/v17/definitions/server/server-events.d.ts @@ -4,12 +4,13 @@ import Podium = require("../../../../podium/index"); * an event name string. * an event options object. * a podium emitter object. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents) */ export type ServerEventsApplication = string | ServerEventsApplicationObject | Podium; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents) * Object that it will be used in Event + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents) */ export interface ServerEventsApplicationObject { /** the event name string (required). */ @@ -27,8 +28,8 @@ export interface ServerEventsApplicationObject { } /** + * A criteria object with the following optional keys (unless noted otherwise): * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncriteria-listener) - * a criteria object with the following optional keys (unless noted otherwise): */ export interface ServerEventCriteria { /** (required) the event name string. */ diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 1d765d425b..de63cc3125 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -4,15 +4,39 @@ import * as zlib from "zlib"; import * as Podium from "podium"; import {MimosOptions} from "mimos"; import { - ServerOptions, ServerRealm, ServerInfo, Request, PluginsListRegistered, ServerState, - ServerOptionsCache, ServerEventCriteria, ServerEventsApplication, ServerEventsApplicationObject, - PayloadCompressionDecoderSettings, RouteCompressionEncoderSettings, ServerMethodOptions, ServerMethod, + PayloadCompressionDecoderSettings, + Plugin, + PluginsListRegistered, + Request, + RequestExtPointFunction, + RequestRoute, + ResponseToolkit, + RouteCompressionEncoderSettings, + ServerAuth, + ServerEventCriteria, + ServerEventsApplication, + ServerEventsApplicationObject, + ServerExtEventsObject, + ServerExtEventsRequestObject, + ServerExtOptions, + ServerExtPointFunction, + ServerExtRequestType, + ServerExtType, + ServerInfo, + ServerInjectOptions, + ServerInjectResponse, + ServerMethod, ServerMethodConfigurationObject, - RequestExtPointFunction, ServerExtEventsObject, ServerExtEventsRequestObject, ServerExtOptions, - ServerExtPointFunction, ServerExtRequestType, ServerExtType, - ServerInjectOptions, ServerInjectResponse, - RequestRoute, ServerAuth, ServerRegisterPluginObject, ServerRegisterOptions, ServerRoute, - Plugin, ResponseToolkit, Util, ServerStateCookieOptions, + ServerMethodOptions, + ServerOptions, + ServerOptionsCache, + ServerRealm, + ServerRegisterOptions, + ServerRegisterPluginObject, + ServerRoute, + ServerState, + ServerStateCookieOptions, + Util, } from "hapi"; /** @@ -23,12 +47,14 @@ import { export class Server extends Podium { /** - Creates a new server object - */ + * Creates a new server object + * @constructor + */ constructor(); /** * Creates a new server object where: + * @constructor * @param options server configuration object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptions) */ @@ -63,7 +89,7 @@ export class Server extends Podium { /** * Register custom application events where: - * @param events - must be one of: + * @param events must be one of: * * an event name string. * * an event options object with the following optional keys (unless noted otherwise): * * * name - the event name string (required). @@ -83,7 +109,6 @@ export class Server extends Podium { events: { /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsemitcriteria-data) * Emits a custom application event to all the subscribed listeners where: * @param criteria - the event update criteria which must be one of: * * the event name string. @@ -94,8 +119,10 @@ export class Server extends Podium { * @param data - the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. * @return Return value: none. * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsemitcriteria-data) */ - emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: any): void; + emit(criteria: string, data: any): void; + emit(criteria: {name: string, channel?: string, tags?: string | string[]}, data: any): void; /** * Subscribe to an event where: @@ -118,7 +145,6 @@ export class Server extends Podium { on(criteria: ServerEventCriteria, listener: Function): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) * Same as calling [server.events.on()](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) with the count option set to 1. * @param criteria - the subscription criteria which must be one of: * * event name string which can be any of the built-in server events @@ -126,39 +152,40 @@ export class Server extends Podium { * * a criteria object * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) */ once(criteria: string, listener: Function): void; once(criteria: ServerEventsApplicationObject, listener: Function): void; once(criteria: ServerEventCriteria, listener: Function): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsoncecriteria) * Same as calling server.events.on() with the count option set to 1. * @param criteria - the subscription criteria which must be one of: * * event name string which can be any of the built-in server events * * a custom application event registered with server.event(). * * a criteria object * @return Return value: a promise that resolves when the event is emitted. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsoncecriteria) */ once(criteria: string): any; once(criteria: ServerEventsApplicationObject): any; once(criteria: ServerEventCriteria): any; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumremovelistenername-listener) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) */ removeListener(name: string, listener: Function): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumremovealllistenersname) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) */ removeAllListeners(name: string): void; /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumhaslistenersname) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) */ hasListeners(name: string): boolean; From d1b269eb259b950da921d3005c1780106fa31090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Tue, 5 Dec 2017 17:29:22 +0800 Subject: [PATCH 050/298] add button --- types/materialize-css/index.d.ts | 45 +++++++++++++++++++ .../test/materialize-css-global.test.ts | 3 ++ .../test/materialize-css-jquery.test.ts | 5 +++ .../test/materialize-css-module.test.ts | 18 ++++++++ 4 files changed, 71 insertions(+) diff --git a/types/materialize-css/index.d.ts b/types/materialize-css/index.d.ts index ebc997c51f..0c6ab12cbc 100644 --- a/types/materialize-css/index.d.ts +++ b/types/materialize-css/index.d.ts @@ -77,6 +77,48 @@ declare global { sortFunction: (a: string, b: string, inputText: string) => number; } + class FloatingActionButton extends Component { + /** + * Get Instance + */ + static getInstance(elem: Element): FloatingActionButton; + + /** + * Open FAB + */ + open(): void; + + /** + * Close FAB + */ + close(): void; + + /** + * Describes open/close state of FAB. + */ + isOpen: boolean; + } + + interface FloatingActionButtonOptions { + /** + * Direction FAB menu opens + * @default "top" + */ + direction: "top" | "right" | "buttom" | "left"; + + /** + * true: FAB menu appears on hover, false: FAB menu appears on click + * @default true + */ + hoverEnabled: boolean; + + /** + * Enable transit the FAB into a toolbar on click + * @default false + */ + toolbarEnabled: boolean; + } + class Sidenav extends Component { /** * Get Instance @@ -398,6 +440,9 @@ declare global { autocomplete(method: keyof Pick, data: M.AutocompleteData): JQuery; autocomplete(options?: Partial): JQuery; + floatingActionButton(method: keyof Pick): JQuery; + floatingActionButton(options?: Partial): JQuery; + sidenav(method: keyof Pick): JQuery; sidenav(options?: Partial): JQuery; diff --git a/types/materialize-css/test/materialize-css-global.test.ts b/types/materialize-css/test/materialize-css-global.test.ts index fa228b444f..307c83133b 100644 --- a/types/materialize-css/test/materialize-css-global.test.ts +++ b/types/materialize-css/test/materialize-css-global.test.ts @@ -16,3 +16,6 @@ const characterCounter = new M.CharacterCounter(elem); // $ExpectType Tooltip const tooltips = new M.Tooltip(elem); + +// $ExpectType FloatingActionButton +const fab = new M.FloatingActionButton(elem); diff --git a/types/materialize-css/test/materialize-css-jquery.test.ts b/types/materialize-css/test/materialize-css-jquery.test.ts index 42af7fcefd..8ec8770462 100644 --- a/types/materialize-css/test/materialize-css-jquery.test.ts +++ b/types/materialize-css/test/materialize-css-jquery.test.ts @@ -28,3 +28,8 @@ $(".whatever").tooltip(); $(".whatever").tooltip({ html: "" }); $(".whatever").tooltip("open"); $(".whatever").tooltip("destroy"); + +$(".whatever").floatingActionButton(); +$(".whatever").floatingActionButton({ direction: "left" }); +$(".whatever").floatingActionButton("open"); +$(".whatever").floatingActionButton("destroy"); diff --git a/types/materialize-css/test/materialize-css-module.test.ts b/types/materialize-css/test/materialize-css-module.test.ts index 2665586b5d..dfbb2eea8a 100644 --- a/types/materialize-css/test/materialize-css-module.test.ts +++ b/types/materialize-css/test/materialize-css-module.test.ts @@ -140,3 +140,21 @@ tooltip.options; tooltip.el; // $ExpectType boolean tooltip.isOpen; + +// FloatingActionButton +// $ExpectType FloatingActionButton +new materialize.FloatingActionButton(elem); +// $ExpectType FloatingActionButton +const fab = new materialize.FloatingActionButton(elem, { + direction: 'left' +}); +// $ExpectType void +fab.open(); +// $ExpectType void +fab.destroy(); +// $ExpectType FloatingActionButtonOptions +fab.options; +// $ExpectType Element +fab.el; +// $ExpectType boolean +fab.isOpen; From 8baec39877586ce45b40c00b6e90ef016a86e421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Tue, 5 Dec 2017 19:04:36 +0800 Subject: [PATCH 051/298] add toast --- types/materialize-css/index.d.ts | 81 ++++++++++++++++++- .../test/materialize-css-global.test.ts | 3 + .../test/materialize-css-jquery.test.ts | 2 + .../test/materialize-css-module.test.ts | 12 +++ 4 files changed, 97 insertions(+), 1 deletion(-) diff --git a/types/materialize-css/index.d.ts b/types/materialize-css/index.d.ts index 0c6ab12cbc..413822f020 100644 --- a/types/materialize-css/index.d.ts +++ b/types/materialize-css/index.d.ts @@ -324,6 +324,79 @@ declare global { endingTop: string; } + class Toast extends ComponentBase { + /** + * Get Instance + */ + static getInstance(elem: Element): Toast; + + /** + * Describes the current pan state of the Toast. + */ + panning: boolean; + + /** + * The remaining amount of time in ms that the toast will stay before dismissal. + */ + timeRemaining: number; + + /** + * remove a specific toast + */ + dismiss(): void; + + /** + * dismiss all toasts + */ + static dismissAll(): void; + } + + interface ToastOptions { + /** + * The HTML content of the Toast. + */ + html: string; + + /** + * Length in ms the Toast stays before dismissal. + * @default 4000 + */ + displayLength: number; + + /** + * Transition in duration in milliseconds. + * @default 300 + */ + inDuration: number; + + /** + * Transition out duration in milliseconds. + * @default 375 + */ + outDuration: number; + + /** + * Classes to be added to the toast element. + */ + classes: string; + + /** + * Callback function called when toast is dismissed. + */ + completeCallback: () => void; + + /** + * The percentage of the toast's width it takes for a drag to dismiss a Toast. + * @default 0.8 + */ + activationPercent: number; + } + + /** + * Create a toast + */ + function toast(options: Partial): Toast; + class Tooltip extends Component { /** * Get Instance @@ -410,7 +483,7 @@ declare global { static getInstance(elem: Element): CharacterCounter; } - abstract class Component { + abstract class Component extends ComponentBase { /** * Construct component instance and set everything up */ @@ -420,6 +493,10 @@ declare global { * Destroy plugin instance and teardown */ destroy(): void; + } + + abstract class ComponentBase { + constructor(options?: Partial); /** * The DOM element the plugin was initialized with @@ -450,6 +527,8 @@ declare global { tabs(method: keyof Pick, tabId: string): JQuery; tabs(options?: Partial): JQuery; + // Toast can not be invoked using jQuery. + tooltip(method: keyof Pick): JQuery; tooltip(options?: Partial): JQuery; diff --git a/types/materialize-css/test/materialize-css-global.test.ts b/types/materialize-css/test/materialize-css-global.test.ts index 307c83133b..f7a65f6c5b 100644 --- a/types/materialize-css/test/materialize-css-global.test.ts +++ b/types/materialize-css/test/materialize-css-global.test.ts @@ -19,3 +19,6 @@ const tooltips = new M.Tooltip(elem); // $ExpectType FloatingActionButton const fab = new M.FloatingActionButton(elem); + +// $ExpectType Toast +const toast = M.toast({ html: 'I am a toast!' }); diff --git a/types/materialize-css/test/materialize-css-jquery.test.ts b/types/materialize-css/test/materialize-css-jquery.test.ts index 8ec8770462..fe5a72fffa 100644 --- a/types/materialize-css/test/materialize-css-jquery.test.ts +++ b/types/materialize-css/test/materialize-css-jquery.test.ts @@ -33,3 +33,5 @@ $(".whatever").floatingActionButton(); $(".whatever").floatingActionButton({ direction: "left" }); $(".whatever").floatingActionButton("open"); $(".whatever").floatingActionButton("destroy"); + +// Toast can not be invoked using jQuery. diff --git a/types/materialize-css/test/materialize-css-module.test.ts b/types/materialize-css/test/materialize-css-module.test.ts index dfbb2eea8a..c6f487ca2d 100644 --- a/types/materialize-css/test/materialize-css-module.test.ts +++ b/types/materialize-css/test/materialize-css-module.test.ts @@ -158,3 +158,15 @@ fab.options; fab.el; // $ExpectType boolean fab.isOpen; + +// Toasts +// $ExpectType Toast +const toast = materialize.toast({ html: 'I am a toast!' }); +// $ExpectType ToastOptions +toast.options; +// $ExpectType Element +fab.el; +// $ExpectType void +toast.dismiss(); +// $ExpectType void +materialize.Toast.dismissAll(); From 88a3292c9dd870f034ba9be24722a7e117bd6c26 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Wed, 6 Dec 2017 00:11:51 -0300 Subject: [PATCH 052/298] Added some test files. --- .../test/getting-started/02-adding-routes.ts | 41 +++++++++++++++++++ types/hapi/v17/test/index.test.d.ts | 7 ++++ types/hapi/v17/test/path/catch-all.ts | 15 +++++++ types/hapi/v17/test/server/app.ts | 22 ++++++++++ types/hapi/v17/test/server/info.ts | 15 +++++++ types/hapi/v17/test/server/table.ts | 22 ++++++++++ 6 files changed, 122 insertions(+) create mode 100644 types/hapi/v17/test/getting-started/02-adding-routes.ts create mode 100644 types/hapi/v17/test/path/catch-all.ts create mode 100644 types/hapi/v17/test/server/app.ts create mode 100644 types/hapi/v17/test/server/info.ts create mode 100644 types/hapi/v17/test/server/table.ts diff --git a/types/hapi/v17/test/getting-started/02-adding-routes.ts b/types/hapi/v17/test/getting-started/02-adding-routes.ts new file mode 100644 index 0000000000..be46f20efc --- /dev/null +++ b/types/hapi/v17/test/getting-started/02-adding-routes.ts @@ -0,0 +1,41 @@ +// from https://hapijs.com/tutorials/getting-started#adding-routes +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; +const server = new Server(options); + +const serverRoute: ServerRoute = { + path: '/user', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + console.log(request); + return 'ok: ' + request.path; + } +} + +const serverRoutes: ServerRoute[] = [ + { + path: '/test1', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + console.log(request); + return 'ok: ' + request.path; + } + }, + { + path: '/test2', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + console.log(request); + return 'ok: ' + request.path; + } + }, +]; + +server.route(serverRoute); +server.route(serverRoutes); + +server.start(); +console.log(`Server running at: ${server.info!.uri}`); diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/index.test.d.ts index ce156ebbdb..89ddbd9ece 100644 --- a/types/hapi/v17/test/index.test.d.ts +++ b/types/hapi/v17/test/index.test.d.ts @@ -10,3 +10,10 @@ /** Getting Started */ export * from './getting-started/01-creating-a-server'; +export * from './getting-started/02-adding-routes'; +export * from './path/catch-all'; +export * from './server/app'; +export * from './server/info'; +export * from './server/table'; + + diff --git a/types/hapi/v17/test/path/catch-all.ts b/types/hapi/v17/test/path/catch-all.ts new file mode 100644 index 0000000000..87ddfec8be --- /dev/null +++ b/types/hapi/v17/test/path/catch-all.ts @@ -0,0 +1,15 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#catch-all-route +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; +const server = new Server(options); + +const handler = function (request: Request, h: ResponseToolkit) { + return h.response('The page was not found').code(404); +}; +server.route({ method: '*', path: '/{p*}', handler }); + +server.start(); +console.log(`Server running at: ${server.info!.uri}`); diff --git a/types/hapi/v17/test/server/app.ts b/types/hapi/v17/test/server/app.ts new file mode 100644 index 0000000000..ea376560b7 --- /dev/null +++ b/types/hapi/v17/test/server/app.ts @@ -0,0 +1,22 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-serverapp +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; + +const server = new Server(options); +server.app.key = 'value2'; + +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + return 'key: ' + request.server.app.key; + } +} + +server.route(serverRoute); + +server.start(); +console.log(`Server running at: ${server.info!.uri}`); diff --git a/types/hapi/v17/test/server/info.ts b/types/hapi/v17/test/server/info.ts new file mode 100644 index 0000000000..522b234c75 --- /dev/null +++ b/types/hapi/v17/test/server/info.ts @@ -0,0 +1,15 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; +import assert = require('assert'); + +let options: ServerOptions = { + port: 8000, +}; +const server = new Server(options); + +// check the correct port +if(server.info) assert(server.info.port === 8000); +assert(server.info !== null); + +server.start(); +console.log(`Server running at: ${server.info!.uri}`); diff --git a/types/hapi/v17/test/server/table.ts b/types/hapi/v17/test/server/table.ts new file mode 100644 index 0000000000..f6dee501c7 --- /dev/null +++ b/types/hapi/v17/test/server/table.ts @@ -0,0 +1,22 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; + +const server = new Server(options); +server.app.key = 'value2'; + +server.route({ + path: '/', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + return h.response("Hello World"); + } +}); + +server.start(); +const table = server.table(); +console.log(table); +console.log(`Server running at: ${server.info!.uri}`); From d7acc610aa090aa5b9003d801ede9cd69f0be275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Thu, 7 Dec 2017 00:52:32 +0800 Subject: [PATCH 053/298] add DatePicker --- types/materialize-css/index.d.ts | 169 +++++++++++++++++- .../test/materialize-css-global.test.ts | 2 + .../test/materialize-css-jquery.test.ts | 7 + .../test/materialize-css-module.test.ts | 26 +++ 4 files changed, 200 insertions(+), 4 deletions(-) diff --git a/types/materialize-css/index.d.ts b/types/materialize-css/index.d.ts index 413822f020..f1540ff597 100644 --- a/types/materialize-css/index.d.ts +++ b/types/materialize-css/index.d.ts @@ -77,7 +77,157 @@ declare global { sortFunction: (a: string, b: string, inputText: string) => number; } - class FloatingActionButton extends Component { + class DatePicker extends Component implements Openable { + /** + * Get Instance + */ + static getInstance(elem: Element): DatePicker; + + /** + * If the picker is open. + */ + isOpen: boolean; + + /** + * The selected Date. + */ + date: Date; + + /** + * Open datepicker + */ + open(): void; + + /** + * Close datepicker + */ + close(): void; + + /** + * Gets a string representation of the selected date + */ + toString(): string; + + /** + * Set a date on the datepicker + * @param date Date to set on the datepicker. + */ + setDate(date?: Date): void; + + /** + * Change date view to a specific date on the datepicker + * @param date Date to show on the datepicker. + */ + gotoDate(date: Date): void; + } + + interface DatePickerOptions { + /** + * The date output format for the input field value. + * @default 'mmm dd, yyyy' + */ + format: string; + + /** + * Used to create date object from current input string. + */ + parse: (value: string, format: string) => Date; + + /** + * The initial date to view when first opened. + */ + defaultDate: Date; + + /** + * Make the `defaultDate` the initial selected value + * @default false + */ + setDefaultDate: boolean; + + /** + * Prevent selection of any date on the weekend. + * @default false + */ + disableWeekends: boolean; + + /** + * Custom function to disable certain days. + */ + disableDayFn: (day: Date) => boolean; + + /** + * First day of week (0: Sunday, 1: Monday etc). + * @default 0 + */ + firstDay: number; + + /** + * The earliest date that can be selected. + */ + minDate: Date; + + /** + * The latest date that can be selected. + */ + maxDate: Date; + + /** + * Number of years either side, or array of upper/lower range. + * @default 10 + */ + yearRange: number | number[]; + + /** + * Changes Datepicker to RTL. + * @default false + */ + isRTL: boolean; + + /** + * Show month after year in Datepicker title. + * @default false + */ + showMonthAfterYear: boolean; + + /** + * Render days of the calendar grid that fall in the next or previous month. + * @default false + */ + showDaysInNextAndPreviousMonths: false; + + /** + * Specify a selector for a DOM element to render the calendar in, by default it will be placed before the input. + */ + container: string; + + /** + * An array of string returned by `Date.toDateString()`, indicating there are events in the specified days. + * @default [] + */ + events: string[]; + + /** + * Callback function when date is selected, first parameter is the newly selected date. + */ + onSelect: (this: DatePicker, selectedDate: Date) => void; + + /** + * Callback function when Datepicker is opened + */ + onOpen: (this: DatePicker) => void; + + /** + * Callback function when Datepicker is closed + */ + onClose: (this: DatePicker) => void; + + /** + * Callback function when Datepicker HTML is refreshed + */ + onDraw: (this: DatePicker) => void; + } + + class FloatingActionButton extends Component implements Openable { /** * Get Instance */ @@ -119,7 +269,7 @@ declare global { toolbarEnabled: boolean; } - class Sidenav extends Component { + class Sidenav extends Component implements Openable { /** * Get Instance */ @@ -246,7 +396,7 @@ declare global { responsiveThreshold: number; } - class Modal extends Component { + class Modal extends Component implements Openable { /** * Get Instance */ @@ -397,7 +547,7 @@ declare global { */ function toast(options: Partial): Toast; - class Tooltip extends Component { + class Tooltip extends Component implements Openable { /** * Get Instance */ @@ -508,6 +658,12 @@ declare global { */ options: TOptions; } + + interface Openable { + isOpen: boolean; + open(): void; + close(): void; + } } interface JQuery { @@ -517,6 +673,11 @@ declare global { autocomplete(method: keyof Pick, data: M.AutocompleteData): JQuery; autocomplete(options?: Partial): JQuery; + datePicker(method: keyof Pick): JQuery; + datePicker(method: keyof Pick, date?: Date): JQuery; + datePicker(method: keyof Pick, date: Date): JQuery; + datePicker(options?: Partial): JQuery; + floatingActionButton(method: keyof Pick): JQuery; floatingActionButton(options?: Partial): JQuery; diff --git a/types/materialize-css/test/materialize-css-global.test.ts b/types/materialize-css/test/materialize-css-global.test.ts index f7a65f6c5b..7301d98f58 100644 --- a/types/materialize-css/test/materialize-css-global.test.ts +++ b/types/materialize-css/test/materialize-css-global.test.ts @@ -22,3 +22,5 @@ const fab = new M.FloatingActionButton(elem); // $ExpectType Toast const toast = M.toast({ html: 'I am a toast!' }); + +const datePicker = new M.DatePicker(elem); diff --git a/types/materialize-css/test/materialize-css-jquery.test.ts b/types/materialize-css/test/materialize-css-jquery.test.ts index fe5a72fffa..0a70184881 100644 --- a/types/materialize-css/test/materialize-css-jquery.test.ts +++ b/types/materialize-css/test/materialize-css-jquery.test.ts @@ -35,3 +35,10 @@ $(".whatever").floatingActionButton("open"); $(".whatever").floatingActionButton("destroy"); // Toast can not be invoked using jQuery. + +$(".whatever").datePicker(); +$(".whatever").datePicker({ defaultDate: new Date() }); +$(".whatever").datePicker("open"); +$(".whatever").datePicker("destroy"); +$(".whatever").datePicker("setDate", new Date()); +$(".whatever").datePicker("gotoDate", new Date()); diff --git a/types/materialize-css/test/materialize-css-module.test.ts b/types/materialize-css/test/materialize-css-module.test.ts index c6f487ca2d..bfe2952e3f 100644 --- a/types/materialize-css/test/materialize-css-module.test.ts +++ b/types/materialize-css/test/materialize-css-module.test.ts @@ -170,3 +170,29 @@ fab.el; toast.dismiss(); // $ExpectType void materialize.Toast.dismissAll(); + +// DatePicker +// $ExpectType DatePicker +new materialize.DatePicker(elem); +// $ExpectType DatePicker +const datePicker = new materialize.DatePicker(elem, { + defaultDate: new Date(), + onSelect(date) { + // $ExpectType DatePicker + this; + // $ExpectType Date + date; + } +}); +// $ExpectType void +datePicker.open(); +// $ExpectType void +datePicker.setDate(new Date()); +// $ExpectType void +datePicker.destroy(); +// $ExpectType DatePickerOptions +datePicker.options; +// $ExpectType Element +datePicker.el; +// $ExpectType boolean +datePicker.isOpen; From ffad3c7f82707b349e3e4e65b3e928293f424c2a Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Wed, 6 Dec 2017 22:18:06 -0300 Subject: [PATCH 054/298] Changed state() method param from string to object. --- types/hapi/v17/definitions/response/response-object.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/v17/definitions/response/response-object.d.ts index a0f7abdf97..c2ffd457fa 100644 --- a/types/hapi/v17/definitions/response/response-object.d.ts +++ b/types/hapi/v17/definitions/response/response-object.d.ts @@ -213,8 +213,8 @@ export interface ResponseObject extends Podium { * @return Return value: the current response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsestatename-value-options) */ - state(name: string, value: string): ResponseObject; - state(name: string, value: string, options: ServerStateCookieOptions): ResponseObject; + state(name: string, value: object): ResponseObject; + state(name: string, value: object, options: ServerStateCookieOptions): ResponseObject; /** * Sets a string suffix when the response is process via JSON.stringify() where: @@ -234,7 +234,7 @@ export interface ResponseObject extends Podium { /** * Sets the HTTP 'Content-Type' header where: - * @param value - is the mime type. + * @param mimeType - is the mime type. * @return Return value: the current response object. * Should only be used to override the built-in default for each response type. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsetypemimetype) From c159a74456332cf93141f66d5a25ac1915befbd8 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Wed, 6 Dec 2017 22:19:33 -0300 Subject: [PATCH 055/298] Added more tests files. --- .../getting-started/01-creating-a-server.ts | 2 +- .../test/getting-started/02-adding-routes.ts | 8 ++-- types/hapi/v17/test/index.test.d.ts | 6 +++ types/hapi/v17/test/path/catch-all.ts | 4 +- types/hapi/v17/test/path/parameters.ts | 38 +++++++++++++++++++ types/hapi/v17/test/reply/redirect.ts | 20 ++++++++++ types/hapi/v17/test/reply/reply.ts | 37 ++++++++++++++++++ types/hapi/v17/test/reply/state_cookie.ts | 29 ++++++++++++++ types/hapi/v17/test/response/error.ts | 31 +++++++++++++++ types/hapi/v17/test/server/info.ts | 6 +-- types/hapi/v17/test/server/table.ts | 4 +- 11 files changed, 173 insertions(+), 12 deletions(-) create mode 100644 types/hapi/v17/test/path/parameters.ts create mode 100644 types/hapi/v17/test/reply/redirect.ts create mode 100644 types/hapi/v17/test/reply/reply.ts create mode 100644 types/hapi/v17/test/reply/state_cookie.ts create mode 100644 types/hapi/v17/test/response/error.ts diff --git a/types/hapi/v17/test/getting-started/01-creating-a-server.ts b/types/hapi/v17/test/getting-started/01-creating-a-server.ts index b45aca4564..995cac708c 100644 --- a/types/hapi/v17/test/getting-started/01-creating-a-server.ts +++ b/types/hapi/v17/test/getting-started/01-creating-a-server.ts @@ -1,5 +1,5 @@ // From https://hapijs.com/tutorials/getting-started#creating-a-server -import { Server, ServerOptions } from 'hapi'; +import {Server, ServerOptions} from 'hapi'; const options: ServerOptions = { port: 8000, diff --git a/types/hapi/v17/test/getting-started/02-adding-routes.ts b/types/hapi/v17/test/getting-started/02-adding-routes.ts index be46f20efc..4f383c15dc 100644 --- a/types/hapi/v17/test/getting-started/02-adding-routes.ts +++ b/types/hapi/v17/test/getting-started/02-adding-routes.ts @@ -4,16 +4,15 @@ import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi const options: ServerOptions = { port: 8000, }; -const server = new Server(options); const serverRoute: ServerRoute = { - path: '/user', + path: '/test', method: 'GET', handler: function (request: Request, h: ResponseToolkit) { console.log(request); return 'ok: ' + request.path; } -} +}; const serverRoutes: ServerRoute[] = [ { @@ -34,8 +33,9 @@ const serverRoutes: ServerRoute[] = [ }, ]; +const server = new Server(options); server.route(serverRoute); server.route(serverRoutes); server.start(); -console.log(`Server running at: ${server.info!.uri}`); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/index.test.d.ts index 89ddbd9ece..a97dcf8ff0 100644 --- a/types/hapi/v17/test/index.test.d.ts +++ b/types/hapi/v17/test/index.test.d.ts @@ -12,6 +12,12 @@ export * from './getting-started/01-creating-a-server'; export * from './getting-started/02-adding-routes'; export * from './path/catch-all'; +export * from './path/parameters'; +export * from './reply/redirect'; +export * from './reply/reply'; +export * from './reply/state_cookie'; +export * from './response/error'; + export * from './server/app'; export * from './server/info'; export * from './server/table'; diff --git a/types/hapi/v17/test/path/catch-all.ts b/types/hapi/v17/test/path/catch-all.ts index 87ddfec8be..a5292d4b7e 100644 --- a/types/hapi/v17/test/path/catch-all.ts +++ b/types/hapi/v17/test/path/catch-all.ts @@ -1,5 +1,5 @@ // From https://github.com/hapijs/hapi/blob/master/API.md#catch-all-route -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; +import {Request, ResponseToolkit, Server, ServerOptions} from "hapi"; const options: ServerOptions = { port: 8000, @@ -12,4 +12,4 @@ const handler = function (request: Request, h: ResponseToolkit) { server.route({ method: '*', path: '/{p*}', handler }); server.start(); -console.log(`Server running at: ${server.info!.uri}`); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/path/parameters.ts b/types/hapi/v17/test/path/parameters.ts new file mode 100644 index 0000000000..11684555db --- /dev/null +++ b/types/hapi/v17/test/path/parameters.ts @@ -0,0 +1,38 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-requestparams +import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; + +// Example 1 +// http://localhost:8000/album-name/song-optional +const getAlbum: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { + console.log(request.params); + return 'ok: ' + request.path; +} +const serverRoute1: ServerRoute = { + path: '/{album}/{song?}', + method: 'GET', + handler: getAlbum +} + +// Example 2 +// http://localhost:8000/person/rafael/fijalkowski +const getPerson: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { + const nameParts = request.params.name.split('/'); + return { first: nameParts[0], last: nameParts[1] }; +} +const serverRoute2: ServerRoute = { + path: '/person/{name*2}', + method: 'GET', + handler: getPerson +} + + +const server = new Server(options); +server.route(serverRoute1); +server.route(serverRoute2); + +server.start(); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/reply/redirect.ts b/types/hapi/v17/test/reply/redirect.ts new file mode 100644 index 0000000000..37af39707e --- /dev/null +++ b/types/hapi/v17/test/reply/redirect.ts @@ -0,0 +1,20 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-hredirecturi +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; + +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + return h.redirect('http://example.com'); + } +} + +const server = new Server(options); +server.route(serverRoute); + +server.start(); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/reply/reply.ts b/types/hapi/v17/test/reply/reply.ts new file mode 100644 index 0000000000..185f80ed3d --- /dev/null +++ b/types/hapi/v17/test/reply/reply.ts @@ -0,0 +1,37 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-hresponsevalue +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; + +const serverRoutes: ServerRoute[] = [ + // verbose notation + { + path: '/test1', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + const response = h.response('success'); + response.type('text/plain'); + response.header('X-Custom', 'some-value'); + return response; + } + }, + // Chained notation + { + path: '/test2', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + return h.response('success') + .type('text/plain') + .header('X-Custom', 'some-value'); + } + }, +]; + + +const server = new Server(options); +server.route(serverRoutes); + +server.start(); +console.log('Server started at: ' + server.info.uri); \ No newline at end of file diff --git a/types/hapi/v17/test/reply/state_cookie.ts b/types/hapi/v17/test/reply/state_cookie.ts new file mode 100644 index 0000000000..4ef420915e --- /dev/null +++ b/types/hapi/v17/test/reply/state_cookie.ts @@ -0,0 +1,29 @@ +// from https://hapijs.com/tutorials/cookies?lang=en_US +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute, ServerStateCookieOptions} from "hapi"; + + +const options: ServerOptions = { + port: 8000, +}; + +const serverRoute: ServerRoute = { + path: '/say-hello', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + return h.response('Hello').state('data', { firstVisit: false }); + } +} + +const server = new Server(options); +server.route(serverRoute); + +const stateOption: ServerStateCookieOptions = { + ttl: 24 * 60 * 60 * 1000, // One day + isSecure: false, + isHttpOnly: false, + encoding: 'base64json', +} +server.state('data', stateOption); + +server.start(); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/response/error.ts b/types/hapi/v17/test/response/error.ts new file mode 100644 index 0000000000..c9c5e3e822 --- /dev/null +++ b/types/hapi/v17/test/response/error.ts @@ -0,0 +1,31 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#errors +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; +import * as Boom from "boom"; + +const options: ServerOptions = { + port: 8000, +}; + +const serverRoutes: ServerRoute[] = [ + { + path: '/badRequest', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + throw Boom.badRequest('Unsupported parameter'); + } + }, + { + path: '/internal', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + throw new Error('unexpect error'); + } + }, +]; + + +const server = new Server(options); +server.route(serverRoutes); + +server.start(); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/server/info.ts b/types/hapi/v17/test/server/info.ts index 522b234c75..1fd15b240b 100644 --- a/types/hapi/v17/test/server/info.ts +++ b/types/hapi/v17/test/server/info.ts @@ -1,8 +1,8 @@ // From https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; +import {Server, ServerOptions} from "hapi"; import assert = require('assert'); -let options: ServerOptions = { +const options: ServerOptions = { port: 8000, }; const server = new Server(options); @@ -12,4 +12,4 @@ if(server.info) assert(server.info.port === 8000); assert(server.info !== null); server.start(); -console.log(`Server running at: ${server.info!.uri}`); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/server/table.ts b/types/hapi/v17/test/server/table.ts index f6dee501c7..58c8e4c52d 100644 --- a/types/hapi/v17/test/server/table.ts +++ b/types/hapi/v17/test/server/table.ts @@ -1,5 +1,5 @@ // From https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; +import {Request, ResponseToolkit, Server, ServerOptions} from "hapi"; const options: ServerOptions = { port: 8000, @@ -19,4 +19,4 @@ server.route({ server.start(); const table = server.table(); console.log(table); -console.log(`Server running at: ${server.info!.uri}`); +console.log('Server started at: ' + server.info.uri); From fd6f26dcd095c7294e97d7e2dc7ce9044b074199 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Wed, 6 Dec 2017 22:52:47 -0300 Subject: [PATCH 056/298] RequestExtPointFunction should inherit from Lifecycle.Method --- types/hapi/v17/definitions/server/server-ext.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/hapi/v17/definitions/server/server-ext.d.ts b/types/hapi/v17/definitions/server/server-ext.d.ts index 960a342998..40d0969f09 100644 --- a/types/hapi/v17/definitions/server/server-ext.d.ts +++ b/types/hapi/v17/definitions/server/server-ext.d.ts @@ -1,4 +1,4 @@ -import {Server, Request, ResponseToolkit} from "hapi"; +import {Server, Lifecycle} from "hapi"; /** * The extension point event name. The available extension points include the request extension points as well as the following server extension points: @@ -76,8 +76,8 @@ export interface ServerExtPointFunction { (server: Server): void; } -export interface RequestExtPointFunction { - (request: Request, h: ResponseToolkit): void; +export interface RequestExtPointFunction extends Lifecycle.Method { + } /** From 18e4f83a2481f63085a63952adb48e9bd3e77d40 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Wed, 6 Dec 2017 22:54:33 -0300 Subject: [PATCH 057/298] Added "continue.ts" test file. --- types/hapi/v17/test/index.test.d.ts | 1 + types/hapi/v17/test/reply/continue.ts | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 types/hapi/v17/test/reply/continue.ts diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/index.test.d.ts index a97dcf8ff0..9e98fa9c31 100644 --- a/types/hapi/v17/test/index.test.d.ts +++ b/types/hapi/v17/test/index.test.d.ts @@ -13,6 +13,7 @@ export * from './getting-started/01-creating-a-server'; export * from './getting-started/02-adding-routes'; export * from './path/catch-all'; export * from './path/parameters'; +export * from './reply/continue'; export * from './reply/redirect'; export * from './reply/reply'; export * from './reply/state_cookie'; diff --git a/types/hapi/v17/test/reply/continue.ts b/types/hapi/v17/test/reply/continue.ts new file mode 100644 index 0000000000..5a0b37b5f9 --- /dev/null +++ b/types/hapi/v17/test/reply/continue.ts @@ -0,0 +1,25 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; + +const serverRoute: ServerRoute = { + path: '/test', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + return 'ok: ' + request.path; + } +}; + +const server = new Server(options); +server.route(serverRoute); + +server.ext("onRequest", (request: Request, h: ResponseToolkit) => { + request.setUrl('/test'); + return h.continue; +}); + +server.start(); +console.log('Server started at: ' + server.info.uri); From b580b70dcdb1afbc757aa46a062ddde2049f49ba Mon Sep 17 00:00:00 2001 From: Technion Date: Thu, 7 Dec 2017 04:42:26 +0000 Subject: [PATCH 058/298] Changes Jest type to use array rather than Set. Set may be technically stricter but as per #19662, there have been a number of associated problems with this. --- types/jest/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 5c2152694f..dda9bded66 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -1050,7 +1050,7 @@ declare namespace jest { onTestResult?(test: Test, testResult: TestResult, aggregatedResult: AggregatedResult): void; onRunStart?(results: AggregatedResult, options: ReporterOnStartOptions): void; onTestStart?(test: Test): void; - onRunComplete?(contexts: Set, results: AggregatedResult): Maybe>; + onRunComplete?(contexts: [Context], results: AggregatedResult): Maybe>; getLastError?(): Maybe; } From e9538b2994f378bd1e9976ac6c8751d2a8630807 Mon Sep 17 00:00:00 2001 From: devuxer Date: Wed, 6 Dec 2017 22:27:40 -0800 Subject: [PATCH 059/298] Replaced onActionTouchTap w/ onActionClick Snackbar property `onActionTouchTap` was replaced with `onActionClick` in [release 0.20.0](https://github.com/mui-org/material-ui/releases/tag/v0.20.0). This relates to [pull request 9058](https://github.com/mui-org/material-ui/pull/9058) and specifically [this commit](https://github.com/mui-org/material-ui/pull/9058/commits/bc97082dd318f8d4f872fc0c65cdc8539f7ea981). --- types/material-ui/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/material-ui/index.d.ts b/types/material-ui/index.d.ts index 5ae63560cc..1590771b78 100644 --- a/types/material-ui/index.d.ts +++ b/types/material-ui/index.d.ts @@ -1628,7 +1628,7 @@ declare namespace __MaterialUI { className?: string; contentStyle?: React.CSSProperties; message: React.ReactNode; - onActionTouchTap?: React.TouchEventHandler<{}>; + onActionClick?: React.MouseEventHandler<{}>; onRequestClose?(reason: string): void; open: boolean; style?: React.CSSProperties; @@ -1684,7 +1684,7 @@ declare namespace __MaterialUI { bodyStyle?: React.CSSProperties; className?: string; message: string | JSX.Element; - onActionTouchTap?: React.TouchEventHandler<{}>; + onActionClick?: React.MouseEventHandler<{}>; /** @deprecated Use the open property to control the component instead */ onDismiss?(): void; // DEPRECATED onRequestClose(reason: string): void; From 1d784eb72b4fcda4abde5927cb2913dab1c1809f Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Thu, 7 Dec 2017 15:16:21 -0800 Subject: [PATCH 060/298] add text-encoding-utf-8 --- types/text-encoding-utf-8/index.d.ts | 60 ++++++++++++++ .../text-encoding-utf-8-tests.ts | 52 ++++++++++++ types/text-encoding-utf-8/tsconfig.json | 23 ++++++ types/text-encoding-utf-8/tslint.json | 79 +++++++++++++++++++ 4 files changed, 214 insertions(+) create mode 100644 types/text-encoding-utf-8/index.d.ts create mode 100644 types/text-encoding-utf-8/text-encoding-utf-8-tests.ts create mode 100644 types/text-encoding-utf-8/tsconfig.json create mode 100644 types/text-encoding-utf-8/tslint.json diff --git a/types/text-encoding-utf-8/index.d.ts b/types/text-encoding-utf-8/index.d.ts new file mode 100644 index 0000000000..73aed16d6f --- /dev/null +++ b/types/text-encoding-utf-8/index.d.ts @@ -0,0 +1,60 @@ +// Type definitions for text-encoding-utf-8 +// Project: https://github.com/arv/text-encoding-utf-8 +// Definitions by: Paul Taylor +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace TextEncoding { + interface TextDecoderOptions { + fatal?: boolean; + ignoreBOM?: boolean; + } + + interface TextDecodeOptions { + stream?: boolean; + } + + interface TextEncoderOptions { + NONSTANDARD_allowLegacyEncoding?: boolean; + } + + interface TextDecoder { + encoding: string; + fatal: boolean; + ignoreBOM: boolean; + decode(input?: ArrayBuffer | ArrayBufferView, options?: TextDecodeOptions): string; + } + + interface TextEncoder { + encoding: string; + encode(input?: string, options?: TextEncodeOptions): Uint8Array; + } + + interface TextEncodeOptions { + stream?: boolean; + } + + interface TextEncoderStatic { + (utfLabel?: string, options?: TextEncoderOptions): TextEncoder; + new (utfLabel?: string, options?: TextEncoderOptions): TextEncoder; + } + + interface TextDecoderStatic { + (label?: string, options?: TextDecoderOptions): TextDecoder; + new (label?: string, options?: TextDecoderOptions): TextDecoder; + } + + interface TextEncodingStatic { + TextEncoder: TextEncoderStatic; + TextDecoder: TextDecoderStatic; + } +} + +declare var TextDecoder: TextEncoding.TextDecoderStatic; + +declare var TextEncoder: TextEncoding.TextEncoderStatic; + +declare var TextEncoding: TextEncoding.TextEncodingStatic; + +declare module "text-encoding-utf-8" { + export = TextEncoding; +} diff --git a/types/text-encoding-utf-8/text-encoding-utf-8-tests.ts b/types/text-encoding-utf-8/text-encoding-utf-8-tests.ts new file mode 100644 index 0000000000..afa837c65d --- /dev/null +++ b/types/text-encoding-utf-8/text-encoding-utf-8-tests.ts @@ -0,0 +1,52 @@ + + +function test_encoder() { + var text = "plain text"; + var uint8array: Uint8Array; + + // constructor + uint8array = new TextEncoder().encode(text); + uint8array = new TextEncoder('utf-8').encode(text); + + uint8array = TextEncoder().encode(text); + uint8array = TextEncoder('utf-8').encode(text); + + // attributes + var encoder = new TextEncoder(); + encoder.encoding = 'utf-8'; + var encoding: string = encoder.encoding; + + // methods + encoder.encode(); + encoder.encode(text); +} + +function test_decoder() { + var text = "plain text"; + var uint8array: Uint8Array = TextEncoder().encode(text); + var arrayBuffer: ArrayBuffer = uint8array.buffer + + // constructor + text = new TextDecoder().decode(uint8array); + text = new TextDecoder('utf-8').decode(uint8array); + + text = TextDecoder().decode(uint8array); + text = TextDecoder('utf-8').decode(uint8array); + + // attributes + var decoder = new TextDecoder(); + + decoder.encoding = 'utf-8'; + var encoding: string = decoder.encoding; + + decoder.fatal = true; + var fatal: boolean = decoder.fatal; + + decoder.ignoreBOM = true; + var ignoreBOM: boolean = decoder.ignoreBOM; + + // methods + decoder.decode(); + decoder.decode(uint8array); + decoder.decode(arrayBuffer); +} diff --git a/types/text-encoding-utf-8/tsconfig.json b/types/text-encoding-utf-8/tsconfig.json new file mode 100644 index 0000000000..f9d410c8c5 --- /dev/null +++ b/types/text-encoding-utf-8/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "text-encoding-utf-8-tests.ts" + ] +} \ No newline at end of file diff --git a/types/text-encoding-utf-8/tslint.json b/types/text-encoding-utf-8/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/text-encoding-utf-8/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} From c739273012528ec666398c5366ecdc55861794e9 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Thu, 7 Dec 2017 21:36:04 -0300 Subject: [PATCH 061/298] Add overloaded function "response(value: object)" to work with hapijs test: https://github.com/hapijs/hapi/blob/4144f9397cf639e22379699cdfc967d2c84e8509/test/response.js#L220 Following suggestion of @gitawego --- types/hapi/v17/definitions/response/response-toolkit.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/hapi/v17/definitions/response/response-toolkit.d.ts b/types/hapi/v17/definitions/response/response-toolkit.d.ts index a421f7c1a1..ae737bf085 100644 --- a/types/hapi/v17/definitions/response/response-toolkit.d.ts +++ b/types/hapi/v17/definitions/response/response-toolkit.d.ts @@ -98,6 +98,7 @@ export interface ResponseToolkit { */ response(): ResponseObject; response(value: string): ResponseObject; + response(value: object): ResponseObject; /** * Sets a response cookie using the same arguments as response.state(). From fddcaebffad884da18b7e398b27b90a6763ca701 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Fri, 8 Dec 2017 11:43:06 -0300 Subject: [PATCH 062/298] Add object arguments (...args) instead of Function. Is it good idea? TODO created. --- types/hapi/v17/definitions/server/server.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index de63cc3125..8c6a37baeb 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -154,7 +154,7 @@ export class Server extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) */ - once(criteria: string, listener: Function): void; + once(criteria: string, listener: (...args: any[]) => void): void; // TODO I am not sure if the best way is use Function or (...args: any[]) => void) considering the JSDocs "The function signature depends on the event argument" once(criteria: ServerEventsApplicationObject, listener: Function): void; once(criteria: ServerEventCriteria, listener: Function): void; From 43152aaabd6d3aae6537e8f79279fc816ed11c87 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Fri, 8 Dec 2017 11:46:45 -0300 Subject: [PATCH 063/298] Add new RequestEvents type. --- .../definitions/request/request-events.d.ts | 45 +++++++++++++++++++ .../hapi/v17/definitions/request/request.d.ts | 3 +- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 types/hapi/v17/definitions/request/request-events.d.ts diff --git a/types/hapi/v17/definitions/request/request-events.d.ts b/types/hapi/v17/definitions/request/request-events.d.ts new file mode 100644 index 0000000000..c61b3ed65c --- /dev/null +++ b/types/hapi/v17/definitions/request/request-events.d.ts @@ -0,0 +1,45 @@ +import * as Podium from "podium"; + +/** + * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). + * 'finish' - emitted when the request payload finished reading. The event method signature is function (). + * 'disconnect' - emitted when a request errors or aborts unexpectedly. + * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) + */ +export type RequestEventType = "peek" | "finish" | "disconnect"; + +/** + * Access: read only and the public podium interface. + * The request.events supports the following events: + * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). + * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). + * * 'disconnect' - emitted when a request errors or aborts unexpectedly. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) + */ +export interface RequestEvents extends Podium { + + /** + * Access: read only and the public podium interface. + * The request.events supports the following events: + * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). + * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). + * * 'disconnect' - emitted when a request errors or aborts unexpectedly. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) + */ + on(criteria: RequestEventType, listener: Function): void; + + /** + * Access: read only and the public podium interface. + * The request.events supports the following events: + * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). + * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). + * * 'disconnect' - emitted when a request errors or aborts unexpectedly. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) + */ + once(criteria: RequestEventType, listener: Function): void; + + + + // TODO is it necessary to implement "emmit" event here? + +} diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index c77614ee9d..8d004553da 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -9,6 +9,7 @@ import {RequestRoute} from "./request-route"; import {RequestAuth} from "./request-auth"; import {RequestInfo} from "./request-info"; import * as Podium from "podium"; +import {RequestEvents} from "hapi"; /** * TODO both objects ReplyValue and _ReplyValue I found in the v16 TS definition, but I don't found it in the documentation. Need review. @@ -61,7 +62,7 @@ export interface Request extends Podium { * * 'disconnect' - emitted when a request errors or aborts unexpectedly. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) */ - events: 'peek' | 'finish' | 'disconnect'; // TODO I think it's wrong. Maybe is events.on(' ', ' '). It needs revision. + events: RequestEvents; /** * The raw request headers (references request.raw.req.headers). From eebddd8c141ec345589273af7b19aeff510fce34 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Fri, 8 Dec 2017 11:47:33 -0300 Subject: [PATCH 064/298] Add RequestEvents type in index.d.ts --- types/hapi/v17/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index de0cb95cca..f2b0f40c22 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -15,6 +15,7 @@ export * from './definitions/plugin/plugin-registered' /** REQUEST */ export * from './definitions/request/request' export * from './definitions/request/request-auth' +export * from './definitions/request/request-events' export * from './definitions/request/request-info' export * from './definitions/request/request-route' From 81a8109fede35a74225b79f7d03dd7cf01af1041 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Fri, 8 Dec 2017 12:19:12 -0300 Subject: [PATCH 065/298] Separate ServerEvents in a new file. Fixed method overriding from Podium interface. I hope. --- .../v17/definitions/server/server-events.d.ts | 98 ++++++++++++++++++- types/hapi/v17/definitions/server/server.d.ts | 98 +++---------------- 2 files changed, 109 insertions(+), 87 deletions(-) diff --git a/types/hapi/v17/definitions/server/server-events.d.ts b/types/hapi/v17/definitions/server/server-events.d.ts index 7d0d600e6b..16e81f34ef 100644 --- a/types/hapi/v17/definitions/server/server-events.d.ts +++ b/types/hapi/v17/definitions/server/server-events.d.ts @@ -1,4 +1,4 @@ -import Podium = require("../../../../podium/index"); +import * as Podium from "podium"; /** * an event name string. @@ -54,3 +54,99 @@ export interface ServerEventCriteria { /** if true and the criteria object passed to server.event.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end. Defaults to the event registration option (which defaults to false). */ tags?: boolean; } + +/** + * Access: podium public interface. + * The server events emitter. Utilizes the podium with support for event criteria validation, channels, and filters. + * Use the following methods to interact with server.events: + * [server.event(events)](https://github.com/hapijs/hapi/blob/master/API.md#server.event()) - register application events. + * [server.events.emit(criteria, data)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.emit()) - emit server events. + * [server.events.on(criteria, listener)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) - subscribe to all events. + * [server.events.once(criteria, listener)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.once()) - subscribe to + * Other methods include: server.events.removeListener(name, listener), server.events.removeAllListeners(name), and server.events.hasListeners(name). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) + */ +export interface ServerEvents extends Podium { + + /** + * Emits a custom application event to all the subscribed listeners where: + * @param criteria - the event update criteria which must be one of: + * * the event name string. + * * an object with the following optional keys (unless noted otherwise): + * * * name - the event name string (required). + * * * channel - the channel name string. + * * * tags - a tag string or array of tag strings. + * @param data - the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. + * @return Return value: none. + * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsemitcriteria-data) + */ + emit(criteria: string, data: any): void; + emit(criteria: {name: string, channel?: string, tags?: string | string[]}, data: any): void; + + /** + * Subscribe to an event where: + * @param criteria - the subscription criteria which must be one of: + * * event name string which can be any of the built-in server events + * * a custom application event registered with server.event(). + * * a criteria object + * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. + * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncriteria-listener) + * See ['log' event](https://github.com/hapijs/hapi/blob/master/API.md#-log-event) + * See ['request' event](https://github.com/hapijs/hapi/blob/master/API.md#-request-event) + * See ['response' event](https://github.com/hapijs/hapi/blob/master/API.md#-response-event) + * See ['route' event](https://github.com/hapijs/hapi/blob/master/API.md#-route-event) + * See ['start' event](https://github.com/hapijs/hapi/blob/master/API.md#-start-event) + * See ['stop' event](https://github.com/hapijs/hapi/blob/master/API.md#-stop-event) + */ + on(criteria: string, listener: Function): void; + on(criteria: ServerEventsApplicationObject, listener: Function): void; + on(criteria: ServerEventCriteria, listener: Function): void; + + /** + * Same as calling [server.events.on()](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) with the count option set to 1. + * @param criteria - the subscription criteria which must be one of: + * * event name string which can be any of the built-in server events + * * a custom application event registered with server.event(). + * * a criteria object + * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. + * @return Return value: none. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) + */ + once(criteria: string, listener: (...args: any[]) => void): void; // TODO I am not sure if the best way (here and the functions above/below) is use Function or (...args: any[]) => void) considering the JSDocs "The function signature depends on the event argument" + once(criteria: ServerEventsApplicationObject, listener: Function): void; + once(criteria: ServerEventCriteria, listener: Function): void; + + /** + * Same as calling server.events.on() with the count option set to 1. + * @param criteria - the subscription criteria which must be one of: + * * event name string which can be any of the built-in server events + * * a custom application event registered with server.event(). + * * a criteria object + * @return Return value: a promise that resolves when the event is emitted. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsoncecriteria) + */ + once(criteria: string): any; + once(criteria: ServerEventsApplicationObject): any; + once(criteria: ServerEventCriteria): any; + + /** + * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumremovelistenername-listener) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) + */ + removeListener(name: string, listener: Podium.Listener): Podium; + + /** + * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumremovealllistenersname) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) + */ + removeAllListeners(name: string): Podium; + + /** + * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumhaslistenersname) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) + */ + hasListeners(name: string): boolean; + +} diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 8c6a37baeb..8f0e792a06 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -13,9 +13,8 @@ import { ResponseToolkit, RouteCompressionEncoderSettings, ServerAuth, - ServerEventCriteria, + ServerEvents, ServerEventsApplication, - ServerEventsApplicationObject, ServerExtEventsObject, ServerExtEventsRequestObject, ServerExtOptions, @@ -106,90 +105,17 @@ export class Server extends Podium { event(events: ServerEventsApplication): void; event(events: ServerEventsApplication[]): void; - events: { - - /** - * Emits a custom application event to all the subscribed listeners where: - * @param criteria - the event update criteria which must be one of: - * * the event name string. - * * an object with the following optional keys (unless noted otherwise): - * * * name - the event name string (required). - * * * channel - the channel name string. - * * * tags - a tag string or array of tag strings. - * @param data - the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. - * @return Return value: none. - * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsemitcriteria-data) - */ - emit(criteria: string, data: any): void; - emit(criteria: {name: string, channel?: string, tags?: string | string[]}, data: any): void; - - /** - * Subscribe to an event where: - * @param criteria - the subscription criteria which must be one of: - * * event name string which can be any of the built-in server events - * * a custom application event registered with server.event(). - * * a criteria object - * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncriteria-listener) - * See ['log' event](https://github.com/hapijs/hapi/blob/master/API.md#-log-event) - * See ['request' event](https://github.com/hapijs/hapi/blob/master/API.md#-request-event) - * See ['response' event](https://github.com/hapijs/hapi/blob/master/API.md#-response-event) - * See ['route' event](https://github.com/hapijs/hapi/blob/master/API.md#-route-event) - * See ['start' event](https://github.com/hapijs/hapi/blob/master/API.md#-start-event) - * See ['stop' event](https://github.com/hapijs/hapi/blob/master/API.md#-stop-event) - */ - on(criteria: string, listener: Function): void; - on(criteria: ServerEventsApplicationObject, listener: Function): void; - on(criteria: ServerEventCriteria, listener: Function): void; - - /** - * Same as calling [server.events.on()](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) with the count option set to 1. - * @param criteria - the subscription criteria which must be one of: - * * event name string which can be any of the built-in server events - * * a custom application event registered with server.event(). - * * a criteria object - * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) - */ - once(criteria: string, listener: (...args: any[]) => void): void; // TODO I am not sure if the best way is use Function or (...args: any[]) => void) considering the JSDocs "The function signature depends on the event argument" - once(criteria: ServerEventsApplicationObject, listener: Function): void; - once(criteria: ServerEventCriteria, listener: Function): void; - - /** - * Same as calling server.events.on() with the count option set to 1. - * @param criteria - the subscription criteria which must be one of: - * * event name string which can be any of the built-in server events - * * a custom application event registered with server.event(). - * * a criteria object - * @return Return value: a promise that resolves when the event is emitted. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsoncecriteria) - */ - once(criteria: string): any; - once(criteria: ServerEventsApplicationObject): any; - once(criteria: ServerEventCriteria): any; - - /** - * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumremovelistenername-listener) - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) - */ - removeListener(name: string, listener: Function): void; - - /** - * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumremovealllistenersname) - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) - */ - removeAllListeners(name: string): void; - - /** - * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumhaslistenersname) - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) - */ - hasListeners(name: string): boolean; - - }; + /** + * Access: podium public interface. + * The server events emitter. Utilizes the podium with support for event criteria validation, channels, and filters. + * Use the following methods to interact with server.events: + * [server.events.emit(criteria, data)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.emit()) - emit server events. + * [server.events.on(criteria, listener)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) - subscribe to all events. + * [server.events.once(criteria, listener)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.once()) - subscribe to + * Other methods include: server.events.removeListener(name, listener), server.events.removeAllListeners(name), and server.events.hasListeners(name). + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) + */ + events: ServerEvents; /** * An object containing information about the server where: From bbfeda585bd4ae6ddaa413d705e34a176f7bad30 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Fri, 8 Dec 2017 12:22:32 -0300 Subject: [PATCH 066/298] Add events (server and request) test files. --- types/hapi/v17/test/index.test.d.ts | 5 ++ types/hapi/v17/test/request/event-types.ts | 71 +++++++++++++++++++ .../v17/test/server/server-events-once.ts | 26 +++++++ 3 files changed, 102 insertions(+) create mode 100644 types/hapi/v17/test/request/event-types.ts create mode 100644 types/hapi/v17/test/server/server-events-once.ts diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/index.test.d.ts index 9e98fa9c31..35555aa057 100644 --- a/types/hapi/v17/test/index.test.d.ts +++ b/types/hapi/v17/test/index.test.d.ts @@ -17,10 +17,15 @@ export * from './reply/continue'; export * from './reply/redirect'; export * from './reply/reply'; export * from './reply/state_cookie'; + +export * from './request/event-types'; + export * from './response/error'; export * from './server/app'; export * from './server/info'; +export * from './server/server-events-once'; export * from './server/table'; + diff --git a/types/hapi/v17/test/request/event-types.ts b/types/hapi/v17/test/request/event-types.ts new file mode 100644 index 0000000000..ae1c0ac081 --- /dev/null +++ b/types/hapi/v17/test/request/event-types.ts @@ -0,0 +1,71 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents +// From https://github.com/hapijs/hapi/blob/master/API.md#-requestevents +import { + Request, RequestExtPointFunction, ResponseToolkit, RouteOptions, Server, ServerOptions, + ServerRoute +} from "hapi"; +import * as Crypto from 'crypto'; + +const options: ServerOptions = { + port: 8000, +}; + +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + return 'ok: ' + request.path; + } +}; + +const onRequest: RequestExtPointFunction = function (request: Request, h: ResponseToolkit) { + + /* + * Server events + */ + request.server.events.on('request', (request: Request, event: any, tags: any) => { + console.log(request.paramsArray); + console.log(event); + console.log(tags); + }); + + request.server.events.on('response', (request: Request) => { + console.log('Response sent for request: ' + request.path); + }); + + request.server.events.on('start', (route: RouteOptions) => { + console.log('Server started'); + }); + + request.server.events.once('stop', (route: RouteOptions) => { + console.log('Server stoped'); + }); + + /* + * Request events + */ + const hash = Crypto.createHash('sha1'); + + request.events.on("peek", (chunk: any) => { + hash.update(chunk); + }); + + request.events.once("finish", () => { + console.log(hash.digest('hex')); + }); + + request.events.once("disconnect", () => { + console.error('request aborted'); + }); + + return h.continue; + +}; + +const server = new Server(options); +server.route(serverRoute); +server.ext('onRequest', onRequest); + +server.start(); +console.log('Server started at: ' + server.info.uri); + diff --git a/types/hapi/v17/test/server/server-events-once.ts b/types/hapi/v17/test/server/server-events-once.ts new file mode 100644 index 0000000000..d36deb10bb --- /dev/null +++ b/types/hapi/v17/test/server/server-events-once.ts @@ -0,0 +1,26 @@ +// from https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; + +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + return 'oks: ' + request.path; + } +}; + +const server = new Server(options); +server.route(serverRoute); +server.event('test1'); +server.event('test2'); +server.events.once('test1', function(update: any) {console.log(update);}); +server.events.once('test2', function(...args: any[]) {console.log(args);}); +server.events.emit('test1', 'hello-1'); +server.events.emit('test2', 'hello-2'); // Ignored + +server.start(); +console.log('Server started at: ' + server.info.uri); From ad6ae77e6d53256527d8a561fdbf9324ddbd8cb2 Mon Sep 17 00:00:00 2001 From: devuxer Date: Fri, 8 Dec 2017 09:13:52 -0800 Subject: [PATCH 067/298] Replaced TouchTap w/ Click in Snackbar --- types/material-ui/material-ui-tests.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/material-ui/material-ui-tests.tsx b/types/material-ui/material-ui-tests.tsx index ab1abc4577..3187188e99 100644 --- a/types/material-ui/material-ui-tests.tsx +++ b/types/material-ui/material-ui-tests.tsx @@ -5736,7 +5736,7 @@ class SnackbarExampleAction extends Component<{}, {open?: boolean, autoHideDurat }); } - handleActionTouchTap = () => { + handleActionClick = () => { this.setState({ open: false, }); @@ -5774,7 +5774,7 @@ class SnackbarExampleAction extends Component<{}, {open?: boolean, autoHideDurat message={this.state.message} action="undo" autoHideDuration={this.state.autoHideDuration} - onActionTouchTap={this.handleActionTouchTap} + onActionClick={this.handleActionClick} onRequestClose={this.handleRequestClose} /> From 833eeee25bdedb2073f92a447b4212289481226b Mon Sep 17 00:00:00 2001 From: Sergei Dryganets Date: Fri, 8 Dec 2017 12:11:54 -0800 Subject: [PATCH 068/298] some of the not implemented lint rules disabled for react --- types/react/tslint.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/react/tslint.json b/types/react/tslint.json index c09aa3940e..6a9d91ddbd 100644 --- a/types/react/tslint.json +++ b/types/react/tslint.json @@ -6,6 +6,8 @@ "no-any-union": false, "no-object-literal-type-assertion": false, "no-unnecessary-generics": false, - "no-void-expression": false + "no-void-expression": false, + "strict-export-declare-modifiers": false, + "void-return": false } } From e189cf6b5e09901f6c068fc78960e37fa129ec77 Mon Sep 17 00:00:00 2001 From: "Rafael S. Fijalkowski" Date: Fri, 8 Dec 2017 19:10:47 -0300 Subject: [PATCH 069/298] Replacing any with object. Following the idea of @ctaggart (#4) Review of TS types using 'object' and 'any' mainly. --- .../definitions/plugin/plugin-registered.d.ts | 2 +- .../v17/definitions/request/request-auth.d.ts | 4 +-- .../hapi/v17/definitions/request/request.d.ts | 36 +++++++++---------- .../definitions/response/response-object.d.ts | 4 +-- .../response/response-toolkit.d.ts | 6 ++-- .../route/route-options-access.d.ts | 2 +- .../route/route-options-payload.d.ts | 2 +- .../route/route-options-response.d.ts | 6 ++-- .../route/route-options-validate.d.ts | 14 ++++---- .../v17/definitions/route/route-options.d.ts | 11 +++--- .../server/server-auth-scheme.d.ts | 4 +-- .../v17/definitions/server/server-auth.d.ts | 2 +- .../v17/definitions/server/server-ext.d.ts | 2 +- .../v17/definitions/server/server-inject.d.ts | 8 ++--- .../v17/definitions/server/server-method.d.ts | 5 +-- .../definitions/server/server-options.d.ts | 2 +- .../v17/definitions/server/server-realm.d.ts | 10 +++--- .../definitions/server/server-register.d.ts | 2 +- .../v17/definitions/server/server-route.d.ts | 4 +-- .../server/server-state-options.d.ts | 4 +-- .../v17/definitions/server/server-state.d.ts | 4 +-- types/hapi/v17/definitions/server/server.d.ts | 16 ++++----- 22 files changed, 75 insertions(+), 75 deletions(-) diff --git a/types/hapi/v17/definitions/plugin/plugin-registered.d.ts b/types/hapi/v17/definitions/plugin/plugin-registered.d.ts index 9ee3987a10..e83eb81a63 100644 --- a/types/hapi/v17/definitions/plugin/plugin-registered.d.ts +++ b/types/hapi/v17/definitions/plugin/plugin-registered.d.ts @@ -28,6 +28,6 @@ export interface PluginRegistered { /** * options used to register the plugin. */ - options: any; // OptionsPassedToPlugin; + options: object; } diff --git a/types/hapi/v17/definitions/request/request-auth.d.ts b/types/hapi/v17/definitions/request/request-auth.d.ts index 2382697da0..a11dd07467 100644 --- a/types/hapi/v17/definitions/request/request-auth.d.ts +++ b/types/hapi/v17/definitions/request/request-auth.d.ts @@ -11,9 +11,9 @@ */ export interface RequestAuth { /** an artifact object received from the authentication strategy and used in authentication-related actions. */ - artifacts: any; + artifacts: object; /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ - credentials: any; + credentials: object; /** the authentication error is failed and mode set to 'try'. */ error: Error; /** true if the request has been successfully authenticated, otherwise false. */ diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index 8d004553da..2a92b8a142 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -11,21 +11,14 @@ import {RequestInfo} from "./request-info"; import * as Podium from "podium"; import {RequestEvents} from "hapi"; -/** - * TODO both objects ReplyValue and _ReplyValue I found in the v16 TS definition, but I don't found it in the documentation. Need review. - * TODO I think it's not very elegant solution - */ -export type ReplyValue = _ReplyValue | Promise<_ReplyValue>; -export type _ReplyValue = null | undefined | string | number | boolean | Buffer | Error | stream.Stream | Object; // | array; - /** * An object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestorig) */ export interface RequestOrig { - params: any; - query: any; - payload: any; + params: object; + query: object; + payload: object; } /** @@ -39,7 +32,7 @@ export interface Request extends Podium { * Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestapp) */ - app: any; + app: object; /** * Authentication information: @@ -92,7 +85,7 @@ export interface Request extends Podium { * An array containing the logged request events. * Note that this array will be empty if route log.collect is set to false. */ - readonly logs: any[]; + readonly logs: object[]; /** * The request method in lower case (e.g. 'get', 'post'). @@ -128,7 +121,7 @@ export interface Request extends Podium { * The request payload based on the route payload.output and payload.parse settings. * TODO check this typing and add references / links. */ - readonly payload: stream.Readable | Buffer | any; + readonly payload: stream.Readable | Buffer | string | object; /** * Plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. @@ -138,7 +131,7 @@ export interface Request extends Podium { /** * An object where each key is the name assigned by a route pre-handler methods function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. */ - readonly pre: Object; + readonly pre: Util.Dictionary; /** * Access: read / write (see limitations below). @@ -149,12 +142,12 @@ export interface Request extends Podium { /** * Same as pre but represented as the response object created by the pre method. */ - readonly preResponses: Object; + readonly preResponses: Util.Dictionary; /** * By default the object outputted from node's URL parse() method. Might also be set indirectly via request.setUrl in which case it may be a string (if url is set to an object with the query attribute as an unparsed string). */ - readonly query: any; + readonly query: object; /** * An object containing the Node HTTP server objects. Direct interaction with these raw objects is not recommended. @@ -187,7 +180,7 @@ export interface Request extends Podium { /** * An object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. */ - readonly state: Util.Dictionary; + readonly state: Map; /** * The parsed request URI. @@ -199,9 +192,11 @@ export interface Request extends Podium { * @param source - the value to set as the source of the reply interface, optional. * @param options - options for the method, optional. * @return ResponseObject - * [See docs](https://hapijs.com/api/17.0.1#request.generateResponse()) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestgenerateresponsesource-options) */ - generateResponse(source?: ReplyValue, options?: {marshal?: any; prepare?: any; close?: any; variety?: any}): ResponseObject; + generateResponse(source: object, options?: {variety?: string; prepare?: Function; marshal?: Function; close?: Function; }): ResponseObject; + generateResponse(source: string, options?: {variety?: string; prepare?: Function; marshal?: Function; close?: Function; }): ResponseObject; + generateResponse(source: null, options?: {variety?: string; prepare?: Function; marshal?: Function; close?: Function; }): ResponseObject; /** * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. The arguments are: @@ -211,7 +206,8 @@ export interface Request extends Podium { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data) */ - log(tags: string | string[], data?: string | Object | (() => string | Object)): void; + log(tags: string, data?: string | object | (() => string | object)): void; + log(tags: string[], data?: string | object | (() => string | object)): void; /** * Validates a request against the route's authentication access configuration, where: diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/v17/definitions/response/response-object.d.ts index c2ffd457fa..71415c0b33 100644 --- a/types/hapi/v17/definitions/response/response-object.d.ts +++ b/types/hapi/v17/definitions/response/response-object.d.ts @@ -35,7 +35,7 @@ export interface ResponseObject extends Podium { * Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseapp) */ - app: any; + app: object; /** * Access: read only and the public podium interface. @@ -44,7 +44,7 @@ export interface ResponseObject extends Podium { * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). * [See docs](https://hapijs.com/api/17.0.1#-responseevents) */ - readonly events: any; // TODO need to be implemented. I didn't understand yet. + readonly events: object; // TODO need to be implemented. I didn't understand yet. /** * Default value: {}. diff --git a/types/hapi/v17/definitions/response/response-toolkit.d.ts b/types/hapi/v17/definitions/response/response-toolkit.d.ts index ae737bf085..0ab64f10b0 100644 --- a/types/hapi/v17/definitions/response/response-toolkit.d.ts +++ b/types/hapi/v17/definitions/response/response-toolkit.d.ts @@ -52,7 +52,7 @@ export interface ResponseToolkit { * The [request] object. This is a duplication of the request lifecycle method argument used by * [toolkit decorations](https://github.com/hapijs/hapi/blob/master/API.md#server.decorate()) to access the current request. */ - request: any; // TODO needs review + request: object; // TODO needs review /** * Used by the [authentication] method to pass back valid credentials where: @@ -61,7 +61,7 @@ export interface ResponseToolkit { * * artifacts - (optional) authentication artifacts object specific to the authentication scheme. * @return Return value: an internal authentication object. */ - authenticated(data: {credentials: any, artifacts?: any}): any; + authenticated(data: {credentials: object, artifacts?: object}): object; /** * Sets the response 'ETag' and 'Last-Modified' headers and checks for any conditional request headers to decide if @@ -125,7 +125,7 @@ export interface ResponseToolkit { * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hunauthenticatederror-data) */ unauthenticated(error: Error): void; - unauthenticated(error: Error, data: {credentials: any, artifacts?: any}): void; + unauthenticated(error: Error, data: {credentials: object, artifacts?: object}): void; /** * Clears a response cookie using the same arguments as diff --git a/types/hapi/v17/definitions/route/route-options-access.d.ts b/types/hapi/v17/definitions/route/route-options-access.d.ts index 8bc175b10a..57cd13e405 100644 --- a/types/hapi/v17/definitions/route/route-options-access.d.ts +++ b/types/hapi/v17/definitions/route/route-options-access.d.ts @@ -46,7 +46,7 @@ export interface RouteOptionsAccess { * An object or array of objects specifying the route access rules. Each rule is evaluated against an incoming request and access is granted if at least one of the rules matches. Each rule object must include at least one of scope or entity. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccess) */ - access?: any | any[]; + access?: object | object[]; /** * Default value: false (no scope requirements). diff --git a/types/hapi/v17/definitions/route/route-options-payload.d.ts b/types/hapi/v17/definitions/route/route-options-payload.d.ts index c07bf45fd4..c48d09aa0c 100644 --- a/types/hapi/v17/definitions/route/route-options-payload.d.ts +++ b/types/hapi/v17/definitions/route/route-options-payload.d.ts @@ -12,7 +12,7 @@ export type PayloadOutput = 'data' | 'stream' | 'file'; /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) */ -export type PayloadCompressionDecoderSettings = any; +export type PayloadCompressionDecoderSettings = object; /** * Determines how the request payload is processed. diff --git a/types/hapi/v17/definitions/route/route-options-response.d.ts b/types/hapi/v17/definitions/route/route-options-response.d.ts index cbf389e862..16c2249e29 100644 --- a/types/hapi/v17/definitions/route/route-options-response.d.ts +++ b/types/hapi/v17/definitions/route/route-options-response.d.ts @@ -9,6 +9,8 @@ export enum EmptyStatusCode { HTTP_204 = 204, } +export type RouteOptionsResponseSchema = boolean | ValidationOptions | ((value: object, options: object) => Function); + /** * Processing rules for the outgoing response. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponse) @@ -69,7 +71,7 @@ export interface RouteOptionsResponse { * * * if the function returns a value and modify is true, the value is used as the new response. If the original response is an error, the return value is used to override the original error output.payload. If an error is thrown, the error is processed according to failAction. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseschema) */ - schema?: boolean | ValidationOptions | ((value: any, options: any) => Function); // TODO it must be better + schema?: RouteOptionsResponseSchema; /** * Default value: none. @@ -77,6 +79,6 @@ export interface RouteOptionsResponse { * status is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsestatus) */ - status?: Util.Dictionary; // TODO it must be better + status?: Map; } diff --git a/types/hapi/v17/definitions/route/route-options-validate.d.ts b/types/hapi/v17/definitions/route/route-options-validate.d.ts index 6fba5dfc67..7fa61d5bef 100644 --- a/types/hapi/v17/definitions/route/route-options-validate.d.ts +++ b/types/hapi/v17/definitions/route/route-options-validate.d.ts @@ -1,4 +1,4 @@ -import {Lifecycle} from "hapi"; +import {Lifecycle, RouteOptionsResponseSchema} from "hapi"; import {ValidationOptions} from "joi"; /** @@ -13,7 +13,7 @@ export interface RouteOptionsValidate { * An optional object with error fields copied into every validation error response. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateerrorfields) */ - errorFields?: any; + errorFields?: object; /** * Default value: 'error' (return a Bad Request (400) error response). @@ -34,7 +34,7 @@ export interface RouteOptionsValidate { * Note that all header field names must be in lowercase to match the headers normalized by node. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateheaders) */ - headers?: boolean | ValidationOptions | ((value: any, option: any) => Function); + headers?: RouteOptionsResponseSchema; /** * Default value: none. @@ -45,7 +45,7 @@ export interface RouteOptionsValidate { * If the validation rules for headers, params, query, and payload are defined at both the server routes level and at the route level, the individual route settings override the routes defaults (the rules are not merged). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateparams) */ - options?: ValidationOptions | Object; // TODO need review + options?: ValidationOptions | object; /** * Default value: true (no validation). @@ -59,7 +59,7 @@ export interface RouteOptionsValidate { * Note that failing to match the validation rules to the route path parameters definition will cause all requests to fail. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateparams) */ - params?: boolean | ValidationOptions | ((value: any, option: any) => Function); // TODO need review + params?: RouteOptionsResponseSchema; /** * Default value: true (no validation). @@ -73,7 +73,7 @@ export interface RouteOptionsValidate { * Note that validating large payloads and modifying them will cause memory duplication of the payload (since the original is kept), as well as the significant performance cost of validating large amounts of data. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidatepayload) */ - payload?: boolean | ValidationOptions | ((value: any, option: any) => Function); // TODO need review + payload?: RouteOptionsResponseSchema; /** * Default value: true (no validation). @@ -87,6 +87,6 @@ export interface RouteOptionsValidate { * Note that changes to the query parameters will not be reflected in request.url. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidatequery) */ - query?: boolean | ValidationOptions | ((value: any, option: any) => Function); // TODO need review + query?: RouteOptionsResponseSchema; } diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/v17/definitions/route/route-options.d.ts index 5f8523b322..daf0005ddd 100644 --- a/types/hapi/v17/definitions/route/route-options.d.ts +++ b/types/hapi/v17/definitions/route/route-options.d.ts @@ -15,7 +15,7 @@ import {Lifecycle} from "hapi"; * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression) * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder) */ -export type RouteCompressionEncoderSettings = any; +export type RouteCompressionEncoderSettings = object; /** * Each route can be customized to change the default behavior of the request lifecycle. @@ -27,7 +27,7 @@ export interface RouteOptions { * Application-specific route configuration state. Should not be used by plugins which should use options.plugins[name] instead. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsapp) */ - app?: any; + app?: object; /** * Route authentication configuration. Value can be: @@ -43,7 +43,7 @@ export interface RouteOptions { * An object passed back to the provided handler (via this) when called. Ignored if the method is an arrow function. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsbind) */ - bind?: any; + bind?: object; /** * Default value: { privacy: 'default', statuses: [200], otherwise: 'no-cache' }. @@ -93,8 +93,9 @@ export interface RouteOptions { * Default value: none. * Route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the server.ext(events) event argument. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsext) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) */ - ext?: any; //TODO need to review and rewrite this definition // I saw again and I keep not understanding. + ext?: object; /** * Default value: { relativeTo: '.' }. @@ -114,7 +115,7 @@ export interface RouteOptions { * Note: handlers using a fat arrow style function cannot be bound to any bind property. Instead, the bound context is available under h.context. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionshandler) */ - handler?: Lifecycle.Method | Object; //TODO need to review + handler?: Lifecycle.Method | object; /** * Default value: none. diff --git a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts index 52a7b732a3..55aa77eba1 100644 --- a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts +++ b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts @@ -7,7 +7,7 @@ import {Lifecycle} from "hapi"; * The scheme options argument passed to server.auth.strategy() when instantiation a strategy. * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme) */ -export type ServerAuthSchemeOptions = any; +export type ServerAuthSchemeOptions = object; /** * the method implementing the scheme with signature function(server, options) where: @@ -28,7 +28,7 @@ export interface ServerAuthSchemeObject { /** * optional object which is exposed via the [server.auth.api](https://github.com/hapijs/hapi/blob/master/API.md#server.auth.api) object. */ - api?: any; + api?: object; /** * A lifecycle method function called for each incoming request configured with the authentication scheme. The diff --git a/types/hapi/v17/definitions/server/server-auth.d.ts b/types/hapi/v17/definitions/server/server-auth.d.ts index 785cee3a9d..d49b12439d 100644 --- a/types/hapi/v17/definitions/server/server-auth.d.ts +++ b/types/hapi/v17/definitions/server/server-auth.d.ts @@ -77,7 +77,7 @@ export interface ServerAuth { * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthstrategyname-scheme-options) */ strategy(name: string, scheme: string): void; - strategy(name: string, scheme: string, options: any): void; + strategy(name: string, scheme: string, options: object): void; /** * Tests a request against an authentication strategy where: diff --git a/types/hapi/v17/definitions/server/server-ext.d.ts b/types/hapi/v17/definitions/server/server-ext.d.ts index 40d0969f09..ce73328b6c 100644 --- a/types/hapi/v17/definitions/server/server-ext.d.ts +++ b/types/hapi/v17/definitions/server/server-ext.d.ts @@ -91,7 +91,7 @@ export interface RequestExtPointFunction extends Lifecycle.Method { export interface ServerExtOptions { before: string | string[]; after: string | string[]; - bind: any; + bind: object; sandbox?: 'server' | 'plugin'; } diff --git a/types/hapi/v17/definitions/server/server-inject.d.ts b/types/hapi/v17/definitions/server/server-inject.d.ts index cb04ba3aab..21ba1a8afa 100644 --- a/types/hapi/v17/definitions/server/server-inject.d.ts +++ b/types/hapi/v17/definitions/server/server-inject.d.ts @@ -23,9 +23,9 @@ import * as Shot from "shot"; * For context [Shot module](https://github.com/hapijs/shot) */ export interface ServerInjectOptions extends Shot.RequestOptions { - credentials?: any; - artifacts?: any; - app?: any; + credentials?: object; + artifacts?: object; + app?: object; plugins?: PluginsStates; allowInternals?: boolean; } @@ -45,6 +45,6 @@ export interface ServerInjectOptions extends Shot.RequestOptions { * For context [Shot module](https://github.com/hapijs/shot) */ export interface ServerInjectResponse extends Shot.ResponseObject { - result: any; + result: object | undefined; request: Request; } diff --git a/types/hapi/v17/definitions/server/server-method.d.ts b/types/hapi/v17/definitions/server/server-method.d.ts index 9806ffc5cb..e24f36cf74 100644 --- a/types/hapi/v17/definitions/server/server-method.d.ts +++ b/types/hapi/v17/definitions/server/server-method.d.ts @@ -8,7 +8,8 @@ import * as catbox from "catbox"; * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) */ export interface ServerMethod { - (args: any[], flags: {ttl?: number}): any; +// (args: any[], flags: {ttl?: number}): any; + (...args: any[]): any; // TODO it needs review. Look the doc: the first param is a ...args and the second is "flags". Typescript supports ...args only in the last param } /** @@ -29,7 +30,7 @@ export interface ServerMethodCache extends catbox.PolicyOptions { * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) */ export interface ServerMethodOptions { - bind: any; + bind: object; cache: ServerMethodCache; generateKey: Function; } diff --git a/types/hapi/v17/definitions/server/server-options.d.ts b/types/hapi/v17/definitions/server/server-options.d.ts index 4273a01988..dd96c8ea3a 100644 --- a/types/hapi/v17/definitions/server/server-options.d.ts +++ b/types/hapi/v17/definitions/server/server-options.d.ts @@ -26,7 +26,7 @@ export interface ServerOptions { * Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsapp) */ - app?: any; + app?: object; /** * Default value: true. diff --git a/types/hapi/v17/definitions/server/server-realm.d.ts b/types/hapi/v17/definitions/server/server-realm.d.ts index 289ea48018..ba60524ebd 100644 --- a/types/hapi/v17/definitions/server/server-realm.d.ts +++ b/types/hapi/v17/definitions/server/server-realm.d.ts @@ -1,8 +1,8 @@ import {PluginsStates} from "../plugin/plugin"; /** - The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When registering a plugin or an authentication scheme, a server object reference is provided with a new server.realm container specific to that registration. It allows each plugin to maintain its own settings without leaking and affecting other plugins. - For example, a plugin can set a default file path for local resources without breaking other plugins' configured paths. When calling server.bind(), the active realm's settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). + * The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When registering a plugin or an authentication scheme, a server object reference is provided with a new server.realm container specific to that registration. It allows each plugin to maintain its own settings without leaking and affecting other plugins. + * For example, a plugin can set a default file path for local resources without breaking other plugins' configured paths. When calling server.bind(), the active realm's settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). */ export interface ServerRealm { /** when the server object is provided as an argument to the plugin register() method, modifiers provides the registration preferences passed the server.register() method and includes: */ @@ -16,11 +16,11 @@ export interface ServerRealm { } }; /** the realm of the parent server object, or null for the root server. */ - parent: any | null; + parent: object | null; /** the active plugin name (empty string if at the server root). */ plugin: string; /** the plugin options object passed at registration. */ - pluginOptions: any; // OptionsPassedToPlugin; + pluginOptions: object; /** plugin-specific state to be shared only among activities sharing the same active state. plugins is an object where each key is a plugin name and the value is the plugin state. */ plugins: PluginsStates; /** settings overrides */ @@ -28,6 +28,6 @@ export interface ServerRealm { files: { relativeTo: string; }; - bind: any; + bind: object; }; } diff --git a/types/hapi/v17/definitions/server/server-register.d.ts b/types/hapi/v17/definitions/server/server-register.d.ts index 14746bc85a..a16db4547b 100644 --- a/types/hapi/v17/definitions/server/server-register.d.ts +++ b/types/hapi/v17/definitions/server/server-register.d.ts @@ -28,5 +28,5 @@ export interface ServerRegisterOptions { */ export interface ServerRegisterPluginObject extends ServerRegisterOptions { plugin: Plugin; - options?: any; + options?: object; } diff --git a/types/hapi/v17/definitions/server/server-route.d.ts b/types/hapi/v17/definitions/server/server-route.d.ts index 70e0bf1d34..efcc910f57 100644 --- a/types/hapi/v17/definitions/server/server-route.d.ts +++ b/types/hapi/v17/definitions/server/server-route.d.ts @@ -37,11 +37,11 @@ export interface ServerRoute { /** * additional route options. The options value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. */ - options?: Object | ((server: Server) => Function); + options?: object | ((server: Server) => Function); /** * route custom rules object. The object is passed to each rules processor registered with server.rules(). Cannot be used if route.options.rules is defined. */ - rules?: any; + rules?: object; } diff --git a/types/hapi/v17/definitions/server/server-state-options.d.ts b/types/hapi/v17/definitions/server/server-state-options.d.ts index 289507b849..e650309d95 100644 --- a/types/hapi/v17/definitions/server/server-state-options.d.ts +++ b/types/hapi/v17/definitions/server/server-state-options.d.ts @@ -43,13 +43,13 @@ export interface ServerStateCookieOptions { * * password - password used for HMAC key generation (must be at least 32 characters long). */ sign?: { - integrity?: any; // TODO make iron definitions and getting typing from iron + integrity?: object; // TODO make iron definitions and getting typing from iron. Needs review! password: string; }; /** password used for 'iron' encoding (must be at least 32 characters long). */ password?: string; /** options for 'iron' encoding. Defaults to require('iron').defaults. */ - iron?: any; // TODO make iron definitions and getting typing from iron + iron?: object; // TODO make iron definitions and getting typing from iron. Needs review! /** if true, errors are ignored and treated as missing cookies. */ ignoreErrors?: boolean; /** if true, automatically instruct the client to remove invalid cookies. Defaults to false. */ diff --git a/types/hapi/v17/definitions/server/server-state.d.ts b/types/hapi/v17/definitions/server/server-state.d.ts index 1331d32e4a..32107b8f07 100644 --- a/types/hapi/v17/definitions/server/server-state.d.ts +++ b/types/hapi/v17/definitions/server/server-state.d.ts @@ -23,7 +23,7 @@ export interface ServerState { * The server cookies manager. * Access: read only and statehood public interface. */ - readonly states: any; + readonly states: object; /** * The server cookies manager settings. The settings are based on the values configured in [server.options.state](https://github.com/hapijs/hapi/blob/master/API.md#server.options.state). @@ -34,7 +34,7 @@ export interface ServerState { * An object containing the configuration of each cookie added via [server.state()](https://github.com/hapijs/hapi/blob/master/API.md#server.state()) where each key is the * cookie name and value is the configuration object. */ - readonly cookies: any; // TODO what the difference between this one and the settings above? This one should be an array? + readonly cookies: object; /** * An array containing the names of all configued cookies. diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 8f0e792a06..44ab2a5280 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -65,7 +65,7 @@ export class Server extends Podium { * Initialized with an empty object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverapp) */ - app?: any; + app?: object; /** * Server Auth: properties and methods @@ -104,7 +104,7 @@ export class Server extends Podium { */ event(events: ServerEventsApplication): void; event(events: ServerEventsApplication[]): void; - + /** * Access: podium public interface. * The server events emitter. Utilizes the podium with support for event criteria validation, channels, and filters. @@ -177,7 +177,7 @@ export class Server extends Podium { * the server.plugins[name] object directly or via the server.expose() method. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins) */ - plugins: any; + plugins: object; /** * The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When @@ -233,7 +233,7 @@ export class Server extends Podium { * When setting a context inside a plugin, the context is applied only to methods set up by the plugin. Note that the context applies only to routes and extensions added after it has been set. Ignored if the method being bound is an arrow function. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverbindcontext) */ - bind(context: any): void; + bind(context: object): void; /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) @@ -348,7 +348,7 @@ export class Server extends Podium { * objects. Instead favor server.expose(key, value), which only copies a reference to value. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposeobj) */ - expose(obj: Object): void; + expose(obj: object): void; /** * Registers an extension function in one of the request lifecycle extension points where: @@ -441,7 +441,7 @@ export class Server extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverlogtags-data-timestamp) */ - log(tags: string | string[], data?: string | Object | (() => Function), timestamp?: number): void; + log(tags: string | string[], data?: string | object | (() => Function), timestamp?: number): void; /** * Looks up a route configuration where: @@ -556,8 +556,8 @@ export class Server extends Podium { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrulesprocessor-options) */ - rules(processor: (rules: any, info: {method: string, path: string, vhost?: string}) => Function): void; - rules(processor: (rules: any, info: {method: string, path: string, vhost?: string}) => Function, options: {validate: any}): void; // TODO needs implementation + rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => Function): void; + rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => Function, options: {validate: object}): void; // TODO needs implementation /** * Starts the server by listening for incoming requests on the configured port (unless the connection was configured with autoListen set to false). From 9fb4ab18b394a9aec15afee86d80588dbba834f1 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Fri, 8 Dec 2017 19:44:37 -0300 Subject: [PATCH 070/298] Replace Dictionary by Map supported in es6 --- types/hapi/v17/definitions/request/request.d.ts | 8 ++++---- types/hapi/v17/definitions/response/response-object.d.ts | 2 +- .../hapi/v17/definitions/route/route-options-payload.d.ts | 2 +- types/hapi/v17/definitions/route/route-options.d.ts | 6 +++--- types/hapi/v17/definitions/server/server-auth.d.ts | 2 +- types/hapi/v17/definitions/server/server-inject.d.ts | 2 +- types/hapi/v17/definitions/server/server-options.d.ts | 2 +- types/hapi/v17/definitions/server/server-state.d.ts | 4 ++-- types/hapi/v17/definitions/server/server.d.ts | 6 +++--- types/hapi/v17/definitions/util/util.d.ts | 6 ------ 10 files changed, 17 insertions(+), 23 deletions(-) diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index 2a92b8a142..992a117b7d 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -61,7 +61,7 @@ export interface Request extends Podium { * The raw request headers (references request.raw.req.headers). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestheaders) */ - readonly headers: Util.Dictionary; + readonly headers: Map; /** * Request information: @@ -105,7 +105,7 @@ export interface Request extends Podium { /** * An object where each key is a path parameter name with matching value as described in [Path parameters](https://github.com/hapijs/hapi/blob/master/API.md#path-parameters). */ - readonly params: Util.Dictionary; + readonly params: Map; /** * An array containing all the path params values in the order they appeared in the path. @@ -131,7 +131,7 @@ export interface Request extends Podium { /** * An object where each key is the name assigned by a route pre-handler methods function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. */ - readonly pre: Util.Dictionary; + readonly pre: Map; /** * Access: read / write (see limitations below). @@ -142,7 +142,7 @@ export interface Request extends Podium { /** * Same as pre but represented as the response object created by the pre method. */ - readonly preResponses: Util.Dictionary; + readonly preResponses: Map; /** * By default the object outputted from node's URL parse() method. Might also be set indirectly via request.setUrl in which case it may be a string (if url is set to an object with the query attribute as an unparsed string). diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/v17/definitions/response/response-object.d.ts index 71415c0b33..40b827d31b 100644 --- a/types/hapi/v17/definitions/response/response-object.d.ts +++ b/types/hapi/v17/definitions/response/response-object.d.ts @@ -52,7 +52,7 @@ export interface ResponseObject extends Podium { * Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheaders) */ - readonly headers: Util.Dictionary; + readonly headers: Map; /** * Default value: {}. diff --git a/types/hapi/v17/definitions/route/route-options-payload.d.ts b/types/hapi/v17/definitions/route/route-options-payload.d.ts index c48d09aa0c..79efc0d144 100644 --- a/types/hapi/v17/definitions/route/route-options-payload.d.ts +++ b/types/hapi/v17/definitions/route/route-options-payload.d.ts @@ -38,7 +38,7 @@ export interface RouteOptionsPayload { * An object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in compression. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) */ - compression?: Util.Dictionary; + compression?: Map; /** * Default value: 'application/json'. diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/v17/definitions/route/route-options.d.ts index daf0005ddd..8284f9b21a 100644 --- a/types/hapi/v17/definitions/route/route-options.d.ts +++ b/types/hapi/v17/definitions/route/route-options.d.ts @@ -27,7 +27,7 @@ export interface RouteOptions { * Application-specific route configuration state. Should not be used by plugins which should use options.plugins[name] instead. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsapp) */ - app?: object; + app?: any; /** * Route authentication configuration. Value can be: @@ -65,7 +65,7 @@ export interface RouteOptions { * An object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in compression. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression) */ - compression?: Util.Dictionary; + compression?: Map; /** * Default value: false (no CORS headers). @@ -180,7 +180,7 @@ export interface RouteOptions { * Plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsplugins) */ - plugins?: Util.Dictionary; + plugins?: Map; /** * Default value: none. diff --git a/types/hapi/v17/definitions/server/server-auth.d.ts b/types/hapi/v17/definitions/server/server-auth.d.ts index d49b12439d..56e13edc8d 100644 --- a/types/hapi/v17/definitions/server/server-auth.d.ts +++ b/types/hapi/v17/definitions/server/server-auth.d.ts @@ -27,7 +27,7 @@ export interface ServerAuth { * returned from its implementation function. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi) */ - api: Util.Dictionary; + api: Map; /** * Contains the default authentication configuration is a default strategy was set via diff --git a/types/hapi/v17/definitions/server/server-inject.d.ts b/types/hapi/v17/definitions/server/server-inject.d.ts index 21ba1a8afa..e398e1915e 100644 --- a/types/hapi/v17/definitions/server/server-inject.d.ts +++ b/types/hapi/v17/definitions/server/server-inject.d.ts @@ -25,7 +25,7 @@ import * as Shot from "shot"; export interface ServerInjectOptions extends Shot.RequestOptions { credentials?: object; artifacts?: object; - app?: object; + app?: any; plugins?: PluginsStates; allowInternals?: boolean; } diff --git a/types/hapi/v17/definitions/server/server-options.d.ts b/types/hapi/v17/definitions/server/server-options.d.ts index dd96c8ea3a..4273a01988 100644 --- a/types/hapi/v17/definitions/server/server-options.d.ts +++ b/types/hapi/v17/definitions/server/server-options.d.ts @@ -26,7 +26,7 @@ export interface ServerOptions { * Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsapp) */ - app?: object; + app?: any; /** * Default value: true. diff --git a/types/hapi/v17/definitions/server/server-state.d.ts b/types/hapi/v17/definitions/server/server-state.d.ts index 32107b8f07..bfc9568c51 100644 --- a/types/hapi/v17/definitions/server/server-state.d.ts +++ b/types/hapi/v17/definitions/server/server-state.d.ts @@ -39,7 +39,7 @@ export interface ServerState { /** * An array containing the names of all configued cookies. */ - readonly names: Util.Dictionary; + readonly names: string[]; /** * Same as calling [server.state()](https://github.com/hapijs/hapi/blob/master/API.md#server.state()). @@ -67,6 +67,6 @@ export interface ServerState { * Note that this utility uses the server configuration but does not change the server state. It is provided for manual cookie parsing (e.g. when server parsing is disabled). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-async-serverstatesparseheader) */ - parse(header: string): Util.Dictionary; + parse(header: string): Map; } diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 44ab2a5280..4b82f4a8b4 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -65,7 +65,7 @@ export class Server extends Podium { * Initialized with an empty object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverapp) */ - app?: object; + app?: any; /** * Server Auth: properties and methods @@ -104,7 +104,7 @@ export class Server extends Podium { */ event(events: ServerEventsApplication): void; event(events: ServerEventsApplication[]): void; - + /** * Access: podium public interface. * The server events emitter. Utilizes the podium with support for event criteria validation, channels, and filters. @@ -162,7 +162,7 @@ export class Server extends Podium { * server method name is an object property. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethods */ - readonly methods: Util.Dictionary; + readonly methods: Map; /** * Provides access to the server MIME database used for setting content-type information. The object must not be diff --git a/types/hapi/v17/definitions/util/util.d.ts b/types/hapi/v17/definitions/util/util.d.ts index f92b23bb4d..9e2264a257 100644 --- a/types/hapi/v17/definitions/util/util.d.ts +++ b/types/hapi/v17/definitions/util/util.d.ts @@ -1,11 +1,5 @@ export namespace Util { - - export interface Dictionary { - [key: string]: T; - } - export type HTTP_METHODS_PARTIAL_LOWERCASE = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_LOWERCASE; export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; - } From 81e58330cca9951cfc9eb9781a6295957af385fb Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Fri, 8 Dec 2017 19:52:20 -0300 Subject: [PATCH 071/298] Add h.redirect() without param to work with hapijs official tests. --- types/hapi/v17/definitions/response/response-toolkit.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/hapi/v17/definitions/response/response-toolkit.d.ts b/types/hapi/v17/definitions/response/response-toolkit.d.ts index 0ab64f10b0..1157002f99 100644 --- a/types/hapi/v17/definitions/response/response-toolkit.d.ts +++ b/types/hapi/v17/definitions/response/response-toolkit.d.ts @@ -87,6 +87,7 @@ export interface ResponseToolkit { * @return Returns a response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hredirecturi) */ + redirect(): ResponseObject; redirect(uri: string): ResponseObject; /** From 7b4dd11955c9e3ac3620be64848787d40d24c17c Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 8 Dec 2017 15:59:09 -0700 Subject: [PATCH 072/298] fix typo --- types/expo/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/expo/index.d.ts b/types/expo/index.d.ts index 04d500ab6b..bfb1819515 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -1400,7 +1400,7 @@ export interface SvgCommonProps { originY?: number; } -export class Svg extends Component<{ width: number, heigth: number }> { } +export class Svg extends Component<{ width: number, height: number }> { } export class Rect extends Component { } export interface CircleProps extends SvgCommonProps { From b74e40249b1270f30a28147a376d2ee17c3a85c1 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Fri, 8 Dec 2017 20:48:07 -0300 Subject: [PATCH 073/298] Add ResponseEvent types. --- .../definitions/response/response-events.d.ts | 24 +++++++++++++++++++ .../definitions/response/response-object.d.ts | 8 +++---- types/hapi/v17/index.d.ts | 1 + 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 types/hapi/v17/definitions/response/response-events.d.ts diff --git a/types/hapi/v17/definitions/response/response-events.d.ts b/types/hapi/v17/definitions/response/response-events.d.ts new file mode 100644 index 0000000000..469009087c --- /dev/null +++ b/types/hapi/v17/definitions/response/response-events.d.ts @@ -0,0 +1,24 @@ +import * as Podium from "podium"; + +/** + * Access: read only and the public podium interface. + * The response.events object supports the following events: + * * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). + * * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). + * [See docs](https://hapijs.com/api/17.0.1#-responseevents) + */ +export interface ResponseEvents extends Podium { + + /** + * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). + */ + on(criteria: 'peak', listener: Function): void; + once(criteria: 'peak', listener: Function): void; + + /** + * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). + */ + on(criteria: 'finish', listener: Function): void; + once(criteria: 'finish', listener: Function): void; + +} diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/v17/definitions/response/response-object.d.ts index 40b827d31b..1cb2c27862 100644 --- a/types/hapi/v17/definitions/response/response-object.d.ts +++ b/types/hapi/v17/definitions/response/response-object.d.ts @@ -1,9 +1,9 @@ import {PluginsStates} from "../plugin/plugin"; -import {Util} from "../util/util"; import {ResponseSettings} from "./response-settings"; import {ServerStateCookieOptions} from "../server/server-state-options"; import * as Podium from "podium"; import {Json, Lifecycle} from "hapi"; +import {ResponseEvents} from "./response-events"; /** * Object where: @@ -40,11 +40,11 @@ export interface ResponseObject extends Podium { /** * Access: read only and the public podium interface. * The response.events object supports the following events: - * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). - * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). + * * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). + * * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). * [See docs](https://hapijs.com/api/17.0.1#-responseevents) */ - readonly events: object; // TODO need to be implemented. I didn't understand yet. + readonly events: ResponseEvents; /** * Default value: {}. diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index f2b0f40c22..3ded9fe2bf 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -20,6 +20,7 @@ export * from './definitions/request/request-info' export * from './definitions/request/request-route' /** RESPONSE */ +export * from './definitions/response/response-events' export * from './definitions/response/response-object' export * from './definitions/response/response-settings' export * from './definitions/response/response-toolkit' From baeccd245e804f5fa82b9160aaaa368d98be0aae Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Fri, 8 Dec 2017 20:49:42 -0300 Subject: [PATCH 074/298] Add request.route.auth.access() method --- .../definitions/request/request-route.d.ts | 21 ++++++++++++++++++- .../hapi/v17/definitions/request/request.d.ts | 19 ++--------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/types/hapi/v17/definitions/request/request-route.d.ts b/types/hapi/v17/definitions/request/request-route.d.ts index 531b60f796..2917c00606 100644 --- a/types/hapi/v17/definitions/request/request-route.d.ts +++ b/types/hapi/v17/definitions/request/request-route.d.ts @@ -1,4 +1,4 @@ -import {RouteOptions, ServerRealm, Util} from "hapi"; +import {RouteOptions, ServerRealm, Util, Request} from "hapi"; /** * The request route information object, where: @@ -11,16 +11,35 @@ import {RouteOptions, ServerRealm, Util} from "hapi"; * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestroute) */ export interface RequestRoute { + /** the route HTTP method. */ method: Util.HTTP_METHODS_PARTIAL; + /** the route path. */ path: string; + /** the route vhost option if configured. */ vhost?: string | string[]; + /** the active realm associated with the route.*/ realm: ServerRealm; + /** the route options object with all defaults applied. */ settings: RouteOptions; + /** the route internal normalized string representing the normalized path. */ fingerprint: string; + + auth: { + /** + * Validates a request against the route's authentication access configuration, where: + * @param request - the request object. + * @return Return value: true if the request would have passed the route's access requirements. + * Note that the route's authentication mode and strategies are ignored. The only match is made between the request.auth.credentials scope and entity information and the route access configuration. + * If the route uses dynamic scopes, the scopes are constructed against the request.query, request.params, request.payload, and request.auth.credentials which may or may not match between the route and the request's route. If this method is called using a request that has not been authenticated (yet or not at all), it will return false if the route requires any authentication. + * [See docs](https://hapijs.com/api/17.0.1#-requestrouteauthaccessrequest) + */ + access(request: Request): boolean; + } + } diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index 992a117b7d..7e7ec43e7c 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -160,14 +160,9 @@ export interface Request extends Podium { }; /** - * The request route information object, where: - * * method - the route HTTP method. - * * path - the route path. - * * vhost - the route vhost option if configured. - * * realm - the active realm associated with the route. - * * settings - the route options object with all defaults applied. - * * fingerprint - the route internal normalized string representing the normalized path. + * The request route information object and method * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestroute) + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestrouteauthaccessrequest) */ readonly route: RequestRoute; @@ -209,16 +204,6 @@ export interface Request extends Podium { log(tags: string, data?: string | object | (() => string | object)): void; log(tags: string[], data?: string | object | (() => string | object)): void; - /** - * Validates a request against the route's authentication access configuration, where: - * @param request - the request object. - * @return Return value: true if the request would have passed the route's access requirements. - * Note that the route's authentication mode and strategies are ignored. The only match is made between the request.auth.credentials scope and entity information and the route access configuration. - * If the route uses dynamic scopes, the scopes are constructed against the request.query, request.params, request.payload, and request.auth.credentials which may or may not match between the route and the request's route. If this method is called using a request that has not been authenticated (yet or not at all), it will return false if the route requires any authentication. - * [See docs](https://hapijs.com/api/17.0.1#-requestrouteauthaccessrequest) - */ - // TODO how to implement it? It is a function inside route.auth! We have another "route" properti in this file. (The v16 doesn't have this option) - /** * Changes the request method before the router begins processing the request where: * @param method - is the request HTTP method (e.g. 'GET'). From 32bfe6b2889d846398e0ddf1e155dcc2ffdb4156 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Fri, 8 Dec 2017 20:51:40 -0300 Subject: [PATCH 075/298] Add "Function" support param in server.events.emit() --- types/hapi/v17/definitions/server/server-events.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/hapi/v17/definitions/server/server-events.d.ts b/types/hapi/v17/definitions/server/server-events.d.ts index 16e81f34ef..8d07ee0b5b 100644 --- a/types/hapi/v17/definitions/server/server-events.d.ts +++ b/types/hapi/v17/definitions/server/server-events.d.ts @@ -81,7 +81,7 @@ export interface ServerEvents extends Podium { * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsemitcriteria-data) */ - emit(criteria: string, data: any): void; + emit(criteria: string, data: any | Function): void; emit(criteria: {name: string, channel?: string, tags?: string | string[]}, data: any): void; /** From aff418b46dbb3407b39145358fefc7d4caed0b67 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Fri, 8 Dec 2017 21:07:53 -0300 Subject: [PATCH 076/298] Optimize imports. --- types/hapi/v17/definitions/plugin/plugin.d.ts | 3 +-- .../definitions/request/request-route.d.ts | 2 +- .../hapi/v17/definitions/request/request.d.ts | 9 +------ .../definitions/response/response-object.d.ts | 6 +---- .../response/response-toolkit.d.ts | 3 +-- .../route/route-options-payload.d.ts | 2 +- .../route/route-options-response.d.ts | 2 +- .../v17/definitions/route/route-options.d.ts | 25 ++++++++++--------- .../server/server-auth-scheme.d.ts | 5 +--- .../v17/definitions/server/server-auth.d.ts | 5 +--- .../v17/definitions/server/server-ext.d.ts | 2 +- .../v17/definitions/server/server-inject.d.ts | 2 +- .../definitions/server/server-options.d.ts | 3 +-- .../v17/definitions/server/server-realm.d.ts | 2 +- .../v17/definitions/server/server-route.d.ts | 2 +- .../server/server-state-options.d.ts | 2 +- .../v17/definitions/server/server-state.d.ts | 1 - .../hapi/v17/definitions/util/lifecycle.d.ts | 4 +-- 18 files changed, 30 insertions(+), 50 deletions(-) diff --git a/types/hapi/v17/definitions/plugin/plugin.d.ts b/types/hapi/v17/definitions/plugin/plugin.d.ts index cda5c37f4a..cd499c5645 100644 --- a/types/hapi/v17/definitions/plugin/plugin.d.ts +++ b/types/hapi/v17/definitions/plugin/plugin.d.ts @@ -1,5 +1,4 @@ -import {Server} from "../server/server"; -import {ServerRegisterOptions} from "hapi"; +import {Server, ServerRegisterOptions} from "hapi"; export interface PluginsStates { [pluginName: string]: any; diff --git a/types/hapi/v17/definitions/request/request-route.d.ts b/types/hapi/v17/definitions/request/request-route.d.ts index 2917c00606..fbafd033a6 100644 --- a/types/hapi/v17/definitions/request/request-route.d.ts +++ b/types/hapi/v17/definitions/request/request-route.d.ts @@ -1,4 +1,4 @@ -import {RouteOptions, ServerRealm, Util, Request} from "hapi"; +import {Request, RouteOptions, ServerRealm, Util} from "hapi"; /** * The request route information object, where: diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index 7e7ec43e7c..e22d1ed391 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -1,15 +1,8 @@ import * as stream from "stream"; import * as url from "url"; import * as http from "http"; -import {Server} from "../server/server"; -import {ResponseObject} from "../response/response-object"; -import {Util} from "../util/util"; -import {PluginsStates} from "../plugin/plugin"; -import {RequestRoute} from "./request-route"; -import {RequestAuth} from "./request-auth"; -import {RequestInfo} from "./request-info"; import * as Podium from "podium"; -import {RequestEvents} from "hapi"; +import {PluginsStates, RequestAuth, RequestEvents, RequestInfo, RequestRoute, ResponseObject, Server, Util} from "hapi"; /** * An object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/v17/definitions/response/response-object.d.ts index 1cb2c27862..28afdbba0a 100644 --- a/types/hapi/v17/definitions/response/response-object.d.ts +++ b/types/hapi/v17/definitions/response/response-object.d.ts @@ -1,9 +1,5 @@ -import {PluginsStates} from "../plugin/plugin"; -import {ResponseSettings} from "./response-settings"; -import {ServerStateCookieOptions} from "../server/server-state-options"; import * as Podium from "podium"; -import {Json, Lifecycle} from "hapi"; -import {ResponseEvents} from "./response-events"; +import {Json, Lifecycle, PluginsStates, ResponseEvents, ResponseSettings, ServerStateCookieOptions} from "hapi"; /** * Object where: diff --git a/types/hapi/v17/definitions/response/response-toolkit.d.ts b/types/hapi/v17/definitions/response/response-toolkit.d.ts index 1157002f99..41fcf0d62a 100644 --- a/types/hapi/v17/definitions/response/response-toolkit.d.ts +++ b/types/hapi/v17/definitions/response/response-toolkit.d.ts @@ -1,5 +1,4 @@ -import {ServerRealm, ServerStateCookieOptions} from "hapi"; -import {ResponseObject} from "./response-object"; +import {ResponseObject, ServerRealm, ServerStateCookieOptions} from "hapi"; /** * See more about Lifecycle diff --git a/types/hapi/v17/definitions/route/route-options-payload.d.ts b/types/hapi/v17/definitions/route/route-options-payload.d.ts index 79efc0d144..5213f2c230 100644 --- a/types/hapi/v17/definitions/route/route-options-payload.d.ts +++ b/types/hapi/v17/definitions/route/route-options-payload.d.ts @@ -1,4 +1,4 @@ -import {Util, Lifecycle} from "hapi"; +import {Lifecycle} from "hapi"; /** * The value must be one of: diff --git a/types/hapi/v17/definitions/route/route-options-response.d.ts b/types/hapi/v17/definitions/route/route-options-response.d.ts index 16c2249e29..64318af3d9 100644 --- a/types/hapi/v17/definitions/route/route-options-response.d.ts +++ b/types/hapi/v17/definitions/route/route-options-response.d.ts @@ -1,4 +1,4 @@ -import {Lifecycle, Util} from "hapi"; +import {Lifecycle} from "hapi"; import {ValidationOptions} from "joi"; /** diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/v17/definitions/route/route-options.d.ts index 8284f9b21a..a1fc8814ec 100644 --- a/types/hapi/v17/definitions/route/route-options.d.ts +++ b/types/hapi/v17/definitions/route/route-options.d.ts @@ -1,15 +1,16 @@ -import {RouteOptionsAccess} from "./route-options-access"; -import {RouteOptionsCache} from "./route-options-cache"; -import {Util} from "../util/util"; -import {RouteOptionsCors} from "./route-options-cors"; -import {RouteOptionsResponse} from "./route-options-response"; -import {RouteOptionsPayload} from "./route-options-payload"; -import {RouteOptionsSecure} from "./route-options-secure"; -import {RouteOptionsValidate} from "./route-options-validate"; -import {PluginSpecificConfiguration} from "../plugin/plugin"; -import {Json} from "../util/json"; -import {RouteOptionsPreArray} from "./route-options-pre"; -import {Lifecycle} from "hapi"; +import { + Json, + Lifecycle, + PluginSpecificConfiguration, + RouteOptionsAccess, + RouteOptionsCache, + RouteOptionsCors, + RouteOptionsPayload, + RouteOptionsPreArray, + RouteOptionsResponse, + RouteOptionsSecure, + RouteOptionsValidate +} from "hapi"; /** * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression) diff --git a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts index 55aa77eba1..e8a4d2adbe 100644 --- a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts +++ b/types/hapi/v17/definitions/server/server-auth-scheme.d.ts @@ -1,7 +1,4 @@ -import {Server} from "./server"; -import {ResponseToolkit} from "../response/response-toolkit"; -import {Request} from "../request/request"; -import {Lifecycle} from "hapi"; +import {Lifecycle, Request, ResponseToolkit, Server} from "hapi"; /** * The scheme options argument passed to server.auth.strategy() when instantiation a strategy. diff --git a/types/hapi/v17/definitions/server/server-auth.d.ts b/types/hapi/v17/definitions/server/server-auth.d.ts index 56e13edc8d..c52a0a3cda 100644 --- a/types/hapi/v17/definitions/server/server-auth.d.ts +++ b/types/hapi/v17/definitions/server/server-auth.d.ts @@ -1,7 +1,4 @@ -import {ServerAuthScheme} from "./server-auth-scheme"; -import {Request} from "../request/request"; -import {RouteOptionsAccess} from "hapi"; -import {Util} from "../util/util"; +import {Request, RouteOptionsAccess, ServerAuthScheme} from "hapi"; /** * The authentication credentials object diff --git a/types/hapi/v17/definitions/server/server-ext.d.ts b/types/hapi/v17/definitions/server/server-ext.d.ts index ce73328b6c..02853a2888 100644 --- a/types/hapi/v17/definitions/server/server-ext.d.ts +++ b/types/hapi/v17/definitions/server/server-ext.d.ts @@ -1,4 +1,4 @@ -import {Server, Lifecycle} from "hapi"; +import {Lifecycle, Server} from "hapi"; /** * The extension point event name. The available extension points include the request extension points as well as the following server extension points: diff --git a/types/hapi/v17/definitions/server/server-inject.d.ts b/types/hapi/v17/definitions/server/server-inject.d.ts index e398e1915e..ddb3c3e7b7 100644 --- a/types/hapi/v17/definitions/server/server-inject.d.ts +++ b/types/hapi/v17/definitions/server/server-inject.d.ts @@ -1,4 +1,4 @@ -import {Request, PluginsStates} from "hapi"; +import {PluginsStates, Request} from "hapi"; import * as Shot from "shot"; /** diff --git a/types/hapi/v17/definitions/server/server-options.d.ts b/types/hapi/v17/definitions/server/server-options.d.ts index 4273a01988..407ebfd1c4 100644 --- a/types/hapi/v17/definitions/server/server-options.d.ts +++ b/types/hapi/v17/definitions/server/server-options.d.ts @@ -1,9 +1,8 @@ -import {ServerOptionsCache} from "./server-options-cache"; import * as http from "http"; import * as https from "https"; import * as catbox from "catbox"; import {MimosOptions} from "mimos"; -import {PluginSpecificConfiguration, RouteOptions} from "hapi"; +import {PluginSpecificConfiguration, RouteOptions, ServerOptionsCache} from "hapi"; /** * he server options control the behavior of the server object. Note that the options object is deeply cloned diff --git a/types/hapi/v17/definitions/server/server-realm.d.ts b/types/hapi/v17/definitions/server/server-realm.d.ts index ba60524ebd..cfab9b75b7 100644 --- a/types/hapi/v17/definitions/server/server-realm.d.ts +++ b/types/hapi/v17/definitions/server/server-realm.d.ts @@ -1,4 +1,4 @@ -import {PluginsStates} from "../plugin/plugin"; +import {PluginsStates} from "hapi"; /** * The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When registering a plugin or an authentication scheme, a server object reference is provided with a new server.realm container specific to that registration. It allows each plugin to maintain its own settings without leaking and affecting other plugins. diff --git a/types/hapi/v17/definitions/server/server-route.d.ts b/types/hapi/v17/definitions/server/server-route.d.ts index efcc910f57..c2d972c631 100644 --- a/types/hapi/v17/definitions/server/server-route.d.ts +++ b/types/hapi/v17/definitions/server/server-route.d.ts @@ -1,4 +1,4 @@ -import {Util, Lifecycle, Server} from "hapi"; +import {Lifecycle, Server, Util} from "hapi"; /** * A route configuration object or an array of configuration objects where each object contains: diff --git a/types/hapi/v17/definitions/server/server-state-options.d.ts b/types/hapi/v17/definitions/server/server-state-options.d.ts index e650309d95..55f749792f 100644 --- a/types/hapi/v17/definitions/server/server-state-options.d.ts +++ b/types/hapi/v17/definitions/server/server-state-options.d.ts @@ -1,4 +1,4 @@ -import {Request} from "../request/request"; +import {Request} from "hapi"; /** * Optional cookie settings diff --git a/types/hapi/v17/definitions/server/server-state.d.ts b/types/hapi/v17/definitions/server/server-state.d.ts index bfc9568c51..e09937f32e 100644 --- a/types/hapi/v17/definitions/server/server-state.d.ts +++ b/types/hapi/v17/definitions/server/server-state.d.ts @@ -1,5 +1,4 @@ import {ServerStateCookieOptions} from "hapi"; -import {Util} from "hapi"; /** * A single object or an array of object where each contains: diff --git a/types/hapi/v17/definitions/util/lifecycle.d.ts b/types/hapi/v17/definitions/util/lifecycle.d.ts index 583fdf3c28..87dcf8ff1a 100644 --- a/types/hapi/v17/definitions/util/lifecycle.d.ts +++ b/types/hapi/v17/definitions/util/lifecycle.d.ts @@ -1,6 +1,6 @@ -import * as Boom from "../../../../boom/index"; +import * as Boom from "boom"; import * as stream from "stream"; -import {ResponseToolkit, Request} from "hapi"; +import {Request, ResponseToolkit} from "hapi"; export namespace Lifecycle { From b453000bc5ca0cc89e2e3c0a082fa3ae0557148a Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 9 Dec 2017 12:00:10 -0300 Subject: [PATCH 077/298] Going back with Dictionary. It didn't work as expected :-/ --- types/hapi/v17/definitions/request/request.d.ts | 10 +++++----- .../hapi/v17/definitions/response/response-object.d.ts | 4 ++-- .../v17/definitions/route/route-options-payload.d.ts | 4 ++-- .../v17/definitions/route/route-options-response.d.ts | 4 ++-- types/hapi/v17/definitions/route/route-options.d.ts | 7 ++++--- types/hapi/v17/definitions/server/server-auth.d.ts | 4 ++-- types/hapi/v17/definitions/server/server-state.d.ts | 4 ++-- types/hapi/v17/definitions/server/server.d.ts | 2 +- types/hapi/v17/definitions/util/util.d.ts | 6 ++++++ 9 files changed, 26 insertions(+), 19 deletions(-) diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index e22d1ed391..a9a8c8b6d2 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -54,7 +54,7 @@ export interface Request extends Podium { * The raw request headers (references request.raw.req.headers). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestheaders) */ - readonly headers: Map; + readonly headers: Util.Dictionary; /** * Request information: @@ -98,7 +98,7 @@ export interface Request extends Podium { /** * An object where each key is a path parameter name with matching value as described in [Path parameters](https://github.com/hapijs/hapi/blob/master/API.md#path-parameters). */ - readonly params: Map; + readonly params: Util.Dictionary; /** * An array containing all the path params values in the order they appeared in the path. @@ -124,7 +124,7 @@ export interface Request extends Podium { /** * An object where each key is the name assigned by a route pre-handler methods function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. */ - readonly pre: Map; + readonly pre: Util.Dictionary; /** * Access: read / write (see limitations below). @@ -135,7 +135,7 @@ export interface Request extends Podium { /** * Same as pre but represented as the response object created by the pre method. */ - readonly preResponses: Map; + readonly preResponses: Util.Dictionary; /** * By default the object outputted from node's URL parse() method. Might also be set indirectly via request.setUrl in which case it may be a string (if url is set to an object with the query attribute as an unparsed string). @@ -168,7 +168,7 @@ export interface Request extends Podium { /** * An object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. */ - readonly state: Map; + readonly state: Util.Dictionary; /** * The parsed request URI. diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/v17/definitions/response/response-object.d.ts index 28afdbba0a..378fee420f 100644 --- a/types/hapi/v17/definitions/response/response-object.d.ts +++ b/types/hapi/v17/definitions/response/response-object.d.ts @@ -1,5 +1,5 @@ import * as Podium from "podium"; -import {Json, Lifecycle, PluginsStates, ResponseEvents, ResponseSettings, ServerStateCookieOptions} from "hapi"; +import {Json, Lifecycle, PluginsStates, ResponseEvents, ResponseSettings, ServerStateCookieOptions, Util} from "hapi"; /** * Object where: @@ -48,7 +48,7 @@ export interface ResponseObject extends Podium { * Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheaders) */ - readonly headers: Map; + readonly headers: Util.Dictionary; /** * Default value: {}. diff --git a/types/hapi/v17/definitions/route/route-options-payload.d.ts b/types/hapi/v17/definitions/route/route-options-payload.d.ts index 5213f2c230..a13db35c32 100644 --- a/types/hapi/v17/definitions/route/route-options-payload.d.ts +++ b/types/hapi/v17/definitions/route/route-options-payload.d.ts @@ -1,4 +1,4 @@ -import {Lifecycle} from "hapi"; +import {Lifecycle, Util} from "hapi"; /** * The value must be one of: @@ -38,7 +38,7 @@ export interface RouteOptionsPayload { * An object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in compression. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) */ - compression?: Map; + compression?: Util.Dictionary; /** * Default value: 'application/json'. diff --git a/types/hapi/v17/definitions/route/route-options-response.d.ts b/types/hapi/v17/definitions/route/route-options-response.d.ts index 64318af3d9..a1c4d71a75 100644 --- a/types/hapi/v17/definitions/route/route-options-response.d.ts +++ b/types/hapi/v17/definitions/route/route-options-response.d.ts @@ -1,4 +1,4 @@ -import {Lifecycle} from "hapi"; +import {Lifecycle, Util} from "hapi"; import {ValidationOptions} from "joi"; /** @@ -79,6 +79,6 @@ export interface RouteOptionsResponse { * status is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsestatus) */ - status?: Map; + status?: Util.Dictionary; } diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/v17/definitions/route/route-options.d.ts index a1fc8814ec..2bc2542f4a 100644 --- a/types/hapi/v17/definitions/route/route-options.d.ts +++ b/types/hapi/v17/definitions/route/route-options.d.ts @@ -9,7 +9,8 @@ import { RouteOptionsPreArray, RouteOptionsResponse, RouteOptionsSecure, - RouteOptionsValidate + RouteOptionsValidate, + Util } from "hapi"; /** @@ -66,7 +67,7 @@ export interface RouteOptions { * An object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in compression. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression) */ - compression?: Map; + compression?: Util.Dictionary; /** * Default value: false (no CORS headers). @@ -181,7 +182,7 @@ export interface RouteOptions { * Plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsplugins) */ - plugins?: Map; + plugins?: Util.Dictionary; /** * Default value: none. diff --git a/types/hapi/v17/definitions/server/server-auth.d.ts b/types/hapi/v17/definitions/server/server-auth.d.ts index c52a0a3cda..0d0bafc7e1 100644 --- a/types/hapi/v17/definitions/server/server-auth.d.ts +++ b/types/hapi/v17/definitions/server/server-auth.d.ts @@ -1,4 +1,4 @@ -import {Request, RouteOptionsAccess, ServerAuthScheme} from "hapi"; +import {Request, RouteOptionsAccess, ServerAuthScheme, Util} from "hapi"; /** * The authentication credentials object @@ -24,7 +24,7 @@ export interface ServerAuth { * returned from its implementation function. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi) */ - api: Map; + api: Util.Dictionary; /** * Contains the default authentication configuration is a default strategy was set via diff --git a/types/hapi/v17/definitions/server/server-state.d.ts b/types/hapi/v17/definitions/server/server-state.d.ts index e09937f32e..f233956a29 100644 --- a/types/hapi/v17/definitions/server/server-state.d.ts +++ b/types/hapi/v17/definitions/server/server-state.d.ts @@ -1,4 +1,4 @@ -import {ServerStateCookieOptions} from "hapi"; +import {ServerStateCookieOptions, Util} from "hapi"; /** * A single object or an array of object where each contains: @@ -66,6 +66,6 @@ export interface ServerState { * Note that this utility uses the server configuration but does not change the server state. It is provided for manual cookie parsing (e.g. when server parsing is disabled). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-async-serverstatesparseheader) */ - parse(header: string): Map; + parse(header: string): Util.Dictionary; } diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 4b82f4a8b4..2af9a5edf0 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -162,7 +162,7 @@ export class Server extends Podium { * server method name is an object property. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethods */ - readonly methods: Map; + readonly methods: Util.Dictionary; /** * Provides access to the server MIME database used for setting content-type information. The object must not be diff --git a/types/hapi/v17/definitions/util/util.d.ts b/types/hapi/v17/definitions/util/util.d.ts index 9e2264a257..f92b23bb4d 100644 --- a/types/hapi/v17/definitions/util/util.d.ts +++ b/types/hapi/v17/definitions/util/util.d.ts @@ -1,5 +1,11 @@ export namespace Util { + + export interface Dictionary { + [key: string]: T; + } + export type HTTP_METHODS_PARTIAL_LOWERCASE = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_LOWERCASE; export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; + } From 6fd4625f823dc6ad40559c1f84987f4f65bf143d Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 9 Dec 2017 12:03:06 -0300 Subject: [PATCH 078/298] Add more tests files. --- types/hapi/v17/test/index.test.d.ts | 2 ++ types/hapi/v17/test/reply/state_cookie.ts | 1 - types/hapi/v17/test/request/get-log.ts | 30 +++++++++++++++++++++++ types/hapi/v17/test/request/query.ts | 27 ++++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 types/hapi/v17/test/request/get-log.ts create mode 100644 types/hapi/v17/test/request/query.ts diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/index.test.d.ts index 35555aa057..fb3babbbec 100644 --- a/types/hapi/v17/test/index.test.d.ts +++ b/types/hapi/v17/test/index.test.d.ts @@ -19,6 +19,8 @@ export * from './reply/reply'; export * from './reply/state_cookie'; export * from './request/event-types'; +export * from './request/get-log'; +export * from './request/query'; export * from './response/error'; diff --git a/types/hapi/v17/test/reply/state_cookie.ts b/types/hapi/v17/test/reply/state_cookie.ts index 4ef420915e..9952ee0e77 100644 --- a/types/hapi/v17/test/reply/state_cookie.ts +++ b/types/hapi/v17/test/reply/state_cookie.ts @@ -1,7 +1,6 @@ // from https://hapijs.com/tutorials/cookies?lang=en_US import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute, ServerStateCookieOptions} from "hapi"; - const options: ServerOptions = { port: 8000, }; diff --git a/types/hapi/v17/test/request/get-log.ts b/types/hapi/v17/test/request/get-log.ts new file mode 100644 index 0000000000..89084cbb07 --- /dev/null +++ b/types/hapi/v17/test/request/get-log.ts @@ -0,0 +1,30 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data +import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; + +const handler: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { + request.log(['test', 'error'], 'Test event'); + return 'path: ' + request.path; +}; + +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: handler +}; + +const server = new Server(options); +server.route(serverRoute); +server.start(); +console.log('Server started at: ' + server.info.uri); + +server.events.on('request', (request: Request, event: any, tags: any) => { + console.log(event); + console.log(tags); + if (tags.error) { + console.log(event); + } +}); diff --git a/types/hapi/v17/test/request/query.ts b/types/hapi/v17/test/request/query.ts new file mode 100644 index 0000000000..e176e078e9 --- /dev/null +++ b/types/hapi/v17/test/request/query.ts @@ -0,0 +1,27 @@ +// Added test in addition to docs, for request.query +import {Request, ResponseToolkit, Lifecycle, Server, ServerOptions, ServerRoute} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; + +const handler: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { + const query = request.query as GetThingQuery; + // http://localhost:8000/?name=test + return `You asked for ${query.name}` +}; + +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: handler +}; + +interface GetThingQuery { + name: string; +} + +const server = new Server(options); +server.route(serverRoute); +server.start(); +console.log('Server started at: ' + server.info.uri); From 08477d7c3dbe20b20712740a25fbdb450bd3e122 Mon Sep 17 00:00:00 2001 From: TeamworkGuy2 Date: Sat, 9 Dec 2017 15:06:00 +0000 Subject: [PATCH 079/298] [lokijs] additional tests --- types/lokijs/lokijs-tests.ts | 110 +++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 4 deletions(-) diff --git a/types/lokijs/lokijs-tests.ts b/types/lokijs/lokijs-tests.ts index 167adba4ad..ac16e5cc15 100644 --- a/types/lokijs/lokijs-tests.ts +++ b/types/lokijs/lokijs-tests.ts @@ -1,7 +1,18 @@ - import Loki = require("lokijs"); + +interface EarthLocation { + longitude: number; + latitude: number; +} + +interface User { + name: string; + age: number; +} + + class Ant { static uniqueId = 1; @@ -37,10 +48,12 @@ class QueenAnt extends Ant { class AntColony { + location: EarthLocation; ants: Loki.Collection; queens: Loki.Collection; - constructor(ants: Loki.Collection, queens: Loki.Collection) { + constructor(location: EarthLocation, ants: Loki.Collection, queens: Loki.Collection) { + this.location = location; this.ants = ants; this.queens = queens; } @@ -73,15 +86,104 @@ class Test { throw new Error("queen object's '.$loki' property lookup failed"); } - var anotherColl = new Loki.Collection("anotherCollection"); + Test.events(lokiInst); + Test.insertUpdateRemove(lokiInst); + Test.dynamicViews(lokiInst); + Test.transform(lokiInst); + } + + static events(lokiInst: Loki) { + var coll = new Loki.Collection("anotherCollection", {}); + var onUpdate: (t: any) => void; + + coll.on("update", onUpdate = function (target) { + console.log("update", target); + }); + + coll.on("error", function (target) { + console.log("error", target); + }); + + coll.emit("update", { data: "abc" }); + + coll.removeListener("update", onUpdate); + } + + + static insertUpdateRemove(lokiInst: Loki) { + var coll = new Loki.Collection("anotherCollection", { + unique: <["id"]>["id"], + indices: <["dob"]>["dob"], + autoupdate: true + }); + + coll.insert({ + id: 127, + dob: new Date(2012, 9, 1), + health: 1.0, + lengthMm: 3.5, + weightMg: 0.4, + }); + + var doc = coll.by("id", 127); + if (doc) doc.health -= 0.25; + + // untyped collection (collection type should default to 'any') + var tmpColl = lokiInst.addCollection("_temp"); + tmpColl.insert(coll.find()); + var res = tmpColl.findOne({ id: 127 }); + if (res) res.health -= 0.25; + + coll.clear({ removeIndices: true }); + + tmpColl.removeWhere({ id: 127 }); + + if(doc) coll.add(doc); + + coll.remove(1); + coll.removeDataOnly(); + } + + + static dynamicViews(lokiInst: Loki) { + var users = lokiInst.addCollection("users"); + + users.insert({ name: "joe", age: 39 }); + users.insert({ name: "jack", age: 20 }); + users.insert({ name: "jim", age: 40 }); + users.insert([ + { name: "dave", age: 33 }, + { name: "eric", age: 29 }, + { name: "dave", age: 21 } + ]); + + var dv = users.addDynamicView("testview"); + dv.applyWhere(function (obj) { + return obj.name.length > 3; + }); + + console.log("expect 2 == " + dv.data().length); + + users.removeWhere(function (obj: User) { + return obj.age > 35; + }); + + console.log("expect 0 == " + dv.data().length); + } + + + static transform(lokiInst: Loki) { + var ants = lokiInst.addCollection("tmpAnts"); + var len = ants.chain().transform([{ property: "id" }]).data().length; + ants.addTransform("tmpAnts", [{ type: "map", mapFun: (a: any) => a, desc: true }]); } static createAntColony(lokiInst: Loki, antCount: number, queenCount: number = 1) { var ants = lokiInst.addCollection("ants", { indices: "id" }); var queens = lokiInst.addCollection("queenAnts", { indices: "id" }); - var antColony = new AntColony(ants, queens); + var antColony = new AntColony({ latitude: 0, longitude: 0 }, ants, queens); for (var i = 0; i < antCount; i++) { ants.add(Ant.createAnt()); From 2cbd2d48e8cc91839437d77aa3ea55fe8260842d Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 9 Dec 2017 16:41:54 -0300 Subject: [PATCH 080/298] Add more test files. --- types/hapi/v17/test/index.test.d.ts | 30 +++++++---- .../v17/test/{path => request}/catch-all.ts | 0 types/hapi/v17/test/request/get-log.ts | 1 - .../v17/test/{path => request}/parameters.ts | 0 .../v17/test/{reply => response}/continue.ts | 0 .../v17/test/{reply => response}/redirect.ts | 0 .../v17/test/{reply => response}/reply.ts | 4 +- .../test/{reply => response}/state_cookie.ts | 0 .../adding-routes.ts} | 5 +- types/hapi/v17/test/route/config.ts | 54 +++++++++++++++++++ types/hapi/v17/test/route/handler.ts | 9 ++++ .../a-simple-server.ts} | 0 types/hapi/v17/test/server/app.ts | 2 +- types/hapi/v17/test/server/info.ts | 16 +++--- types/hapi/v17/test/server/select.ts | 17 ++++++ .../v17/test/server/server-events-once.ts | 8 ++- types/hapi/v17/test/server/settings.ts | 12 +++++ types/hapi/v17/test/server/start.ts | 11 ++++ types/hapi/v17/test/server/stop.ts | 17 ++++++ types/hapi/v17/test/server/version.ts | 9 ++++ 20 files changed, 164 insertions(+), 31 deletions(-) rename types/hapi/v17/test/{path => request}/catch-all.ts (100%) rename types/hapi/v17/test/{path => request}/parameters.ts (100%) rename types/hapi/v17/test/{reply => response}/continue.ts (100%) rename types/hapi/v17/test/{reply => response}/redirect.ts (100%) rename types/hapi/v17/test/{reply => response}/reply.ts (92%) rename types/hapi/v17/test/{reply => response}/state_cookie.ts (100%) rename types/hapi/v17/test/{getting-started/02-adding-routes.ts => route/adding-routes.ts} (88%) create mode 100644 types/hapi/v17/test/route/config.ts create mode 100644 types/hapi/v17/test/route/handler.ts rename types/hapi/v17/test/{getting-started/01-creating-a-server.ts => server/a-simple-server.ts} (100%) create mode 100644 types/hapi/v17/test/server/select.ts create mode 100644 types/hapi/v17/test/server/settings.ts create mode 100644 types/hapi/v17/test/server/start.ts create mode 100644 types/hapi/v17/test/server/stop.ts create mode 100644 types/hapi/v17/test/server/version.ts diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/index.test.d.ts index fb3babbbec..228ffdc02c 100644 --- a/types/hapi/v17/test/index.test.d.ts +++ b/types/hapi/v17/test/index.test.d.ts @@ -8,26 +8,36 @@ /// -/** Getting Started */ -export * from './getting-started/01-creating-a-server'; -export * from './getting-started/02-adding-routes'; -export * from './path/catch-all'; -export * from './path/parameters'; -export * from './reply/continue'; -export * from './reply/redirect'; -export * from './reply/reply'; -export * from './reply/state_cookie'; - +/** REQUEST */ +export * from './request/catch-all'; export * from './request/event-types'; export * from './request/get-log'; +export * from './request/parameters'; export * from './request/query'; +/** RESPONSE */ +export * from './response/continue'; export * from './response/error'; +export * from './response/redirect'; +export * from './response/reply'; +export * from './response/state_cookie'; +/** ROUTE */ +export * from './route/adding-routes'; +export * from './route/config'; +export * from './route/handler'; + +/** SERVER */ +export * from './server/a-simple-server'; export * from './server/app'; export * from './server/info'; +export * from './server/select'; export * from './server/server-events-once'; +export * from './server/settings'; +export * from './server/start'; +export * from './server/stop'; export * from './server/table'; +export * from './server/version'; diff --git a/types/hapi/v17/test/path/catch-all.ts b/types/hapi/v17/test/request/catch-all.ts similarity index 100% rename from types/hapi/v17/test/path/catch-all.ts rename to types/hapi/v17/test/request/catch-all.ts diff --git a/types/hapi/v17/test/request/get-log.ts b/types/hapi/v17/test/request/get-log.ts index 89084cbb07..047799c394 100644 --- a/types/hapi/v17/test/request/get-log.ts +++ b/types/hapi/v17/test/request/get-log.ts @@ -22,7 +22,6 @@ server.start(); console.log('Server started at: ' + server.info.uri); server.events.on('request', (request: Request, event: any, tags: any) => { - console.log(event); console.log(tags); if (tags.error) { console.log(event); diff --git a/types/hapi/v17/test/path/parameters.ts b/types/hapi/v17/test/request/parameters.ts similarity index 100% rename from types/hapi/v17/test/path/parameters.ts rename to types/hapi/v17/test/request/parameters.ts diff --git a/types/hapi/v17/test/reply/continue.ts b/types/hapi/v17/test/response/continue.ts similarity index 100% rename from types/hapi/v17/test/reply/continue.ts rename to types/hapi/v17/test/response/continue.ts diff --git a/types/hapi/v17/test/reply/redirect.ts b/types/hapi/v17/test/response/redirect.ts similarity index 100% rename from types/hapi/v17/test/reply/redirect.ts rename to types/hapi/v17/test/response/redirect.ts diff --git a/types/hapi/v17/test/reply/reply.ts b/types/hapi/v17/test/response/reply.ts similarity index 92% rename from types/hapi/v17/test/reply/reply.ts rename to types/hapi/v17/test/response/reply.ts index 185f80ed3d..a2d4c250ed 100644 --- a/types/hapi/v17/test/reply/reply.ts +++ b/types/hapi/v17/test/response/reply.ts @@ -17,7 +17,7 @@ const serverRoutes: ServerRoute[] = [ return response; } }, - // Chained notation + // chained notation { path: '/test2', method: 'GET', @@ -34,4 +34,4 @@ const server = new Server(options); server.route(serverRoutes); server.start(); -console.log('Server started at: ' + server.info.uri); \ No newline at end of file +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/reply/state_cookie.ts b/types/hapi/v17/test/response/state_cookie.ts similarity index 100% rename from types/hapi/v17/test/reply/state_cookie.ts rename to types/hapi/v17/test/response/state_cookie.ts diff --git a/types/hapi/v17/test/getting-started/02-adding-routes.ts b/types/hapi/v17/test/route/adding-routes.ts similarity index 88% rename from types/hapi/v17/test/getting-started/02-adding-routes.ts rename to types/hapi/v17/test/route/adding-routes.ts index 4f383c15dc..7d503502c2 100644 --- a/types/hapi/v17/test/getting-started/02-adding-routes.ts +++ b/types/hapi/v17/test/route/adding-routes.ts @@ -6,10 +6,9 @@ const options: ServerOptions = { }; const serverRoute: ServerRoute = { - path: '/test', + path: '/', method: 'GET', handler: function (request: Request, h: ResponseToolkit) { - console.log(request); return 'ok: ' + request.path; } }; @@ -19,7 +18,6 @@ const serverRoutes: ServerRoute[] = [ path: '/test1', method: 'GET', handler: function (request: Request, h: ResponseToolkit) { - console.log(request); return 'ok: ' + request.path; } }, @@ -27,7 +25,6 @@ const serverRoutes: ServerRoute[] = [ path: '/test2', method: 'GET', handler: function (request: Request, h: ResponseToolkit) { - console.log(request); return 'ok: ' + request.path; } }, diff --git a/types/hapi/v17/test/route/config.ts b/types/hapi/v17/test/route/config.ts new file mode 100644 index 0000000000..1ecabd0c56 --- /dev/null +++ b/types/hapi/v17/test/route/config.ts @@ -0,0 +1,54 @@ +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute, RouteOptions} from "hapi"; + +const options: ServerOptions = { + port: 8000, +}; + + +// different methods +var routeConfig: ServerRoute = { + path: '/signin', + method: 'PUT', + vhost: 'site.coms', +}; +var routeConfig: ServerRoute = { + path: '/signin', + method: '*' +}; +var routeConfig: ServerRoute = { + path: '/signin', + method: ['OPTIONS', '*'] +}; + +// different handlers +var routeConfig: ServerRoute = { + path: '/signin', + method: 'PUT', + handler: function (request: Request, h: ResponseToolkit) { + return 'ok'; + } +}; +var routeConfig: ServerRoute = { + path: '/signin', + method: 'PUT', + handler: function (request: Request, h: ResponseToolkit) { + return 'ok'; + } +}; + +const server = new Server(options); +server.route(routeConfig); + +// Handler in config +const user: RouteOptions = { + cache: { expiresIn: 5000 }, + handler: function (request: Request, h: ResponseToolkit) { + return { name: 'John' }; + } +}; + +server.route({method: 'GET', path: '/user', options: user }); +//server.route({ method: 'GET', path: '/public/{path*}', options: { cache: { privacy: 'public', expiresIn: 24 * 60 * 60 * 1000 } }, handler: { directory: { path: __dirname, listing: false, index: false } } }); + +server.start(); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/route/handler.ts b/types/hapi/v17/test/route/handler.ts new file mode 100644 index 0000000000..fa20d7b677 --- /dev/null +++ b/types/hapi/v17/test/route/handler.ts @@ -0,0 +1,9 @@ +import {Lifecycle, Request, ResponseToolkit} from "hapi"; + +const handler: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { + return 'success'; +} + +const strictHandler: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { + return 123; +} diff --git a/types/hapi/v17/test/getting-started/01-creating-a-server.ts b/types/hapi/v17/test/server/a-simple-server.ts similarity index 100% rename from types/hapi/v17/test/getting-started/01-creating-a-server.ts rename to types/hapi/v17/test/server/a-simple-server.ts diff --git a/types/hapi/v17/test/server/app.ts b/types/hapi/v17/test/server/app.ts index ea376560b7..cfd0bd91a4 100644 --- a/types/hapi/v17/test/server/app.ts +++ b/types/hapi/v17/test/server/app.ts @@ -19,4 +19,4 @@ const serverRoute: ServerRoute = { server.route(serverRoute); server.start(); -console.log(`Server running at: ${server.info!.uri}`); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/server/info.ts b/types/hapi/v17/test/server/info.ts index 1fd15b240b..253a1b72aa 100644 --- a/types/hapi/v17/test/server/info.ts +++ b/types/hapi/v17/test/server/info.ts @@ -1,15 +1,15 @@ // From https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo -import {Server, ServerOptions} from "hapi"; -import assert = require('assert'); +import {Server} from "hapi"; +import * as assert from "assert"; -const options: ServerOptions = { +const server = new Server({ port: 8000, -}; -const server = new Server(options); +}); +server.start(); // check the correct port -if(server.info) assert(server.info.port === 8000); -assert(server.info !== null); +console.log(server.info); +if (server.info) assert(server.info.port === 8000); -server.start(); +assert(server.info !== null); console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/server/select.ts b/types/hapi/v17/test/server/select.ts new file mode 100644 index 0000000000..cdf2cfd1e7 --- /dev/null +++ b/types/hapi/v17/test/server/select.ts @@ -0,0 +1,17 @@ +// From https://hapijs.com/api/16.1.1#serverselectlabels +import {Server} from "hapi"; + +/* +const server = new Hapi.Server(); +server.connection({ port: 80, labels: ['a', 'b'] }); +server.connection({ port: 8080, labels: ['a', 'c'] }); +server.connection({ port: 8081, labels: ['b', 'c'] }); + +const a = server.select('a'); // 80, 8080 +const ac = a.select('c'); // 8080 +*/ +// TODO How do this with v17? + +const server = new Server({ + port: 8000, +}); diff --git a/types/hapi/v17/test/server/server-events-once.ts b/types/hapi/v17/test/server/server-events-once.ts index d36deb10bb..022cdb6f33 100644 --- a/types/hapi/v17/test/server/server-events-once.ts +++ b/types/hapi/v17/test/server/server-events-once.ts @@ -1,10 +1,6 @@ // from https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; -const options: ServerOptions = { - port: 8000, -}; - const serverRoute: ServerRoute = { path: '/', method: 'GET', @@ -13,7 +9,9 @@ const serverRoute: ServerRoute = { } }; -const server = new Server(options); +const server = new Server({ + port: 8000, +}); server.route(serverRoute); server.event('test1'); server.event('test2'); diff --git a/types/hapi/v17/test/server/settings.ts b/types/hapi/v17/test/server/settings.ts new file mode 100644 index 0000000000..ebe7588b88 --- /dev/null +++ b/types/hapi/v17/test/server/settings.ts @@ -0,0 +1,12 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-serversettings +import {Server} from "hapi"; + +const server = new Server({ + port: 8000, + app: { + key: 'value' + } +}); +server.start(); + +console.log(server.settings.app); // { key: 'value' } diff --git a/types/hapi/v17/test/server/start.ts b/types/hapi/v17/test/server/start.ts new file mode 100644 index 0000000000..425c287842 --- /dev/null +++ b/types/hapi/v17/test/server/start.ts @@ -0,0 +1,11 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstart +import {Server} from "hapi"; + +const server = new Server({ + port: 8000, +}); +server.start(); + +server.events.on('start', () => { + console.log('Server started at: ' + server.info.uri); +}); diff --git a/types/hapi/v17/test/server/stop.ts b/types/hapi/v17/test/server/stop.ts new file mode 100644 index 0000000000..2e7f3f9b2b --- /dev/null +++ b/types/hapi/v17/test/server/stop.ts @@ -0,0 +1,17 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstopoptions +import {Server} from "hapi"; + +const server = new Server({ + port: 8000, +}); + +server.start(); +server.events.on('start', () => { + console.log('Server started at: ' + server.info.uri); +}); +server.events.on('stop', () => { + console.log('Server stoped.'); +}); +setTimeout(function() { + server.stop({ timeout: 10 * 1000 }); +}, 5 * 1000); diff --git a/types/hapi/v17/test/server/version.ts b/types/hapi/v17/test/server/version.ts new file mode 100644 index 0000000000..041a565f48 --- /dev/null +++ b/types/hapi/v17/test/server/version.ts @@ -0,0 +1,9 @@ +// From https://github.com/hapijs/hapi/blob/master/API.md#-serverversion +import {Server} from "hapi"; + +const server = new Server({ + port: 8000, +}); + +server.start(); +console.log(server.version); // 17.x.x From 6e56e7d01475358216be222d690cc350db99c771 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 9 Dec 2017 17:34:00 -0300 Subject: [PATCH 081/298] Fix decorate() param. It must support the "toolkit" option. --- types/hapi/v17/definitions/server/server.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 2af9a5edf0..6674ceed2f 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -303,7 +303,7 @@ export class Server extends Podium { * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options) */ decorate(type: 'request', property: string, method: ((request: Request) => Function), options?: {apply: true; extend: false} ): void; - decorate(type: 'handler' | 'request' | 'reply' | 'server', property: string, method: Function, options?: {apply: boolean; extend: boolean} ): void; + decorate(type: 'handler' | 'request' | 'server' | 'toolkit', property: string, method: Function, options?: {apply: boolean; extend: boolean} ): void; /** * Used within a plugin to declare a required dependency on other plugins where: From 4d97af115e344c72a6e80d0c36636ec6f224680a Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 9 Dec 2017 17:36:15 -0300 Subject: [PATCH 082/298] Fix mime property. It must be "any" like v16. --- types/hapi/v17/definitions/server/server.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 6674ceed2f..2cc215f627 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -2,7 +2,6 @@ import * as http from "http"; import * as catbox from "catbox"; import * as zlib from "zlib"; import * as Podium from "podium"; -import {MimosOptions} from "mimos"; import { PayloadCompressionDecoderSettings, Plugin, @@ -169,7 +168,7 @@ export class Server extends Podium { * modified directly but only through the [mime](https://github.com/hapijs/hapi/blob/master/API.md#server.options.mime) server setting. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermime) */ - mime: MimosOptions; + mime: any; /** * An object containing the values exposed by each registered plugin where each key is a plugin name and the values From a476fcedc1f5822bcc4b9d5582c0d7c87b7892a2 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 9 Dec 2017 18:46:52 -0300 Subject: [PATCH 083/298] Many fix discovered with the tests. --- types/hapi/v17/definitions/plugin/plugin.d.ts | 2 +- .../v17/definitions/request/request-auth.d.ts | 2 +- .../response/response-toolkit.d.ts | 2 +- .../route/route-options-response.d.ts | 2 +- .../v17/definitions/server/server-auth.d.ts | 10 +--- .../v17/definitions/server/server-cache.d.ts | 42 +++++++++++++++ .../v17/definitions/server/server-inject.d.ts | 2 +- .../v17/definitions/server/server-route.d.ts | 2 +- types/hapi/v17/definitions/server/server.d.ts | 53 +++---------------- 9 files changed, 57 insertions(+), 60 deletions(-) create mode 100644 types/hapi/v17/definitions/server/server-cache.d.ts diff --git a/types/hapi/v17/definitions/plugin/plugin.d.ts b/types/hapi/v17/definitions/plugin/plugin.d.ts index cd499c5645..4340f804e1 100644 --- a/types/hapi/v17/definitions/plugin/plugin.d.ts +++ b/types/hapi/v17/definitions/plugin/plugin.d.ts @@ -22,7 +22,7 @@ export interface Plugin { * * server - the server object with a plugin-specific server.realm. * * options - any options passed to the plugin during registration via server.register(). */ - register: (server: Server, options: ServerRegisterOptions) => Function; + register: (server: Server, options: ServerRegisterOptions) => void; /** * (required) the plugin name string. The name is used as a unique key. Published plugins (e.g. published in the npm diff --git a/types/hapi/v17/definitions/request/request-auth.d.ts b/types/hapi/v17/definitions/request/request-auth.d.ts index a11dd07467..72dd69a4b4 100644 --- a/types/hapi/v17/definitions/request/request-auth.d.ts +++ b/types/hapi/v17/definitions/request/request-auth.d.ts @@ -13,7 +13,7 @@ export interface RequestAuth { /** an artifact object received from the authentication strategy and used in authentication-related actions. */ artifacts: object; /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ - credentials: object; + credentials: any; /** the authentication error is failed and mode set to 'try'. */ error: Error; /** true if the request has been successfully authenticated, otherwise false. */ diff --git a/types/hapi/v17/definitions/response/response-toolkit.d.ts b/types/hapi/v17/definitions/response/response-toolkit.d.ts index 41fcf0d62a..7c5b122c2f 100644 --- a/types/hapi/v17/definitions/response/response-toolkit.d.ts +++ b/types/hapi/v17/definitions/response/response-toolkit.d.ts @@ -33,7 +33,7 @@ export interface ResponseToolkit { * A response symbol. Provides access to the route or server context set via the route [bind](https://github.com/hapijs/hapi/blob/master/API.md#route.options.bind) * option or [server.bind()](https://github.com/hapijs/hapi/blob/master/API.md#server.bind()). */ - readonly context: Object; + readonly context: any; /** * A response symbol. When returned by a lifecycle method, the request lifecycle continues without changing the response. diff --git a/types/hapi/v17/definitions/route/route-options-response.d.ts b/types/hapi/v17/definitions/route/route-options-response.d.ts index a1c4d71a75..fa3c8f8560 100644 --- a/types/hapi/v17/definitions/route/route-options-response.d.ts +++ b/types/hapi/v17/definitions/route/route-options-response.d.ts @@ -9,7 +9,7 @@ export enum EmptyStatusCode { HTTP_204 = 204, } -export type RouteOptionsResponseSchema = boolean | ValidationOptions | ((value: object, options: object) => Function); +export type RouteOptionsResponseSchema = boolean | ValidationOptions | ((value: object, options: object) => any); /** * Processing rules for the outgoing response. diff --git a/types/hapi/v17/definitions/server/server-auth.d.ts b/types/hapi/v17/definitions/server/server-auth.d.ts index 0d0bafc7e1..d8f1c257e6 100644 --- a/types/hapi/v17/definitions/server/server-auth.d.ts +++ b/types/hapi/v17/definitions/server/server-auth.d.ts @@ -1,13 +1,5 @@ import {Request, RouteOptionsAccess, ServerAuthScheme, Util} from "hapi"; -/** - * The authentication credentials object - * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverauthteststrategy-request) - */ -export interface ServerAuthenticatedCredentials { - -} - /** * An authentication configuration object using the same format as the route auth handler options. * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions) @@ -86,7 +78,7 @@ export interface ServerAuth { * include verifying scope, entity, or other route properties. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverauthteststrategy-request) */ - test(strategy: string, request: Request): ServerAuthenticatedCredentials; + test(strategy: string, request: Request): any; } diff --git a/types/hapi/v17/definitions/server/server-cache.d.ts b/types/hapi/v17/definitions/server/server-cache.d.ts new file mode 100644 index 0000000000..d21d3c2613 --- /dev/null +++ b/types/hapi/v17/definitions/server/server-cache.d.ts @@ -0,0 +1,42 @@ +import * as catbox from "catbox"; +import {ServerOptionsCache} from "hapi"; + +/** + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) + */ +export interface ServerCache { + + /** + * Provisions a cache segment within the server cache facility where: + * @param options - [catbox policy](https://github.com/hapijs/catbox#policy) configuration where: + * * expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. + * * expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records expire. Uses local time. Cannot be used together with expiresIn. + * * generateFunc - a function used to generate a new cache item if one is not found in the cache when calling get(). The method's signature is async function(id, flags) where: + * - `id` - the `id` string or object provided to the `get()` method. + * - `flags` - an object used to pass back additional flags to the cache where: + * - `ttl` - the cache ttl value in milliseconds. Set to `0` to skip storing in the cache. Defaults to the cache global policy. + * * staleIn - number of milliseconds to mark an item stored in cache as stale and attempt to regenerate it when generateFunc is provided. Must be less than expiresIn. + * * staleTimeout - number of milliseconds to wait before checking if an item is stale. + * * generateTimeout - number of milliseconds to wait before returning a timeout error when the generateFunc function takes too long to return a value. When the value is eventually returned, it is stored in the cache for future requests. Required if generateFunc is present. Set to false to disable timeouts which may cause all get() requests to get stuck forever. + * * generateOnReadError - if false, an upstream cache read error will stop the cache.get() method from calling the generate function and will instead pass back the cache error. Defaults to true. + * * generateIgnoreWriteError - if false, an upstream cache write error when calling cache.get() will be passed back with the generated value when calling. Defaults to true. + * * dropOnError - if true, an error or timeout in the generateFunc causes the stale value to be evicted from the cache. Defaults to true. + * * pendingGenerateTimeout - number of milliseconds while generateFunc call is in progress for a given id, before a subsequent generateFunc call is allowed. Defaults to 0 (no blocking of concurrent generateFunc calls beyond staleTimeout). + * * cache - the cache name configured in server.cache. Defaults to the default cache. + * * segment - string segment name, used to isolate cached items within the cache partition. When called within a plugin, defaults to '!name' where 'name' is the plugin name. When called within a server method, defaults to '#name' where 'name' is the server method name. Required when called outside of a plugin. + * * shared - if true, allows multiple cache provisions to share the same segment. Default to false. + * @return Catbox Policy. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) + */ + (options: ServerOptionsCache): catbox.Policy; + + /** + * Provisions a server cache as described in server.cache where: + * @param options - same as the server cache configuration options. + * @return Return value: none. + * Note that if the server has been initialized or started, the cache will be automatically started to match the state of any other provisioned server cache. + * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions) + */ + provision(options: ServerOptionsCache): void; + +} diff --git a/types/hapi/v17/definitions/server/server-inject.d.ts b/types/hapi/v17/definitions/server/server-inject.d.ts index ddb3c3e7b7..d034bbf0a0 100644 --- a/types/hapi/v17/definitions/server/server-inject.d.ts +++ b/types/hapi/v17/definitions/server/server-inject.d.ts @@ -23,7 +23,7 @@ import * as Shot from "shot"; * For context [Shot module](https://github.com/hapijs/shot) */ export interface ServerInjectOptions extends Shot.RequestOptions { - credentials?: object; + credentials?: any; artifacts?: object; app?: any; plugins?: PluginsStates; diff --git a/types/hapi/v17/definitions/server/server-route.d.ts b/types/hapi/v17/definitions/server/server-route.d.ts index c2d972c631..b3c8e6fcee 100644 --- a/types/hapi/v17/definitions/server/server-route.d.ts +++ b/types/hapi/v17/definitions/server/server-route.d.ts @@ -37,7 +37,7 @@ export interface ServerRoute { /** * additional route options. The options value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. */ - options?: object | ((server: Server) => Function); + options?: object | ((server: Server) => object); /** * route custom rules object. The object is passed to each rules processor registered with server.rules(). Cannot be used if route.options.rules is defined. diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 2cc215f627..1f3654b1be 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -1,5 +1,4 @@ import * as http from "http"; -import * as catbox from "catbox"; import * as zlib from "zlib"; import * as Podium from "podium"; import { @@ -11,7 +10,7 @@ import { RequestRoute, ResponseToolkit, RouteCompressionEncoderSettings, - ServerAuth, + ServerAuth, ServerCache, ServerEvents, ServerEventsApplication, ServerExtEventsObject, @@ -27,7 +26,6 @@ import { ServerMethodConfigurationObject, ServerMethodOptions, ServerOptions, - ServerOptionsCache, ServerRealm, ServerRegisterOptions, ServerRegisterPluginObject, @@ -176,7 +174,7 @@ export class Server extends Podium { * the server.plugins[name] object directly or via the server.expose() method. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins) */ - plugins: object; + plugins: any; /** * The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When @@ -237,42 +235,7 @@ export class Server extends Podium { /** * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) */ - cache: { - - /** - * Provisions a cache segment within the server cache facility where: - * @param options - [catbox policy](https://github.com/hapijs/catbox#policy) configuration where: - * * expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. - * * expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records expire. Uses local time. Cannot be used together with expiresIn. - * * generateFunc - a function used to generate a new cache item if one is not found in the cache when calling get(). The method's signature is async function(id, flags) where: - * - `id` - the `id` string or object provided to the `get()` method. - * - `flags` - an object used to pass back additional flags to the cache where: - * - `ttl` - the cache ttl value in milliseconds. Set to `0` to skip storing in the cache. Defaults to the cache global policy. - * * staleIn - number of milliseconds to mark an item stored in cache as stale and attempt to regenerate it when generateFunc is provided. Must be less than expiresIn. - * * staleTimeout - number of milliseconds to wait before checking if an item is stale. - * * generateTimeout - number of milliseconds to wait before returning a timeout error when the generateFunc function takes too long to return a value. When the value is eventually returned, it is stored in the cache for future requests. Required if generateFunc is present. Set to false to disable timeouts which may cause all get() requests to get stuck forever. - * * generateOnReadError - if false, an upstream cache read error will stop the cache.get() method from calling the generate function and will instead pass back the cache error. Defaults to true. - * * generateIgnoreWriteError - if false, an upstream cache write error when calling cache.get() will be passed back with the generated value when calling. Defaults to true. - * * dropOnError - if true, an error or timeout in the generateFunc causes the stale value to be evicted from the cache. Defaults to true. - * * pendingGenerateTimeout - number of milliseconds while generateFunc call is in progress for a given id, before a subsequent generateFunc call is allowed. Defaults to 0 (no blocking of concurrent generateFunc calls beyond staleTimeout). - * * cache - the cache name configured in server.cache. Defaults to the default cache. - * * segment - string segment name, used to isolate cached items within the cache partition. When called within a plugin, defaults to '!name' where 'name' is the plugin name. When called within a server method, defaults to '#name' where 'name' is the server method name. Required when called outside of a plugin. - * * shared - if true, allows multiple cache provisions to share the same segment. Default to false. - * @return Catbox Policy. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) - */ - (options: catbox.PolicyOptions): catbox.Policy; - - /** - * Provisions a server cache as described in server.cache where: - * @param options - same as the server cache configuration options. - * @return Return value: none. - * Note that if the server has been initialized or started, the cache will be automatically started to match the state of any other provisioned server cache. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions) - */ - provision(options: ServerOptionsCache): void; - - }; + cache: ServerCache; /** * Registers a custom content decoding compressor to extend the built-in support for 'gzip' and 'deflate' where: @@ -316,9 +279,9 @@ export class Server extends Podium { * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdependencydependencies-after) */ dependency(dependencies: string): void; - dependency(dependencies: string, after: ((server: Server) => Function)): void; + dependency(dependencies: string, after: ((server: Server) => void)): void; dependency(dependencies: string[]): void; - dependency(dependencies: string[], after: ((server: Server) => Function)): void; + dependency(dependencies: string[], after: ((server: Server) => void)): void; /** * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' where: @@ -440,7 +403,7 @@ export class Server extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverlogtags-data-timestamp) */ - log(tags: string | string[], data?: string | object | (() => Function), timestamp?: number): void; + log(tags: string | string[], data?: string | object | (() => any), timestamp?: number): void; /** * Looks up a route configuration where: @@ -555,8 +518,8 @@ export class Server extends Podium { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrulesprocessor-options) */ - rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => Function): void; - rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => Function, options: {validate: object}): void; // TODO needs implementation + rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => object): void; + rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => object, options: {validate: object}): void; // TODO needs implementation /** * Starts the server by listening for incoming requests on the configured port (unless the connection was configured with autoListen set to false). From b65a79ab8bcb16f499ddc4861879792bacaf8e69 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 9 Dec 2017 19:55:35 -0300 Subject: [PATCH 084/298] Many fix discovered with the tests cases. --- types/hapi/v17/definitions/server/server-method.d.ts | 6 +++--- types/hapi/v17/definitions/server/server-route.d.ts | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/types/hapi/v17/definitions/server/server-method.d.ts b/types/hapi/v17/definitions/server/server-method.d.ts index e24f36cf74..c7d6e01446 100644 --- a/types/hapi/v17/definitions/server/server-method.d.ts +++ b/types/hapi/v17/definitions/server/server-method.d.ts @@ -30,9 +30,9 @@ export interface ServerMethodCache extends catbox.PolicyOptions { * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) */ export interface ServerMethodOptions { - bind: object; - cache: ServerMethodCache; - generateKey: Function; + bind?: object; + cache?: ServerMethodCache; + generateKey?: Function; } /** diff --git a/types/hapi/v17/definitions/server/server-route.d.ts b/types/hapi/v17/definitions/server/server-route.d.ts index b3c8e6fcee..caaa348fe0 100644 --- a/types/hapi/v17/definitions/server/server-route.d.ts +++ b/types/hapi/v17/definitions/server/server-route.d.ts @@ -32,7 +32,7 @@ export interface ServerRoute { /** * (required when handler is not set) the route handler function called to generate the response after successful authentication and validation. */ - handler?: Lifecycle.Method; + handler?: Lifecycle.Method | object; /** * additional route options. The options value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. @@ -44,4 +44,9 @@ export interface ServerRoute { */ rules?: object; + /** + * TODO: Missing documentation. Exist only in examples and test files. + */ + config?: any; + } From d91c350ad54b5751492eda6e295dbc4a10b647c4 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 9 Dec 2017 20:25:18 -0300 Subject: [PATCH 085/298] Add more new test files, mainly Server test files. --- types/hapi/v17/test/index.test.d.ts | 39 +++++++++++++----- types/hapi/v17/test/request/catch-all.ts | 2 +- types/hapi/v17/test/request/event-types.ts | 11 +++-- types/hapi/v17/test/request/get-log.ts | 2 +- types/hapi/v17/test/request/parameters.ts | 2 +- types/hapi/v17/test/request/query.ts | 2 +- types/hapi/v17/test/response/continue.ts | 2 +- types/hapi/v17/test/response/error.ts | 2 +- types/hapi/v17/test/response/redirect.ts | 2 +- types/hapi/v17/test/response/reply.ts | 2 +- types/hapi/v17/test/route/config.ts | 2 +- types/hapi/v17/test/server/a-simple-server.ts | 11 ----- types/hapi/v17/test/server/select.ts | 17 -------- .../v17/test/server/{app.ts => server-app.ts} | 2 +- types/hapi/v17/test/server/server-auth-api.ts | 40 +++++++++++++++++++ .../v17/test/server/server-auth-default.ts | 35 ++++++++++++++++ .../hapi/v17/test/server/server-auth-test.ts | 40 +++++++++++++++++++ types/hapi/v17/test/server/server-bind.ts | 31 ++++++++++++++ .../v17/test/server/server-cache-provision.ts | 21 ++++++++++ types/hapi/v17/test/server/server-cache.ts | 23 +++++++++++ types/hapi/v17/test/server/server-decoder.ts | 8 ++++ .../v17/test/server/server-decorations.ts | 25 ++++++++++++ types/hapi/v17/test/server/server-encoder.ts | 8 ++++ .../v17/test/server/server-events-once.ts | 2 +- types/hapi/v17/test/server/server-events.ts | 11 +++++ types/hapi/v17/test/server/server-expose.ts | 22 ++++++++++ .../test/server/{info.ts => server-info.ts} | 2 +- types/hapi/v17/test/server/server-inject.ts | 20 ++++++++++ types/hapi/v17/test/server/server-listener.ts | 14 +++++++ types/hapi/v17/test/server/server-load.ts | 15 +++++++ types/hapi/v17/test/server/server-lookup.ts | 20 ++++++++++ types/hapi/v17/test/server/server-match.ts | 20 ++++++++++ types/hapi/v17/test/server/server-method.ts | 26 ++++++++++++ types/hapi/v17/test/server/server-methods.ts | 11 +++++ types/hapi/v17/test/server/server-mime.ts | 22 ++++++++++ types/hapi/v17/test/server/server-path.ts | 30 ++++++++++++++ types/hapi/v17/test/server/server-plugins.ts | 20 ++++++++++ .../{settings.ts => server-settings.ts} | 2 +- .../test/server/{start.ts => server-start.ts} | 2 +- .../server-state.ts} | 0 .../test/server/{stop.ts => server-stop.ts} | 2 +- .../test/server/{table.ts => server-table.ts} | 2 +- .../server/{version.ts => server-version.ts} | 2 +- 43 files changed, 516 insertions(+), 58 deletions(-) delete mode 100644 types/hapi/v17/test/server/a-simple-server.ts delete mode 100644 types/hapi/v17/test/server/select.ts rename types/hapi/v17/test/server/{app.ts => server-app.ts} (87%) create mode 100644 types/hapi/v17/test/server/server-auth-api.ts create mode 100644 types/hapi/v17/test/server/server-auth-default.ts create mode 100644 types/hapi/v17/test/server/server-auth-test.ts create mode 100644 types/hapi/v17/test/server/server-bind.ts create mode 100644 types/hapi/v17/test/server/server-cache-provision.ts create mode 100644 types/hapi/v17/test/server/server-cache.ts create mode 100644 types/hapi/v17/test/server/server-decoder.ts create mode 100644 types/hapi/v17/test/server/server-decorations.ts create mode 100644 types/hapi/v17/test/server/server-encoder.ts create mode 100644 types/hapi/v17/test/server/server-events.ts create mode 100644 types/hapi/v17/test/server/server-expose.ts rename types/hapi/v17/test/server/{info.ts => server-info.ts} (81%) create mode 100644 types/hapi/v17/test/server/server-inject.ts create mode 100644 types/hapi/v17/test/server/server-listener.ts create mode 100644 types/hapi/v17/test/server/server-load.ts create mode 100644 types/hapi/v17/test/server/server-lookup.ts create mode 100644 types/hapi/v17/test/server/server-match.ts create mode 100644 types/hapi/v17/test/server/server-method.ts create mode 100644 types/hapi/v17/test/server/server-methods.ts create mode 100644 types/hapi/v17/test/server/server-mime.ts create mode 100644 types/hapi/v17/test/server/server-path.ts create mode 100644 types/hapi/v17/test/server/server-plugins.ts rename types/hapi/v17/test/server/{settings.ts => server-settings.ts} (71%) rename types/hapi/v17/test/server/{start.ts => server-start.ts} (71%) rename types/hapi/v17/test/{response/state_cookie.ts => server/server-state.ts} (100%) rename types/hapi/v17/test/server/{stop.ts => server-stop.ts} (80%) rename types/hapi/v17/test/server/{table.ts => server-table.ts} (86%) rename types/hapi/v17/test/server/{version.ts => server-version.ts} (65%) diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/index.test.d.ts index 228ffdc02c..ed5b66c2ba 100644 --- a/types/hapi/v17/test/index.test.d.ts +++ b/types/hapi/v17/test/index.test.d.ts @@ -20,7 +20,6 @@ export * from './response/continue'; export * from './response/error'; export * from './response/redirect'; export * from './response/reply'; -export * from './response/state_cookie'; /** ROUTE */ export * from './route/adding-routes'; @@ -28,16 +27,36 @@ export * from './route/config'; export * from './route/handler'; /** SERVER */ -export * from './server/a-simple-server'; -export * from './server/app'; -export * from './server/info'; -export * from './server/select'; +export * from './server/server-app'; +export * from './server/server-auth-api'; +export * from './server/server-auth-default'; +export * from './server/server-auth-test'; +export * from './server/server-bind'; +export * from './server/server-cache'; +export * from './server/server-cache-provision'; +export * from './server/server-decoder'; +export * from './server/server-decorations'; +export * from './server/server-encoder'; +export * from './server/server-events'; export * from './server/server-events-once'; -export * from './server/settings'; -export * from './server/start'; -export * from './server/stop'; -export * from './server/table'; -export * from './server/version'; +export * from './server/server-expose'; +export * from './server/server-info'; +export * from './server/server-inject'; +export * from './server/server-listener'; +export * from './server/server-load'; +export * from './server/server-lookup'; +export * from './server/server-match'; +export * from './server/server-method'; +export * from './server/server-methods'; +export * from './server/server-mime'; +export * from './server/server-path'; +export * from './server/server-plugins'; +export * from './server/server-settings'; +export * from './server/server-start'; +export * from './server/server-state'; +export * from './server/server-stop'; +export * from './server/server-table'; +export * from './server/server-version'; diff --git a/types/hapi/v17/test/request/catch-all.ts b/types/hapi/v17/test/request/catch-all.ts index a5292d4b7e..38a5638841 100644 --- a/types/hapi/v17/test/request/catch-all.ts +++ b/types/hapi/v17/test/request/catch-all.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#catch-all-route +// https://github.com/hapijs/hapi/blob/master/API.md#catch-all-route import {Request, ResponseToolkit, Server, ServerOptions} from "hapi"; const options: ServerOptions = { diff --git a/types/hapi/v17/test/request/event-types.ts b/types/hapi/v17/test/request/event-types.ts index ae1c0ac081..411472d70f 100644 --- a/types/hapi/v17/test/request/event-types.ts +++ b/types/hapi/v17/test/request/event-types.ts @@ -1,7 +1,12 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents -// From https://github.com/hapijs/hapi/blob/master/API.md#-requestevents +// https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents +// https://github.com/hapijs/hapi/blob/master/API.md#-requestevents import { - Request, RequestExtPointFunction, ResponseToolkit, RouteOptions, Server, ServerOptions, + Request, + RequestExtPointFunction, + ResponseToolkit, + RouteOptions, + Server, + ServerOptions, ServerRoute } from "hapi"; import * as Crypto from 'crypto'; diff --git a/types/hapi/v17/test/request/get-log.ts b/types/hapi/v17/test/request/get-log.ts index 047799c394..34e5ac56dc 100644 --- a/types/hapi/v17/test/request/get-log.ts +++ b/types/hapi/v17/test/request/get-log.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data +// https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { diff --git a/types/hapi/v17/test/request/parameters.ts b/types/hapi/v17/test/request/parameters.ts index 11684555db..40f79746dc 100644 --- a/types/hapi/v17/test/request/parameters.ts +++ b/types/hapi/v17/test/request/parameters.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-requestparams +// https://github.com/hapijs/hapi/blob/master/API.md#-requestparams import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { diff --git a/types/hapi/v17/test/request/query.ts b/types/hapi/v17/test/request/query.ts index e176e078e9..332d8914ee 100644 --- a/types/hapi/v17/test/request/query.ts +++ b/types/hapi/v17/test/request/query.ts @@ -1,5 +1,5 @@ // Added test in addition to docs, for request.query -import {Request, ResponseToolkit, Lifecycle, Server, ServerOptions, ServerRoute} from "hapi"; +import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { port: 8000, diff --git a/types/hapi/v17/test/response/continue.ts b/types/hapi/v17/test/response/continue.ts index 5a0b37b5f9..56d1cd4ddd 100644 --- a/types/hapi/v17/test/response/continue.ts +++ b/types/hapi/v17/test/response/continue.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options +// https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { diff --git a/types/hapi/v17/test/response/error.ts b/types/hapi/v17/test/response/error.ts index c9c5e3e822..7103e8361f 100644 --- a/types/hapi/v17/test/response/error.ts +++ b/types/hapi/v17/test/response/error.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#errors +// https://github.com/hapijs/hapi/blob/master/API.md#errors import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; import * as Boom from "boom"; diff --git a/types/hapi/v17/test/response/redirect.ts b/types/hapi/v17/test/response/redirect.ts index 37af39707e..735a07d7cd 100644 --- a/types/hapi/v17/test/response/redirect.ts +++ b/types/hapi/v17/test/response/redirect.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-hredirecturi +// https://github.com/hapijs/hapi/blob/master/API.md#-hredirecturi import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { diff --git a/types/hapi/v17/test/response/reply.ts b/types/hapi/v17/test/response/reply.ts index a2d4c250ed..4d6d7fc323 100644 --- a/types/hapi/v17/test/response/reply.ts +++ b/types/hapi/v17/test/response/reply.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-hresponsevalue +// https://github.com/hapijs/hapi/blob/master/API.md#-hresponsevalue import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { diff --git a/types/hapi/v17/test/route/config.ts b/types/hapi/v17/test/route/config.ts index 1ecabd0c56..f4ace674e9 100644 --- a/types/hapi/v17/test/route/config.ts +++ b/types/hapi/v17/test/route/config.ts @@ -1,4 +1,4 @@ -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute, RouteOptions} from "hapi"; +import {Request, ResponseToolkit, RouteOptions, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { port: 8000, diff --git a/types/hapi/v17/test/server/a-simple-server.ts b/types/hapi/v17/test/server/a-simple-server.ts deleted file mode 100644 index 995cac708c..0000000000 --- a/types/hapi/v17/test/server/a-simple-server.ts +++ /dev/null @@ -1,11 +0,0 @@ -// From https://hapijs.com/tutorials/getting-started#creating-a-server -import {Server, ServerOptions} from 'hapi'; - -const options: ServerOptions = { - port: 8000, -}; - -const server = new Server(options); -server.start(); - -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/server/select.ts b/types/hapi/v17/test/server/select.ts deleted file mode 100644 index cdf2cfd1e7..0000000000 --- a/types/hapi/v17/test/server/select.ts +++ /dev/null @@ -1,17 +0,0 @@ -// From https://hapijs.com/api/16.1.1#serverselectlabels -import {Server} from "hapi"; - -/* -const server = new Hapi.Server(); -server.connection({ port: 80, labels: ['a', 'b'] }); -server.connection({ port: 8080, labels: ['a', 'c'] }); -server.connection({ port: 8081, labels: ['b', 'c'] }); - -const a = server.select('a'); // 80, 8080 -const ac = a.select('c'); // 8080 -*/ -// TODO How do this with v17? - -const server = new Server({ - port: 8000, -}); diff --git a/types/hapi/v17/test/server/app.ts b/types/hapi/v17/test/server/server-app.ts similarity index 87% rename from types/hapi/v17/test/server/app.ts rename to types/hapi/v17/test/server/server-app.ts index cfd0bd91a4..f4f5d51540 100644 --- a/types/hapi/v17/test/server/app.ts +++ b/types/hapi/v17/test/server/server-app.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-serverapp +// https://github.com/hapijs/hapi/blob/master/API.md#-serverapp import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { diff --git a/types/hapi/v17/test/server/server-auth-api.ts b/types/hapi/v17/test/server/server-auth-api.ts new file mode 100644 index 0000000000..b1b40bdd5e --- /dev/null +++ b/types/hapi/v17/test/server/server-auth-api.ts @@ -0,0 +1,40 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi +import { + Request, + ResponseToolkit, + Server, + ServerAuthScheme, + ServerAuthSchemeObject, + ServerAuthSchemeOptions +} from "hapi"; +import * as Boom from "boom"; + +const scheme:ServerAuthScheme = function (server:Server, options:ServerAuthSchemeOptions): ServerAuthSchemeObject { + + return { + api: { + settings: { + x: 5 + } + }, + authenticate: function (request: Request, h: ResponseToolkit) { + + const authorization = request.headers.authorization; + if (!authorization) { + throw Boom.unauthorized(null, 'Custom'); + } + + return h.authenticated({ credentials: { user: 'john' } }); + } + }; + +}; + +const server = new Server({ + port: 8000, +}); +server.auth.scheme('custom', scheme); +server.auth.strategy('default', 'custom'); +server.start(); + +console.log(server.auth.api.default.settings.x); // 5 diff --git a/types/hapi/v17/test/server/server-auth-default.ts b/types/hapi/v17/test/server/server-auth-default.ts new file mode 100644 index 0000000000..415b7ad243 --- /dev/null +++ b/types/hapi/v17/test/server/server-auth-default.ts @@ -0,0 +1,35 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions +// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme +import {Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions} from "hapi"; +import * as Boom from "boom"; + +const server = new Server({ + port: 8000, +}); + +const scheme:ServerAuthScheme = function (server:Server, options:ServerAuthSchemeOptions) { + return { + authenticate: function (request:Request, h:ResponseToolkit) { + const req = request.raw.req; + const authorization = req.headers.authorization; + if (!authorization) { + throw Boom.unauthorized(null, 'Custom'); + } + return h.authenticated({ credentials: { user: 'john' } }); + } + }; +}; + +server.auth.scheme('custom', scheme); +server.auth.strategy('default', 'custom'); +server.auth.default('default'); + +server.route({ + method: 'GET', + path: '/', + handler: function (request:Request, h:ResponseToolkit) { + return request.auth.credentials.user; + } +}); + +server.start(); diff --git a/types/hapi/v17/test/server/server-auth-test.ts b/types/hapi/v17/test/server/server-auth-test.ts new file mode 100644 index 0000000000..0747d8abc2 --- /dev/null +++ b/types/hapi/v17/test/server/server-auth-test.ts @@ -0,0 +1,40 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverauthteststrategy-request +// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme +import {Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions} from "hapi"; +import * as Boom from "boom"; + +const server = new Server({ + port: 8000, +}); + +const scheme:ServerAuthScheme = function (server:Server, options:ServerAuthSchemeOptions) { + return { + authenticate: function (request:Request, h:ResponseToolkit) { + const req = request.raw.req; + const authorization = req.headers.authorization; + if (!authorization) { + throw Boom.unauthorized(null, 'Custom'); + } + return h.authenticated({ credentials: { user: 'john' } }); + } + }; +}; + +server.auth.scheme('custom', scheme); +server.auth.strategy('default', 'custom'); + +server.route({ + method: 'GET', + path: '/', + handler: function (request:Request, h:ResponseToolkit) { + try { + const credentials = request.server.auth.test('default', request); + return { status: true, user: credentials.name }; + } + catch (err) { + return { status: false }; + } + } +}); + +server.start(); diff --git a/types/hapi/v17/test/server/server-bind.ts b/types/hapi/v17/test/server/server-bind.ts new file mode 100644 index 0000000000..9653bcee3a --- /dev/null +++ b/types/hapi/v17/test/server/server-bind.ts @@ -0,0 +1,31 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverbindcontext +import {Plugin, Request, ResponseToolkit, Server, ServerRegisterOptions} from "hapi"; + +const server = new Server({ + port: 8000, +}); +const handler = function (request:Request, h:ResponseToolkit) { + return h.context.message; // Or h.context.message +}; + +const plugin:Plugin = { + name: 'example', + register: function (server:Server, options:ServerRegisterOptions) { + + const bind = { + message: 'hello' + }; + + server.bind(bind); + server.route({ method: 'GET', path: '/', handler }); + } +}; + + + +server.start(); +server.register(plugin); + +server.events.on('start', () => { + console.log('Server started at: ' + server.info.uri); +}); diff --git a/types/hapi/v17/test/server/server-cache-provision.ts b/types/hapi/v17/test/server/server-cache-provision.ts new file mode 100644 index 0000000000..3eac02cc51 --- /dev/null +++ b/types/hapi/v17/test/server/server-cache-provision.ts @@ -0,0 +1,21 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions +import {Server} from "hapi"; +import * as catbox from "catbox"; + +const server = new Server({ + port: 8000, +}); +server.initialize(); +server.cache.provision({engine: require('catbox-memory'), name: 'countries' }); + +const cache:catbox.Policy = server.cache({segment: 'countries', cache: 'countries', expiresIn: 60 * 60 * 1000 }); +cache.set('norway', 'oslo', 10 * 1000, null); +const value = cache.get('norway', null); + +// TODO Not working. It needs review. + +server.start(); + +server.events.on('start', () => { + console.log('Server started at: ' + server.info.uri); +}); diff --git a/types/hapi/v17/test/server/server-cache.ts b/types/hapi/v17/test/server/server-cache.ts new file mode 100644 index 0000000000..79049f23fd --- /dev/null +++ b/types/hapi/v17/test/server/server-cache.ts @@ -0,0 +1,23 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions +import {Server, ServerOptionsCache} from "hapi"; +import * as catbox from "catbox"; + +const server = new Server({ + port: 8000, +}); + +const catboxOptions:ServerOptionsCache = { + segment: 'countries', + expiresIn: 60 * 60 * 1000 +} +const cache:catbox.Policy = server.cache(catboxOptions); +cache.set('norway', 'oslo', 10 * 1000, null); + +const value = cache.get('norway', null); +console.log("Value: " + value); + +server.start(); + +server.events.on('start', () => { + console.log('Server started at: ' + server.info.uri); +}); diff --git a/types/hapi/v17/test/server/server-decoder.ts b/types/hapi/v17/test/server/server-decoder.ts new file mode 100644 index 0000000000..67e0a3abaa --- /dev/null +++ b/types/hapi/v17/test/server/server-decoder.ts @@ -0,0 +1,8 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoderencoding-decoder +import {Server} from "hapi"; +import * as Zlib from "zlib"; + +const server = new Server({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } }); +server.decoder('special', (options) => Zlib.createGunzip(options)); + +server.start(); diff --git a/types/hapi/v17/test/server/server-decorations.ts b/types/hapi/v17/test/server/server-decorations.ts new file mode 100644 index 0000000000..dd9c1ffcf3 --- /dev/null +++ b/types/hapi/v17/test/server/server-decorations.ts @@ -0,0 +1,25 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options +import {Server} from "hapi"; + +const server = new Server({ + port: 8000, +}); + +/* +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + return h.success(); + } +}; +const success = function () { + return this.response({ status: 'ok' }); +}; + +server.start(); +server.decorate('toolkit', 'success', success); +*/ +// TODO how to implement it with TS? + +console.log(server.decorations.toolkit); // ['success'] diff --git a/types/hapi/v17/test/server/server-encoder.ts b/types/hapi/v17/test/server/server-encoder.ts new file mode 100644 index 0000000000..ccc00e93e9 --- /dev/null +++ b/types/hapi/v17/test/server/server-encoder.ts @@ -0,0 +1,8 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder +import {Server} from "hapi"; +import * as Zlib from "zlib"; + +const server = new Server({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } }); +server.encoder('special', (options) => Zlib.createGzip(options)); + +server.start(); diff --git a/types/hapi/v17/test/server/server-events-once.ts b/types/hapi/v17/test/server/server-events-once.ts index 022cdb6f33..d81852f539 100644 --- a/types/hapi/v17/test/server/server-events-once.ts +++ b/types/hapi/v17/test/server/server-events-once.ts @@ -1,5 +1,5 @@ // from https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; +import {Request, ResponseToolkit, Server, ServerRoute} from "hapi"; const serverRoute: ServerRoute = { path: '/', diff --git a/types/hapi/v17/test/server/server-events.ts b/types/hapi/v17/test/server/server-events.ts new file mode 100644 index 0000000000..6c77d1826b --- /dev/null +++ b/types/hapi/v17/test/server/server-events.ts @@ -0,0 +1,11 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents +import {Server} from "hapi"; + +const server = new Server({ + port: 8000, +}); +server.event('test'); +server.events.on('test', (update:any) => console.log(update)); +server.events.emit('test', 'hello'); + +server.start(); diff --git a/types/hapi/v17/test/server/server-expose.ts b/types/hapi/v17/test/server/server-expose.ts new file mode 100644 index 0000000000..1852a26aec --- /dev/null +++ b/types/hapi/v17/test/server/server-expose.ts @@ -0,0 +1,22 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins +import {Plugin, Server, ServerRegisterOptions} from "hapi"; + +const plugin1:Plugin = { + name: 'example1', + register: function (server:Server, options:ServerRegisterOptions) { + server.expose('util', () => console.log('something')); + } +}; +const plugin2:Plugin = { + name: 'example2', + register: function (server:Server, options:ServerRegisterOptions) { + server.expose('util', () => console.log('something')); + } +}; + +const server = new Server({ + port: 8000, +}); +server.start(); +server.register(plugin1); +server.register(plugin2); diff --git a/types/hapi/v17/test/server/info.ts b/types/hapi/v17/test/server/server-info.ts similarity index 81% rename from types/hapi/v17/test/server/info.ts rename to types/hapi/v17/test/server/server-info.ts index 253a1b72aa..3543f5d30e 100644 --- a/types/hapi/v17/test/server/info.ts +++ b/types/hapi/v17/test/server/server-info.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo +// https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo import {Server} from "hapi"; import * as assert from "assert"; diff --git a/types/hapi/v17/test/server/server-inject.ts b/types/hapi/v17/test/server/server-inject.ts new file mode 100644 index 0000000000..03cb591e06 --- /dev/null +++ b/types/hapi/v17/test/server/server-inject.ts @@ -0,0 +1,20 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions +import {Request, ResponseToolkit, Server, ServerRoute} from "hapi"; + +const server = new Server({ + port: 8000, +}); +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: function (request: Request, h: ResponseToolkit) { + return 'Success!'; + } +}; + +server.route(serverRoute); +server.start(); + +const res = server.inject('/'); +console.log(res.result); // 'Success!' // TODO It's not working + diff --git a/types/hapi/v17/test/server/server-listener.ts b/types/hapi/v17/test/server/server-listener.ts new file mode 100644 index 0000000000..7a99ed260d --- /dev/null +++ b/types/hapi/v17/test/server/server-listener.ts @@ -0,0 +1,14 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverlistener +import {Server} from "hapi"; +import * as SocketIO from "socket.io" + +const server = new Server({ + port: 8000, +}); + +const io = SocketIO.listen(server.listener); +io.sockets.on('connection', (socket) => { + socket.emit('welcome'); +}); + +server.start(); diff --git a/types/hapi/v17/test/server/server-load.ts b/types/hapi/v17/test/server/server-load.ts new file mode 100644 index 0000000000..2b28bcda9d --- /dev/null +++ b/types/hapi/v17/test/server/server-load.ts @@ -0,0 +1,15 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverload +import {Server} from "hapi"; + +const server = new Server({ + port: 8000, + load: { sampleInterval: 1000 } +}); +server.start(); + +setTimeout(function() { + console.log(server.load.rss); + console.log(server.load.eventLoopDelay); + console.log(server.load.heapUsed); +}, 5 * 1000); + diff --git a/types/hapi/v17/test/server/server-lookup.ts b/types/hapi/v17/test/server/server-lookup.ts new file mode 100644 index 0000000000..c0531afb49 --- /dev/null +++ b/types/hapi/v17/test/server/server-lookup.ts @@ -0,0 +1,20 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverlookupid +import {RequestRoute, Server} from "hapi"; + +const server = new Server({ + port: 8000, +}); + +server.route({ + path: '/', + method: 'GET', + config: { + id: 'root', + handler: () => 'ok' + } +}); + +const route:RequestRoute = server.lookup('root'); +console.log(route); + +server.start(); diff --git a/types/hapi/v17/test/server/server-match.ts b/types/hapi/v17/test/server/server-match.ts new file mode 100644 index 0000000000..4a3a7805af --- /dev/null +++ b/types/hapi/v17/test/server/server-match.ts @@ -0,0 +1,20 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-servermatchmethod-path-host +import {RequestRoute, Server} from "hapi"; + +const server = new Server({ + port: 8000, +}); + +server.route({ + path: '/', + method: 'GET', + config: { + id: 'root', + handler: () => 'ok' + } +}); + +const route:RequestRoute = server.match('get', '/'); +console.log(route.path); + +server.start(); diff --git a/types/hapi/v17/test/server/server-method.ts b/types/hapi/v17/test/server/server-method.ts new file mode 100644 index 0000000000..8214842760 --- /dev/null +++ b/types/hapi/v17/test/server/server-method.ts @@ -0,0 +1,26 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-servermethodmethods +import {Server, ServerMethodConfigurationObject} from "hapi"; + +const server = new Server({ + port: 8000, +}); +server.start(); + +const add = function (a:any, b:any) { + return a + b; +}; + +const methodObject:ServerMethodConfigurationObject = { + name: 'sum', + method: add, + options: { + cache: { + expiresIn: 2000, + generateTimeout: 100 + } + } +} + +server.method(methodObject); + + diff --git a/types/hapi/v17/test/server/server-methods.ts b/types/hapi/v17/test/server/server-methods.ts new file mode 100644 index 0000000000..1d0831fd53 --- /dev/null +++ b/types/hapi/v17/test/server/server-methods.ts @@ -0,0 +1,11 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-servermethods +import {Server} from "hapi"; + +const server = new Server({ + port: 8000, +}); +server.start(); + +server.method('add', (a, b) => (a + b)); +const result = server.methods.add(1, 2); // 3 +console.log(result); diff --git a/types/hapi/v17/test/server/server-mime.ts b/types/hapi/v17/test/server/server-mime.ts new file mode 100644 index 0000000000..76fcac5594 --- /dev/null +++ b/types/hapi/v17/test/server/server-mime.ts @@ -0,0 +1,22 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-servermime +import {Server, ServerOptions} from "hapi"; + +const options:ServerOptions = { + port: 8000, + mime: { + override: { + 'node/module': { + source: 'steve', + compressible: false, + extensions: ['node', 'module', 'npm'], + type: 'node/module' + } + } + } +}; + +const server = new Server(options); +console.log(server.mime.path('code.js').type) // 'application/javascript' +console.log(server.mime.path('file.npm').type) // 'node/module' + +server.start(); diff --git a/types/hapi/v17/test/server/server-path.ts b/types/hapi/v17/test/server/server-path.ts new file mode 100644 index 0000000000..4baa613245 --- /dev/null +++ b/types/hapi/v17/test/server/server-path.ts @@ -0,0 +1,30 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverpathrelativeto +import {Plugin, Server, ServerRegisterOptions, ServerRoute} from "hapi"; + +const server = new Server({ + port: 8000, +}); + +const serverRouteOption:ServerRoute = { + path: '/file', + method: 'GET', + handler: { + file: './test.html' + } +} + +const plugin:Plugin = { + name: 'example', + register: function (server:Server, options:ServerRegisterOptions) { + // Assuming the Inert plugin was registered previously + server.path(__dirname + '../static'); + server.route(serverRouteOption); + } +}; + +server.start(); +server.register(plugin); + +server.events.on('start', () => { + console.log('Server started at: ' + server.info.uri); +}); diff --git a/types/hapi/v17/test/server/server-plugins.ts b/types/hapi/v17/test/server/server-plugins.ts new file mode 100644 index 0000000000..620609b4cb --- /dev/null +++ b/types/hapi/v17/test/server/server-plugins.ts @@ -0,0 +1,20 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins +import {Plugin, Server, ServerRegisterOptions} from "hapi"; + +const plugin:Plugin = { + name: 'example', + register: function (server:Server, options:ServerRegisterOptions) { + + server.expose('key', 'value'); + server.plugins.example.other = 'other'; + + console.log(server.plugins.example.key); // 'value' + console.log(server.plugins.example.other); // 'other' + } +}; + +const server = new Server({ + port: 8000, +}); +server.start(); +server.register(plugin); diff --git a/types/hapi/v17/test/server/settings.ts b/types/hapi/v17/test/server/server-settings.ts similarity index 71% rename from types/hapi/v17/test/server/settings.ts rename to types/hapi/v17/test/server/server-settings.ts index ebe7588b88..07bfec2b64 100644 --- a/types/hapi/v17/test/server/settings.ts +++ b/types/hapi/v17/test/server/server-settings.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-serversettings +// https://github.com/hapijs/hapi/blob/master/API.md#-serversettings import {Server} from "hapi"; const server = new Server({ diff --git a/types/hapi/v17/test/server/start.ts b/types/hapi/v17/test/server/server-start.ts similarity index 71% rename from types/hapi/v17/test/server/start.ts rename to types/hapi/v17/test/server/server-start.ts index 425c287842..ab95930a4d 100644 --- a/types/hapi/v17/test/server/start.ts +++ b/types/hapi/v17/test/server/server-start.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstart +// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstart import {Server} from "hapi"; const server = new Server({ diff --git a/types/hapi/v17/test/response/state_cookie.ts b/types/hapi/v17/test/server/server-state.ts similarity index 100% rename from types/hapi/v17/test/response/state_cookie.ts rename to types/hapi/v17/test/server/server-state.ts diff --git a/types/hapi/v17/test/server/stop.ts b/types/hapi/v17/test/server/server-stop.ts similarity index 80% rename from types/hapi/v17/test/server/stop.ts rename to types/hapi/v17/test/server/server-stop.ts index 2e7f3f9b2b..a143577410 100644 --- a/types/hapi/v17/test/server/stop.ts +++ b/types/hapi/v17/test/server/server-stop.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstopoptions +// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstopoptions import {Server} from "hapi"; const server = new Server({ diff --git a/types/hapi/v17/test/server/table.ts b/types/hapi/v17/test/server/server-table.ts similarity index 86% rename from types/hapi/v17/test/server/table.ts rename to types/hapi/v17/test/server/server-table.ts index 58c8e4c52d..78f2df90db 100644 --- a/types/hapi/v17/test/server/table.ts +++ b/types/hapi/v17/test/server/server-table.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost +// https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost import {Request, ResponseToolkit, Server, ServerOptions} from "hapi"; const options: ServerOptions = { diff --git a/types/hapi/v17/test/server/version.ts b/types/hapi/v17/test/server/server-version.ts similarity index 65% rename from types/hapi/v17/test/server/version.ts rename to types/hapi/v17/test/server/server-version.ts index 041a565f48..02f7ca1d20 100644 --- a/types/hapi/v17/test/server/version.ts +++ b/types/hapi/v17/test/server/server-version.ts @@ -1,4 +1,4 @@ -// From https://github.com/hapijs/hapi/blob/master/API.md#-serverversion +// https://github.com/hapijs/hapi/blob/master/API.md#-serverversion import {Server} from "hapi"; const server = new Server({ From 0e389ba4e7e9a47f43069539f8f9d150be687993 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 9 Dec 2017 20:25:57 -0300 Subject: [PATCH 086/298] Add new type ServerCache in index. --- types/hapi/v17/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index 3ded9fe2bf..9dcc6b841c 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -41,6 +41,7 @@ export * from './definitions/route/route-options-validate' export * from './definitions/server/server' export * from './definitions/server/server-auth' export * from './definitions/server/server-auth-scheme' +export * from './definitions/server/server-cache' export * from './definitions/server/server-events' export * from './definitions/server/server-ext' export * from './definitions/server/server-info' From 1b597e080af8a3e72aca5b5f4a327783e9358195 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 9 Dec 2017 21:17:58 -0300 Subject: [PATCH 087/298] More fix based in test cases. --- types/hapi/v17/definitions/request/request.d.ts | 2 +- .../v17/definitions/response/response-events.d.ts | 9 ++------- types/hapi/v17/definitions/server/server-ext.d.ts | 10 +++------- types/hapi/v17/definitions/server/server.d.ts | 12 +++++------- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index a9a8c8b6d2..5fe1a63f5b 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -140,7 +140,7 @@ export interface Request extends Podium { /** * By default the object outputted from node's URL parse() method. Might also be set indirectly via request.setUrl in which case it may be a string (if url is set to an object with the query attribute as an unparsed string). */ - readonly query: object; + readonly query: any; /** * An object containing the Node HTTP server objects. Direct interaction with these raw objects is not recommended. diff --git a/types/hapi/v17/definitions/response/response-events.d.ts b/types/hapi/v17/definitions/response/response-events.d.ts index 469009087c..e5dcb43d30 100644 --- a/types/hapi/v17/definitions/response/response-events.d.ts +++ b/types/hapi/v17/definitions/response/response-events.d.ts @@ -11,14 +11,9 @@ export interface ResponseEvents extends Podium { /** * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). - */ - on(criteria: 'peak', listener: Function): void; - once(criteria: 'peak', listener: Function): void; - - /** * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). */ - on(criteria: 'finish', listener: Function): void; - once(criteria: 'finish', listener: Function): void; + on(criteria: 'peek' | 'finish', listener: Function): void; + once(criteria: 'peek' | 'finish', listener: Function): void; } diff --git a/types/hapi/v17/definitions/server/server-ext.d.ts b/types/hapi/v17/definitions/server/server-ext.d.ts index 02853a2888..809f4ddc61 100644 --- a/types/hapi/v17/definitions/server/server-ext.d.ts +++ b/types/hapi/v17/definitions/server/server-ext.d.ts @@ -9,7 +9,7 @@ import {Lifecycle, Server} from "hapi"; * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) */ -export type ServerExtType = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; +export type ServerExtType = 'onRequest' | 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'| 'onPreResponse'; /** * The extension point event name for Request @@ -41,7 +41,7 @@ export type ServerExtRequestType = 'onRequest'; */ export interface ServerExtEventsObject { type: ServerExtType; - method: ServerExtPointFunction | ServerExtPointFunction[]; + method: ServerExtPointFunction | ServerExtPointFunction[] | Function; options?: ServerExtOptions; } @@ -68,7 +68,7 @@ export interface ServerExtEventsObject { */ export interface ServerExtEventsRequestObject { type: ServerExtRequestType; - method: RequestExtPointFunction | RequestExtPointFunction[]; + method: Lifecycle.Method | Lifecycle.Method[]; options?: ServerExtOptions; } @@ -76,10 +76,6 @@ export interface ServerExtPointFunction { (server: Server): void; } -export interface RequestExtPointFunction extends Lifecycle.Method { - -} - /** * An object with the following: * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index 1f3654b1be..b7ac0e908f 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -2,22 +2,22 @@ import * as http from "http"; import * as zlib from "zlib"; import * as Podium from "podium"; import { + Lifecycle, PayloadCompressionDecoderSettings, Plugin, PluginsListRegistered, Request, - RequestExtPointFunction, RequestRoute, ResponseToolkit, RouteCompressionEncoderSettings, - ServerAuth, ServerCache, + ServerAuth, + ServerCache, ServerEvents, ServerEventsApplication, ServerExtEventsObject, ServerExtEventsRequestObject, ServerExtOptions, ServerExtPointFunction, - ServerExtRequestType, ServerExtType, ServerInfo, ServerInjectOptions, @@ -343,10 +343,8 @@ export class Server extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options) */ - ext(event: ServerExtType, method: ServerExtPointFunction): void; - ext(event: ServerExtType, method: ServerExtPointFunction, options: ServerExtOptions): void; - ext(event: ServerExtRequestType, method: RequestExtPointFunction): void; - ext(event: ServerExtRequestType, method: RequestExtPointFunction, options: ServerExtOptions): void; + ext(event: ServerExtType, method: ServerExtPointFunction | Lifecycle.Method | Function): void; + ext(event: ServerExtType, method: ServerExtPointFunction | Lifecycle.Method | Function, options: ServerExtOptions): void; /** * Initializes the server (starts the caches, finalizes plugin registration) but does not start listening on the connection port. From b1ca20cc48deaae2223556de1a2fcc4080cfb127 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 9 Dec 2017 21:29:43 -0300 Subject: [PATCH 088/298] Add more tests. --- types/hapi/v17/test/index.test.d.ts | 4 +- types/hapi/v17/test/request/event-types.ts | 4 +- .../hapi/v17/test/response/response-events.ts | 31 ++++++++++++++ .../test/response/{reply.ts => response.ts} | 4 +- .../hapi/v17/test/route/route-options-pre.ts | 42 +++++++++++++++++++ 5 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 types/hapi/v17/test/response/response-events.ts rename types/hapi/v17/test/response/{reply.ts => response.ts} (95%) create mode 100644 types/hapi/v17/test/route/route-options-pre.ts diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/index.test.d.ts index ed5b66c2ba..a3e94ac7dd 100644 --- a/types/hapi/v17/test/index.test.d.ts +++ b/types/hapi/v17/test/index.test.d.ts @@ -19,12 +19,14 @@ export * from './request/query'; export * from './response/continue'; export * from './response/error'; export * from './response/redirect'; -export * from './response/reply'; +export * from './response/response'; +export * from './response/response-events'; /** ROUTE */ export * from './route/adding-routes'; export * from './route/config'; export * from './route/handler'; +export * from './route/route-options-pre'; /** SERVER */ export * from './server/server-app'; diff --git a/types/hapi/v17/test/request/event-types.ts b/types/hapi/v17/test/request/event-types.ts index 411472d70f..7e22841e64 100644 --- a/types/hapi/v17/test/request/event-types.ts +++ b/types/hapi/v17/test/request/event-types.ts @@ -1,8 +1,8 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents // https://github.com/hapijs/hapi/blob/master/API.md#-requestevents import { + Lifecycle, Request, - RequestExtPointFunction, ResponseToolkit, RouteOptions, Server, @@ -23,7 +23,7 @@ const serverRoute: ServerRoute = { } }; -const onRequest: RequestExtPointFunction = function (request: Request, h: ResponseToolkit) { +const onRequest: Lifecycle.Method = function (request: Request, h: ResponseToolkit) { /* * Server events diff --git a/types/hapi/v17/test/response/response-events.ts b/types/hapi/v17/test/response/response-events.ts new file mode 100644 index 0000000000..3b0f29879f --- /dev/null +++ b/types/hapi/v17/test/response/response-events.ts @@ -0,0 +1,31 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-responseevents +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute, ResponseObject} from "hapi"; +import * as Crypto from "crypto"; + +const preResponse = function (request: Request, h: ResponseToolkit) { + + const response:ResponseObject = request.response; + // if (response.isBoom) { + // return null; + // } + + const hash = Crypto.createHash('sha1'); + response.events.on('peek', (chunk:any) => { + hash.update(chunk); + }); + + response.events.once('finish', () => { + console.log(hash.digest('hex')); + }); + + return h.continue; +}; + +const server = new Server({ + port: 8000, +}); + +server.ext('onPreResponse', preResponse); + +server.start(); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/response/reply.ts b/types/hapi/v17/test/response/response.ts similarity index 95% rename from types/hapi/v17/test/response/reply.ts rename to types/hapi/v17/test/response/response.ts index 4d6d7fc323..55af428a34 100644 --- a/types/hapi/v17/test/response/reply.ts +++ b/types/hapi/v17/test/response/response.ts @@ -6,7 +6,7 @@ const options: ServerOptions = { }; const serverRoutes: ServerRoute[] = [ - // verbose notation + // Detailed notation { path: '/test1', method: 'GET', @@ -17,7 +17,7 @@ const serverRoutes: ServerRoute[] = [ return response; } }, - // chained notation + // Chained notation { path: '/test2', method: 'GET', diff --git a/types/hapi/v17/test/route/route-options-pre.ts b/types/hapi/v17/test/route/route-options-pre.ts new file mode 100644 index 0000000000..63cbe09647 --- /dev/null +++ b/types/hapi/v17/test/route/route-options-pre.ts @@ -0,0 +1,42 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre +import {Server, Request, ResponseToolkit} from "hapi"; + +const server = new Server({ + port: 8000, +}); + +const pre1 = function(request: Request, h: ResponseToolkit) { + return 'Hello'; +}; + +const pre2 = function(request: Request, h: ResponseToolkit) { + return 'World'; +}; + +const pre3 = function(request: Request, h: ResponseToolkit) { + return request.pre.m1 + ' ' + request.pre.m2; +}; + +server.route({ + method: 'GET', + path: '/', + config: { + pre: [ + [ + // m1 and m2 executed in parallel + { method: pre1, assign: 'm1' }, + { method: pre2, assign: 'm2' } + ], + { method: pre3, assign: 'm3' }, + ], + handler: function (request: Request, h: ResponseToolkit) { + return request.pre.m3 + '!\n'; + } + } +}); + +server.start(); + +server.events.on('start', () => { + console.log('Server started at: ' + server.info.uri); +}); From b5a4bb1fb61b5081d48ca99d92969c4b18edffdc Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Sat, 9 Dec 2017 19:36:51 -0800 Subject: [PATCH 089/298] Update tslint.json --- types/text-encoding-utf-8/tslint.json | 78 +-------------------------- 1 file changed, 1 insertion(+), 77 deletions(-) diff --git a/types/text-encoding-utf-8/tslint.json b/types/text-encoding-utf-8/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/text-encoding-utf-8/tslint.json +++ b/types/text-encoding-utf-8/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } From 5f28ba9c8cc50314ce1bfdaf188d57fbe650b0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Pluci=C5=84ski?= Date: Sun, 10 Dec 2017 11:23:28 +0100 Subject: [PATCH 090/298] vakata helpers exposed vakata helpers exposed --- types/jstree/index.d.ts | 106 +++++++++++++++++++++++++++++------ types/jstree/jstree-tests.ts | 2 - 2 files changed, 88 insertions(+), 20 deletions(-) diff --git a/types/jstree/index.d.ts b/types/jstree/index.d.ts index 21e07de80d..1aeaf07761 100644 --- a/types/jstree/index.d.ts +++ b/types/jstree/index.d.ts @@ -1,8 +1,7 @@ -// Type definitions for jsTree v3.3.3 +// Type definitions for jsTree v3.3.4 // Project: http://www.jstree.com/ // Definitions by: Adam Pluciński // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 /// @@ -15,6 +14,11 @@ interface JQueryStatic { * @type {JSTreeStatic} */ jstree?: JSTreeStatic; + + /** + * helpers + */ + vakata?: VakataStatic; } interface JQuery { @@ -96,25 +100,25 @@ interface JSTreeStatic { core(id: number): void; /** - * get a reference to an existing instance - * - * __Examples__ - * - * // provided a container with an ID of "tree", and a nested node with an ID of "branch" - * // all of there will return the same instance - * $.jstree.reference('tree'); - * $.jstree.reference('#tree'); + * get a reference to an existing instance + * + * __Examples__ + * + * // provided a container with an ID of "tree", and a nested node with an ID of "branch" + * // all of there will return the same instance + * $.jstree.reference('tree'); + * $.jstree.reference('#tree'); * $.jstree.reference($('#tree')); * $.jstree.reference(document.getElementByID('tree')); - * $.jstree.reference('branch'); - * $.jstree.reference('#branch'); - * $.jstree.reference($('#branch')); + * $.jstree.reference('branch'); + * $.jstree.reference('#branch'); + * $.jstree.reference($('#branch')); * $.jstree.reference(document.getElementByID('branch')); - * + * * @name $.jstree.reference(needle) * @param {DOMElement|jQuery|String} needle * @return {jsTree|null} the instance or `null` if not found - */ + */ reference(needle: HTMLElement|JQuery|string): JSTree; } @@ -282,7 +286,7 @@ interface JSTreeStaticDefaultsCore { * $('#tree').jstree({ * 'core' : { * 'check_callback' : function (operation, node, node_parent, node_position, more) { - * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node' or 'copy_node' + * // operation can be 'create_node', 'rename_node', 'delete_node', 'move_node', 'copy_node' or 'edit' * // in case of 'rename_node' node_position is filled with the new node name * return operation === 'rename_node' ? true : false; * } @@ -445,6 +449,20 @@ interface JSTreeStaticDefaultsCheckbox { * @plugin checkbox */ tie_selection: boolean; + + /** + * This setting controls if cascading down affects disabled checkboxes + * @name $.jstree.defaults.checkbox.cascade_to_disabled + * @plugin checkbox + */ + cascade_to_disabled : boolean; + + /** + * This setting controls if cascading down affects hidden checkboxes + * @name $.jstree.defaults.checkbox.cascade_to_hidden + * @plugin checkbox + */ + cascade_to_hidden : boolean; } interface JSTreeStaticDefaultsContextMenu { @@ -708,6 +726,43 @@ interface JSTreeStaticDefaultsUnique { duplicate: (name: string, counter: number) => string; } +interface VakataStatic { + /** + * collect attributes + */ + attributes: (node: any, with_values: any) => any; + + /** + * returns array with unique elements + */ + array_unique: (array: Array) => Array; + + /** + * remove item from array + */ + array_remove: (array: Array, from: number) => Array; + + /** + * remove item from array + */ + array_remove_item: (array: Array, item: any) => Array; + + /** + * filter array + */ + array_filter: (c: any, a: any, b: any, d: Array, e: any) => Array; + + context: any; + + html: any; + + dnd: any; + + search: any; + + storage: any; +} + interface JSTree extends JQuery { /** * used to decorate an instance with a plugin. Used internally. @@ -871,12 +926,12 @@ interface JSTree extends JQuery { get_parent: (obj: any) => string; /** - * get a jQuery collection of all the children of a node (node must be rendered) + * get a jQuery collection of all the children of a node (node must be rendered), returns false on error * @name get_children_dom(obj) * @param {mixed} obj * @return {jQuery} */ - get_children_dom: (obj: any) => JQuery; + get_children_dom: (obj: any) => JQuery|boolean; /** * checks if a node has children @@ -1686,6 +1741,21 @@ interface JSTree extends JQuery { */ enable_checkbox: (obj: any) => boolean; + /** + * Unchecks a node and all its descendants. This function does NOT affect hidden and disabled nodes (or their descendants). + * However if these unaffected nodes are already selected their ids will be included in the returned array. + * @param id + * @param checkedState + * @returns {Array} Array of all node id's (in this tree branch) that are checked. + */ + _cascade_new_checked_state: (id: string, checkedState: string) => string[]; + + /** + * Gets ids of nodes selected in branch (of tree) specified by id (does not include the node specified by id) + * @param id + */ + get_checked_descendants: (id: string) => string[]; + /** * check a node (only if tie_selection in checkbox settings is false, otherwise select_node will be called internally) * @name check_node(obj) diff --git a/types/jstree/jstree-tests.ts b/types/jstree/jstree-tests.ts index 208ae9b979..d939bb6b29 100644 --- a/types/jstree/jstree-tests.ts +++ b/types/jstree/jstree-tests.ts @@ -1,5 +1,3 @@ - - // gets version of lib var version: string = $.jstree.version; From dbb203c4d7de19feb75b1e8cbca90d1f705e20cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Pluci=C5=84ski?= Date: Sun, 10 Dec 2017 11:32:25 +0100 Subject: [PATCH 091/298] sample of invokaction --- types/jstree/jstree-tests.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/jstree/jstree-tests.ts b/types/jstree/jstree-tests.ts index d939bb6b29..57ef47cb8c 100644 --- a/types/jstree/jstree-tests.ts +++ b/types/jstree/jstree-tests.ts @@ -124,3 +124,9 @@ var treeWithNewCoreProperties = $('#treeWithNewEllipsisProperties').jstree({ themes: coreThemes } }); + +var vakata: VakataStatic = $.vakata; + +var testArray: Array = []; +vakata.attributes(tree.get_node(null), true); +var storage = vakata.storage; \ No newline at end of file From 9e23698cb5401c9295300ac2d6c5aa9d079a7a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Pluci=C5=84ski?= Date: Sun, 10 Dec 2017 11:43:33 +0100 Subject: [PATCH 092/298] changed header - compatible with version 2.3 of typescript --- types/jstree/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/jstree/index.d.ts b/types/jstree/index.d.ts index 1aeaf07761..6bbbb43d2a 100644 --- a/types/jstree/index.d.ts +++ b/types/jstree/index.d.ts @@ -2,6 +2,7 @@ // Project: http://www.jstree.com/ // Definitions by: Adam Pluciński // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// From 6a11db62bdd29720dbe008cbfc25b563764f4b0f Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 10 Dec 2017 17:08:15 -0300 Subject: [PATCH 093/298] Delete comments. --- types/hapi/v17/test/response/response-events.ts | 3 --- types/hapi/v17/test/route/config.ts | 1 - types/hapi/v17/test/server/server-decorations.ts | 16 +++------------- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/types/hapi/v17/test/response/response-events.ts b/types/hapi/v17/test/response/response-events.ts index 3b0f29879f..8427352cba 100644 --- a/types/hapi/v17/test/response/response-events.ts +++ b/types/hapi/v17/test/response/response-events.ts @@ -5,9 +5,6 @@ import * as Crypto from "crypto"; const preResponse = function (request: Request, h: ResponseToolkit) { const response:ResponseObject = request.response; - // if (response.isBoom) { - // return null; - // } const hash = Crypto.createHash('sha1'); response.events.on('peek', (chunk:any) => { diff --git a/types/hapi/v17/test/route/config.ts b/types/hapi/v17/test/route/config.ts index f4ace674e9..94465cd736 100644 --- a/types/hapi/v17/test/route/config.ts +++ b/types/hapi/v17/test/route/config.ts @@ -48,7 +48,6 @@ const user: RouteOptions = { }; server.route({method: 'GET', path: '/user', options: user }); -//server.route({ method: 'GET', path: '/public/{path*}', options: { cache: { privacy: 'public', expiresIn: 24 * 60 * 60 * 1000 } }, handler: { directory: { path: __dirname, listing: false, index: false } } }); server.start(); console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/server/server-decorations.ts b/types/hapi/v17/test/server/server-decorations.ts index dd9c1ffcf3..05e7714f2b 100644 --- a/types/hapi/v17/test/server/server-decorations.ts +++ b/types/hapi/v17/test/server/server-decorations.ts @@ -1,25 +1,15 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options -import {Server} from "hapi"; +import {ResponseToolkit, Server} from "hapi"; const server = new Server({ port: 8000, }); -/* -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { - return h.success(); - } -}; -const success = function () { - return this.response({ status: 'ok' }); +const success = function (h: ResponseToolkit) { + return h.response({ status: 'ok' }); }; server.start(); server.decorate('toolkit', 'success', success); -*/ -// TODO how to implement it with TS? console.log(server.decorations.toolkit); // ['success'] From 3d6b18467eae8940f5834142d38f0a2d15817854 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 10 Dec 2017 17:08:40 -0300 Subject: [PATCH 094/298] Remove asserts. It's not necessary here. --- types/hapi/v17/test/server/server-info.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/types/hapi/v17/test/server/server-info.ts b/types/hapi/v17/test/server/server-info.ts index 3543f5d30e..6599fe5b5a 100644 --- a/types/hapi/v17/test/server/server-info.ts +++ b/types/hapi/v17/test/server/server-info.ts @@ -1,15 +1,10 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo import {Server} from "hapi"; -import * as assert from "assert"; const server = new Server({ port: 8000, }); server.start(); -// check the correct port console.log(server.info); -if (server.info) assert(server.info.port === 8000); - -assert(server.info !== null); console.log('Server started at: ' + server.info.uri); From 1a5f4f589451493176d9325b5a012cc9fd286d1a Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 10 Dec 2017 17:36:53 -0300 Subject: [PATCH 095/298] Replace all "function" with arrow function "() =>". --- types/hapi/v17/test/request/catch-all.ts | 4 ++-- types/hapi/v17/test/request/event-types.ts | 8 ++++---- types/hapi/v17/test/request/get-log.ts | 4 ++-- types/hapi/v17/test/request/parameters.ts | 6 +++--- types/hapi/v17/test/request/query.ts | 2 +- types/hapi/v17/test/response/continue.ts | 4 ++-- types/hapi/v17/test/response/error.ts | 6 +++--- types/hapi/v17/test/response/redirect.ts | 4 ++-- types/hapi/v17/test/response/response-events.ts | 4 ++-- types/hapi/v17/test/response/response.ts | 6 +++--- types/hapi/v17/test/route/adding-routes.ts | 6 +++--- types/hapi/v17/test/route/config.ts | 7 +++---- types/hapi/v17/test/route/handler.ts | 4 ++-- types/hapi/v17/test/route/route-options-pre.ts | 10 +++++----- types/hapi/v17/test/server/server-app.ts | 4 ++-- types/hapi/v17/test/server/server-auth-api.ts | 6 +++--- types/hapi/v17/test/server/server-auth-default.ts | 8 ++++---- types/hapi/v17/test/server/server-auth-test.ts | 8 ++++---- types/hapi/v17/test/server/server-bind.ts | 10 +++------- types/hapi/v17/test/server/server-cache-provision.ts | 2 +- types/hapi/v17/test/server/server-cache.ts | 2 +- types/hapi/v17/test/server/server-decorations.ts | 4 ++-- types/hapi/v17/test/server/server-encoder.ts | 2 +- types/hapi/v17/test/server/server-events-once.ts | 6 +++--- types/hapi/v17/test/server/server-events.ts | 2 +- types/hapi/v17/test/server/server-expose.ts | 6 +++--- types/hapi/v17/test/server/server-info.ts | 2 +- types/hapi/v17/test/server/server-inject.ts | 4 ++-- types/hapi/v17/test/server/server-listener.ts | 2 +- types/hapi/v17/test/server/server-load.ts | 4 ++-- types/hapi/v17/test/server/server-lookup.ts | 2 +- types/hapi/v17/test/server/server-match.ts | 2 +- types/hapi/v17/test/server/server-method.ts | 4 ++-- types/hapi/v17/test/server/server-methods.ts | 2 +- types/hapi/v17/test/server/server-mime.ts | 2 +- types/hapi/v17/test/server/server-path.ts | 4 ++-- types/hapi/v17/test/server/server-plugins.ts | 4 ++-- types/hapi/v17/test/server/server-settings.ts | 2 +- types/hapi/v17/test/server/server-start.ts | 2 +- types/hapi/v17/test/server/server-state.ts | 2 +- types/hapi/v17/test/server/server-stop.ts | 4 ++-- types/hapi/v17/test/server/server-table.ts | 4 ++-- types/hapi/v17/test/server/server-version.ts | 2 +- 43 files changed, 89 insertions(+), 94 deletions(-) diff --git a/types/hapi/v17/test/request/catch-all.ts b/types/hapi/v17/test/request/catch-all.ts index 38a5638841..1917cd8fff 100644 --- a/types/hapi/v17/test/request/catch-all.ts +++ b/types/hapi/v17/test/request/catch-all.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#catch-all-route +// https://github.com/hapijs/hapi/blob/master/API.md#catch-all-route import {Request, ResponseToolkit, Server, ServerOptions} from "hapi"; const options: ServerOptions = { @@ -6,7 +6,7 @@ const options: ServerOptions = { }; const server = new Server(options); -const handler = function (request: Request, h: ResponseToolkit) { +const handler = (request: Request, h: ResponseToolkit) => { return h.response('The page was not found').code(404); }; server.route({ method: '*', path: '/{p*}', handler }); diff --git a/types/hapi/v17/test/request/event-types.ts b/types/hapi/v17/test/request/event-types.ts index 7e22841e64..894e4dcf39 100644 --- a/types/hapi/v17/test/request/event-types.ts +++ b/types/hapi/v17/test/request/event-types.ts @@ -1,5 +1,5 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents -// https://github.com/hapijs/hapi/blob/master/API.md#-requestevents +// https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents +// https://github.com/hapijs/hapi/blob/master/API.md#-requestevents import { Lifecycle, Request, @@ -18,12 +18,12 @@ const options: ServerOptions = { const serverRoute: ServerRoute = { path: '/', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return 'ok: ' + request.path; } }; -const onRequest: Lifecycle.Method = function (request: Request, h: ResponseToolkit) { +const onRequest: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { /* * Server events diff --git a/types/hapi/v17/test/request/get-log.ts b/types/hapi/v17/test/request/get-log.ts index 34e5ac56dc..007d396fe5 100644 --- a/types/hapi/v17/test/request/get-log.ts +++ b/types/hapi/v17/test/request/get-log.ts @@ -1,11 +1,11 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data +// https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { port: 8000, }; -const handler: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { +const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { request.log(['test', 'error'], 'Test event'); return 'path: ' + request.path; }; diff --git a/types/hapi/v17/test/request/parameters.ts b/types/hapi/v17/test/request/parameters.ts index 40f79746dc..43259ea4fb 100644 --- a/types/hapi/v17/test/request/parameters.ts +++ b/types/hapi/v17/test/request/parameters.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-requestparams +// https://github.com/hapijs/hapi/blob/master/API.md#-requestparams import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { @@ -7,7 +7,7 @@ const options: ServerOptions = { // Example 1 // http://localhost:8000/album-name/song-optional -const getAlbum: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { +const getAlbum: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { console.log(request.params); return 'ok: ' + request.path; } @@ -19,7 +19,7 @@ const serverRoute1: ServerRoute = { // Example 2 // http://localhost:8000/person/rafael/fijalkowski -const getPerson: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { +const getPerson: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { const nameParts = request.params.name.split('/'); return { first: nameParts[0], last: nameParts[1] }; } diff --git a/types/hapi/v17/test/request/query.ts b/types/hapi/v17/test/request/query.ts index 332d8914ee..b5a950e2ad 100644 --- a/types/hapi/v17/test/request/query.ts +++ b/types/hapi/v17/test/request/query.ts @@ -5,7 +5,7 @@ const options: ServerOptions = { port: 8000, }; -const handler: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { +const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { const query = request.query as GetThingQuery; // http://localhost:8000/?name=test return `You asked for ${query.name}` diff --git a/types/hapi/v17/test/response/continue.ts b/types/hapi/v17/test/response/continue.ts index 56d1cd4ddd..4839b4b6e2 100644 --- a/types/hapi/v17/test/response/continue.ts +++ b/types/hapi/v17/test/response/continue.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options +// https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { @@ -8,7 +8,7 @@ const options: ServerOptions = { const serverRoute: ServerRoute = { path: '/test', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return 'ok: ' + request.path; } }; diff --git a/types/hapi/v17/test/response/error.ts b/types/hapi/v17/test/response/error.ts index 7103e8361f..6cc92acbdb 100644 --- a/types/hapi/v17/test/response/error.ts +++ b/types/hapi/v17/test/response/error.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#errors +// https://github.com/hapijs/hapi/blob/master/API.md#errors import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; import * as Boom from "boom"; @@ -10,14 +10,14 @@ const serverRoutes: ServerRoute[] = [ { path: '/badRequest', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { throw Boom.badRequest('Unsupported parameter'); } }, { path: '/internal', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { throw new Error('unexpect error'); } }, diff --git a/types/hapi/v17/test/response/redirect.ts b/types/hapi/v17/test/response/redirect.ts index 735a07d7cd..3cb6addba7 100644 --- a/types/hapi/v17/test/response/redirect.ts +++ b/types/hapi/v17/test/response/redirect.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-hredirecturi +// https://github.com/hapijs/hapi/blob/master/API.md#-hredirecturi import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { @@ -8,7 +8,7 @@ const options: ServerOptions = { const serverRoute: ServerRoute = { path: '/', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return h.redirect('http://example.com'); } } diff --git a/types/hapi/v17/test/response/response-events.ts b/types/hapi/v17/test/response/response-events.ts index 8427352cba..06c6d6bfa8 100644 --- a/types/hapi/v17/test/response/response-events.ts +++ b/types/hapi/v17/test/response/response-events.ts @@ -1,8 +1,8 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-responseevents +// https://github.com/hapijs/hapi/blob/master/API.md#-responseevents import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute, ResponseObject} from "hapi"; import * as Crypto from "crypto"; -const preResponse = function (request: Request, h: ResponseToolkit) { +const preResponse = (request: Request, h: ResponseToolkit) => { const response:ResponseObject = request.response; diff --git a/types/hapi/v17/test/response/response.ts b/types/hapi/v17/test/response/response.ts index 55af428a34..66b11b352f 100644 --- a/types/hapi/v17/test/response/response.ts +++ b/types/hapi/v17/test/response/response.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-hresponsevalue +// https://github.com/hapijs/hapi/blob/master/API.md#-hresponsevalue import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { @@ -10,7 +10,7 @@ const serverRoutes: ServerRoute[] = [ { path: '/test1', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { const response = h.response('success'); response.type('text/plain'); response.header('X-Custom', 'some-value'); @@ -21,7 +21,7 @@ const serverRoutes: ServerRoute[] = [ { path: '/test2', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return h.response('success') .type('text/plain') .header('X-Custom', 'some-value'); diff --git a/types/hapi/v17/test/route/adding-routes.ts b/types/hapi/v17/test/route/adding-routes.ts index 7d503502c2..8136c6508b 100644 --- a/types/hapi/v17/test/route/adding-routes.ts +++ b/types/hapi/v17/test/route/adding-routes.ts @@ -8,7 +8,7 @@ const options: ServerOptions = { const serverRoute: ServerRoute = { path: '/', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return 'ok: ' + request.path; } }; @@ -17,14 +17,14 @@ const serverRoutes: ServerRoute[] = [ { path: '/test1', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return 'ok: ' + request.path; } }, { path: '/test2', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return 'ok: ' + request.path; } }, diff --git a/types/hapi/v17/test/route/config.ts b/types/hapi/v17/test/route/config.ts index 94465cd736..1f36cd51b3 100644 --- a/types/hapi/v17/test/route/config.ts +++ b/types/hapi/v17/test/route/config.ts @@ -4,7 +4,6 @@ const options: ServerOptions = { port: 8000, }; - // different methods var routeConfig: ServerRoute = { path: '/signin', @@ -24,14 +23,14 @@ var routeConfig: ServerRoute = { var routeConfig: ServerRoute = { path: '/signin', method: 'PUT', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return 'ok'; } }; var routeConfig: ServerRoute = { path: '/signin', method: 'PUT', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return 'ok'; } }; @@ -42,7 +41,7 @@ server.route(routeConfig); // Handler in config const user: RouteOptions = { cache: { expiresIn: 5000 }, - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return { name: 'John' }; } }; diff --git a/types/hapi/v17/test/route/handler.ts b/types/hapi/v17/test/route/handler.ts index fa20d7b677..e3bea54939 100644 --- a/types/hapi/v17/test/route/handler.ts +++ b/types/hapi/v17/test/route/handler.ts @@ -1,9 +1,9 @@ import {Lifecycle, Request, ResponseToolkit} from "hapi"; -const handler: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { +const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { return 'success'; } -const strictHandler: Lifecycle.Method = function(request: Request, h: ResponseToolkit) { +const strictHandler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { return 123; } diff --git a/types/hapi/v17/test/route/route-options-pre.ts b/types/hapi/v17/test/route/route-options-pre.ts index 63cbe09647..fedfab4c45 100644 --- a/types/hapi/v17/test/route/route-options-pre.ts +++ b/types/hapi/v17/test/route/route-options-pre.ts @@ -1,19 +1,19 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre +// https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre import {Server, Request, ResponseToolkit} from "hapi"; const server = new Server({ port: 8000, }); -const pre1 = function(request: Request, h: ResponseToolkit) { +const pre1 = (request: Request, h: ResponseToolkit) => { return 'Hello'; }; -const pre2 = function(request: Request, h: ResponseToolkit) { +const pre2 = (request: Request, h: ResponseToolkit) => { return 'World'; }; -const pre3 = function(request: Request, h: ResponseToolkit) { +const pre3 = (request: Request, h: ResponseToolkit) => { return request.pre.m1 + ' ' + request.pre.m2; }; @@ -29,7 +29,7 @@ server.route({ ], { method: pre3, assign: 'm3' }, ], - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return request.pre.m3 + '!\n'; } } diff --git a/types/hapi/v17/test/server/server-app.ts b/types/hapi/v17/test/server/server-app.ts index f4f5d51540..b70a83c301 100644 --- a/types/hapi/v17/test/server/server-app.ts +++ b/types/hapi/v17/test/server/server-app.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverapp +// https://github.com/hapijs/hapi/blob/master/API.md#-serverapp import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; const options: ServerOptions = { @@ -11,7 +11,7 @@ server.app.key = 'value2'; const serverRoute: ServerRoute = { path: '/', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return 'key: ' + request.server.app.key; } } diff --git a/types/hapi/v17/test/server/server-auth-api.ts b/types/hapi/v17/test/server/server-auth-api.ts index b1b40bdd5e..9f2bc5da3b 100644 --- a/types/hapi/v17/test/server/server-auth-api.ts +++ b/types/hapi/v17/test/server/server-auth-api.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi +// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi import { Request, ResponseToolkit, @@ -9,7 +9,7 @@ import { } from "hapi"; import * as Boom from "boom"; -const scheme:ServerAuthScheme = function (server:Server, options:ServerAuthSchemeOptions): ServerAuthSchemeObject { +const scheme:ServerAuthScheme = (server:Server, options:ServerAuthSchemeOptions): ServerAuthSchemeObject => { return { api: { @@ -17,7 +17,7 @@ const scheme:ServerAuthScheme = function (server:Server, options:ServerAuthSchem x: 5 } }, - authenticate: function (request: Request, h: ResponseToolkit) { + authenticate: (request: Request, h: ResponseToolkit) => { const authorization = request.headers.authorization; if (!authorization) { diff --git a/types/hapi/v17/test/server/server-auth-default.ts b/types/hapi/v17/test/server/server-auth-default.ts index 415b7ad243..3287da5ab8 100644 --- a/types/hapi/v17/test/server/server-auth-default.ts +++ b/types/hapi/v17/test/server/server-auth-default.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions +// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions // https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme import {Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions} from "hapi"; import * as Boom from "boom"; @@ -7,9 +7,9 @@ const server = new Server({ port: 8000, }); -const scheme:ServerAuthScheme = function (server:Server, options:ServerAuthSchemeOptions) { +const scheme:ServerAuthScheme = (server:Server, options:ServerAuthSchemeOptions) => { return { - authenticate: function (request:Request, h:ResponseToolkit) { + authenticate: (request:Request, h:ResponseToolkit) => { const req = request.raw.req; const authorization = req.headers.authorization; if (!authorization) { @@ -27,7 +27,7 @@ server.auth.default('default'); server.route({ method: 'GET', path: '/', - handler: function (request:Request, h:ResponseToolkit) { + handler: (request:Request, h:ResponseToolkit) => { return request.auth.credentials.user; } }); diff --git a/types/hapi/v17/test/server/server-auth-test.ts b/types/hapi/v17/test/server/server-auth-test.ts index 0747d8abc2..668fb27994 100644 --- a/types/hapi/v17/test/server/server-auth-test.ts +++ b/types/hapi/v17/test/server/server-auth-test.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverauthteststrategy-request +// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverauthteststrategy-request // https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme import {Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions} from "hapi"; import * as Boom from "boom"; @@ -7,9 +7,9 @@ const server = new Server({ port: 8000, }); -const scheme:ServerAuthScheme = function (server:Server, options:ServerAuthSchemeOptions) { +const scheme:ServerAuthScheme = (server:Server, options:ServerAuthSchemeOptions) => { return { - authenticate: function (request:Request, h:ResponseToolkit) { + authenticate: (request:Request, h:ResponseToolkit) => { const req = request.raw.req; const authorization = req.headers.authorization; if (!authorization) { @@ -26,7 +26,7 @@ server.auth.strategy('default', 'custom'); server.route({ method: 'GET', path: '/', - handler: function (request:Request, h:ResponseToolkit) { + handler: (request:Request, h:ResponseToolkit) => { try { const credentials = request.server.auth.test('default', request); return { status: true, user: credentials.name }; diff --git a/types/hapi/v17/test/server/server-bind.ts b/types/hapi/v17/test/server/server-bind.ts index 9653bcee3a..ebd071fb63 100644 --- a/types/hapi/v17/test/server/server-bind.ts +++ b/types/hapi/v17/test/server/server-bind.ts @@ -1,28 +1,24 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverbindcontext +// https://github.com/hapijs/hapi/blob/master/API.md#-serverbindcontext import {Plugin, Request, ResponseToolkit, Server, ServerRegisterOptions} from "hapi"; const server = new Server({ port: 8000, }); -const handler = function (request:Request, h:ResponseToolkit) { +const handler = (request:Request, h:ResponseToolkit) => { return h.context.message; // Or h.context.message }; const plugin:Plugin = { name: 'example', - register: function (server:Server, options:ServerRegisterOptions) { - + register: (server:Server, options:ServerRegisterOptions) => { const bind = { message: 'hello' }; - server.bind(bind); server.route({ method: 'GET', path: '/', handler }); } }; - - server.start(); server.register(plugin); diff --git a/types/hapi/v17/test/server/server-cache-provision.ts b/types/hapi/v17/test/server/server-cache-provision.ts index 3eac02cc51..ce733403f3 100644 --- a/types/hapi/v17/test/server/server-cache-provision.ts +++ b/types/hapi/v17/test/server/server-cache-provision.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions +// https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions import {Server} from "hapi"; import * as catbox from "catbox"; diff --git a/types/hapi/v17/test/server/server-cache.ts b/types/hapi/v17/test/server/server-cache.ts index 79049f23fd..df92a45038 100644 --- a/types/hapi/v17/test/server/server-cache.ts +++ b/types/hapi/v17/test/server/server-cache.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions +// https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions import {Server, ServerOptionsCache} from "hapi"; import * as catbox from "catbox"; diff --git a/types/hapi/v17/test/server/server-decorations.ts b/types/hapi/v17/test/server/server-decorations.ts index 05e7714f2b..a5a5f3d69f 100644 --- a/types/hapi/v17/test/server/server-decorations.ts +++ b/types/hapi/v17/test/server/server-decorations.ts @@ -1,11 +1,11 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options +// https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options import {ResponseToolkit, Server} from "hapi"; const server = new Server({ port: 8000, }); -const success = function (h: ResponseToolkit) { +const success = (h: ResponseToolkit) => { return h.response({ status: 'ok' }); }; diff --git a/types/hapi/v17/test/server/server-encoder.ts b/types/hapi/v17/test/server/server-encoder.ts index ccc00e93e9..920ade785b 100644 --- a/types/hapi/v17/test/server/server-encoder.ts +++ b/types/hapi/v17/test/server/server-encoder.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder +// https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder import {Server} from "hapi"; import * as Zlib from "zlib"; diff --git a/types/hapi/v17/test/server/server-events-once.ts b/types/hapi/v17/test/server/server-events-once.ts index d81852f539..18f9fe2fd3 100644 --- a/types/hapi/v17/test/server/server-events-once.ts +++ b/types/hapi/v17/test/server/server-events-once.ts @@ -4,7 +4,7 @@ import {Request, ResponseToolkit, Server, ServerRoute} from "hapi"; const serverRoute: ServerRoute = { path: '/', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return 'oks: ' + request.path; } }; @@ -15,8 +15,8 @@ const server = new Server({ server.route(serverRoute); server.event('test1'); server.event('test2'); -server.events.once('test1', function(update: any) {console.log(update);}); -server.events.once('test2', function(...args: any[]) {console.log(args);}); +server.events.once('test1', (update: any) => {console.log(update);}); +server.events.once('test2', (...args: any[]) => {console.log(args);}); server.events.emit('test1', 'hello-1'); server.events.emit('test2', 'hello-2'); // Ignored diff --git a/types/hapi/v17/test/server/server-events.ts b/types/hapi/v17/test/server/server-events.ts index 6c77d1826b..32deb7c8e6 100644 --- a/types/hapi/v17/test/server/server-events.ts +++ b/types/hapi/v17/test/server/server-events.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents +// https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents import {Server} from "hapi"; const server = new Server({ diff --git a/types/hapi/v17/test/server/server-expose.ts b/types/hapi/v17/test/server/server-expose.ts index 1852a26aec..c35e3c1d78 100644 --- a/types/hapi/v17/test/server/server-expose.ts +++ b/types/hapi/v17/test/server/server-expose.ts @@ -1,15 +1,15 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins +// https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins import {Plugin, Server, ServerRegisterOptions} from "hapi"; const plugin1:Plugin = { name: 'example1', - register: function (server:Server, options:ServerRegisterOptions) { + register: (server:Server, options:ServerRegisterOptions) => { server.expose('util', () => console.log('something')); } }; const plugin2:Plugin = { name: 'example2', - register: function (server:Server, options:ServerRegisterOptions) { + register: (server:Server, options:ServerRegisterOptions) => { server.expose('util', () => console.log('something')); } }; diff --git a/types/hapi/v17/test/server/server-info.ts b/types/hapi/v17/test/server/server-info.ts index 6599fe5b5a..6f7ed24912 100644 --- a/types/hapi/v17/test/server/server-info.ts +++ b/types/hapi/v17/test/server/server-info.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo +// https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo import {Server} from "hapi"; const server = new Server({ diff --git a/types/hapi/v17/test/server/server-inject.ts b/types/hapi/v17/test/server/server-inject.ts index 03cb591e06..4d50f766e0 100644 --- a/types/hapi/v17/test/server/server-inject.ts +++ b/types/hapi/v17/test/server/server-inject.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions +// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions import {Request, ResponseToolkit, Server, ServerRoute} from "hapi"; const server = new Server({ @@ -7,7 +7,7 @@ const server = new Server({ const serverRoute: ServerRoute = { path: '/', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return 'Success!'; } }; diff --git a/types/hapi/v17/test/server/server-listener.ts b/types/hapi/v17/test/server/server-listener.ts index 7a99ed260d..b4cdcc47ed 100644 --- a/types/hapi/v17/test/server/server-listener.ts +++ b/types/hapi/v17/test/server/server-listener.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverlistener +// https://github.com/hapijs/hapi/blob/master/API.md#-serverlistener import {Server} from "hapi"; import * as SocketIO from "socket.io" diff --git a/types/hapi/v17/test/server/server-load.ts b/types/hapi/v17/test/server/server-load.ts index 2b28bcda9d..e53f8e8546 100644 --- a/types/hapi/v17/test/server/server-load.ts +++ b/types/hapi/v17/test/server/server-load.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverload +// https://github.com/hapijs/hapi/blob/master/API.md#-serverload import {Server} from "hapi"; const server = new Server({ @@ -7,7 +7,7 @@ const server = new Server({ }); server.start(); -setTimeout(function() { +setTimeout(() => { console.log(server.load.rss); console.log(server.load.eventLoopDelay); console.log(server.load.heapUsed); diff --git a/types/hapi/v17/test/server/server-lookup.ts b/types/hapi/v17/test/server/server-lookup.ts index c0531afb49..45e8ef304c 100644 --- a/types/hapi/v17/test/server/server-lookup.ts +++ b/types/hapi/v17/test/server/server-lookup.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverlookupid +// https://github.com/hapijs/hapi/blob/master/API.md#-serverlookupid import {RequestRoute, Server} from "hapi"; const server = new Server({ diff --git a/types/hapi/v17/test/server/server-match.ts b/types/hapi/v17/test/server/server-match.ts index 4a3a7805af..8da8ba6220 100644 --- a/types/hapi/v17/test/server/server-match.ts +++ b/types/hapi/v17/test/server/server-match.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servermatchmethod-path-host +// https://github.com/hapijs/hapi/blob/master/API.md#-servermatchmethod-path-host import {RequestRoute, Server} from "hapi"; const server = new Server({ diff --git a/types/hapi/v17/test/server/server-method.ts b/types/hapi/v17/test/server/server-method.ts index 8214842760..396cfa62d8 100644 --- a/types/hapi/v17/test/server/server-method.ts +++ b/types/hapi/v17/test/server/server-method.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servermethodmethods +// https://github.com/hapijs/hapi/blob/master/API.md#-servermethodmethods import {Server, ServerMethodConfigurationObject} from "hapi"; const server = new Server({ @@ -6,7 +6,7 @@ const server = new Server({ }); server.start(); -const add = function (a:any, b:any) { +const add = (a:any, b:any) => { return a + b; }; diff --git a/types/hapi/v17/test/server/server-methods.ts b/types/hapi/v17/test/server/server-methods.ts index 1d0831fd53..4ce4b8ceaf 100644 --- a/types/hapi/v17/test/server/server-methods.ts +++ b/types/hapi/v17/test/server/server-methods.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servermethods +// https://github.com/hapijs/hapi/blob/master/API.md#-servermethods import {Server} from "hapi"; const server = new Server({ diff --git a/types/hapi/v17/test/server/server-mime.ts b/types/hapi/v17/test/server/server-mime.ts index 76fcac5594..ad8922d0b5 100644 --- a/types/hapi/v17/test/server/server-mime.ts +++ b/types/hapi/v17/test/server/server-mime.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servermime +// https://github.com/hapijs/hapi/blob/master/API.md#-servermime import {Server, ServerOptions} from "hapi"; const options:ServerOptions = { diff --git a/types/hapi/v17/test/server/server-path.ts b/types/hapi/v17/test/server/server-path.ts index 4baa613245..7578a9ba2f 100644 --- a/types/hapi/v17/test/server/server-path.ts +++ b/types/hapi/v17/test/server/server-path.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverpathrelativeto +// https://github.com/hapijs/hapi/blob/master/API.md#-serverpathrelativeto import {Plugin, Server, ServerRegisterOptions, ServerRoute} from "hapi"; const server = new Server({ @@ -15,7 +15,7 @@ const serverRouteOption:ServerRoute = { const plugin:Plugin = { name: 'example', - register: function (server:Server, options:ServerRegisterOptions) { + register: (server:Server, options:ServerRegisterOptions) => { // Assuming the Inert plugin was registered previously server.path(__dirname + '../static'); server.route(serverRouteOption); diff --git a/types/hapi/v17/test/server/server-plugins.ts b/types/hapi/v17/test/server/server-plugins.ts index 620609b4cb..c38f240067 100644 --- a/types/hapi/v17/test/server/server-plugins.ts +++ b/types/hapi/v17/test/server/server-plugins.ts @@ -1,9 +1,9 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins +// https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins import {Plugin, Server, ServerRegisterOptions} from "hapi"; const plugin:Plugin = { name: 'example', - register: function (server:Server, options:ServerRegisterOptions) { + register: (server:Server, options:ServerRegisterOptions) => { server.expose('key', 'value'); server.plugins.example.other = 'other'; diff --git a/types/hapi/v17/test/server/server-settings.ts b/types/hapi/v17/test/server/server-settings.ts index 07bfec2b64..ec30cdc606 100644 --- a/types/hapi/v17/test/server/server-settings.ts +++ b/types/hapi/v17/test/server/server-settings.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serversettings +// https://github.com/hapijs/hapi/blob/master/API.md#-serversettings import {Server} from "hapi"; const server = new Server({ diff --git a/types/hapi/v17/test/server/server-start.ts b/types/hapi/v17/test/server/server-start.ts index ab95930a4d..228b9ca6a2 100644 --- a/types/hapi/v17/test/server/server-start.ts +++ b/types/hapi/v17/test/server/server-start.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstart +// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstart import {Server} from "hapi"; const server = new Server({ diff --git a/types/hapi/v17/test/server/server-state.ts b/types/hapi/v17/test/server/server-state.ts index 9952ee0e77..7a6c118c4d 100644 --- a/types/hapi/v17/test/server/server-state.ts +++ b/types/hapi/v17/test/server/server-state.ts @@ -8,7 +8,7 @@ const options: ServerOptions = { const serverRoute: ServerRoute = { path: '/say-hello', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return h.response('Hello').state('data', { firstVisit: false }); } } diff --git a/types/hapi/v17/test/server/server-stop.ts b/types/hapi/v17/test/server/server-stop.ts index a143577410..c07649ff65 100644 --- a/types/hapi/v17/test/server/server-stop.ts +++ b/types/hapi/v17/test/server/server-stop.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstopoptions +// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstopoptions import {Server} from "hapi"; const server = new Server({ @@ -12,6 +12,6 @@ server.events.on('start', () => { server.events.on('stop', () => { console.log('Server stoped.'); }); -setTimeout(function() { +setTimeout(() => { server.stop({ timeout: 10 * 1000 }); }, 5 * 1000); diff --git a/types/hapi/v17/test/server/server-table.ts b/types/hapi/v17/test/server/server-table.ts index 78f2df90db..75d63ac724 100644 --- a/types/hapi/v17/test/server/server-table.ts +++ b/types/hapi/v17/test/server/server-table.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost +// https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost import {Request, ResponseToolkit, Server, ServerOptions} from "hapi"; const options: ServerOptions = { @@ -11,7 +11,7 @@ server.app.key = 'value2'; server.route({ path: '/', method: 'GET', - handler: function (request: Request, h: ResponseToolkit) { + handler: (request: Request, h: ResponseToolkit) => { return h.response("Hello World"); } }); diff --git a/types/hapi/v17/test/server/server-version.ts b/types/hapi/v17/test/server/server-version.ts index 02f7ca1d20..ecca8ba5ba 100644 --- a/types/hapi/v17/test/server/server-version.ts +++ b/types/hapi/v17/test/server/server-version.ts @@ -1,4 +1,4 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverversion +// https://github.com/hapijs/hapi/blob/master/API.md#-serverversion import {Server} from "hapi"; const server = new Server({ From 9f0b8755afd962705a549c3c3b056004d4c54f2a Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 10 Dec 2017 18:20:19 -0300 Subject: [PATCH 096/298] Add "server-options.ts" test file containing all possible options. --- types/hapi/v17/test/index.test.d.ts | 1 + types/hapi/v17/test/server/server-options.ts | 103 +++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 types/hapi/v17/test/server/server-options.ts diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/index.test.d.ts index a3e94ac7dd..7b9041f929 100644 --- a/types/hapi/v17/test/index.test.d.ts +++ b/types/hapi/v17/test/index.test.d.ts @@ -51,6 +51,7 @@ export * from './server/server-match'; export * from './server/server-method'; export * from './server/server-methods'; export * from './server/server-mime'; +export * from './server/server-options'; export * from './server/server-path'; export * from './server/server-plugins'; export * from './server/server-settings'; diff --git a/types/hapi/v17/test/server/server-options.ts b/types/hapi/v17/test/server/server-options.ts new file mode 100644 index 0000000000..8057613781 --- /dev/null +++ b/types/hapi/v17/test/server/server-options.ts @@ -0,0 +1,103 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-server-options +import {Server, ServerOptions, Plugin, Request, ServerRegisterOptions, ServerRoute, ResponseToolkit} from "hapi"; +import {MimosOptions, MimosOptionsValue} from "mimos"; + +const CatboxMemory = require('catbox-memory'); + +const mimeOptions: MimosOptions = { + override: { + 'node/module': { + source: 'iana', + compressible: true, + extensions: ['node', 'modsule', 'npm'], + type: 'node/module' + }, + 'application/javascript': { + source: 'iana', + charset: 'UTF-8', + compressible: true, + extensions: ['js', 'javascript'], + type: 'text/javascript' + }, + 'text/html': { + predicate: (mime:MimosOptionsValue) => { + if (1 == 1) { + //mime.foo = 'test'; + } + else { + //mime.foo = 'bar'; + } + return mime; + } + } + } +}; + +const plugin: Plugin = { + name: 'example', + register: (server:Server, options:ServerRegisterOptions) => { + server.expose('key', 'value'); + server.plugins.example.other = 'other'; + console.log(server.plugins.example.key); // 'value' + console.log(server.plugins.example.other); // 'other' + } +}; + +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: (request: Request, h: ResponseToolkit) => { + return 'ok: ' + request.path; + } +}; + +const options: ServerOptions = { + address: '0.0.0.0', + app: { + key1: 'value1', + key2: 'value2', + any_thing: 'any_value', + }, + autoListen: true, + cache: { + engine: CatboxMemory, + name: 'test', + shared: true, + partition: 'hapi-cache', + any_thing_1: 'any_thing_1', + any_thing_2: 'any_thing_2' + }, + compression: { + minBytes: 1024 + }, + debug: { + request: ['implementation'] + }, + host: 'localhost', + listener: null, + load: { sampleInterval: 0 }, + mime: mimeOptions, + plugins: plugin, + port: 8000, + router: { + isCaseSensitive: true, + stripTrailingSlash: false + }, + routes: serverRoute, + state: { + strictHeader: true, + ignoreErrors: false, + isSecure: true, + isHttpOnly: true, + isSameSite: 'Strict', + encoding: 'none' + }, + tls: null +}; + +const server = new Server(options); +server.start(); + +server.events.on('start', () => { + console.log('Server started at: ' + server.info.uri); +}); From cb280b5ccfa3fb9d43501cf47d59acb965361d40 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 10 Dec 2017 18:49:38 -0300 Subject: [PATCH 097/298] Add type object to compression property. It is not only boolean. --- types/hapi/v17/definitions/server/server-options.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/hapi/v17/definitions/server/server-options.d.ts b/types/hapi/v17/definitions/server/server-options.d.ts index 407ebfd1c4..606dd701ba 100644 --- a/types/hapi/v17/definitions/server/server-options.d.ts +++ b/types/hapi/v17/definitions/server/server-options.d.ts @@ -55,7 +55,7 @@ export interface ServerOptions { * Default value: { minBytes: 1024 }. * Defines server handling of content encoding requests. If false, response content encoding is disabled and no compression is performed by the server. */ - compression?: boolean; + compression?: boolean | object; /** * Default value: '1024'. From 6a92487939470e96f6f3219963e66962a97ff6ac Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 10 Dec 2017 18:50:21 -0300 Subject: [PATCH 098/298] Add more options in "server-options.ts" test file. --- types/hapi/v17/test/server/server-options.ts | 22 +++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/types/hapi/v17/test/server/server-options.ts b/types/hapi/v17/test/server/server-options.ts index 8057613781..49d567eee8 100644 --- a/types/hapi/v17/test/server/server-options.ts +++ b/types/hapi/v17/test/server/server-options.ts @@ -1,5 +1,5 @@ // https://github.com/hapijs/hapi/blob/master/API.md#-server-options -import {Server, ServerOptions, Plugin, Request, ServerRegisterOptions, ServerRoute, ResponseToolkit} from "hapi"; +import {Server, ServerOptions, Plugin, ServerRegisterOptions, RouteOptions} from "hapi"; import {MimosOptions, MimosOptionsValue} from "mimos"; const CatboxMemory = require('catbox-memory'); @@ -43,12 +43,18 @@ const plugin: Plugin = { } }; -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - } +const routeOptions: RouteOptions = { + compression: { + test: { + some: 'option' + } + }, + files: { + relativeTo: __dirname + }, + cors: { + origin: ['http://test.example.com', 'http://www.example.com', 'http://*.a.com'] + }, }; const options: ServerOptions = { @@ -83,7 +89,7 @@ const options: ServerOptions = { isCaseSensitive: true, stripTrailingSlash: false }, - routes: serverRoute, + routes: routeOptions, state: { strictHeader: true, ignoreErrors: false, From bb52a85035d13e6d5a5232c8a85a4559902826cf Mon Sep 17 00:00:00 2001 From: segayuu Date: Mon, 11 Dec 2017 14:05:15 +0900 Subject: [PATCH 099/298] Delete unnecessary rule invalidation setting --- types/vinyl/tslint.json | 64 +---------------------------------------- 1 file changed, 1 insertion(+), 63 deletions(-) diff --git a/types/vinyl/tslint.json b/types/vinyl/tslint.json index a41bf5d19a..537285c84b 100644 --- a/types/vinyl/tslint.json +++ b/types/vinyl/tslint.json @@ -1,79 +1,17 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, "comment-format": false, "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, "no-var-keyword": false, "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, "only-arrow-functions": false, - "prefer-conditional-expression": false, "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "space-before-function-paren": false } } From d780053e7fe2af628a64ef46ce112ac17cf5889c Mon Sep 17 00:00:00 2001 From: rsouza Date: Mon, 11 Dec 2017 15:06:56 -0300 Subject: [PATCH 100/298] Following best practices of Function Overloading: https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html --- .../hapi/v17/definitions/request/request.d.ts | 7 +-- .../definitions/response/response-events.d.ts | 5 ++ .../definitions/response/response-object.d.ts | 12 ++--- .../response/response-toolkit.d.ts | 19 +++---- .../v17/definitions/server/server-auth.d.ts | 6 +-- .../v17/definitions/server/server-events.d.ts | 12 ++--- .../v17/definitions/server/server-state.d.ts | 6 +-- types/hapi/v17/definitions/server/server.d.ts | 54 +++++++------------ 8 files changed, 42 insertions(+), 79 deletions(-) diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/v17/definitions/request/request.d.ts index 5fe1a63f5b..a0605254a8 100644 --- a/types/hapi/v17/definitions/request/request.d.ts +++ b/types/hapi/v17/definitions/request/request.d.ts @@ -182,9 +182,7 @@ export interface Request extends Podium { * @return ResponseObject * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestgenerateresponsesource-options) */ - generateResponse(source: object, options?: {variety?: string; prepare?: Function; marshal?: Function; close?: Function; }): ResponseObject; - generateResponse(source: string, options?: {variety?: string; prepare?: Function; marshal?: Function; close?: Function; }): ResponseObject; - generateResponse(source: null, options?: {variety?: string; prepare?: Function; marshal?: Function; close?: Function; }): ResponseObject; + generateResponse(source: string | object | null, options?: {variety?: string; prepare?: Function; marshal?: Function; close?: Function; }): ResponseObject; /** * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. The arguments are: @@ -194,8 +192,7 @@ export interface Request extends Podium { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data) */ - log(tags: string, data?: string | object | (() => string | object)): void; - log(tags: string[], data?: string | object | (() => string | object)): void; + log(tags: string | string[], data?: string | object | (() => string | object)): void; /** * Changes the request method before the router begins processing the request where: diff --git a/types/hapi/v17/definitions/response/response-events.d.ts b/types/hapi/v17/definitions/response/response-events.d.ts index e5dcb43d30..087b92cf37 100644 --- a/types/hapi/v17/definitions/response/response-events.d.ts +++ b/types/hapi/v17/definitions/response/response-events.d.ts @@ -14,6 +14,11 @@ export interface ResponseEvents extends Podium { * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). */ on(criteria: 'peek' | 'finish', listener: Function): void; + + /** + * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). + * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). + */ once(criteria: 'peek' | 'finish', listener: Function): void; } diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/v17/definitions/response/response-object.d.ts index 378fee420f..b9887c4ae6 100644 --- a/types/hapi/v17/definitions/response/response-object.d.ts +++ b/types/hapi/v17/definitions/response/response-object.d.ts @@ -150,8 +150,7 @@ export interface ResponseObject extends Podium { * @return Return value: the current response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseetagtag-options) */ - etag(tag: string): ResponseObject; - etag(tag: string, options: {weak: boolean, vary: boolean}): ResponseObject; + etag(tag: string, options?: {weak: boolean, vary: boolean}): ResponseObject; /** * Sets an HTTP header where: @@ -165,8 +164,7 @@ export interface ResponseObject extends Podium { * @return Return value: the current response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheadername-value-options) */ - header(name: string, value: string): ResponseObject; - header(name: string, value: string, options: ResponseObjectHeaderOptions): ResponseObject; + header(name: string, value: string, options?: ResponseObjectHeaderOptions): ResponseObject; /** * Sets the HTTP 'Location' header where: @@ -209,8 +207,7 @@ export interface ResponseObject extends Podium { * @return Return value: the current response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsestatename-value-options) */ - state(name: string, value: object): ResponseObject; - state(name: string, value: object, options: ServerStateCookieOptions): ResponseObject; + state(name: string, value: object, options?: ServerStateCookieOptions): ResponseObject; /** * Sets a string suffix when the response is process via JSON.stringify() where: @@ -244,8 +241,7 @@ export interface ResponseObject extends Podium { * @return Return value: the current response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseunstatename-options) */ - unstate(name: string): ResponseObject; - unstate(name: string, options: ServerStateCookieOptions): ResponseObject; + unstate(name: string, options?: ServerStateCookieOptions): ResponseObject; /** * Adds the provided header to the list of inputs affected the response generation via the HTTP 'Vary' header where: diff --git a/types/hapi/v17/definitions/response/response-toolkit.d.ts b/types/hapi/v17/definitions/response/response-toolkit.d.ts index 7c5b122c2f..7496b4cee2 100644 --- a/types/hapi/v17/definitions/response/response-toolkit.d.ts +++ b/types/hapi/v17/definitions/response/response-toolkit.d.ts @@ -77,8 +77,7 @@ export interface ResponseToolkit { * it should be used as the return value (but may be customize using the response methods). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hentityoptions) */ - entity(): ResponseObject | undefined; - entity(options: {etag?: string, modified?: string, vary?: boolean}): ResponseObject | undefined; + entity(options?: {etag?: string, modified?: string, vary?: boolean}): ResponseObject | undefined; /** * Redirects the client to the specified uri. Same as calling h.response().redirect(uri). @@ -86,8 +85,7 @@ export interface ResponseToolkit { * @return Returns a response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hredirecturi) */ - redirect(): ResponseObject; - redirect(uri: string): ResponseObject; + redirect(uri?: string): ResponseObject; /** * Wraps the provided value and returns a response object which allows customizing the response @@ -96,9 +94,7 @@ export interface ResponseToolkit { * @return Returns a response object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hresponsevalue) */ - response(): ResponseObject; - response(value: string): ResponseObject; - response(value: object): ResponseObject; + response(value?: string | object): ResponseObject; /** * Sets a response cookie using the same arguments as response.state(). @@ -108,8 +104,7 @@ export interface ResponseToolkit { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hstatename-value-options) */ - state(name: string, value: string): void; - state(name: string, value: string, options: ServerStateCookieOptions): void; + state(name: string, value: string, options?: ServerStateCookieOptions): void; /** * Used by the [authentication] method to indicate authentication failed and pass back the credentials received where: @@ -124,8 +119,7 @@ export interface ResponseToolkit { * There is no difference between throwing the error or passing it with the h.unauthenticated() method is no credentials are passed, but it might still be helpful for code clarity. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hunauthenticatederror-data) */ - unauthenticated(error: Error): void; - unauthenticated(error: Error, data: {credentials: object, artifacts?: object}): void; + unauthenticated(error: Error, data?: {credentials: object, artifacts?: object}): void; /** * Clears a response cookie using the same arguments as @@ -134,7 +128,6 @@ export interface ResponseToolkit { * @return void. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hunstatename-options) */ - unstate(name: string): void; - unstate(name: string, options: ServerStateCookieOptions): void; + unstate(name: string, options?: ServerStateCookieOptions): void; } diff --git a/types/hapi/v17/definitions/server/server-auth.d.ts b/types/hapi/v17/definitions/server/server-auth.d.ts index d8f1c257e6..0b082c2872 100644 --- a/types/hapi/v17/definitions/server/server-auth.d.ts +++ b/types/hapi/v17/definitions/server/server-auth.d.ts @@ -43,8 +43,7 @@ export interface ServerAuth { * authentication configuration of a route, use server.auth.lookup(request.route). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions) */ - default(options: string): void; - default(options: ServerAuthConfig): void; + default(options: string | ServerAuthConfig): void; /** * Registers an authentication scheme where: @@ -65,8 +64,7 @@ export interface ServerAuth { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthstrategyname-scheme-options) */ - strategy(name: string, scheme: string): void; - strategy(name: string, scheme: string, options: object): void; + strategy(name: string, scheme: string, options?: object): void; /** * Tests a request against an authentication strategy where: diff --git a/types/hapi/v17/definitions/server/server-events.d.ts b/types/hapi/v17/definitions/server/server-events.d.ts index 8d07ee0b5b..5eb7bdc283 100644 --- a/types/hapi/v17/definitions/server/server-events.d.ts +++ b/types/hapi/v17/definitions/server/server-events.d.ts @@ -100,9 +100,7 @@ export interface ServerEvents extends Podium { * See ['start' event](https://github.com/hapijs/hapi/blob/master/API.md#-start-event) * See ['stop' event](https://github.com/hapijs/hapi/blob/master/API.md#-stop-event) */ - on(criteria: string, listener: Function): void; - on(criteria: ServerEventsApplicationObject, listener: Function): void; - on(criteria: ServerEventCriteria, listener: Function): void; + on(criteria: string | ServerEventsApplicationObject | ServerEventCriteria, listener: Function): void; /** * Same as calling [server.events.on()](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) with the count option set to 1. @@ -114,9 +112,7 @@ export interface ServerEvents extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) */ - once(criteria: string, listener: (...args: any[]) => void): void; // TODO I am not sure if the best way (here and the functions above/below) is use Function or (...args: any[]) => void) considering the JSDocs "The function signature depends on the event argument" - once(criteria: ServerEventsApplicationObject, listener: Function): void; - once(criteria: ServerEventCriteria, listener: Function): void; + once(criteria: string | ServerEventsApplicationObject | ServerEventCriteria, listener: Function): void; /** * Same as calling server.events.on() with the count option set to 1. @@ -127,9 +123,7 @@ export interface ServerEvents extends Podium { * @return Return value: a promise that resolves when the event is emitted. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsoncecriteria) */ - once(criteria: string): any; - once(criteria: ServerEventsApplicationObject): any; - once(criteria: ServerEventCriteria): any; + once(criteria: string | ServerEventsApplicationObject | ServerEventCriteria): any; /** * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumremovelistenername-listener) diff --git a/types/hapi/v17/definitions/server/server-state.d.ts b/types/hapi/v17/definitions/server/server-state.d.ts index f233956a29..74842abd78 100644 --- a/types/hapi/v17/definitions/server/server-state.d.ts +++ b/types/hapi/v17/definitions/server/server-state.d.ts @@ -43,8 +43,7 @@ export interface ServerState { /** * Same as calling [server.state()](https://github.com/hapijs/hapi/blob/master/API.md#server.state()). */ - add(name: string): void; - add(name: string, options: ServerStateCookieOptions): void; + add(name: string, options?: ServerStateCookieOptions): void; /** * Formats an HTTP 'Set-Cookie' header based on the server.options.state where: @@ -56,8 +55,7 @@ export interface ServerState { * Note that this utility uses the server configuration but does not change the server state. It is provided for manual cookie formating (e.g. when headers are set manually). * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-async-serverstatesformatcookies) */ - format(cookies: ServerStateFormat): string; - format(cookies: ServerStateFormat[]): string; + format(cookies: ServerStateFormat | ServerStateFormat[]): string; /** * Parses an HTTP 'Cookies' header based on the server.options.state where: diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/v17/definitions/server/server.d.ts index b7ac0e908f..01d5fcc062 100644 --- a/types/hapi/v17/definitions/server/server.d.ts +++ b/types/hapi/v17/definitions/server/server.d.ts @@ -99,8 +99,7 @@ export class Server extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) */ - event(events: ServerEventsApplication): void; - event(events: ServerEventsApplication[]): void; + event(events: ServerEventsApplication | ServerEventsApplication[]): void; /** * Access: podium public interface. @@ -278,10 +277,7 @@ export class Server extends Podium { * The method does not provide version dependency which should be implemented using npm peer dependencies. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdependencydependencies-after) */ - dependency(dependencies: string): void; - dependency(dependencies: string, after: ((server: Server) => void)): void; - dependency(dependencies: string[]): void; - dependency(dependencies: string[], after: ((server: Server) => void)): void; + dependency(dependencies: string | string[], after?: ((server: Server) => void)): void; /** * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' where: @@ -333,18 +329,15 @@ export class Server extends Podium { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) */ - ext(events: ServerExtEventsObject): void; - ext(events: ServerExtEventsObject[]): void; - ext(events: ServerExtEventsRequestObject): void; - ext(events: ServerExtEventsRequestObject[]): void; + ext(events: ServerExtEventsObject | ServerExtEventsObject[]): void; + ext(events: ServerExtEventsRequestObject | ServerExtEventsRequestObject[]): void; /** * Registers a single extension event using the same properties as used in server.ext(events), but passed as arguments. * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options) */ - ext(event: ServerExtType, method: ServerExtPointFunction | Lifecycle.Method | Function): void; - ext(event: ServerExtType, method: ServerExtPointFunction | Lifecycle.Method | Function, options: ServerExtOptions): void; + ext(event: ServerExtType, method: ServerExtPointFunction | Lifecycle.Method | Function, options?: ServerExtOptions): void; /** * Initializes the server (starts the caches, finalizes plugin registration) but does not start listening on the connection port. @@ -390,8 +383,7 @@ export class Server extends Podium { * * request - the request object. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions) */ - inject(options: string): ServerInjectResponse; - inject(options: ServerInjectOptions): ServerInjectResponse; + inject(options: string | ServerInjectOptions): ServerInjectResponse; /** * Logs server events that cannot be associated with a specific request. When called the server emits a 'log' event which can be used by other listeners or plugins to record the information or output to the console. The arguments are: @@ -419,8 +411,7 @@ export class Server extends Podium { * @return Return value: the route information if found, otherwise null. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermatchmethod-path-host) */ - match(method: Util.HTTP_METHODS, path: string): RequestRoute | null; - match(method: Util.HTTP_METHODS, path: string, host: string): RequestRoute | null; + match(method: Util.HTTP_METHODS, path: string, host?: string): RequestRoute | null; /** * Registers a server method where: @@ -438,8 +429,7 @@ export class Server extends Podium { * When configured with caching enabled, server.methods[name].cache is assigned an object with the following properties and methods: - await drop(...args) - a function that can be used to clear the cache for a given key. - stats - an object with cache statistics, see catbox for stats documentation. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) */ - method(name: string, method: ServerMethod): void; - method(name: string, method: ServerMethod, options: ServerMethodOptions): void; + method(name: string, method: ServerMethod, options?: ServerMethodOptions): void; /** * Registers a server method function as described in server.method() using a configuration object where: @@ -450,8 +440,7 @@ export class Server extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodmethods) */ - method(methods: ServerMethodConfigurationObject): void; - method(methods: ServerMethodConfigurationObject[]): void; + method(methods: ServerMethodConfigurationObject | ServerMethodConfigurationObject[]): void; /** * Sets the path prefix used to locate static resources (files and view templates) when relative paths are used where: @@ -470,7 +459,7 @@ export class Server extends Podium { * * * plugin - a plugin object. * * * options - (optional) options passed to the plugin during registration. * * * once, routes - (optional) plugin-specific registration options as defined below. - * @paramoptions - (optional) registration options (different from the options passed to the registration function): + * @param options - (optional) registration options (different from the options passed to the registration function): * * once - if true, subsequent registrations of the same plugin are skipped without error. Cannot be used with plugin options. Defaults to false. If not set to true, an error will be thrown the second time a plugin is registered on the server. * * routes - modifiers applied to each route added by the plugin: * * * prefix - string added as prefix to any route path (must begin with '/'). If a plugin registers a child plugin the prefix is passed on to the child or is added in front of the child-specific prefix. @@ -478,10 +467,8 @@ export class Server extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options) */ - register(plugins: Plugin | ServerRegisterPluginObject): void; - register(plugins: Plugin | ServerRegisterPluginObject, options: ServerRegisterOptions): void; - register(plugins: Plugin[] | ServerRegisterPluginObject[]): void; - register(plugins: Plugin[] | ServerRegisterPluginObject[], options: ServerRegisterOptions): void; + register(plugins: Plugin | Plugin[], options?: ServerRegisterOptions): void; + register(plugins: ServerRegisterPluginObject | ServerRegisterPluginObject[], options?: ServerRegisterOptions): void; /** * Adds a route where: @@ -496,8 +483,7 @@ export class Server extends Podium { * Note that the options object is deeply cloned (with the exception of bind which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrouteroute) */ - route(route: ServerRoute): void; - route(route: ServerRoute[]): void; + route(route: ServerRoute | ServerRoute[]): void; /** * Defines a route rules processor for converting route rules object into route configuration where: @@ -506,7 +492,7 @@ export class Server extends Podium { * * info - an object with the following properties: * * * method - the route method. * * * path - the route path. - * * *vhost - the route virtual host (if any defined). + * * * vhost - the route virtual host (if any defined). * * returns a route config object. * @param options - optional settings: * * validate - rules object validation: @@ -516,8 +502,7 @@ export class Server extends Podium { * @return void * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrulesprocessor-options) */ - rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => object): void; - rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => object, options: {validate: object}): void; // TODO needs implementation + rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => object, options?: {validate: object}): void; // TODO needs implementation /** * Starts the server by listening for incoming requests on the configured port (unless the connection was configured with autoListen set to false). @@ -536,8 +521,7 @@ export class Server extends Podium { * State defaults can be modified via the server default state configuration option. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverstatename-options) */ - state(name: string): void; - state(name: string, options: ServerStateCookieOptions): void; + state(name: string, options?: ServerStateCookieOptions): void; /** * Stops the server's listener by refusing to accept any new connections or requests (existing connections will continue until closed or timeout), where: @@ -546,8 +530,7 @@ export class Server extends Podium { * @return Return value: none. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstopoptions) */ - stop(): void; - stop(options: {timeout: number}): void; + stop(options?: {timeout: number}): void; /** * Returns a copy of the routing table where: @@ -558,7 +541,6 @@ export class Server extends Podium { * * path - the route path. * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost) */ - table(): {settings: ServerRoute; method: Util.HTTP_METHODS_PARTIAL_LOWERCASE, path: string}[]; // TODO I am not sure if the ServerRoute is the object expected here - table(host: string): {settings: ServerRoute; method: Util.HTTP_METHODS_PARTIAL_LOWERCASE, path: string}[]; + table(host?: string): {settings: ServerRoute; method: Util.HTTP_METHODS_PARTIAL_LOWERCASE, path: string}[]; // TODO I am not sure if the ServerRoute is the object expected here } From a1c8fc8f932797b0e303450ed2355ae3fbb1c1bb Mon Sep 17 00:00:00 2001 From: rsouza Date: Mon, 11 Dec 2017 16:18:57 -0300 Subject: [PATCH 101/298] Add RouteOptions test file with complete available options. --- types/hapi/v17/test/index.test.d.ts | 1 + types/hapi/v17/test/route/route-options.ts | 167 +++++++++++++++++++++ 2 files changed, 168 insertions(+) create mode 100644 types/hapi/v17/test/route/route-options.ts diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/index.test.d.ts index 7b9041f929..08711f00f6 100644 --- a/types/hapi/v17/test/index.test.d.ts +++ b/types/hapi/v17/test/index.test.d.ts @@ -26,6 +26,7 @@ export * from './response/response-events'; export * from './route/adding-routes'; export * from './route/config'; export * from './route/handler'; +export * from './route/route-options'; export * from './route/route-options-pre'; /** SERVER */ diff --git a/types/hapi/v17/test/route/route-options.ts b/types/hapi/v17/test/route/route-options.ts new file mode 100644 index 0000000000..5e2506684f --- /dev/null +++ b/types/hapi/v17/test/route/route-options.ts @@ -0,0 +1,167 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#route-options +import { + EmptyStatusCode, + Request, + ResponseToolkit, + RouteOptions, + RouteOptionsAccess, + RouteOptionsAccessEntity, + RouteOptionsAccessMode, + RouteOptionsAccessPayload, + RouteOptionsCors, + RouteOptionsPayload, + RouteOptionsResponse, + RouteOptionsValidate, + Server +} from "hapi"; + +const routeOptionsAccess: RouteOptionsAccess = { + access: {}, + scope: false, + entity: RouteOptionsAccessEntity.User, + mode: RouteOptionsAccessMode.Optional, + payload: RouteOptionsAccessPayload.Optional, + strategies: ['', ''], + strategy: '' +}; + +const corsOption: RouteOptionsCors = { + origin: 'ignore', + maxAge: 5000, + headers: ['test', 'test', 'test'], + additionalHeaders: ['test', 'test', 'test'], + exposedHeaders: ['test', 'test', 'test'], + additionalExposedHeaders: ['test', 'test', 'test'], + credentials: false +}; + +const payloadOptions: RouteOptionsPayload = { + allow: 'string', + compression: { + test1: { + test: 2 + } + }, + defaultContentType: 'application/json', + failAction: (request: Request, h: ResponseToolkit) => { + return 'ok: ' + request.path; + }, + maxBytes: 1048576, + multipart: { + output: 'annotated' + }, + output: 'stream', + override: '', + parse: 'gunzip', + timeout: 5000, + uploads: 'dir/' +}; + +const pre1 = (request: Request, h: ResponseToolkit) => { + return 'Hello'; +}; + +const pre2 = (request: Request, h: ResponseToolkit) => { + return 'World'; +}; + +const pre3 = (request: Request, h: ResponseToolkit) => { + return request.pre.m1 + ' ' + request.pre.m2; +}; + +const routeOptionsResponse:RouteOptionsResponse = { + emptyStatusCode: EmptyStatusCode.HTTP_200, + failAction: (request: Request, h: ResponseToolkit) => { + return 'ok: ' + request.path; + }, + modify: false, + options: null, + ranges: true, + sample: 100, + schema: true, + status: { + '200': true, + '302': true, + '404': false, + } +}; + +const routeOptionsValidate: RouteOptionsValidate = { + errorFields: {}, + failAction: (request: Request, h: ResponseToolkit) => { + return 'ok: ' + request.path; + }, + headers: false, + options: {}, + params: false, + payload: true, + query: true, +}; + +const routeOptions: RouteOptions = { + + app: {}, + auth: routeOptionsAccess, + bind: null, + cache: { + privacy: 'default', + statuses: [200], + otherwise: 'no-cache' + }, + compression: { + test1: { + test: 2 + } + }, + cors: corsOption, + description: 'description here', + ext: null, + files: { relativeTo: '.' }, + handler: (request: Request, h: ResponseToolkit) => { + return 'ok: ' + request.path; + }, + id: 'test', + isInternal: false, + json: null, + jsonp: 'callback', + log: { collect: false }, + notes: ['test', 'test', 'test'], + payload: payloadOptions, + plugins: { + plugin1: {}, + plugin2: {}, + }, + pre: [ + [ + // m1 and m2 executed in parallel + { method: pre1, assign: 'm1' }, + { method: pre2, assign: 'm2' } + ], + { method: pre3, assign: 'm3' }, + ], + response: routeOptionsResponse, + security: false, + state: { + parse: true, + failAction: (request: Request, h: ResponseToolkit) => { + return 'ok: ' + request.path; + }, + }, + tags: ['test', 'test', 'test'], + timeout: { + server: 10000, + socket: false + }, + validate: routeOptionsValidate + +}; + +const server = new Server({ + port: 8000, + routes: routeOptions +}); +server.start(); + +server.events.on('start', () => { + console.log('Server started at: ' + server.info.uri); +}); From 1811eadb30f891cd04f1d347c696df31fc1ffd44 Mon Sep 17 00:00:00 2001 From: rsouza Date: Mon, 11 Dec 2017 17:07:57 -0300 Subject: [PATCH 102/298] Update author name. --- types/hapi/v17/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index 9dcc6b841c..dc5c79a680 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for hapi 17.0 // Project: https://github.com/hapijs/hapi -// Definitions by: Marc Bornträger +// Definitions by: Marc Borntraeger // Rafael Souza Fijalkowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 4162d093471260f95866261d473785e3ab883b4f Mon Sep 17 00:00:00 2001 From: rsouza Date: Mon, 11 Dec 2017 17:21:40 -0300 Subject: [PATCH 103/298] Update author name. --- types/hapi/v17/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index dc5c79a680..831fcb00e7 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for hapi 17.0 // Project: https://github.com/hapijs/hapi -// Definitions by: Marc Borntraeger +// Definitions by: Marc Borntraeger // Rafael Souza Fijalkowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From e02a3fa4da1d2a04a8f319a4d5c0adb3706b00a6 Mon Sep 17 00:00:00 2001 From: rsouza Date: Mon, 11 Dec 2017 18:05:29 -0300 Subject: [PATCH 104/298] Rename to hapi-tests.ts file. --- types/hapi/v17/index.d.ts | 2 +- types/hapi/v17/test/{index.test.d.ts => hapi-tests.ts} | 0 types/hapi/v17/tsconfig.json | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename types/hapi/v17/test/{index.test.d.ts => hapi-tests.ts} (100%) diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts index 831fcb00e7..5b941c2b2c 100644 --- a/types/hapi/v17/index.d.ts +++ b/types/hapi/v17/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for hapi 17.0 // Project: https://github.com/hapijs/hapi -// Definitions by: Marc Borntraeger +// Definitions by: Marc Bornträger // Rafael Souza Fijalkowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/hapi/v17/test/index.test.d.ts b/types/hapi/v17/test/hapi-tests.ts similarity index 100% rename from types/hapi/v17/test/index.test.d.ts rename to types/hapi/v17/test/hapi-tests.ts diff --git a/types/hapi/v17/tsconfig.json b/types/hapi/v17/tsconfig.json index 8ce2562c61..51b2d076a0 100644 --- a/types/hapi/v17/tsconfig.json +++ b/types/hapi/v17/tsconfig.json @@ -23,6 +23,6 @@ }, "files": [ "index.d.ts", - "test/index.test.d.ts" + "test/hapi-tests.ts" ] } From f7facb58461bc623f8d0b0ec7084b3847dbcc5d6 Mon Sep 17 00:00:00 2001 From: rsouza Date: Mon, 11 Dec 2017 18:10:12 -0300 Subject: [PATCH 105/298] Unnecessarily references, which is already referenced in the type definition. --- types/hapi/v17/test/hapi-tests.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/types/hapi/v17/test/hapi-tests.ts b/types/hapi/v17/test/hapi-tests.ts index 08711f00f6..b717f5724e 100644 --- a/types/hapi/v17/test/hapi-tests.ts +++ b/types/hapi/v17/test/hapi-tests.ts @@ -1,12 +1,3 @@ -// Type definitions for hapi 17.0 -// Project: https://github.com/hapijs/hapi -// Definitions by: Marc Bornträger -// Rafael Souza Fijalkowski -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -// Note/Disclaimer: None. - -/// /** REQUEST */ export * from './request/catch-all'; From 51e0b2b92b92af2c8f39d2356c159863cccb037f Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Mon, 11 Dec 2017 19:46:25 -0300 Subject: [PATCH 106/298] Add references to test files in "tsconfig.json". Delete "hapi-test.ts" --- types/hapi/v17/test/hapi-tests.ts | 57 ------------------------------- types/hapi/v17/tsconfig.json | 47 ++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 58 deletions(-) delete mode 100644 types/hapi/v17/test/hapi-tests.ts diff --git a/types/hapi/v17/test/hapi-tests.ts b/types/hapi/v17/test/hapi-tests.ts deleted file mode 100644 index b717f5724e..0000000000 --- a/types/hapi/v17/test/hapi-tests.ts +++ /dev/null @@ -1,57 +0,0 @@ - -/** REQUEST */ -export * from './request/catch-all'; -export * from './request/event-types'; -export * from './request/get-log'; -export * from './request/parameters'; -export * from './request/query'; - -/** RESPONSE */ -export * from './response/continue'; -export * from './response/error'; -export * from './response/redirect'; -export * from './response/response'; -export * from './response/response-events'; - -/** ROUTE */ -export * from './route/adding-routes'; -export * from './route/config'; -export * from './route/handler'; -export * from './route/route-options'; -export * from './route/route-options-pre'; - -/** SERVER */ -export * from './server/server-app'; -export * from './server/server-auth-api'; -export * from './server/server-auth-default'; -export * from './server/server-auth-test'; -export * from './server/server-bind'; -export * from './server/server-cache'; -export * from './server/server-cache-provision'; -export * from './server/server-decoder'; -export * from './server/server-decorations'; -export * from './server/server-encoder'; -export * from './server/server-events'; -export * from './server/server-events-once'; -export * from './server/server-expose'; -export * from './server/server-info'; -export * from './server/server-inject'; -export * from './server/server-listener'; -export * from './server/server-load'; -export * from './server/server-lookup'; -export * from './server/server-match'; -export * from './server/server-method'; -export * from './server/server-methods'; -export * from './server/server-mime'; -export * from './server/server-options'; -export * from './server/server-path'; -export * from './server/server-plugins'; -export * from './server/server-settings'; -export * from './server/server-start'; -export * from './server/server-state'; -export * from './server/server-stop'; -export * from './server/server-table'; -export * from './server/server-version'; - - - diff --git a/types/hapi/v17/tsconfig.json b/types/hapi/v17/tsconfig.json index 51b2d076a0..0134ca5ae1 100644 --- a/types/hapi/v17/tsconfig.json +++ b/types/hapi/v17/tsconfig.json @@ -23,6 +23,51 @@ }, "files": [ "index.d.ts", - "test/hapi-tests.ts" + "test/request/catch-all.ts", + "test/request/event-types.ts", + "test/request/get-log.ts", + "test/request/parameters.ts", + "test/request/query.ts", + "test/response/continue.ts", + "test/response/error.ts", + "test/response/redirect.ts", + "test/response/response.ts", + "test/response/response-events.ts", + "test/route/adding-routes.ts", + "test/route/config.ts", + "test/route/handler.ts", + "test/route/route-options.ts", + "test/route/route-options-pre.ts", + "test/server/server-app.ts", + "test/server/server-auth-api.ts", + "test/server/server-auth-default.ts", + "test/server/server-auth-test.ts", + "test/server/server-bind.ts", + "test/server/server-cache.ts", + "test/server/server-cache-provision.ts", + "test/server/server-decoder.ts", + "test/server/server-decorations.ts", + "test/server/server-encoder.ts", + "test/server/server-events.ts", + "test/server/server-events-once.ts", + "test/server/server-expose.ts", + "test/server/server-info.ts", + "test/server/server-inject.ts", + "test/server/server-listener.ts", + "test/server/server-load.ts", + "test/server/server-lookup.ts", + "test/server/server-match.ts", + "test/server/server-method.ts", + "test/server/server-methods.ts", + "test/server/server-mime.ts", + "test/server/server-options.ts", + "test/server/server-path.ts", + "test/server/server-plugins.ts", + "test/server/server-settings.ts", + "test/server/server-start.ts", + "test/server/server-state.ts", + "test/server/server-stop.ts", + "test/server/server-table.ts", + "test/server/server-version.ts" ] } From 769c5388ac96908a0a258868583e8fa78e1d27c5 Mon Sep 17 00:00:00 2001 From: wwestrop Date: Mon, 11 Dec 2017 22:58:06 +0000 Subject: [PATCH 107/298] mochajs - IRunner declared as extending Node EventEmitter --- types/mocha/index.d.ts | 4 +++- types/mocha/mocha-tests.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/types/mocha/index.d.ts b/types/mocha/index.d.ts index 4ae915f683..09b596dcfc 100644 --- a/types/mocha/index.d.ts +++ b/types/mocha/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: Kazi Manzur Rashid , otiai10 , jt000 , Vadim Macagon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + interface MochaSetupOptions { //milliseconds to wait before considering a test slow slow?: number; @@ -172,7 +174,7 @@ declare namespace Mocha { /** Partial interface for Mocha's `Runner` class. */ - interface IRunner { } + interface IRunner extends NodeJS.EventEmitter { } interface IContextDefinition { (description: string, callback: (this: ISuiteCallbackContext) => void): ISuite; diff --git a/types/mocha/mocha-tests.ts b/types/mocha/mocha-tests.ts index c3fa00da84..490cacd325 100644 --- a/types/mocha/mocha-tests.ts +++ b/types/mocha/mocha-tests.ts @@ -455,3 +455,15 @@ function test_run_withOnComplete() { function test_throwError() { mocha.throwError(new Error("I'm an error!")); } + + + + + + +// dtslint + +import * as Mocha from "mocha"; + +new Mocha().run(); // $ExpectType IRunner +new Mocha().run().on("", function() {}); // $ExpectType IRunner \ No newline at end of file From 074fe0665fdab40322989dad7afc3817df2129d4 Mon Sep 17 00:00:00 2001 From: "VML\\snau" Date: Mon, 11 Dec 2017 15:15:03 -0800 Subject: [PATCH 108/298] updating the definition file per the Siema documentation, to allow `string` OR `HTMLElement` for the `selector` property --- types/siema/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/siema/index.d.ts b/types/siema/index.d.ts index d1b2c0d604..b8faf3d644 100644 --- a/types/siema/index.d.ts +++ b/types/siema/index.d.ts @@ -22,7 +22,7 @@ interface perPageInterface { } interface SiemaOptions { - selector?: string; + selector?: string | HTMLElement; duration?: number; easing?: string; perPage?: number | perPageInterface; From cbfb1ff40fd9100002437a512553d7c9630b6eae Mon Sep 17 00:00:00 2001 From: Dustin Barnes Date: Mon, 11 Dec 2017 15:48:19 -0800 Subject: [PATCH 109/298] Allowing `get` calls without key nconf allows you to call `get` without a key, to return the entire configuration object. This changes the `get` exports to allow the key to be optional. --- types/nconf/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/nconf/index.d.ts b/types/nconf/index.d.ts index f03eb88b39..71a0d497ab 100644 --- a/types/nconf/index.d.ts +++ b/types/nconf/index.d.ts @@ -11,7 +11,7 @@ export declare var stores: any; export declare var sources: any[]; export declare function clear(key: string, callback?: ICallbackFunction): any; -export function get(key: string, callback?: ICallbackFunction): any; +export function get(key?: string, callback?: ICallbackFunction): any; export declare function merge(key: string, value: any, callback?: ICallbackFunction): any; export declare function set(key: string, value: any, callback?: ICallbackFunction): any; export declare function reset(callback?: ICallbackFunction): any; @@ -75,7 +75,7 @@ export declare class Provider { sources: any[]; clear(key: string, callback?: ICallbackFunction): any; - get(key: string, callback?: ICallbackFunction): any; + get(key?: string, callback?: ICallbackFunction): any; merge(key: string, value: any, callback?: ICallbackFunction): any; set(key: string, value: any, callback?: ICallbackFunction): any; reset(callback?: ICallbackFunction): any; From 0518ce2cc41eebafce6631c5cc0e413ddf85de1b Mon Sep 17 00:00:00 2001 From: "Angus.Fenying" Date: Tue, 12 Dec 2017 12:01:28 +0800 Subject: [PATCH 110/298] Patch for fixing issue #15849. --- types/async/index.d.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/types/async/index.d.ts b/types/async/index.d.ts index f1b38e8130..604e2c0525 100644 --- a/types/async/index.d.ts +++ b/types/async/index.d.ts @@ -11,7 +11,7 @@ export interface Dictionary { [key: string]: T; } export interface ErrorCallback { (err?: T): void; } export interface AsyncBooleanResultCallback { (err?: E, truthValue?: boolean): void; } export interface AsyncResultCallback { (err?: E, result?: T): void; } -export interface AsyncResultArrayCallback { (err?: E, results?: (T | undefined)[]): void; } +export interface AsyncResultArrayCallback { (err?: E, results?: Array): void; } export interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } export interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } @@ -116,8 +116,12 @@ export const eachOfLimit: typeof forEachOfLimit; export function map(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; export function map(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; export const mapSeries: typeof map; -export function mapLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; -export function mapLimit(arr: Dictionary, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function mapLimit( + arr: T[] | Dictionary | IterableIterator, + limit: number, + iterator: AsyncResultIterator, + callback?: AsyncResultArrayCallback +): void; export function mapValuesLimit(obj: Dictionary, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; export function mapValues(obj: Dictionary, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; export const mapValuesSeries: typeof mapValues; @@ -222,7 +226,7 @@ export function memoize(fn: Function, hasher?: Function): Function; export function unmemoize(fn: Function): Function; export function ensureAsync(fn: (... argsAndCallback: any[]) => void): Function; export function constant(...values: any[]): Function; -export function asyncify(fn: Function): Function; +export function asyncify(fn: Function): (...args: any[]) => any; export function wrapSync(fn: Function): Function; export function log(fn: Function, ...args: any[]): void; export function dir(fn: Function, ...args: any[]): void; From 1814054edd4e4768bb497cd6ff5c3a2d496e72d4 Mon Sep 17 00:00:00 2001 From: Daniel Perez Alvarez Date: Mon, 11 Dec 2017 20:45:15 -0800 Subject: [PATCH 111/298] Update types for license-checker to 15.0 --- types/license-checker/index.d.ts | 159 +++++++++++------- .../license-checker/license-checker-tests.ts | 36 +++- 2 files changed, 122 insertions(+), 73 deletions(-) diff --git a/types/license-checker/index.d.ts b/types/license-checker/index.d.ts index d0286a05af..4ae2995ea0 100644 --- a/types/license-checker/index.d.ts +++ b/types/license-checker/index.d.ts @@ -1,86 +1,117 @@ -// Type definitions for license-checker 11.0 +// Type definitions for license-checker 15.0 // Project: https://github.com/davglass/license-checker -// Definitions by: Rogier Schouten +// Definitions by: Rogier Schouten , Daniel Perez Alvarez // Definitions: https://github.com/borisyankov/DefinitelyTyped /** * Options struct for the init() function */ export interface InitOpts { - /** - * Path to start checking dependencies from - */ - start: string; - /** - * only show production dependencies - */ - production?: boolean; - /** - * only show development dependencies - */ - development?: boolean; - /** - * report guessed licenses as unknown licenses - */ - unknown?: boolean; - /** - * only list packages with unknown or guessed licenses - */ - onlyunknown?: boolean; - /** - * to add a custom Format file in JSON - */ - customPath?: string; - /** - * exclude modules which licenses are in the comma-separated list from the output - */ - exclude?: string[]; - /** - * Use chalk to colorize the licenses member of each returned module info. Unknown licenses become red. - */ - color?: boolean; - /** - * output the location of the license files as relative paths - */ - relativeLicensePath?: boolean; + /** + * Path to start checking dependencies from + */ + start: string; + /** + * Only show production dependencies + */ + production?: boolean; + /** + * Only show development dependencies + */ + development?: boolean; + /** + * Report guessed licenses as unknown licenses + */ + unknown?: boolean; + /** + * Only list packages with unknown or guessed licenses + */ + onlyunknown?: boolean; + /** + * to add a custom Format file in JSON + */ + customPath?: string | ModuleInfo; + /** + * Exclude modules which licenses are in the comma-separated list from the output + */ + exclude?: string[]; + /** + * Output the location of the license files as relative paths + */ + relativeLicensePath?: boolean; + /** + * Output a summary of the license usage + */ + summary?: boolean; + /** + * Fail (exit with code 1) on the first occurrence of the licenses of the comma-separated list + */ + failOn?: string[]; + /** + * Use chalk to colorize the licenses member of each returned module info. Unknown licenses become red. + */ + color?: boolean; } /** * Information about one dependency */ export interface ModuleInfo { - /** - * licenses, either one string or an array of multiple licenses - */ - licenses: string | string[]; - /** - * Repository URL - */ - repository: string; - /** - * Publisher name - */ - publisher?: string; - /** - * Publisher e-mail - */ - email?: string; - /** - * Publisher URL - */ - url?: string; - /** - * Path to license file, if available - */ - licenseFile?: string; + /** + * Module name + */ + name?: string; + /** + * Module version + */ + version?: string; + /** + * Module description + */ + description?: string; + /** + * Repository URL + */ + repository?: string; + /** + * Publisher name + */ + publisher?: string; + /** + * Publisher e-mail + */ + email?: string; + /** + * Publisher URL + */ + url?: string; + /** + * Array of licenses + */ + licenses?: string | string[]; + /** + * Path to license file, if available + */ + licenseFile?: string; + /** + * Contents of the license + */ + licenseText?: string; + /** + * Whether the license is modified + */ + licenseModified?: string; } export interface ModuleInfos { - [packageName: string]: ModuleInfo; + [packageName: string]: ModuleInfo; } /** * Run the license check * @param opts specifies the path to the module to check dependencies of */ -export function init(opts: InitOpts, callback: (err: Error, ret: ModuleInfos) => void): void; +export function init( + opts: InitOpts, + callback: (err: Error, ret: ModuleInfos) => void +): void; diff --git a/types/license-checker/license-checker-tests.ts b/types/license-checker/license-checker-tests.ts index 0caf98a373..ab9039837f 100644 --- a/types/license-checker/license-checker-tests.ts +++ b/types/license-checker/license-checker-tests.ts @@ -1,13 +1,31 @@ // From README.md: -import * as checker from 'license-checker'; +import * as checker from "license-checker"; -checker.init({ - start: '/path/to/start/looking' -}, (err: Error, json: checker.ModuleInfos): void => { - if (err) { - // Handle error - } else { - // The sorted json data +checker.init( + { + start: "/path/to/start/looking", + production: true, + customPath: { + licenseText: "" + } + }, + (err: Error, json: checker.ModuleInfos): void => { + if (err) { + throw err; + } else { + const licenses = Object.keys(json).reduce( + (memo, key) => { + const license = json[key]; + const { name, version, repository, licenseText } = license; + if (licenseText == null) { + return memo; + } + memo.push(license); + return memo; + }, + [] as checker.ModuleInfo[] + ); + } } -}); +); From 8d233ed377e9e190dbbccca357fe9f517d852dc3 Mon Sep 17 00:00:00 2001 From: Jon LUCAS Date: Tue, 12 Dec 2017 10:04:55 +0100 Subject: [PATCH 112/298] add global compatibility. fix Rater setImageData declaration --- types/paper/index.d.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/types/paper/index.d.ts b/types/paper/index.d.ts index 46d5f58786..64d961ed10 100644 --- a/types/paper/index.d.ts +++ b/types/paper/index.d.ts @@ -1,11 +1,14 @@ // Type definitions for Paper.js v0.9.24 // Project: http://paperjs.org/ -// Definitions by: Clark Stevenson +// Definitions by: Clark Stevenson , Jon Lucas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped type NativeMouseEvent = MouseEvent; -declare module 'paper' { +/** + * @namespace paper + */ +declare module paper { /** * The version of Paper.js, as a string. @@ -2093,8 +2096,7 @@ declare module 'paper' { * @param data * @param point */ - getImageData(data: ImageData, point: Point): void; - + setImageData(data: ImageData, point: Point): void; } /** * A PlacedSymbol represents an instance of a symbol which has been placed in a Paper.js project. @@ -4196,3 +4198,8 @@ declare module 'paper' { stop(): void; } } + +declare module 'paper' +{ + export = paper; +} From 7ecf2a804423ba70eb4f53ae44ad7269db1abb2e Mon Sep 17 00:00:00 2001 From: "VML\\snau" Date: Tue, 12 Dec 2017 08:10:28 -0800 Subject: [PATCH 113/298] adding `dom` to the `tsconfig` to accomdate the `HTMLElement` value allowed for the `selector` property --- types/siema/index.d.ts | 1 + types/siema/tsconfig.json | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/siema/index.d.ts b/types/siema/index.d.ts index b8faf3d644..c291fa8319 100644 --- a/types/siema/index.d.ts +++ b/types/siema/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for siema 1.4 // Project: https://github.com/pawelgrzybek/siema // Definitions by: Irmantas Zenkus +// Sam Nau // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Siema { currentSlide: number; diff --git a/types/siema/tsconfig.json b/types/siema/tsconfig.json index 4fe63d2a73..035dfc51d0 100644 --- a/types/siema/tsconfig.json +++ b/types/siema/tsconfig.json @@ -2,7 +2,8 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, @@ -20,4 +21,4 @@ "index.d.ts", "siema-tests.ts" ] -} \ No newline at end of file +} From 5f94ed59214b49d11393c5017d4e5f8d775cb6f5 Mon Sep 17 00:00:00 2001 From: Alan Lins Date: Tue, 12 Dec 2017 16:14:43 +0000 Subject: [PATCH 114/298] added guess(ignoreCache) --- types/moment-timezone/index.d.ts | 4 ++-- types/moment-timezone/moment-timezone-tests.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/moment-timezone/index.d.ts b/types/moment-timezone/index.d.ts index ca62b3cb82..c3927415c6 100644 --- a/types/moment-timezone/index.d.ts +++ b/types/moment-timezone/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for moment-timezone.js 0.5 // Project: http://momentjs.com/timezone/ -// Definitions by: Michel Salib +// Definitions by: Michel Salib , Alan Brazil Lins // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as moment from 'moment'; @@ -51,7 +51,7 @@ declare module "moment" { }): void; names(): string[]; - guess(): string; + guess(ignoreCache?: boolean): string; setDefault(timezone: string): void; } diff --git a/types/moment-timezone/moment-timezone-tests.ts b/types/moment-timezone/moment-timezone-tests.ts index 14df62915b..66bb7403ea 100644 --- a/types/moment-timezone/moment-timezone-tests.ts +++ b/types/moment-timezone/moment-timezone-tests.ts @@ -78,6 +78,8 @@ moment.tz.setDefault('America/Los_Angeles'); moment.tz.guess(); +moment.tz.guess(true); + const zoneAbbr: string = moment.tz('America/Los_Angeles').zoneAbbr(); const zoneName: string = moment.tz('America/Los_Angeles').zoneName(); From 267157dfba5efa100329ab2a729c418db2853b6a Mon Sep 17 00:00:00 2001 From: abeall Date: Tue, 12 Dec 2017 13:16:23 -0500 Subject: [PATCH 115/298] Support for strictNullChecks --- types/react-intl/index.d.ts | 7 ++++--- types/react-intl/react-intl-tests.tsx | 15 +++++++++++---- types/react-intl/tsconfig.json | 4 ++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/types/react-intl/index.d.ts b/types/react-intl/index.d.ts index 8557f22cb0..7fc19e41ab 100644 --- a/types/react-intl/index.d.ts +++ b/types/react-intl/index.d.ts @@ -12,6 +12,7 @@ declare namespace ReactIntl { type DateSource = Date | string | number; + type MessageValue = string | number | boolean | Date | null | undefined; interface Locale { locale: string; @@ -69,8 +70,8 @@ declare namespace ReactIntl { formatRelative(value: DateSource, options?: FormattedRelative.PropsBase & { now?: any }): string; formatNumber(value: number, options?: FormattedNumber.PropsBase): string; formatPlural(value: number, options?: FormattedPlural.Base): keyof FormattedPlural.PropsBase; - formatMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number | boolean | Date}): string; - formatHTMLMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number | boolean | Date}): string; + formatMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: MessageValue}): string; + formatHTMLMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: MessageValue}): string; locale: string; formats: any; messages: { [id: string]: string }; @@ -138,7 +139,7 @@ declare namespace ReactIntl { } interface Props extends MessageDescriptor { - values?: {[key: string]: string | number | boolean | Date | JSX.Element}; + values?: {[key: string]: MessageValue | JSX.Element}; tagName?: string; } } diff --git a/types/react-intl/react-intl-tests.tsx b/types/react-intl/react-intl-tests.tsx index 25f1016026..726802a8bb 100644 --- a/types/react-intl/react-intl-tests.tsx +++ b/types/react-intl/react-intl-tests.tsx @@ -50,12 +50,12 @@ const SomeFunctionalComponentWithIntl: React.ComponentClass const formattedRelative = formatRelative(new Date().getTime(), { format: "short" }); const formattedNumber = formatNumber(123, { format: "short" }); const formattedPlural = formatPlural(1, { style: "ordinal" }); - const formattedMessage = formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); + const formattedMessage = formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger", nullAllowed: null, undefinedAllowed: undefined }); const formattedMessagePlurals = formatMessage({ id: "hello", - defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" }, - { name: "Roger", unreadCount: 123 }); - const formattedHTMLMessage = formatHTMLMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" }); + defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" + }, { name: "Roger", unreadCount: 123 }); + const formattedHTMLMessage = formatHTMLMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger", nullAllowed: null, undefinedAllowed: undefined }); return (
@@ -136,6 +136,13 @@ class SomeComponent extends React.Component + + Date: Tue, 12 Dec 2017 22:09:21 +0100 Subject: [PATCH 116/298] Updated moo definitions for moo 0.4.3 --- types/moo/index.d.ts | 73 +++++++++++++++++++++++++----------------- types/moo/moo-tests.ts | 67 +++++++++++++++++++++++++++++++------- 2 files changed, 99 insertions(+), 41 deletions(-) diff --git a/types/moo/index.d.ts b/types/moo/index.d.ts index 8bdc583cc9..7b6938ad11 100644 --- a/types/moo/index.d.ts +++ b/types/moo/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for moo 0.3 +// Type definitions for moo 0.4.3 // Project: https://github.com/tjvr/moo#readme // Definitions by: Nikita Litvin +// Jörg Vehlow // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace moo; @@ -14,32 +15,42 @@ export function compile(rules: Rules): Lexer; export function states(states: {[x: string]: Rules}, start?: string): Lexer; +export interface Rule { + match?: RegExp | string | string[], + /** + * Moo tracks detailed information about the input for you. + * It will track line numbers, as long as you apply the `lineBreaks: true` + * option to any tokens which might contain newlines. Moo will try to warn you if you forget to do this. + */ + lineBreaks?: boolean, + /** + * Moves the lexer to a new state, and pushes the old state onto the stack. + */ + push?: string, + /** + * Returns to a previous state, by removing one or more states from the stack. + */ + pop?: number, + /** + * Moves to a new state, but does not affect the stack. + */ + next?: string, + /** + * You can have a token type that both matches tokens and contains error values. + */ + error?: true, + /** + * Moo doesn't allow capturing groups, but you can supply a transform function, value(), + * which will be called on the value before storing it in the Token object. + */ + value?: (x: string) => string, + + keywords?: { + [x: string]: string | string[] + } +} export interface Rules { - [x: string]: RegExp | string | string[] | { - match: RegExp | string | string[], - /** - * Moo tracks detailed information about the input for you. - * It will track line numbers, as long as you apply the `lineBreaks: true` - * option to any tokens which might contain newlines. Moo will try to warn you if you forget to do this. - */ - lineBreaks?: boolean, - /** - * Moves the lexer to a new state, and pushes the old state onto the stack. - */ - push?: string, - /** - * Returns to a previous state, by removing one or more states from the stack. - */ - pop?: number, - /** - * Moves to a new state, but does not affect the stack. - */ - next?: string, - /** - * You can have a token type that both matches tokens and contains error values. - */ - error?: true - }; + [x: string]: RegExp | string | string[] | Rule; } export interface Lexer { @@ -59,12 +70,14 @@ export interface Lexer { /** * Empty the internal buffer of the lexer, and set the line, column, and offset counts back to their initial value. */ - reset(chunk: string, state?: LexerState): void; + reset(chunk?: string, state?: LexerState): void; /** * Returns current state, which you can later pass it as the second argument * to reset() to explicitly control the internal state of the lexer. */ save(): LexerState; + + [Symbol.iterator]: () => Iterator; } export interface Token { @@ -77,7 +90,7 @@ export interface Token { */ type?: string; /** - * The contents of the capturing group (or the whole match, if the token RegExp doesn't define a capture). + * The match contents. */ value: string; /** @@ -85,9 +98,9 @@ export interface Token { */ offset: number; /** - * The total length of the match (value may be shorter if you have capturing groups). + * The complete match. */ - size: number; + text: string; /** * The number of line breaks found in the match. (Always zero if this rule has lineBreaks: false.) */ diff --git a/types/moo/moo-tests.ts b/types/moo/moo-tests.ts index 52defb99ce..43f9a9f86b 100644 --- a/types/moo/moo-tests.ts +++ b/types/moo/moo-tests.ts @@ -2,28 +2,73 @@ import * as moo from 'moo'; let lexer = moo.compile({ lparen: '(', - word: /[a-z]+/, + word: /[a-z]+/, rparen: ')', keyword: ['while', 'if', 'else', 'moo', 'cows'] }); +lexer = moo.compile({ + WS: /[ \t]+/, + comment: /\/\/.*?$/, + number: /0|[1-9][0-9]*/, + string: /"(?:\\["\\]|[^\n"\\])*"/, + lparen: '(', + rparen: ')', + keyword: ['while', 'if', 'else', 'moo', 'cows'], + NL: { match: /\n/, lineBreaks: true }, +}); + +lexer = moo.compile({ + IDEN: { + match: /[a-zA-Z]+/, keywords: { + KW: ['while', 'if', 'else', 'moo', 'reloacows'] + } + }, + SPACE: { match: /\s+/, lineBreaks: true } +}); + +lexer = moo.compile({ + name: { + match: /[a-zA-Z]+/, keywords: { + 'kw-class': 'class', + 'kw-def': 'def', + 'kw-if': 'if', + } + } +}); + lexer = moo.states({ main: { - strstart: {match: '`', push: 'lit'}, - ident: /\w+/, - lbrace: {match: '{', push: 'main'}, - rbrace: {match: '}', pop: 1}, - colon: ':', - space: {match: /\s+/, lineBreaks: true}, + strstart: { match: '`', push: 'lit' }, + ident: /\w+/, + lbrace: { match: '{', push: 'main' }, + rbrace: { match: '}', pop: 1 }, + colon: ':', + space: { match: /\s+/, lineBreaks: true }, }, lit: { - interp: {match: '${', push: 'main'}, // tslint:disable-line no-invalid-template-strings - escape: /\\./, - strend: {match: '`', pop: 1}, - const: {match: /(?:[^$`]|\$(?!\{))+/, lineBreaks: true}, + interp: { match: '${', push: 'main' }, // tslint:disable-line no-invalid-template-strings + escape: /\\./, + strend: { match: '`', pop: 1 }, + const: { match: /(?:[^$`]|\$(?!\{))+/, lineBreaks: true }, }, }); +moo.compile({ + myError: moo.error +}); + +moo.compile({ + myError: { match: /[\$?`]/, error: true } +}); + +for (const here of lexer) { + const t: string = here.type; + const v: string = here.value; +} + +const tokens: moo.Token[] = Array.from(lexer); + lexer.reset('some line\n'); const info = lexer.save(); lexer.next(); From 2946765dcfe6655be3f97288db6e1d666067225b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Vehlow?= Date: Tue, 12 Dec 2017 22:33:45 +0100 Subject: [PATCH 117/298] fixed tslint errors --- types/moo/index.d.ts | 20 ++++++++++---------- types/moo/moo-tests.ts | 2 +- types/moo/tsconfig.json | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/types/moo/index.d.ts b/types/moo/index.d.ts index 7b6938ad11..dbb6d81f5b 100644 --- a/types/moo/index.d.ts +++ b/types/moo/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for moo 0.4.3 +// Type definitions for moo 0.4 // Project: https://github.com/tjvr/moo#readme // Definitions by: Nikita Litvin // Jörg Vehlow @@ -16,38 +16,38 @@ export function compile(rules: Rules): Lexer; export function states(states: {[x: string]: Rules}, start?: string): Lexer; export interface Rule { - match?: RegExp | string | string[], + match?: RegExp | string | string[]; /** * Moo tracks detailed information about the input for you. * It will track line numbers, as long as you apply the `lineBreaks: true` * option to any tokens which might contain newlines. Moo will try to warn you if you forget to do this. */ - lineBreaks?: boolean, + lineBreaks?: boolean; /** * Moves the lexer to a new state, and pushes the old state onto the stack. */ - push?: string, + push?: string; /** * Returns to a previous state, by removing one or more states from the stack. */ - pop?: number, + pop?: number; /** * Moves to a new state, but does not affect the stack. */ - next?: string, + next?: string; /** * You can have a token type that both matches tokens and contains error values. */ - error?: true, + error?: true; /** * Moo doesn't allow capturing groups, but you can supply a transform function, value(), * which will be called on the value before storing it in the Token object. */ - value?: (x: string) => string, + value?: (x: string) => string; keywords?: { [x: string]: string | string[] - } + }; } export interface Rules { [x: string]: RegExp | string | string[] | Rule; @@ -77,7 +77,7 @@ export interface Lexer { */ save(): LexerState; - [Symbol.iterator]: () => Iterator; + [Symbol.iterator](): Iterator; } export interface Token { diff --git a/types/moo/moo-tests.ts b/types/moo/moo-tests.ts index 43f9a9f86b..6f0c18ae2d 100644 --- a/types/moo/moo-tests.ts +++ b/types/moo/moo-tests.ts @@ -63,7 +63,7 @@ moo.compile({ }); for (const here of lexer) { - const t: string = here.type; + const t: string | undefined = here.type; const v: string = here.value; } diff --git a/types/moo/tsconfig.json b/types/moo/tsconfig.json index 895fed83d5..e2659ef342 100644 --- a/types/moo/tsconfig.json +++ b/types/moo/tsconfig.json @@ -5,6 +5,7 @@ "es6", "dom" ], + "target": "es6", "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, From 439f9efd78a748d8cdf01963ef54011cfe82cba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Vehlow?= Date: Tue, 12 Dec 2017 22:40:07 +0100 Subject: [PATCH 118/298] fixed last lint error --- types/moo/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/moo/index.d.ts b/types/moo/index.d.ts index dbb6d81f5b..9cf67c3299 100644 --- a/types/moo/index.d.ts +++ b/types/moo/index.d.ts @@ -40,7 +40,7 @@ export interface Rule { */ error?: true; /** - * Moo doesn't allow capturing groups, but you can supply a transform function, value(), + * Moo doesn't allow capturing groups, but you can supply a transform function, value(), * which will be called on the value before storing it in the Token object. */ value?: (x: string) => string; From 2e0f25538ed4245530231e0a71396ac9f957033b Mon Sep 17 00:00:00 2001 From: Xavier Lozinguez Date: Tue, 12 Dec 2017 17:38:54 -0500 Subject: [PATCH 119/298] Fixed web-bluetooth types as filters are optionals --- types/web-bluetooth/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/web-bluetooth/index.d.ts b/types/web-bluetooth/index.d.ts index 912a7fdd55..ea01176c38 100644 --- a/types/web-bluetooth/index.d.ts +++ b/types/web-bluetooth/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for Web Bluetooth // Project: https://webbluetoothcg.github.io/web-bluetooth/ // Definitions by: Uri Shaked +// Xavier Lozinguez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped type BluetoothServiceUUID = number | string; @@ -16,7 +17,7 @@ interface BluetoothRequestDeviceFilter { } interface RequestDeviceOptions { - filters: BluetoothRequestDeviceFilter[]; + filters?: BluetoothRequestDeviceFilter[]; optionalServices?: BluetoothServiceUUID[]; acceptAllDevices?: boolean; } From 6dd5875e4e4d468c3f787e868e39fc2086d71e5d Mon Sep 17 00:00:00 2001 From: Ricky Lippmann Date: Wed, 13 Dec 2017 09:17:45 +0100 Subject: [PATCH 120/298] [FIX] make amcharts definitions work in strict mode --- types/amcharts/index.d.ts | 59 ++++++++++++++++++------------------ types/amcharts/tsconfig.json | 4 +-- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/types/amcharts/index.d.ts b/types/amcharts/index.d.ts index 4bb6631292..54a750447b 100644 --- a/types/amcharts/index.d.ts +++ b/types/amcharts/index.d.ts @@ -1,7 +1,8 @@ // Type definitions for amCharts // Project: http://www.amcharts.com/ -// Definitions by: aleksey-bykov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Definitions by: aleksey-bykov +// ldrick /// AmCharts object (it's not a class) is create automatically when amcharts.js or amstock.js file is included in a web page. declare namespace AmCharts { @@ -232,13 +233,13 @@ declare namespace AmCharts { {country:"Austria",litres:108.30}, {country:"UK",litres:99.00} ]; - + window.onload = function() { chart = new AmCharts.AmRadarChart(); chart.dataProvider = chartData; chart.categoryField = "country"; chart.startDuration = 2; - + var valueAxis = new AmCharts.ValueAxis(); valueAxis.axisAlpha = 0.15; valueAxis.minimum = 0; @@ -246,13 +247,13 @@ declare namespace AmCharts { valueAxis.axisTitleOffset = 20; valueAxis.gridCount = 5; chart.addValueAxis(valueAxis); - + var graph = new AmCharts.AmGraph(); graph.valueField = "litres"; graph.bullet = "round"; graph.balloonText = "[[value]] litres of beer per year" chart.addGraph(graph); - + chart.write("chartdiv"); } */ @@ -280,23 +281,23 @@ declare namespace AmCharts { {x:13, y:1, value:8}, {x:1, y:6, value:35} ]; - + var chart = new AmCharts.AmXYChart(); chart.pathToImages = "../../amcharts/javascript/images/"; chart.dataProvider = chartData; chart.marginLeft = 35; chart.startDuration = 1.5; - + var xAxis = new AmCharts.ValueAxis(); xAxis.position = "left"; xAxis.autoGridCount = true; chart.addValueAxis(xAxis); - + var yAxis = new AmCharts.ValueAxis(); yAxis.position = "bottom"; yAxis.autoGridCount = true; chart.addValueAxis(yAxis); - + var graph = new AmCharts.AmGraph(); graph.valueField = "value"; graph.xField = "x"; @@ -304,14 +305,14 @@ declare namespace AmCharts { graph.lineAlpha = 0; graph.bullet = "round"; chart.addGraph(graph); - + var chartCursor = new AmCharts.ChartCursor(); chart.addChartCursor(chartCursor); - + var chartScrollbar = new AmCharts.ChartScrollbar(); chartScrollbar.hideResizeGrips = false; chart.addChartScrollbar(chartScrollbar); - + chart.write("chartdiv); */ class AmXYChart extends AmRectangularChart { @@ -327,7 +328,7 @@ declare namespace AmCharts { zoomOut(): void; } /** Guides are straight vertical or horizontal lines or areas supported by AmSerialChart, AmXYChart and AmRadarChart. You can have guides both on value and category axes. To add/remove a guide to an axis, use axis.addGuide(guide)/axis.removeGuide(guide) methods. - + If you do not set properties such as dashLength, lineAlpha, lineColor, etc - values of the axis are used.*/ class Guide { /** If you set it to true, the guide will be displayed above the graphs. */ @@ -1035,7 +1036,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val bold - specifies if text is bold (true/false), url - url */ - addLabel(x: number|string, y: number|string, text: string, align: string, size?: number, color?: string, rotation?: number, alpha?: number, bold?: boolean, url?: string): any; + addLabel(x: number | string, y: number | string, text: string, align: string, size?: number, color?: string, rotation?: number, alpha?: number, bold?: boolean, url?: string): any; /** Adds a legend to the chart. By default, you don't need to create div for your legend, however if you want it to be positioned in some different way, you can create div anywhere you want and pass id or reference to your div as a second parameter. (NOTE: This method will not work on StockPanel.) @@ -1579,21 +1580,21 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** AmSerialChart is the class you have to use for majority of chart types. The supported chart types are: line, area, column, bar, step line, smoothed line, candlestick and OHLC. The chart can be rotated by 90 degrees so the column chart becomes bar chart. The chart supports simple and logarithmic scales, it can have multiple value axes. The chart can place data points at equal intervals or can parse dates and place data points at irregular intervals. @example var chartData = [{title:"sample 1",value:130},{title:"sample 2",value:26}]; - + var chart = new AmCharts.AmSerialChart(); chart.categoryField = "title"; chart.dataProvider = chartData; - + var graph = new AmCharts.AmGraph(); graph.valueField = "value"; graph.type = "column"; graph.fillAlphas = 1; chart.addGraph(graph); - + chart.write("chartdiv"); */ class AmSerialChart extends AmRectangularChart { - /** Date format of the graph balloon (if chart parses dates and you don't use chartCursor). + /** Date format of the graph balloon (if chart parses dates and you don't use chartCursor). @default 'MMM DD, YYYY' */ balloonDateFormat: string; @@ -2318,19 +2319,19 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val valueInterval: number; /** Adds event listener to the object. */ - addListener(type: string, handler: any); + addListener(type: string, handler: any): void; /** Removes event listener from chart object. */ - removeListener(chart: AmChart, type: string, handler: any); + removeListener(chart: AmChart, type: string, handler: any): void; /** Sets bottom text. */ - setBottomText(text: string); + setBottomText(text: string): void; /** Sets top text. */ - setTopText(textstring); + setTopText(textstring: string): void; /** Returns angle of the value. */ - value2angle(value: number); + value2angle(value: number): void; } class GaugeBand { @@ -2367,10 +2368,10 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val url: string; /** Sets end value for the band. */ - setEndValue(value); + setEndValue(value: number): void; /** Sets start value for the band. */ - setStartValue(value); + setStartValue(value: number): void; } class PeriodSelector { @@ -2977,7 +2978,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** Name of the close field (used by candlesticks and ohlc) in your dataProvider. */ closeField: string; /** In case you want to place this graph's columns in front of other columns, set this to false. In case "true", the columns will be clustered next to each other. - + NOTE: clustering works only for graphs of type "column". @default true */ @@ -3366,10 +3367,10 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val integersOnly: boolean; /** You can use this function to format Value axis labels. This function is called and these parameters are passed: labelFunction(value, valueText, valueAxis); Where value is numeric value, valueText is formatted string and valueAxis is a reference to valueAxis object. - + If axis type is "date", labelFunction will pass different arguments: labelFunction(valueText, date, valueAxis) - + Your function should return string.*/ labelFunction(value: number, valueText: string, valueAxis: ValueAxis): string; labelFunction(valueText: string, data: Date, valueAxis: ValueAxis): string; @@ -3490,6 +3491,6 @@ Your function should return string.*/ menu: Object; config: any; capture(config: any, callback: () => void): any; - toJPG(config: any, callback: (config:any) => void): any; + toJPG(config: any, callback: (config: any) => void): any; } } diff --git a/types/amcharts/tsconfig.json b/types/amcharts/tsconfig.json index fa1c069762..2eae92bb60 100644 --- a/types/amcharts/tsconfig.json +++ b/types/amcharts/tsconfig.json @@ -5,9 +5,9 @@ "es6", "dom" ], - "noImplicitAny": false, + "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ From 1906089b02a873c58662b5cac4ccde4ed50e6092 Mon Sep 17 00:00:00 2001 From: Ricky Lippmann Date: Wed, 13 Dec 2017 09:34:41 +0100 Subject: [PATCH 121/298] [FIX] travis checks header --- types/amcharts/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/amcharts/index.d.ts b/types/amcharts/index.d.ts index 54a750447b..e18602df4c 100644 --- a/types/amcharts/index.d.ts +++ b/types/amcharts/index.d.ts @@ -1,8 +1,8 @@ // Type definitions for amCharts // Project: http://www.amcharts.com/ -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Definitions by: aleksey-bykov // ldrick +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// AmCharts object (it's not a class) is create automatically when amcharts.js or amstock.js file is included in a web page. declare namespace AmCharts { From 5aeab8241c1313a15dfc0f1a2f789a58bbd95cdd Mon Sep 17 00:00:00 2001 From: "Remo H. Jansen" Date: Wed, 13 Dec 2017 09:52:53 +0000 Subject: [PATCH 122/298] Added missing IconType https://github.com/recharts/recharts/pull/985 --- types/recharts/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/recharts/index.d.ts b/types/recharts/index.d.ts index 7d42cee0d3..730c320408 100644 --- a/types/recharts/index.d.ts +++ b/types/recharts/index.d.ts @@ -21,7 +21,7 @@ export type ItemSorter = (a: T, b: T) => number; export type ContentRenderer

= (props: P) => React.ReactNode; export type DataKey = string | number | ((dataObject: any) => number | [number, number]); -export type IconType = 'line' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'plainline'; +export type IconType = 'plainline' | 'line' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'plainline'; export type LegendType = IconType | 'none'; export type LayoutType = 'horizontal' | 'vertical'; export type AnimationEasingType = 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'; From 7e045f03b63f4f6ea516e3b8a8101da437312ea7 Mon Sep 17 00:00:00 2001 From: rollymaduk Date: Wed, 13 Dec 2017 15:50:47 +0100 Subject: [PATCH 123/298] Add stop to /types/pubnub/index.d.ts --- types/pubnub/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/pubnub/index.d.ts b/types/pubnub/index.d.ts index 488ad668d9..f70859a991 100644 --- a/types/pubnub/index.d.ts +++ b/types/pubnub/index.d.ts @@ -36,6 +36,8 @@ declare class Pubnub { unsubscribe(params: Pubnub.UnsubscribeParameters): void; unsubscribeAll(): void; + + stop():void; addListener(params: Pubnub.ListenerParameters): void; From 1c2115d7f913895b65412c6a7da04450d22fa805 Mon Sep 17 00:00:00 2001 From: rollymaduk Date: Wed, 13 Dec 2017 15:56:49 +0100 Subject: [PATCH 124/298] Added name to defintions by section --- types/pubnub/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/pubnub/index.d.ts b/types/pubnub/index.d.ts index f70859a991..48f635d1ed 100644 --- a/types/pubnub/index.d.ts +++ b/types/pubnub/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for pubnub 4.0 // Project: https://github.com/pubnub/javascript // Definitions by: bitbankinc +// rollymaduk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // @see https://www.pubnub.com/docs/web-javascript/api-reference-configuration From 152623d9e9ffa3fdad06ad5aef31e9904cb19dd9 Mon Sep 17 00:00:00 2001 From: rollymaduk Date: Wed, 13 Dec 2017 16:09:58 +0100 Subject: [PATCH 125/298] fix whitespace issue in name definitions --- types/pubnub/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/pubnub/index.d.ts b/types/pubnub/index.d.ts index 48f635d1ed..d27af6a6f9 100644 --- a/types/pubnub/index.d.ts +++ b/types/pubnub/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for pubnub 4.0 // Project: https://github.com/pubnub/javascript -// Definitions by: bitbankinc -// rollymaduk +// Definitions by: bitbankinc ,rollymaduk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // @see https://www.pubnub.com/docs/web-javascript/api-reference-configuration From 64f1bba1bccea662e5901c009ed5f1cd3fe33b59 Mon Sep 17 00:00:00 2001 From: rollymaduk Date: Wed, 13 Dec 2017 16:15:29 +0100 Subject: [PATCH 126/298] Whitespace issue fix in Definitions by --- types/pubnub/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/pubnub/index.d.ts b/types/pubnub/index.d.ts index d27af6a6f9..82ffb785cb 100644 --- a/types/pubnub/index.d.ts +++ b/types/pubnub/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for pubnub 4.0 // Project: https://github.com/pubnub/javascript -// Definitions by: bitbankinc ,rollymaduk +// Definitions by: bitbankinc , rollymaduk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // @see https://www.pubnub.com/docs/web-javascript/api-reference-configuration From 0408627bb1f0630ff2aabaab7756b1726ffeab92 Mon Sep 17 00:00:00 2001 From: rollymaduk Date: Wed, 13 Dec 2017 16:23:23 +0100 Subject: [PATCH 127/298] whitespace fix --- types/pubnub/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/pubnub/index.d.ts b/types/pubnub/index.d.ts index 82ffb785cb..3ad70755a0 100644 --- a/types/pubnub/index.d.ts +++ b/types/pubnub/index.d.ts @@ -36,8 +36,8 @@ declare class Pubnub { unsubscribe(params: Pubnub.UnsubscribeParameters): void; unsubscribeAll(): void; - - stop():void; + + stop(): void; addListener(params: Pubnub.ListenerParameters): void; From c07a61d1aa2f0cc628df15f09853dfe1872868c4 Mon Sep 17 00:00:00 2001 From: Sengouttouvane Shanmugam Date: Wed, 13 Dec 2017 11:27:28 -0600 Subject: [PATCH 128/298] Add classes option to jqueryui autocomplete See http://api.jqueryui.com/autocomplete/#option-classes Signed-off-by: Grant Hutchins --- types/jqueryui/index.d.ts | 14 ++++++++++---- types/jqueryui/jqueryui-tests.ts | 7 ++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/types/jqueryui/index.d.ts b/types/jqueryui/index.d.ts index f32c55eb48..a11be350c4 100644 --- a/types/jqueryui/index.d.ts +++ b/types/jqueryui/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jQueryUI 1.11 +// Type definitions for jQueryUI 1.12 // Project: http://jqueryui.com/ // Definitions by: Boris Yankov , John Reilly // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -51,6 +51,12 @@ declare namespace JQueryUI { minLength?: number; position?: any; // object source?: any; // [], string or () + classes?: AutocompleteClasses; + } + + interface AutocompleteClasses { + "ui-autocomplete"?: string; + "ui-autocomplete-input"?: string; } interface AutocompleteUIParams { @@ -377,7 +383,7 @@ declare namespace JQueryUI { open?: DialogEvent; close?: DialogEvent; } - + interface DialogClasses { "ui-dialog"?: string; "ui-dialog-content"?: string; @@ -1384,8 +1390,8 @@ interface JQuery { * @param optionName 'autohide' */ datepicker(methodName: 'option', optionName: 'autohide'): boolean; - - + + /** * Get the endDate after initialization * diff --git a/types/jqueryui/jqueryui-tests.ts b/types/jqueryui/jqueryui-tests.ts index c2067574cd..a9f6f0b5ff 100644 --- a/types/jqueryui/jqueryui-tests.ts +++ b/types/jqueryui/jqueryui-tests.ts @@ -911,7 +911,12 @@ function test_autocomplete() { "Nothing selected, input was " + this.value); } }); - + $("#birds").autocomplete({ + classes: { + 'ui-autocomplete': 'foo', + 'ui-autocomplete-input': 'bar' + } + }) } From bd9beb540b36556a044a5e3460850c6a99859f8c Mon Sep 17 00:00:00 2001 From: id0181 Date: Wed, 13 Dec 2017 13:04:03 -0500 Subject: [PATCH 129/298] Add sourceKey property to AssociationOptionsHasMany interface According to http://docs.sequelizejs.com/class/lib/model.js~Model.html#static-method-hasMany, Model.hasMany should have an sourceKey property. But for now, no sourceKey property for an 1 to Many association exists --- types/sequelize/index.d.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/types/sequelize/index.d.ts b/types/sequelize/index.d.ts index b7bf448aed..dae8b3475c 100644 --- a/types/sequelize/index.d.ts +++ b/types/sequelize/index.d.ts @@ -7,6 +7,7 @@ // Patsakol Tangjitcharoenchai // Sebastien Bramille // Nick Mueller +// Philippe D'Alva // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -1329,7 +1330,13 @@ declare namespace sequelize { * A string or a data type to represent the identifier in the table */ keyType?: DataTypeAbstract; - + /** + * A string to represent the name of the field to use as the key for an 1 to many association in the source table. + * + * @see http://docs.sequelizejs.com/class/lib/model.js~Model.html#static-method-hasMany + * @see https://github.com/sequelize/sequelize/blob/b4fd46426db9cdbb97074bea121203d565e4195d/lib/associations/has-many.js#L81 + */ + sourceKey?: string; } /** From 79258c041a31e9b4d2247000fc8bccb82441f165 Mon Sep 17 00:00:00 2001 From: Retsam Date: Wed, 13 Dec 2017 13:56:16 -0500 Subject: [PATCH 130/298] Make caught an alias for catch --- types/bluebird/index.d.ts | 139 +------------------------------------- 1 file changed, 1 insertion(+), 138 deletions(-) diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index ba7a8bd172..9c68e85212 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -209,144 +209,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * * Alias `.caught();` for compatibility with earlier ECMAScript version. */ - caught(onReject: (error: any) => R | PromiseLike): Bluebird; - caught(onReject: ((error: any) => U | PromiseLike) | undefined | null): Bluebird; - - /** - * This extends `.catch` to work more like catch-clauses in languages like Java or C#. - * - * Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. - * The catch handler that is first met that has eligible constructors specified, is the one that will be called. - * - * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. - * The return result of the predicate will be used determine whether the error handler should be called. - * - * Alias `.caught();` for compatibility with earlier ECMAScript version. - */ - caught( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - filter4: (new (...args: any[]) => E4), - filter5: (new (...args: any[]) => E5), - onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike, - ): Bluebird; - caught( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), - filter4: ((error: E4) => boolean) | (E4 & object), - filter5: ((error: E5) => boolean) | (E5 & object), - onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike, - ): Bluebird; - caught( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - filter4: (new (...args: any[]) => E4), - filter5: (new (...args: any[]) => E5), - onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike, - ): Bluebird; - caught( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), - filter4: ((error: E4) => boolean) | (E4 & object), - filter5: ((error: E5) => boolean) | (E5 & object), - onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike, - ): Bluebird; - - caught( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - filter4: (new (...args: any[]) => E4), - onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike, - ): Bluebird; - caught( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), - filter4: ((error: E4) => boolean) | (E4 & object), - onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike, - ): Bluebird; - caught( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - filter4: (new (...args: any[]) => E4), - onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike, - ): Bluebird; - caught( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), - filter4: ((error: E4) => boolean) | (E4 & object), - onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike, - ): Bluebird; - - caught( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - onReject: (error: E1 | E2 | E3) => R | PromiseLike, - ): Bluebird; - caught( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), - onReject: (error: E1 | E2 | E3) => R | PromiseLike, - ): Bluebird; - caught( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - onReject: (error: E1 | E2 | E3) => U | PromiseLike, - ): Bluebird; - caught( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), - onReject: (error: E1 | E2 | E3) => U | PromiseLike, - ): Bluebird; - - caught( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - onReject: (error: E1 | E2) => R | PromiseLike, - ): Bluebird; - caught( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - onReject: (error: E1 | E2) => R | PromiseLike, - ): Bluebird; - caught( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - onReject: (error: E1 | E2) => U | PromiseLike, - ): Bluebird; - caught( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - onReject: (error: E1 | E2) => U | PromiseLike, - ): Bluebird; - - caught( - filter1: (new (...args: any[]) => E1), - onReject: (error: E1) => R | PromiseLike, - ): Bluebird; - caught( - filter1: ((error: E1) => boolean) | (E1 & object), - onReject: (error: E1) => R | PromiseLike, - ): Bluebird; - caught( - filter1: (new (...args: any[]) => E1), - onReject: (error: E1) => U | PromiseLike, - ): Bluebird; - caught( - filter1: ((error: E1) => boolean) | (E1 & object), - onReject: (error: E1) => U | PromiseLike, - ): Bluebird; + caught: Bluebird["catch"]; /** * Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections. From d73f413fb66639480b96d9031df9727ed61fcd81 Mon Sep 17 00:00:00 2001 From: Retsam Date: Wed, 13 Dec 2017 14:02:42 -0500 Subject: [PATCH 131/298] Fix inferred types for targetted error handlers The typings for targetted catch statements don't infer properly with Error constructors, for example with `.catch(SomeErrorSubtype, (e) => /*...*/)`, `e` is inferred to be the constructor of SomeErrorSubtype, not an instance of SomeErrorSubtype, so this must be explicitly typed as `.catch(SomeErrorSubtype, (e: SomeErrorSubtype) => /*...*/)` for the typings to be accurate. The root causes is that it is erroneously falling into the wrong overload, the overload that accepts arbitrary objects as the first argument to .catch. This fix requires loosening the restriction that SomeErrorSubtype must be a subtype of Error, but otherwise preserves existing behavior. Also, makes a utility type to reduce some of the boilerplate. --- types/bluebird/index.d.ts | 123 ++++++++++---------------------------- 1 file changed, 33 insertions(+), 90 deletions(-) diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index 9c68e85212..b28f821e12 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -35,6 +35,8 @@ * THE SOFTWARE. */ +type CatchFilter = (new (...args: any[]) => E) | ((error: E) => boolean) | (object & E); + declare class Bluebird implements PromiseLike, Bluebird.Inspection { /** * Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise. @@ -77,128 +79,69 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * * Alias `.caught();` for compatibility with earlier ECMAScript version. */ - catch( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - filter4: (new (...args: any[]) => E4), - filter5: (new (...args: any[]) => E5), - onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike, - ): Bluebird; catch( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), - filter4: ((error: E4) => boolean) | (E4 & object), - filter5: ((error: E5) => boolean) | (E5 & object), + filter1: CatchFilter, + filter2: CatchFilter, + filter3: CatchFilter, + filter4: CatchFilter, + filter5: CatchFilter, onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike, ): Bluebird; - catch( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - filter4: (new (...args: any[]) => E4), - filter5: (new (...args: any[]) => E5), - onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike, - ): Bluebird; catch( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), - filter4: ((error: E4) => boolean) | (E4 & object), - filter5: ((error: E5) => boolean) | (E5 & object), + filter1: CatchFilter, + filter2: CatchFilter, + filter3: CatchFilter, + filter4: CatchFilter, + filter5: CatchFilter, onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike, ): Bluebird; - catch( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - filter4: (new (...args: any[]) => E4), - onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike, - ): Bluebird; catch( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), - filter4: ((error: E4) => boolean) | (E4 & object), + filter1: CatchFilter, + filter2: CatchFilter, + filter3: CatchFilter, + filter4: CatchFilter, onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike, ): Bluebird; - catch( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - filter4: (new (...args: any[]) => E4), - onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike, - ): Bluebird; + catch( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), - filter4: ((error: E4) => boolean) | (E4 & object), + filter1: CatchFilter, + filter2: CatchFilter, + filter3: CatchFilter, + filter4: CatchFilter, onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike, ): Bluebird; - catch( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - onReject: (error: E1 | E2 | E3) => R | PromiseLike, - ): Bluebird; catch( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), + filter1: CatchFilter, + filter2: CatchFilter, + filter3: CatchFilter, onReject: (error: E1 | E2 | E3) => R | PromiseLike, ): Bluebird; - catch( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - filter3: (new (...args: any[]) => E3), - onReject: (error: E1 | E2 | E3) => U | PromiseLike, - ): Bluebird; catch( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), - filter3: ((error: E3) => boolean) | (E3 & object), + filter1: CatchFilter, + filter2: CatchFilter, + filter3: CatchFilter, onReject: (error: E1 | E2 | E3) => U | PromiseLike, ): Bluebird; - catch( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - onReject: (error: E1 | E2) => R | PromiseLike, - ): Bluebird; catch( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), + filter1: CatchFilter, + filter2: CatchFilter, onReject: (error: E1 | E2) => R | PromiseLike, ): Bluebird; - catch( - filter1: (new (...args: any[]) => E1), - filter2: (new (...args: any[]) => E2), - onReject: (error: E1 | E2) => U | PromiseLike, - ): Bluebird; catch( - filter1: ((error: E1) => boolean) | (E1 & object), - filter2: ((error: E2) => boolean) | (E2 & object), + filter1: CatchFilter, + filter2: CatchFilter, onReject: (error: E1 | E2) => U | PromiseLike, ): Bluebird; - catch( - filter1: (new (...args: any[]) => E1), - onReject: (error: E1) => R | PromiseLike, - ): Bluebird; catch( - filter1: ((error: E1) => boolean) | (E1 & object), + filter1: CatchFilter, onReject: (error: E1) => R | PromiseLike, ): Bluebird; - catch( - filter1: (new (...args: any[]) => E1), - onReject: (error: E1) => U | PromiseLike, - ): Bluebird; catch( - filter1: ((error: E1) => boolean) | (E1 & object), + filter1: CatchFilter, onReject: (error: E1) => U | PromiseLike, ): Bluebird; From 8015c2aead024a3e53fb3706486fd72f6ecffe2d Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 13 Dec 2017 22:17:57 +0300 Subject: [PATCH 132/298] watchPath returns a Promise --- types/atom/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/atom/index.d.ts b/types/atom/index.d.ts index 4adac61dc1..47cc23d0c3 100644 --- a/types/atom/index.d.ts +++ b/types/atom/index.d.ts @@ -24,7 +24,7 @@ declare global { * Project::onDidChangeFiles instead. */ export function watchPath(rootPath: string, options: {}, eventCallback: (events: - FilesystemChangeEvent) => void): PathWatcher; + FilesystemChangeEvent) => void): Promise; // Essential Classes ========================================================== From 42b8e18474291dc7ee3e233b19b3c8cf60bac967 Mon Sep 17 00:00:00 2001 From: Retsam Date: Wed, 13 Dec 2017 15:45:49 -0500 Subject: [PATCH 133/298] Modify tests so that they verify the inference of filtered catch handlers --- types/bluebird/bluebird-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/bluebird/bluebird-tests.ts b/types/bluebird/bluebird-tests.ts index 9dfb4fdc1f..c9c09221e8 100644 --- a/types/bluebird/bluebird-tests.ts +++ b/types/bluebird/bluebird-tests.ts @@ -352,7 +352,7 @@ class CustomError extends Error { customField: number; } // $ExpectType Bluebird -fooProm.catch(CustomError, (reason: CustomError) => { +fooProm.catch(CustomError, reason => { let a: number = reason.customField; }); @@ -366,7 +366,7 @@ class CustomErrorWithConstructor extends Error { } } // $ExpectType Bluebird -fooProm.catch(CustomErrorWithConstructor, (reason: CustomErrorWithConstructor) => { +fooProm.catch(CustomErrorWithConstructor, reason => { let a: boolean = reason.arg1; let b: number = reason.arg2; }); From 7276b01b55e991e3d9956a4f18ec1b2147d34397 Mon Sep 17 00:00:00 2001 From: Kurt Preston Date: Wed, 13 Dec 2017 15:06:10 -0600 Subject: [PATCH 134/298] Updating react-jsonschema-form types to be 1.0.0 compatible --- types/react-jsonschema-form/index.d.ts | 157 ++++++++++++++++-- .../react-jsonschema-form-tests.tsx | 7 +- 2 files changed, 151 insertions(+), 13 deletions(-) diff --git a/types/react-jsonschema-form/index.d.ts b/types/react-jsonschema-form/index.d.ts index afb4b883a3..e6ad7c52ab 100644 --- a/types/react-jsonschema-form/index.d.ts +++ b/types/react-jsonschema-form/index.d.ts @@ -1,20 +1,23 @@ -// Type definitions for react-jsonschema-form 0.51.0 +// Type definitions for react-jsonschema-form 1.0.0 // Project: https://github.com/mozilla-services/react-jsonschema-form // Definitions by: Dan Fox // Jon Surrell // Ivan Jiang +// Kurt Preston // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 declare module "react-jsonschema-form" { import * as React from "react"; + import { JSONSchema4 } from "json-schema"; export interface FormProps { - schema: {}; - uiSchema?: {}; + schema: JSONSchema4; + uiSchema?: UiSchema; formData?: any; - widgets?: {}; - fields?: {}; + formContext?: any; + widgets?: {[name: string]: Widget}; + fields?: {[name: string]: Field}; noValidate?: boolean; noHtml5Validate?: boolean; showErrorList?: boolean; @@ -23,10 +26,146 @@ declare module "react-jsonschema-form" { onError?: (e: any) => any; onSubmit?: (e: any) => any; liveValidate?: boolean; - ObjectFieldTemplate?:any; + FieldTemplate?: React.StatelessComponent; + ArrayFieldTemplate?: React.StatelessComponent; + ObjectFieldTemplate?: React.StatelessComponent; safeRenderCompletion?: boolean; - FieldTemplate?: any; transformErrors?: (errors: any) => any; + + // HTML Attributes + id?: string; + className?: string; + name?: string; + method?: string; + target?: string; + action?: string; + autocomplete?: string; + enctype?: string; + acceptcharset?: string; + } + + export default class Form extends React.Component { } + + export type UiSchema = { + 'ui:field'?: Field | string; + 'ui:widget'?: Widget | string; + 'ui:options'?: object; + 'ui:order'?: string[]; + [name: string]: any; + }; + + export type IdSchema = { + $id: string; + }; + + export interface WidgetProps extends React.HTMLAttributes { + id: string; + schema: JSONSchema4; + value: any; + required: boolean; + disabled: boolean; + readonly: boolean; + autofocus: boolean; + onChange: (value: any) => void; + options: object; + formContext: any; + } + + export type Widget = React.StatelessComponent | React.ComponentClass; + + export interface FieldProps extends React.HTMLAttributes { + schema: JSONSchema4; + uiSchema: UiSchema; + idSchema: IdSchema; + formData: any; + errorSchema: object; + onChange: (value: any) => void; + registry: { + fields: {[name: string]: Field}; + widgets: {[name: string]: Widget}; + definitions: object; + formContext: any; + }; + formContext: any; + autofocus: boolean; + disabled: boolean; + readonly: boolean; + required: boolean; + name: string; + [prop: string]: any; + } + + export type Field = React.StatelessComponent | React.ComponentClass; + + export type FieldTemplateProps = { + id: string; + classNames: string; + label: string; + description: React.ReactElement; + rawDescription: string; + children: React.ReactElement; + errors: React.ReactElement; + rawErrors: string[]; + help: React.ReactElement; + rawHelp: string; + hidden: boolean; + required: boolean; + readonly: boolean; + disabled: boolean; + displayLabel: boolean; + fields: Field[]; + schema: JSONSchema4; + uiSchema: UiSchema; + formContext: any; + } + + export type ArrayFieldTemplateProps = { + DescriptionField: object; + TitleField: object; + candAdd: boolean; + className: string; + disabled: boolean; + idSchema: IdSchema; + items: { + children: React.ReactElement, + className: string; + disabled: boolean; + hasMoveDown: boolean; + hasMoveUp: boolean; + hasRemove: boolean; + hasToolbar: boolean; + index: number; + onDropIndexClick: (index: number) => (event: any) => void; + onReorderClick: (index: number, newIndex: number) => (event: any) => void; + readonly: boolean; + }[]; + onAddClick: (event: any) => (event: any) => void; + readonly: boolean; + required: boolean; + schema: JSONSchema4; + uiSchema: UiSchema; + title: string; + formContext: any; + formData: any; + } + + export type ObjectFieldTemplateProps = { + DescriptionField: object; + TitleField: object; + title: string; + description: string; + properties: { + content: React.ReactElement, + name: string; + disabled: boolean; + readonly: boolean; + }[], + required: boolean; + schema: JSONSchema4; + uiSchema: UiSchema; + idSchema: IdSchema; + formData: any; + formContext: any; } export interface IChangeEvent { @@ -34,9 +173,7 @@ declare module "react-jsonschema-form" { formData: any; errors: any[]; errorSchema: any; - idSchema: any; + idSchema: IdSchema; status: string; } - - export default class Form extends React.Component { } } diff --git a/types/react-jsonschema-form/react-jsonschema-form-tests.tsx b/types/react-jsonschema-form/react-jsonschema-form-tests.tsx index c8d49a7628..2b4a7e0d67 100644 --- a/types/react-jsonschema-form/react-jsonschema-form-tests.tsx +++ b/types/react-jsonschema-form/react-jsonschema-form-tests.tsx @@ -1,10 +1,11 @@ import * as React from "react"; -import Form from "react-jsonschema-form"; +import Form, { UiSchema } from "react-jsonschema-form"; +import { JSONSchema4 } from "json-schema"; // example taken from the react-jsonschema-form playground: // https://github.com/mozilla-services/react-jsonschema-form/blob/fedd830294417969d88e38fb9f6b3a85e6ad105e/playground/samples/simple.js -const schema = { +const schema: JSONSchema4 = { "title": "A registration form", "type": "object", "required": [ @@ -36,7 +37,7 @@ const schema = { } }; -const uiSchema = { +const uiSchema: UiSchema = { age: { "ui:widget": "updown" }, From b5d0ee30ccfac95ba4f11af4ee6f106f1a2cce8e Mon Sep 17 00:00:00 2001 From: wwestrop Date: Wed, 13 Dec 2017 21:06:27 +0000 Subject: [PATCH 135/298] Better understanding of what dtslint is doing, refined test --- types/mocha/mocha-tests.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/types/mocha/mocha-tests.ts b/types/mocha/mocha-tests.ts index 490cacd325..865f880530 100644 --- a/types/mocha/mocha-tests.ts +++ b/types/mocha/mocha-tests.ts @@ -456,14 +456,8 @@ function test_throwError() { mocha.throwError(new Error("I'm an error!")); } - - - - - -// dtslint - -import * as Mocha from "mocha"; - -new Mocha().run(); // $ExpectType IRunner -new Mocha().run().on("", function() {}); // $ExpectType IRunner \ No newline at end of file +function test_runner_fluentParams() { + new MochaDef().run(); // $ExpectType IRunner + new MochaDef().run().on("event-string", function() {}); // $ExpectType IRunner + new MochaDef().run().on(Symbol("event-symbol"), function() {}); // $ExpectType IRunner +} From 26d1c8ee561f844b14df40102bf32dfb95856651 Mon Sep 17 00:00:00 2001 From: Jim Smart Date: Wed, 13 Dec 2017 21:09:46 +0000 Subject: [PATCH 136/298] Fix incorrect type Transform.rotation should be Quaternion --- types/math3d/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/math3d/index.d.ts b/types/math3d/index.d.ts index 626aed9df6..6851ebe4ce 100644 --- a/types/math3d/index.d.ts +++ b/types/math3d/index.d.ts @@ -148,7 +148,7 @@ export class Transform { position: Vector3; right: Vector3; root: Transform; - rotation: Vector3; + rotation: Quaternion; up: Vector3; worldToLocalMatrix: Matrix4x4; From ee3025252a32bba2a0c09872b70b414368810d99 Mon Sep 17 00:00:00 2001 From: Jim Smart Date: Wed, 13 Dec 2017 21:18:14 +0000 Subject: [PATCH 137/298] Added my details to 'Definitions by' section --- types/math3d/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/math3d/index.d.ts b/types/math3d/index.d.ts index 6851ebe4ce..d7df15850c 100644 --- a/types/math3d/index.d.ts +++ b/types/math3d/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for math3d 0.2 // Project: https://github.com/adragonite/math3d // Definitions by: Laszlo Jakab +// Jim Smart // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export class Vector3 { From 78828b3fb7c864a3491671a21521f991ffaf120f Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Wed, 13 Dec 2017 22:35:49 +0300 Subject: [PATCH 138/298] [atom] update watchPath tests --- types/atom/atom-tests.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/atom/atom-tests.ts b/types/atom/atom-tests.ts index 6ea7b9ae1f..1f5361ce17 100644 --- a/types/atom/atom-tests.ts +++ b/types/atom/atom-tests.ts @@ -1587,7 +1587,8 @@ function testPanel() { } // PathWatcher ================================================================ -function testPathWatcher() { +async function testPathWatcher() { + const pathWatcher = await pathWatcherPromise; pathWatcher.dispose(); subscription = pathWatcher.onDidError((error) => str = error.name); @@ -3213,7 +3214,7 @@ function testWorkspaceCenter() { } // watchPath ================================================================== -const pathWatcher = Atom.watchPath("/var/test", {}, (events) => { +const pathWatcherPromise = Atom.watchPath("/var/test", {}, (events) => { for (const event of events) { str = event.path; str = event.action; From d4901b49b68cf18f789983335d8d9239c1c6a5d1 Mon Sep 17 00:00:00 2001 From: Michael North Date: Wed, 13 Dec 2017 16:43:02 -0600 Subject: [PATCH 139/298] Types for ember-data 'module API' --- types/ember-data/adapter.d.ts | 2 + types/ember-data/adapters/errors.d.ts | 12 +++ types/ember-data/adapters/json-api.d.ts | 2 + types/ember-data/adapters/rest.d.ts | 2 + types/ember-data/attr.d.ts | 2 + types/ember-data/index.d.ts | 1 + types/ember-data/model.d.ts | 2 + types/ember-data/relationships.d.ts | 3 + types/ember-data/serializer.d.ts | 2 + .../serializers/embedded-records-mixin.d.ts | 2 + types/ember-data/serializers/json-api.d.ts | 2 + types/ember-data/serializers/json.d.ts | 2 + types/ember-data/serializers/rest.d.ts | 2 + types/ember-data/store.d.ts | 2 + types/ember-data/test/module-api.ts | 91 +++++++++++++++++++ types/ember-data/transform.d.ts | 2 + types/ember-data/transforms/boolean.d.ts | 2 + types/ember-data/transforms/date.d.ts | 2 + types/ember-data/transforms/number.d.ts | 2 + types/ember-data/transforms/string.d.ts | 2 + types/ember-data/transforms/transform.d.ts | 2 + types/ember-data/tsconfig.json | 21 +++++ 22 files changed, 162 insertions(+) create mode 100644 types/ember-data/adapter.d.ts create mode 100644 types/ember-data/adapters/errors.d.ts create mode 100644 types/ember-data/adapters/json-api.d.ts create mode 100644 types/ember-data/adapters/rest.d.ts create mode 100644 types/ember-data/attr.d.ts create mode 100644 types/ember-data/model.d.ts create mode 100644 types/ember-data/relationships.d.ts create mode 100644 types/ember-data/serializer.d.ts create mode 100644 types/ember-data/serializers/embedded-records-mixin.d.ts create mode 100644 types/ember-data/serializers/json-api.d.ts create mode 100644 types/ember-data/serializers/json.d.ts create mode 100644 types/ember-data/serializers/rest.d.ts create mode 100644 types/ember-data/store.d.ts create mode 100644 types/ember-data/test/module-api.ts create mode 100644 types/ember-data/transform.d.ts create mode 100644 types/ember-data/transforms/boolean.d.ts create mode 100644 types/ember-data/transforms/date.d.ts create mode 100644 types/ember-data/transforms/number.d.ts create mode 100644 types/ember-data/transforms/string.d.ts create mode 100644 types/ember-data/transforms/transform.d.ts diff --git a/types/ember-data/adapter.d.ts b/types/ember-data/adapter.d.ts new file mode 100644 index 0000000000..4adc29b0ed --- /dev/null +++ b/types/ember-data/adapter.d.ts @@ -0,0 +1,2 @@ +import DS from './index'; +export default DS.Adapter; diff --git a/types/ember-data/adapters/errors.d.ts b/types/ember-data/adapters/errors.d.ts new file mode 100644 index 0000000000..917d71b713 --- /dev/null +++ b/types/ember-data/adapters/errors.d.ts @@ -0,0 +1,12 @@ +import DS from '../index'; +export const AdapterError: typeof DS.AdapterError; +export const InvalidError: typeof DS.InvalidError; +export const UnauthorizedError: typeof DS.UnauthorizedError; +export const ForbiddenError: typeof DS.ForbiddenError; +export const NotFoundError: typeof DS.NotFoundError; +export const ConflictError: typeof DS.ConflictError; +export const ServerError: typeof DS.ServerError; +export const TimeoutError: typeof DS.TimeoutError; +export const AbortError: typeof DS.AbortError; +export const errorsHashToArray: typeof DS.errorsHashToArray; +export const errorsArrayToHash: typeof DS.errorsArrayToHash; diff --git a/types/ember-data/adapters/json-api.d.ts b/types/ember-data/adapters/json-api.d.ts new file mode 100644 index 0000000000..300da124fd --- /dev/null +++ b/types/ember-data/adapters/json-api.d.ts @@ -0,0 +1,2 @@ +import DS from '../index'; +export default DS.JSONAPIAdapter; diff --git a/types/ember-data/adapters/rest.d.ts b/types/ember-data/adapters/rest.d.ts new file mode 100644 index 0000000000..b6c48bf751 --- /dev/null +++ b/types/ember-data/adapters/rest.d.ts @@ -0,0 +1,2 @@ +import DS from '../index'; +export default DS.RESTAdapter; diff --git a/types/ember-data/attr.d.ts b/types/ember-data/attr.d.ts new file mode 100644 index 0000000000..609a842541 --- /dev/null +++ b/types/ember-data/attr.d.ts @@ -0,0 +1,2 @@ +import DS from './index'; +export default DS.attr; diff --git a/types/ember-data/index.d.ts b/types/ember-data/index.d.ts index 0e0678e7d7..9f274dcb4f 100644 --- a/types/ember-data/index.d.ts +++ b/types/ember-data/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for ember-data 2.14 // Project: https://github.com/emberjs/data // Definitions by: Derek Wickern +// Mike North // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 diff --git a/types/ember-data/model.d.ts b/types/ember-data/model.d.ts new file mode 100644 index 0000000000..ccb8a8f6b4 --- /dev/null +++ b/types/ember-data/model.d.ts @@ -0,0 +1,2 @@ +import DS from './index'; +export default DS.Model; diff --git a/types/ember-data/relationships.d.ts b/types/ember-data/relationships.d.ts new file mode 100644 index 0000000000..2a789a206a --- /dev/null +++ b/types/ember-data/relationships.d.ts @@ -0,0 +1,3 @@ +import DS from './index'; +export const hasMany: typeof DS.hasMany; +export const belongsTo: typeof DS.belongsTo; diff --git a/types/ember-data/serializer.d.ts b/types/ember-data/serializer.d.ts new file mode 100644 index 0000000000..2195771c81 --- /dev/null +++ b/types/ember-data/serializer.d.ts @@ -0,0 +1,2 @@ +import DS from './index'; +export default DS.Serializer; diff --git a/types/ember-data/serializers/embedded-records-mixin.d.ts b/types/ember-data/serializers/embedded-records-mixin.d.ts new file mode 100644 index 0000000000..6223a4e143 --- /dev/null +++ b/types/ember-data/serializers/embedded-records-mixin.d.ts @@ -0,0 +1,2 @@ +import DS from '../index'; +export default DS.EmbeddedRecordsMixin; diff --git a/types/ember-data/serializers/json-api.d.ts b/types/ember-data/serializers/json-api.d.ts new file mode 100644 index 0000000000..0260008eca --- /dev/null +++ b/types/ember-data/serializers/json-api.d.ts @@ -0,0 +1,2 @@ +import DS from '../index'; +export default DS.JSONAPISerializer; diff --git a/types/ember-data/serializers/json.d.ts b/types/ember-data/serializers/json.d.ts new file mode 100644 index 0000000000..d19c16b9df --- /dev/null +++ b/types/ember-data/serializers/json.d.ts @@ -0,0 +1,2 @@ +import DS from '../index'; +export default DS.JSONSerializer; diff --git a/types/ember-data/serializers/rest.d.ts b/types/ember-data/serializers/rest.d.ts new file mode 100644 index 0000000000..8cbbe82467 --- /dev/null +++ b/types/ember-data/serializers/rest.d.ts @@ -0,0 +1,2 @@ +import DS from '../index'; +export default DS.RESTSerializer; diff --git a/types/ember-data/store.d.ts b/types/ember-data/store.d.ts new file mode 100644 index 0000000000..948f477e7c --- /dev/null +++ b/types/ember-data/store.d.ts @@ -0,0 +1,2 @@ +import DS from './index'; +export default DS.Store; diff --git a/types/ember-data/test/module-api.ts b/types/ember-data/test/module-api.ts new file mode 100644 index 0000000000..3ef3f3a224 --- /dev/null +++ b/types/ember-data/test/module-api.ts @@ -0,0 +1,91 @@ +/** + * Tests for the Ember-Data "module API" introduced in v2.3 + * @see https://www.emberjs.com/blog/2016/01/12/ember-data-2-3-released.html#toc_importing-modules + */ +import DS from 'ember-data'; +// Adapters +import Adapter from 'ember-data/adapter'; +import JSONAPIAdapter from 'ember-data/adapters/json-api'; +import RESTAdapter from 'ember-data/adapters/rest'; +// Serializers +import Serializer from 'ember-data/serializer'; +import RESTSerializer from 'ember-data/serializers/rest'; +import JSONSerializer from 'ember-data/serializers/json'; +import JSONAPISerializer from 'ember-data/serializers/json-api'; + +// Model +import Model from 'ember-data/model'; +// Model - attr +import attr from 'ember-data/attr'; +// Model - relationships +import { hasMany, belongsTo } from 'ember-data/relationships'; + +// Transforms +import BooleanTransform from 'ember-data/transforms/boolean'; +import StringTransform from 'ember-data/transforms/string'; +import NumberTransform from 'ember-data/transforms/number'; +import DateTransform from 'ember-data/transforms/date'; +import Transform from 'ember-data/transforms/transform'; + +// Store +import Store from 'ember-data/store'; + +// Errors +import * as EDErrors from 'ember-data/adapters/errors'; + +import { assertType } from "./lib/assert"; + +// ADAPTERS +// - identity +assertType(Adapter); +assertType(RESTAdapter); +assertType(JSONAPIAdapter); +// - inheritance +assertType(RESTAdapter); +assertType(JSONAPIAdapter); + +// SERIALIZERS +// - identity +assertType(Serializer); +assertType(RESTSerializer); +assertType(JSONSerializer); +assertType(JSONAPISerializer); +// - inheritance +assertType(JSONSerializer); +assertType(RESTSerializer); +assertType(JSONAPISerializer); + +// MODEL +// - identity +assertType(Model); +// - attributes +assertType(attr); +// - relationships +assertType(hasMany); +assertType(belongsTo); + +// TRANSFORMS +// - identity +assertType(BooleanTransform); +assertType(NumberTransform); +assertType(StringTransform); +assertType(DateTransform); +assertType(Transform); + +// STORE +// - identity +assertType(Store); + +// ERRORS +// - identity +assertType(EDErrors.AdapterError); +assertType(EDErrors.InvalidError); +assertType(EDErrors.UnauthorizedError); +assertType(EDErrors.ForbiddenError); +assertType(EDErrors.NotFoundError); +assertType(EDErrors.ConflictError); +assertType(EDErrors.ServerError); +assertType(EDErrors.TimeoutError); +assertType(EDErrors.AbortError); +assertType(EDErrors.errorsHashToArray); +assertType(EDErrors.errorsArrayToHash); diff --git a/types/ember-data/transform.d.ts b/types/ember-data/transform.d.ts new file mode 100644 index 0000000000..0dc2e2cd88 --- /dev/null +++ b/types/ember-data/transform.d.ts @@ -0,0 +1,2 @@ +import DS from './index'; +export default DS.Transform; diff --git a/types/ember-data/transforms/boolean.d.ts b/types/ember-data/transforms/boolean.d.ts new file mode 100644 index 0000000000..aae3eb4872 --- /dev/null +++ b/types/ember-data/transforms/boolean.d.ts @@ -0,0 +1,2 @@ +import DS from '../index'; +export default DS.BooleanTransform; diff --git a/types/ember-data/transforms/date.d.ts b/types/ember-data/transforms/date.d.ts new file mode 100644 index 0000000000..fb56f582df --- /dev/null +++ b/types/ember-data/transforms/date.d.ts @@ -0,0 +1,2 @@ +import DS from '../index'; +export default DS.DateTransform; diff --git a/types/ember-data/transforms/number.d.ts b/types/ember-data/transforms/number.d.ts new file mode 100644 index 0000000000..331a42fe22 --- /dev/null +++ b/types/ember-data/transforms/number.d.ts @@ -0,0 +1,2 @@ +import DS from '../index'; +export default DS.NumberTransform; diff --git a/types/ember-data/transforms/string.d.ts b/types/ember-data/transforms/string.d.ts new file mode 100644 index 0000000000..5f8756f2cf --- /dev/null +++ b/types/ember-data/transforms/string.d.ts @@ -0,0 +1,2 @@ +import DS from '../index'; +export default DS.StringTransform; diff --git a/types/ember-data/transforms/transform.d.ts b/types/ember-data/transforms/transform.d.ts new file mode 100644 index 0000000000..a980eb6940 --- /dev/null +++ b/types/ember-data/transforms/transform.d.ts @@ -0,0 +1,2 @@ +import DS from '../index'; +export default DS.Transform; diff --git a/types/ember-data/tsconfig.json b/types/ember-data/tsconfig.json index 155515ac6b..3eaaeb0509 100644 --- a/types/ember-data/tsconfig.json +++ b/types/ember-data/tsconfig.json @@ -15,10 +15,31 @@ "noEmit": true, "forceConsistentCasingInFileNames": true }, + "files": [ + "adapters/errors.d.ts", + "adapters/json-api.d.ts", + "adapters/rest.d.ts", + "serializers/embedded-records-mixin.d.ts", + "serializers/json-api.d.ts", + "serializers/json.d.ts", + "serializers/rest.d.ts", + "transforms/boolean.d.ts", + "transforms/date.d.ts", + "transforms/number.d.ts", + "transforms/string.d.ts", + "transforms/transform.d.ts", + "adapter.d.ts", + "attr.d.ts", "index.d.ts", + "model.d.ts", + "relationships.d.ts", + "serializer.d.ts", + "store.d.ts", + "transform.d.ts", "test/lib/assert.ts", "test/model.ts", + "test/module-api.ts", "test/adapter.ts", "test/serializer.ts", "test/transform.ts", From 55bb06ba72622c91f7434a5593c94830974ccb1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20R=C3=A4ntil=C3=A4?= Date: Thu, 14 Dec 2017 01:14:14 +0100 Subject: [PATCH 140/298] [iltorb] Added .flush() to compress stream --- types/iltorb/iltorb-tests.ts | 5 ++++- types/iltorb/index.d.ts | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/types/iltorb/iltorb-tests.ts b/types/iltorb/iltorb-tests.ts index 5c30fcd3b5..66bda251d4 100644 --- a/types/iltorb/iltorb-tests.ts +++ b/types/iltorb/iltorb-tests.ts @@ -20,8 +20,11 @@ br.compress(Buffer.from('foo', 'utf8'), onCompress); br.compress(Buffer.from('foo', 'utf8'), opts, onCompress); +const stream = br.compressStream(); +stream.flush(); + createReadStream(__filename) - .pipe(br.compressStream()) + .pipe(stream) .pipe(createWriteStream('foo.ts')); createReadStream(__dirname) diff --git a/types/iltorb/index.d.ts b/types/iltorb/index.d.ts index bd6cd88fb7..5ac707a51b 100644 --- a/types/iltorb/index.d.ts +++ b/types/iltorb/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/MayhemYDG/iltorb // Definitions by: Arturas Molcanovas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// @@ -16,6 +17,10 @@ export interface BrotliEncodeParams { size_hint?: number; } +export interface BrotliFlushable { + flush(): void; +} + export type IltorbCallback = (err: Error | null | undefined, output: Buffer) => void; export function compress(buffer: Buffer, options: BrotliEncodeParams, callback: IltorbCallback): void; @@ -26,5 +31,5 @@ export function decompress(buffer: Buffer, callback: IltorbCallback): void; export function compressSync(buffer: Buffer, options?: BrotliEncodeParams): Buffer; export function decompressSync(buffer: Buffer): Buffer; -export function compressStream(options?: BrotliEncodeParams): Transform; +export function compressStream(options?: BrotliEncodeParams): Transform & BrotliFlushable; export function decompressStream(): Transform; From 5941fd6259bd3f57b8f80fa1d681ca891e92f093 Mon Sep 17 00:00:00 2001 From: Michael North Date: Wed, 13 Dec 2017 18:31:33 -0600 Subject: [PATCH 141/298] Disable linting rules to move submodule declarations into index.d.ts --- types/ember-data/adapter.d.ts | 2 - types/ember-data/adapters/errors.d.ts | 12 - types/ember-data/adapters/json-api.d.ts | 2 - types/ember-data/adapters/rest.d.ts | 2 - types/ember-data/attr.d.ts | 2 - types/ember-data/index.d.ts | 3802 +++++++++-------- types/ember-data/model.d.ts | 2 - types/ember-data/relationships.d.ts | 3 - types/ember-data/serializer.d.ts | 2 - .../serializers/embedded-records-mixin.d.ts | 2 - types/ember-data/serializers/json-api.d.ts | 2 - types/ember-data/serializers/json.d.ts | 2 - types/ember-data/serializers/rest.d.ts | 2 - types/ember-data/store.d.ts | 2 - types/ember-data/transform.d.ts | 2 - types/ember-data/transforms/boolean.d.ts | 2 - types/ember-data/transforms/date.d.ts | 2 - types/ember-data/transforms/number.d.ts | 2 - types/ember-data/transforms/string.d.ts | 2 - types/ember-data/transforms/transform.d.ts | 2 - types/ember-data/tsconfig.json | 20 - types/ember-data/tslint.json | 4 +- 22 files changed, 2135 insertions(+), 1740 deletions(-) delete mode 100644 types/ember-data/adapter.d.ts delete mode 100644 types/ember-data/adapters/errors.d.ts delete mode 100644 types/ember-data/adapters/json-api.d.ts delete mode 100644 types/ember-data/adapters/rest.d.ts delete mode 100644 types/ember-data/attr.d.ts delete mode 100644 types/ember-data/model.d.ts delete mode 100644 types/ember-data/relationships.d.ts delete mode 100644 types/ember-data/serializer.d.ts delete mode 100644 types/ember-data/serializers/embedded-records-mixin.d.ts delete mode 100644 types/ember-data/serializers/json-api.d.ts delete mode 100644 types/ember-data/serializers/json.d.ts delete mode 100644 types/ember-data/serializers/rest.d.ts delete mode 100644 types/ember-data/store.d.ts delete mode 100644 types/ember-data/transform.d.ts delete mode 100644 types/ember-data/transforms/boolean.d.ts delete mode 100644 types/ember-data/transforms/date.d.ts delete mode 100644 types/ember-data/transforms/number.d.ts delete mode 100644 types/ember-data/transforms/string.d.ts delete mode 100644 types/ember-data/transforms/transform.d.ts diff --git a/types/ember-data/adapter.d.ts b/types/ember-data/adapter.d.ts deleted file mode 100644 index 4adc29b0ed..0000000000 --- a/types/ember-data/adapter.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from './index'; -export default DS.Adapter; diff --git a/types/ember-data/adapters/errors.d.ts b/types/ember-data/adapters/errors.d.ts deleted file mode 100644 index 917d71b713..0000000000 --- a/types/ember-data/adapters/errors.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import DS from '../index'; -export const AdapterError: typeof DS.AdapterError; -export const InvalidError: typeof DS.InvalidError; -export const UnauthorizedError: typeof DS.UnauthorizedError; -export const ForbiddenError: typeof DS.ForbiddenError; -export const NotFoundError: typeof DS.NotFoundError; -export const ConflictError: typeof DS.ConflictError; -export const ServerError: typeof DS.ServerError; -export const TimeoutError: typeof DS.TimeoutError; -export const AbortError: typeof DS.AbortError; -export const errorsHashToArray: typeof DS.errorsHashToArray; -export const errorsArrayToHash: typeof DS.errorsArrayToHash; diff --git a/types/ember-data/adapters/json-api.d.ts b/types/ember-data/adapters/json-api.d.ts deleted file mode 100644 index 300da124fd..0000000000 --- a/types/ember-data/adapters/json-api.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from '../index'; -export default DS.JSONAPIAdapter; diff --git a/types/ember-data/adapters/rest.d.ts b/types/ember-data/adapters/rest.d.ts deleted file mode 100644 index b6c48bf751..0000000000 --- a/types/ember-data/adapters/rest.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from '../index'; -export default DS.RESTAdapter; diff --git a/types/ember-data/attr.d.ts b/types/ember-data/attr.d.ts deleted file mode 100644 index 609a842541..0000000000 --- a/types/ember-data/attr.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from './index'; -export default DS.attr; diff --git a/types/ember-data/index.d.ts b/types/ember-data/index.d.ts index 9f274dcb4f..c8cfd8187e 100644 --- a/types/ember-data/index.d.ts +++ b/types/ember-data/index.d.ts @@ -5,1682 +5,2057 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 -import Ember from 'ember'; +declare module "ember-data" { + import Ember from "ember"; + namespace DS { + /** + * Convert an hash of errors into an array with errors in JSON-API format. + */ + function errorsHashToArray(errors: {}): any[]; + /** + * Convert an array of errors in JSON-API format into an object. + */ + function errorsArrayToHash(errors: any[]): {}; + /** + * `DS.belongsTo` is used to define One-To-One and One-To-Many + * relationships on a [DS.Model](/api/data/classes/DS.Model.html). + */ + function belongsTo( + modelName: string, + options: { + async: false; + inverse?: string | null; + polymorphic?: boolean; + } + ): Ember.ComputedProperty; + function belongsTo( + modelName: string, + options?: { + async?: true; + inverse?: string | null; + polymorphic?: boolean; + } + ): Ember.ComputedProperty>; + /** + * `DS.hasMany` is used to define One-To-Many and Many-To-Many + * relationships on a [DS.Model](/api/data/classes/DS.Model.html). + */ + function hasMany( + type: string, + options: { + async: false; + inverse?: string | null; + polymorphic?: boolean; + } + ): Ember.ComputedProperty>; + function hasMany( + type: string, + options?: { + async?: true; + inverse?: string | null; + polymorphic?: boolean; + } + ): Ember.ComputedProperty>; + /** + * This method normalizes a modelName into the format Ember Data uses + * internally. + */ + function normalizeModelName(modelName: string): string; + const VERSION: string; -declare namespace DS { - /** - * Convert an hash of errors into an array with errors in JSON-API format. - */ - function errorsHashToArray(errors: {}): any[]; - /** - * Convert an array of errors in JSON-API format into an object. - */ - function errorsArrayToHash(errors: any[]): {}; - /** - * `DS.belongsTo` is used to define One-To-One and One-To-Many - * relationships on a [DS.Model](/api/data/classes/DS.Model.html). - */ - function belongsTo(modelName: string, options: { - async: false, - inverse?: string | null, - polymorphic?: boolean - }): Ember.ComputedProperty; - function belongsTo(modelName: string, options?: { - async?: true, - inverse?: string | null, - polymorphic?: boolean - }): Ember.ComputedProperty>; - /** - * `DS.hasMany` is used to define One-To-Many and Many-To-Many - * relationships on a [DS.Model](/api/data/classes/DS.Model.html). - */ - function hasMany(type: string, options: { - async: false, - inverse?: string | null, - polymorphic?: boolean - }): Ember.ComputedProperty>; - function hasMany(type: string, options?: { - async?: true, - inverse?: string | null, - polymorphic?: boolean - }): Ember.ComputedProperty>; - /** - * This method normalizes a modelName into the format Ember Data uses - * internally. - */ - function normalizeModelName(modelName: string): string; - const VERSION: string; + interface AttrOptions { + defaultValue?: T | (() => T); + } - interface AttrOptions { - defaultValue?: T | (() => T); - } - - /** - * `DS.attr` defines an attribute on a [DS.Model](/api/data/classes/DS.Model.html). - * By default, attributes are passed through as-is, however you can specify an - * optional type to have the value automatically transformed. - * Ember Data ships with four basic transform types: `string`, `number`, - * `boolean` and `date`. You can define your own transforms by subclassing - * [DS.Transform](/api/data/classes/DS.Transform.html). - */ - function attr(type: 'string', options?: AttrOptions): Ember.ComputedProperty; - function attr(type: 'boolean', options?: AttrOptions): Ember.ComputedProperty; - function attr(type: 'number', options?: AttrOptions): Ember.ComputedProperty; - function attr(type: 'date', options?: AttrOptions): Ember.ComputedProperty; - function attr(type: string, options?: AttrOptions): Ember.ComputedProperty; - function attr(options?: AttrOptions): Ember.ComputedProperty; - /** - * WARNING: This interface is likely to change in order to accomodate https://github.com/emberjs/rfcs/pull/4 - * ## Using BuildURLMixin - * To use url building, include the mixin when extending an adapter, and call `buildURL` where needed. - * The default behaviour is designed for RESTAdapter. - * ### Example - * ```javascript - * export default DS.Adapter.extend(BuildURLMixin, { - * findRecord: function(store, type, id, snapshot) { - * var url = this.buildURL(type.modelName, id, snapshot, 'findRecord'); - * return this.ajax(url, 'GET'); - * } - * }); - * ``` - * ### Attributes - * The `host` and `namespace` attributes will be used if defined, and are optional. - */ - class BuildURLMixin { - /** - * Builds a URL for a given type and optional ID. - */ - buildURL(modelName: string, id: string|any[]|{}, snapshot: Snapshot|any[], requestType: string, query: {}): string; - /** - * Builds a URL for a `store.findRecord(type, id)` call. - */ - urlForFindRecord(id: string, modelName: string, snapshot: Snapshot): string; - /** - * Builds a URL for a `store.findAll(type)` call. - */ - urlForFindAll(modelName: string, snapshot: SnapshotRecordArray): string; - /** - * Builds a URL for a `store.query(type, query)` call. - */ - urlForQuery(query: {}, modelName: string): string; - /** - * Builds a URL for a `store.queryRecord(type, query)` call. - */ - urlForQueryRecord(query: {}, modelName: string): string; - /** - * Builds a URL for coalesceing multiple `store.findRecord(type, id)` - * records into 1 request when the adapter's `coalesceFindRequests` - * property is true. - */ - urlForFindMany(ids: any[], modelName: string, snapshots: any[]): string; - /** - * Builds a URL for fetching a async hasMany relationship when a url - * is not provided by the server. - */ - urlForFindHasMany(id: string, modelName: string, snapshot: Snapshot): string; - /** - * Builds a URL for fetching a async belongsTo relationship when a url - * is not provided by the server. - */ - urlForFindBelongsTo(id: string, modelName: string, snapshot: Snapshot): string; - /** - * Builds a URL for a `record.save()` call when the record was created - * locally using `store.createRecord()`. - */ - urlForCreateRecord(modelName: string, snapshot: Snapshot): string; - /** - * Builds a URL for a `record.save()` call when the record has been update locally. - */ - urlForUpdateRecord(id: string, modelName: string, snapshot: Snapshot): string; - /** - * Builds a URL for a `record.save()` call when the record has been deleted locally. - */ - urlForDeleteRecord(id: string, modelName: string, snapshot: Snapshot): string; - /** - * Determines the pathname for a given type. - */ - pathForType(modelName: string): string; - } - /** - * A `DS.AdapterError` is used by an adapter to signal that an error occurred - * during a request to an external API. It indicates a generic error, and - * subclasses are used to indicate specific error states. The following - * subclasses are provided: - */ - class AdapterError { - } - /** - * A `DS.InvalidError` is used by an adapter to signal the external API - * was unable to process a request because the content was not - * semantically correct or meaningful per the API. Usually this means a - * record failed some form of server side validation. When a promise - * from an adapter is rejected with a `DS.InvalidError` the record will - * transition to the `invalid` state and the errors will be set to the - * `errors` property on the record. - */ - class InvalidError { - } - /** - * A `DS.TimeoutError` is used by an adapter to signal that a request - * to the external API has timed out. I.e. no response was received from - * the external API within an allowed time period. - */ - class TimeoutError { - } - /** - * A `DS.AbortError` is used by an adapter to signal that a request to - * the external API was aborted. For example, this can occur if the user - * navigates away from the current page after a request to the external API - * has been initiated but before a response has been received. - */ - class AbortError { - } - /** - * A `DS.UnauthorizedError` equates to a HTTP `401 Unauthorized` response - * status. It is used by an adapter to signal that a request to the external - * API was rejected because authorization is required and has failed or has not - * yet been provided. - */ - class UnauthorizedError { - } - /** - * A `DS.ForbiddenError` equates to a HTTP `403 Forbidden` response status. - * It is used by an adapter to signal that a request to the external API was - * valid but the server is refusing to respond to it. If authorization was - * provided and is valid, then the authenticated user does not have the - * necessary permissions for the request. - */ - class ForbiddenError { - } - /** - * A `DS.NotFoundError` equates to a HTTP `404 Not Found` response status. - * It is used by an adapter to signal that a request to the external API - * was rejected because the resource could not be found on the API. - */ - class NotFoundError { - } - /** - * A `DS.ConflictError` equates to a HTTP `409 Conflict` response status. - * It is used by an adapter to indicate that the request could not be processed - * because of a conflict in the request. An example scenario would be when - * creating a record with a client generated id but that id is already known - * to the external API. - */ - class ConflictError { - } - /** - * A `DS.ServerError` equates to a HTTP `500 Internal Server Error` response - * status. It is used by the adapter to indicate that a request has failed - * because of an error in the external API. - */ - class ServerError { - } - /** - * Holds validation errors for a given record, organized by attribute names. - */ - interface Errors extends Ember.Enumerable, Ember.Evented {} - class Errors extends Ember.Object { - /** - * DEPRECATED: - * Register with target handler - */ - registerHandlers(target: {}, becameInvalid: Function, becameValid: Function): any; - /** - * Returns errors for a given attribute - */ - errorsFor(attribute: string): any[]; - /** - * An array containing all of the error messages for this - * record. This is useful for displaying all errors to the user. - */ - messages: Ember.ComputedProperty; - /** - * Total number of errors. - */ - length: Ember.ComputedProperty; - isEmpty: Ember.ComputedProperty; - /** - * DEPRECATED: - * Adds error messages to a given attribute and sends - * `becameInvalid` event to the record. - */ - add(attribute: string, messages: any[]|string): any; - /** - * DEPRECATED: - * Removes all error messages from the given attribute and sends - * `becameValid` event to the record if there no more errors left. - */ - remove(attribute: string): any; - /** - * DEPRECATED: - * Removes all error messages and sends `becameValid` event - * to the record. - */ - clear(): any; - /** - * Checks if there is error messages for the given attribute. - */ - has(attribute: string): boolean; - } - /** - * The model class that all Ember Data records descend from. - * This is the public API of Ember Data models. If you are using Ember Data - * in your application, this is the class you should use. - * If you are working on Ember Data internals, you most likely want to be dealing - * with `InternalModel` - */ - class Model extends Ember.Object { - /** - * If this property is `true` the record is in the `empty` - * state. Empty is the first state all records enter after they have - * been created. Most records created by the store will quickly - * transition to the `loading` state if data needs to be fetched from - * the server or the `created` state if the record is created on the - * client. A record can also enter the empty state if the adapter is - * unable to locate the record. - */ - isEmpty: Ember.ComputedProperty; - /** - * If this property is `true` the record is in the `loading` state. A - * record enters this state when the store asks the adapter for its - * data. It remains in this state until the adapter provides the - * requested data. - */ - isLoading: Ember.ComputedProperty; - /** - * If this property is `true` the record is in the `loaded` state. A - * record enters this state when its data is populated. Most of a - * record's lifecycle is spent inside substates of the `loaded` - * state. - */ - isLoaded: Ember.ComputedProperty; - /** - * If this property is `true` the record is in the `dirty` state. The - * record has local changes that have not yet been saved by the - * adapter. This includes records that have been created (but not yet - * saved) or deleted. - */ - hasDirtyAttributes: Ember.ComputedProperty; - /** - * If this property is `true` the record is in the `saving` state. A - * record enters the saving state when `save` is called, but the - * adapter has not yet acknowledged that the changes have been - * persisted to the backend. - */ - isSaving: Ember.ComputedProperty; - /** - * If this property is `true` the record is in the `deleted` state - * and has been marked for deletion. When `isDeleted` is true and - * `hasDirtyAttributes` is true, the record is deleted locally but the deletion - * was not yet persisted. When `isSaving` is true, the change is - * in-flight. When both `hasDirtyAttributes` and `isSaving` are false, the - * change has persisted. - */ - isDeleted: Ember.ComputedProperty; - /** - * If this property is `true` the record is in the `new` state. A - * record will be in the `new` state when it has been created on the - * client and the adapter has not yet report that it was successfully - * saved. - */ - isNew: Ember.ComputedProperty; - /** - * If this property is `true` the record is in the `valid` state. - */ - isValid: Ember.ComputedProperty; - /** - * If the record is in the dirty state this property will report what - * kind of change has caused it to move into the dirty - * state. Possible values are: - */ - dirtyType: Ember.ComputedProperty; - /** - * If `true` the adapter reported that it was unable to save local - * changes to the backend for any reason other than a server-side - * validation error. - */ - isError: boolean; - /** - * If `true` the store is attempting to reload the record from the adapter. - */ - isReloading: boolean; - /** - * All ember models have an id property. This is an identifier - * managed by an external source. These are always coerced to be - * strings before being used internally. Note when declaring the - * attributes for a model it is an error to declare an id - * attribute. - */ - id: string; - /** - * When the record is in the `invalid` state this object will contain - * any errors returned by the adapter. When present the errors hash - * contains keys corresponding to the invalid property names - * and values which are arrays of Javascript objects with two keys: - */ - errors: Ember.ComputedProperty; - /** - * This property holds the `DS.AdapterError` object with which - * last adapter operation was rejected. - */ - adapterError: AdapterError; - /** - * Create a JSON representation of the record, using the serialization - * strategy of the store's adapter. - */ - serialize(options: {}): {}; - /** - * Use [DS.JSONSerializer](DS.JSONSerializer.html) to - * get the JSON representation of a record. - */ - toJSON(options: {}): {}; - /** - * Fired when the record is ready to be interacted with, - * that is either loaded from the server or created locally. - */ - ready(): void; - /** - * Fired when the record is loaded from the server. - */ - didLoad(): void; - /** - * Fired when the record is updated. - */ - didUpdate(): void; - /** - * Fired when a new record is commited to the server. - */ - didCreate(): void; - /** - * Fired when the record is deleted. - */ - didDelete(): void; - /** - * Fired when the record becomes invalid. - */ - becameInvalid(): void; - /** - * Fired when the record enters the error state. - */ - becameError(): void; - /** - * Fired when the record is rolled back. - */ - rolledBack(): void; - /** - * Marks the record as deleted but does not save it. You must call - * `save` afterwards if you want to persist it. You might use this - * method if you want to allow the user to still `rollbackAttributes()` - * after a delete was made. - */ - deleteRecord(): any; - /** - * Same as `deleteRecord`, but saves the record immediately. - */ - destroyRecord(options: {}): Promise; - /** - * Unloads the record from the store. This will cause the record to be destroyed and freed up for garbage collection. - */ - unloadRecord(): any; - /** - * Returns an object, whose keys are changed properties, and value is - * an [oldProp, newProp] array. - */ - changedAttributes(): {}; - /** - * If the model `hasDirtyAttributes` this function will discard any unsaved - * changes. If the model `isNew` it will be removed from the store. - */ - rollbackAttributes(): any; - /** - * Save the record and persist any changes to the record to an - * external source via the adapter. - */ - save(options?: {}): Promise; - /** - * Reload the record from the adapter. - */ - reload(): Promise; - /** - * Get the reference for the specified belongsTo relationship. - */ - belongsTo(name: string): BelongsToReference; - /** - * Get the reference for the specified hasMany relationship. - */ - hasMany(name: string): HasManyReference; - /** - * Given a callback, iterates over each of the relationships in the model, - * invoking the callback with the name of each relationship and its relationship - * descriptor. - */ - eachRelationship(callback: Function, binding: any): any; - /** - * Represents the model's class name as a string. This can be used to look up the model's class name through - * `DS.Store`'s modelFor method. - */ - static modelName: string; - /** - * For a given relationship name, returns the model type of the relationship. - */ - static typeForRelationship(name: string, store: Store): Model; - /** - * Find the relationship which is the inverse of the one asked for. - */ - static inverseFor(name: string, store: Store): {}; - /** - * The model's relationships as a map, keyed on the type of the - * relationship. The value of each entry is an array containing a descriptor - * for each relationship with that type, describing the name of the relationship - * as well as the type. - */ - static relationships: Ember.ComputedProperty; - /** - * A hash containing lists of the model's relationships, grouped - * by the relationship kind. For example, given a model with this - * definition: - */ - static relationshipNames: Ember.ComputedProperty<{}>; - /** - * An array of types directly related to a model. Each type will be - * included once, regardless of the number of relationships it has with - * the model. - */ - static relatedTypes: Ember.ComputedProperty>; - /** - * A map whose keys are the relationships of a model and whose values are - * relationship descriptors. - */ - static relationshipsByName: Ember.ComputedProperty; - /** - * A map whose keys are the fields of the model and whose values are strings - * describing the kind of the field. A model's fields are the union of all of its - * attributes and relationships. - */ - static fields: Ember.ComputedProperty; - /** - * Given a callback, iterates over each of the relationships in the model, - * invoking the callback with the name of each relationship and its relationship - * descriptor. - */ - static eachRelationship(callback: Function, binding: any): any; - /** - * Given a callback, iterates over each of the types related to a model, - * invoking the callback with the related type's class. Each type will be - * returned just once, regardless of how many different relationships it has - * with a model. - */ - static eachRelatedType(callback: Function, binding: any): any; - /** - * A map whose keys are the attributes of the model (properties - * described by DS.attr) and whose values are the meta object for the - * property. - */ - static attributes: Ember.ComputedProperty; - /** - * A map whose keys are the attributes of the model (properties - * described by DS.attr) and whose values are type of transformation - * applied to each attribute. This map does not include any - * attributes that do not have an transformation type. - */ - static transformedAttributes: Ember.ComputedProperty; - /** - * Iterates through the attributes of the model, calling the passed function on each - * attribute. - */ - static eachAttribute(callback: Function, binding: {}): any; - /** - * Iterates through the transformedAttributes of the model, calling - * the passed function on each attribute. Note the callback will not be - * called for any attributes that do not have an transformation type. - */ - static eachTransformedAttribute(callback: Function, binding: {}): any; - /** - * Discards any unsaved changes to the given attribute. This feature is not enabled by default. You must enable `ds-rollback-attribute` and be running a canary build. - */ - rollbackAttribute(): any; - /** - * This Ember.js hook allows an object to be notified when a property - * is defined. - */ - didDefineProperty(proto: {}, key: string, value: Ember.ComputedProperty): any; - } - /** - * ### State - */ - class RootState { - } - /** - * Represents an ordered list of records whose order and membership is - * determined by the adapter. For example, a query sent to the adapter - * may trigger a search on the server, whose results would be loaded - * into an instance of the `AdapterPopulatedRecordArray`. - */ - class AdapterPopulatedRecordArray extends RecordArray { - } - /** - * Represents a list of records whose membership is determined by the - * store. As records are created, loaded, or modified, the store - * evaluates them to determine if they should be part of the record - * array. - */ - class FilteredRecordArray extends RecordArray { - /** - * The filterFunction is a function used to test records from the store to - * determine if they should be part of the record array. - */ - filterFunction(record: Model): boolean; - } - /** - * A record array is an array that contains records of a certain modelName. The record - * array materializes records as needed when they are retrieved for the first - * time. You should not create record arrays yourself. Instead, an instance of - * `DS.RecordArray` or its subclasses will be returned by your application's store - * in response to queries. - */ - interface RecordArray extends Ember.ArrayProxy, Ember.Evented {} - class RecordArray { - /** - * The flag to signal a `RecordArray` is finished loading data. - */ - isLoaded: boolean; - /** - * The flag to signal a `RecordArray` is currently loading data. - */ - isUpdating: boolean; - /** - * The modelClass represented by this record array. - */ - type: Ember.ComputedProperty; - /** - * Used to get the latest version of all of the records in this array - * from the adapter. - */ - update(): any; - /** - * Saves all of the records in the `RecordArray`. - */ - save(): PromiseArray; - } - /** - * A BelongsToReference is a low level API that allows users and - * addon author to perform meta-operations on a belongs-to - * relationship. - */ - class BelongsToReference { - /** - * This returns a string that represents how the reference will be - * looked up when it is loaded. If the relationship has a link it will - * use the "link" otherwise it defaults to "id". - */ - remoteType(): string; - /** - * The `id` of the record that this reference refers to. Together, the - * `type()` and `id()` methods form a composite key for the identity - * map. This can be used to access the id of an async relationship - * without triggering a fetch that would normally happen if you - * attempted to use `record.get('relationship.id')`. - */ - id(): string; - /** - * The link Ember Data will use to fetch or reload this belongs-to - * relationship. - */ - link(): string; - /** - * The meta data for the belongs-to relationship. - */ - meta(): {}; - /** - * `push` can be used to update the data in the relationship and Ember - * Data will treat the new data as the conanical value of this - * relationship on the backend. - */ - push(objectOrPromise: {}|Promise): Promise; - /** - * `value()` synchronously returns the current value of the belongs-to - * relationship. Unlike `record.get('relationshipName')`, calling - * `value()` on a reference does not trigger a fetch if the async - * relationship is not yet loaded. If the relationship is not loaded - * it will always return `null`. - */ - value(objectOrPromise: {}|Promise): Model; - /** - * Loads a record in a belongs to relationship if it is not already - * loaded. If the relationship is already loaded this method does not - * trigger a new load. - */ - load(): Promise; - /** - * Triggers a reload of the value in this relationship. If the - * remoteType is `"link"` Ember Data will use the relationship link to - * reload the relationship. Otherwise it will reload the record by its - * id. - */ - reload(): Promise; - } - /** - * A HasManyReference is a low level API that allows users and addon - * author to perform meta-operations on a has-many relationship. - */ - class HasManyReference { - /** - * This returns a string that represents how the reference will be - * looked up when it is loaded. If the relationship has a link it will - * use the "link" otherwise it defaults to "id". - */ - remoteType(): string; - /** - * The link Ember Data will use to fetch or reload this has-many - * relationship. - */ - link(): string; - /** - * `ids()` returns an array of the record ids in this relationship. - */ - ids(): any[]; - /** - * The meta data for the has-many relationship. - */ - meta(): {}; - /** - * `push` can be used to update the data in the relationship and Ember - * Data will treat the new data as the canonical value of this - * relationship on the backend. - */ - push(objectOrPromise: T[] | Promise): ManyArray; - /** - * `value()` synchronously returns the current value of the has-many - * relationship. Unlike `record.get('relationshipName')`, calling - * `value()` on a reference does not trigger a fetch if the async - * relationship is not yet loaded. If the relationship is not loaded - * it will always return `null`. - */ - value(): ManyArray; - /** - * Loads the relationship if it is not already loaded. If the - * relationship is already loaded this method does not trigger a new - * load. - */ - load(): Promise; - /** - * Reloads this has-many relationship. - */ - reload(): Promise; - } - /** - * An RecordReference is a low level API that allows users and - * addon author to perform meta-operations on a record. - */ - class RecordReference { - /** - * The `id` of the record that this reference refers to. - */ - id(): string; - /** - * How the reference will be looked up when it is loaded: Currently - * this always return `identity` to signifying that a record will be - * loaded by the `type` and `id`. - */ - remoteType(): string; - /** - * This API allows you to provide a reference with new data. The - * simplest usage of this API is similar to `store.push`: you provide a - * normalized hash of data and the object represented by the reference - * will update. - */ - push(payload: Promise|{}): PromiseObject & T; - /** - * If the entity referred to by the reference is already loaded, it is - * present as `reference.value`. Otherwise the value returned by this function - * is `null`. - */ - value(): T | null; - /** - * Triggers a fetch for the backing entity based on its `remoteType` - * (see `remoteType` definitions per reference type). - */ - load(): PromiseObject & T; - /** - * Reloads the record if it is already loaded. If the record is not - * loaded it will load the record via `store.findRecord` - */ - reload(): PromiseObject & T; - } - /** - * A `ManyArray` is a `MutableArray` that represents the contents of a has-many - * relationship. - */ - interface ManyArray extends Ember.MutableArray {} - class ManyArray extends Ember.Object.extend(Ember.MutableArray as {}, Ember.Evented) { - /** - * The loading state of this array - */ - isLoaded: boolean; - /** - * Metadata associated with the request for async hasMany relationships. - */ - meta: {}; - /** - * Reloads all of the records in the manyArray. If the manyArray - * holds a relationship that was originally fetched using a links url - * Ember Data will revisit the original links url to repopulate the - * relationship. - */ - reload(): PromiseArray; - /** - * Saves all of the records in the `ManyArray`. - */ - save(): PromiseArray; - /** - * Create a child record within the owner - */ - createRecord(inputProperties?: {}): T; - } - /** - * A `PromiseArray` is an object that acts like both an `Ember.Array` - * and a promise. When the promise is resolved the resulting value - * will be set to the `PromiseArray`'s `content` property. This makes - * it easy to create data bindings with the `PromiseArray` that will be - * updated when the promise resolves. - */ - interface PromiseArray extends Ember.ArrayProxy, Ember.PromiseProxyMixin> {} - class PromiseArray { - } - /** - * A `PromiseObject` is an object that acts like both an `Ember.Object` - * and a promise. When the promise is resolved, then the resulting value - * will be set to the `PromiseObject`'s `content` property. This makes - * it easy to create data bindings with the `PromiseObject` that will - * be updated when the promise resolves. - */ - interface PromiseObject extends Ember.ObjectProxy, Ember.PromiseProxyMixin> {} - class PromiseObject { - } - /** - * A PromiseManyArray is a PromiseArray that also proxies certain method calls - * to the underlying manyArray. - * Right now we proxy: - */ - class PromiseManyArray extends PromiseArray { - /** - * Reloads all of the records in the manyArray. If the manyArray - * holds a relationship that was originally fetched using a links url - * Ember Data will revisit the original links url to repopulate the - * relationship. - */ - reload(): PromiseManyArray; - /** - * Create a child record within the owner - */ - createRecord(inputProperties?: {}): T; - } - class SnapshotRecordArray { - /** - * Number of records in the array - */ - length: number; - /** - * Meta objects for the record array. - */ - meta: {}; - /** - * A hash of adapter options passed into the store method for this request. - */ - adapterOptions: {}; - /** - * The relationships to include for this request. - */ - include: string|any[]; - /** - * The type of the underlying records for the snapshots in the array, as a DS.Model - */ - type: Model; - /** - * Get snapshots of the underlying record array - */ - snapshots(): any[]; - } - class Snapshot { - /** - * The underlying record for this snapshot. Can be used to access methods and - * properties defined on the record. - */ - record: Model; - /** - * The id of the snapshot's underlying record - */ - id: string; - /** - * A hash of adapter options - */ - adapterOptions: {}; - /** - * The name of the type of the underlying record for this snapshot, as a string. - */ - modelName: string; - /** - * The type of the underlying record for this snapshot, as a DS.Model. - */ - type: Model; - /** - * Returns the value of an attribute. - */ - attr(keyName: string): {}; - /** - * Returns all attributes and their corresponding values. - */ - attributes(): {}; - /** - * Returns all changed attributes and their old and new values. - */ - changedAttributes(): {}; - /** - * Returns the current value of a belongsTo relationship. - */ - belongsTo(keyName: string, options: {}): Snapshot|string|null|undefined; - /** - * Returns the current value of a hasMany relationship. - */ - hasMany(keyName: string, options: {}): any[]|undefined; - /** - * Iterates through all the attributes of the model, calling the passed - * function on each attribute. - */ - eachAttribute(callback: Function, binding: {}): any; - /** - * Iterates through all the relationships of the model, calling the passed - * function on each relationship. - */ - eachRelationship(callback: Function, binding: {}): any; - /** - * Serializes the snapshot using the serializer for the model. - */ - serialize(options: {}): {}; - } - /** - * The store contains all of the data for records loaded from the server. - * It is also responsible for creating instances of `DS.Model` that wrap - * the individual data for a record, so that they can be bound to in your - * Handlebars templates. - */ - class Store { - /** - * The default adapter to use to communicate to a backend server or - * other persistence layer. This will be overridden by an application - * adapter if present. - */ - adapter: string; - /** - * Create a new record in the current store. The properties passed - * to this method are set on the newly created record. - */ - createRecord(modelName: string, inputProperties?: {}): T; - /** - * For symmetry, a record can be deleted via the store. - */ - deleteRecord(record: Model): void; - /** - * For symmetry, a record can be unloaded via the store. - * This will cause the record to be destroyed and freed up for garbage collection. - */ - unloadRecord(record: Model): void; - /** - * This method returns a record for a given type and id combination. - */ - findRecord(modelName: string, id: string|number, options?: {}): PromiseObject & T; - /** - * Get the reference for the specified record. - */ - getReference(modelName: string, id: string|number): RecordReference; - /** - * Get a record by a given type and ID without triggering a fetch. - */ - peekRecord(modelName: string, id: string|number): T|null; - /** - * This method returns true if a record for a given modelName and id is already - * loaded in the store. Use this function to know beforehand if a findRecord() - * will result in a request or that it will be a cache hit. - */ - hasRecordForId(modelName: string, id: string|number): boolean; - /** - * This method delegates a query to the adapter. This is the one place where - * adapter-level semantics are exposed to the application. - */ - query(modelName: string, query: any): AdapterPopulatedRecordArray & PromiseArray; - /** - * This method makes a request for one record, where the `id` is not known - * beforehand (if the `id` is known, use [`findRecord`](#method_findRecord) - * instead). - */ - queryRecord(modelName: string, query: any): Promise; - /** - * `findAll` asks the adapter's `findAll` method to find the records for the - * given type, and returns a promise which will resolve with all records of - * this type present in the store, even if the adapter only returns a subset - * of them. - */ - findAll(modelName: string, options?: { - reload?: boolean, - backgroundReload?: boolean, - include?: string, - adapterOptions?: any - }): PromiseArray; - /** - * This method returns a filtered array that contains all of the - * known records for a given type in the store. - */ - peekAll(modelName: string): RecordArray; - /** - * This method unloads all records in the store. - * It schedules unloading to happen during the next run loop. - */ - unloadAll(modelName: string): void; - /** - * DEPRECATED: - * This method has been deprecated and is an alias for store.hasRecordForId, which should - * be used instead. - */ - recordIsLoaded(modelName: string, id: string): boolean; - /** - * Returns the model class for the particular `modelName`. - */ - modelFor(modelName: string): Model; - /** - * Push some data for a given type into the store. - */ - push(data: {}): Model|any[]; - /** - * Push some raw data into the store. - */ - pushPayload(modelName: string, inputPayload: {}): any; - pushPayload(inputPayload: {}): any; - /** - * `normalize` converts a json payload into the normalized form that - * [push](#method_push) expects. - */ - normalize(modelName: string, payload: {}): {}; - /** - * Returns an instance of the adapter for a given type. For - * example, `adapterFor('person')` will return an instance of - * `App.PersonAdapter`. - */ - adapterFor(modelName: string): Adapter; - /** - * Returns an instance of the serializer for a given type. For - * example, `serializerFor('person')` will return an instance of - * `App.PersonSerializer`. - */ - serializerFor(modelName: string): Serializer; - } - /** - * The `JSONAPIAdapter` is the default adapter used by Ember Data. It - * is responsible for transforming the store's requests into HTTP - * requests that follow the [JSON API](http://jsonapi.org/format/) - * format. - */ - class JSONAPIAdapter extends RESTAdapter { - /** - * By default the JSONAPIAdapter will send each find request coming from a `store.find` - * or from accessing a relationship separately to the server. If your server supports passing - * ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests - * within a single runloop. - */ - coalesceFindRequests: boolean; - } - /** - * The REST adapter allows your store to communicate with an HTTP server by - * transmitting JSON via XHR. Most Ember.js apps that consume a JSON API - * should use the REST adapter. - */ - class RESTAdapter extends Adapter implements BuildURLMixin { - /** - * Takes a URL, an HTTP method and a hash of data, and makes an HTTP request. - */ - ajax(url: string, type: string, options?: object): Promise; - /** - * Generate ajax options - */ - ajaxOptions(url: string, type: string, options?: object): object; - /** - * By default, the RESTAdapter will send the query params sorted alphabetically to the - * server. - */ - sortQueryParams(obj: {}): {}; - /** - * By default the RESTAdapter will send each find request coming from a `store.find` - * or from accessing a relationship separately to the server. If your server supports passing - * ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests - * within a single runloop. - */ - coalesceFindRequests: boolean; - /** - * Endpoint paths can be prefixed with a `namespace` by setting the namespace - * property on the adapter: - */ - namespace: string; - /** - * An adapter can target other hosts by setting the `host` property. - */ - host: string; - /** - * Some APIs require HTTP headers, e.g. to provide an API - * key. Arbitrary headers can be set as key/value pairs on the - * `RESTAdapter`'s `headers` object and Ember Data will send them - * along with each ajax request. For dynamic headers see [headers - * customization](/api/data/classes/DS.RESTAdapter.html#toc_headers-customization). - */ - headers: {}; - /** - * Called by the store in order to fetch the JSON for a given - * type and ID. - */ - findRecord(store: Store, type: Model, id: string, snapshot: Snapshot): Promise; - /** - * Called by the store in order to fetch a JSON array for all - * of the records for a given type. - */ - findAll(store: Store, type: Model, sinceToken: string, snapshotRecordArray: SnapshotRecordArray): Promise; - /** - * Called by the store in order to fetch a JSON array for - * the records that match a particular query. - */ - query(store: Store, type: Model, query: {}): Promise; - /** - * Called by the store in order to fetch a JSON object for - * the record that matches a particular query. - */ - queryRecord(store: Store, type: Model, query: {}): Promise; - /** - * Called by the store in order to fetch several records together if `coalesceFindRequests` is true - */ - findMany(store: Store, type: Model, ids: any[], snapshots: any[]): Promise; - /** - * Called by the store in order to fetch a JSON array for - * the unloaded records in a has-many relationship that were originally - * specified as a URL (inside of `links`). - */ - findHasMany(store: Store, snapshot: Snapshot, url: string, relationship: {}): Promise; - /** - * Called by the store in order to fetch the JSON for the unloaded record in a - * belongs-to relationship that was originally specified as a URL (inside of - * `links`). - */ - findBelongsTo(store: Store, snapshot: Snapshot, url: string): Promise; - /** - * Called by the store when a newly created record is - * saved via the `save` method on a model record instance. - */ - createRecord(store: Store, type: Model, snapshot: Snapshot): Promise; - /** - * Called by the store when an existing record is saved - * via the `save` method on a model record instance. - */ - updateRecord(store: Store, type: Model, snapshot: Snapshot): Promise; - /** - * Called by the store when a record is deleted. - */ - deleteRecord(store: Store, type: Model, snapshot: Snapshot): Promise; - /** - * Organize records into groups, each of which is to be passed to separate - * calls to `findMany`. - */ - groupRecordsForFindMany(store: Store, snapshots: any[]): any[]; - /** - * Takes an ajax response, and returns the json payload or an error. - */ - handleResponse(status: number, headers: {}, payload: {}, requestData: {}): {}; - /** - * Default `handleResponse` implementation uses this hook to decide if the - * response is a success. - */ - isSuccess(status: number, headers: {}, payload: {}): boolean; - /** - * Default `handleResponse` implementation uses this hook to decide if the - * response is an invalid error. - */ - isInvalid(status: number, headers: {}, payload: {}): boolean; - /** - * Get the data (body or query params) for a request. - */ - dataForRequest(params: {}): {}; - /** - * Get the HTTP method for a request. - */ - methodForRequest(params: {}): string; - /** - * Get the URL for a request. - */ - urlForRequest(params: {}): string; - /** - * Get the headers for a request. - */ - headersForRequest(params: {}): {}; - /** - * Builds a URL for a given type and optional ID. - */ - buildURL(modelName: string, id: string|any[]|{}, snapshot: Snapshot|any[], requestType: string, query: {}): string; - /** - * Builds a URL for a `store.findRecord(type, id)` call. - */ - urlForFindRecord(id: string, modelName: string, snapshot: Snapshot): string; - /** - * Builds a URL for a `store.findAll(type)` call. - */ - urlForFindAll(modelName: string, snapshot: SnapshotRecordArray): string; - /** - * Builds a URL for a `store.query(type, query)` call. - */ - urlForQuery(query: {}, modelName: string): string; - /** - * Builds a URL for a `store.queryRecord(type, query)` call. - */ - urlForQueryRecord(query: {}, modelName: string): string; - /** - * Builds a URL for coalesceing multiple `store.findRecord(type, id)` - * records into 1 request when the adapter's `coalesceFindRequests` - * property is true. - */ - urlForFindMany(ids: any[], modelName: string, snapshots: any[]): string; - /** - * Builds a URL for fetching a async hasMany relationship when a url - * is not provided by the server. - */ - urlForFindHasMany(id: string, modelName: string, snapshot: Snapshot): string; - /** - * Builds a URL for fetching a async belongsTo relationship when a url - * is not provided by the server. - */ - urlForFindBelongsTo(id: string, modelName: string, snapshot: Snapshot): string; - /** - * Builds a URL for a `record.save()` call when the record was created - * locally using `store.createRecord()`. - */ - urlForCreateRecord(modelName: string, snapshot: Snapshot): string; - /** - * Builds a URL for a `record.save()` call when the record has been update locally. - */ - urlForUpdateRecord(id: string, modelName: string, snapshot: Snapshot): string; - /** - * Builds a URL for a `record.save()` call when the record has been deleted locally. - */ - urlForDeleteRecord(id: string, modelName: string, snapshot: Snapshot): string; - /** - * Determines the pathname for a given type. - */ - pathForType(modelName: string): string; - } - /** - * ## Using Embedded Records - */ - class EmbeddedRecordsMixin { - /** - * Normalize the record and recursively normalize/extract all the embedded records - * while pushing them into the store as they are encountered - */ - normalize(typeClass: Model, hash: {}, prop: string): {}; - /** - * Serialize `belongsTo` relationship when it is configured as an embedded object. - */ - serializeBelongsTo(snapshot: Snapshot, json: {}, relationship: {}): any; - /** - * Serializes `hasMany` relationships when it is configured as embedded objects. - */ - serializeHasMany(snapshot: Snapshot, json: {}, relationship: {}): any; - /** - * When serializing an embedded record, modify the property (in the json payload) - * that refers to the parent record (foreign key for relationship). - */ - removeEmbeddedForeignKey(snapshot: Snapshot, embeddedSnapshot: Snapshot, relationship: {}, json: {}): any; - } - /** - * Ember Data 2.0 Serializer: - */ - class JSONAPISerializer extends JSONSerializer { - pushPayload(store: Store, payload: {}): any; - /** - * Dasherizes and singularizes the model name in the payload to match - * the format Ember Data uses internally for the model name. - */ - modelNameFromPayloadKey(key: string): string; - /** - * Converts the model name to a pluralized version of the model name. - */ - payloadKeyFromModelName(modelName: string): string; - /** - * `keyForAttribute` can be used to define rules for how to convert an - * attribute name in your model to a key in your JSON. - * By default `JSONAPISerializer` follows the format used on the examples of - * http://jsonapi.org/format and uses dashes as the word separator in the JSON - * attribute keys. - */ - keyForAttribute(key: string, method: string): string; - /** - * `keyForRelationship` can be used to define a custom key when - * serializing and deserializing relationship properties. - * By default `JSONAPISerializer` follows the format used on the examples of - * http://jsonapi.org/format and uses dashes as word separators in - * relationship properties. - */ - keyForRelationship(key: string, typeClass: string, method: string): string; - /** - * `modelNameFromPayloadType` can be used to change the mapping for a DS model - * name, taken from the value in the payload. - */ - modelNameFromPayloadType(payloadType: string): string; - /** - * `payloadTypeFromModelName` can be used to change the mapping for the type in - * the payload, taken from the model name. - */ - payloadTypeFromModelName(modelname: string): string; - } - /** - * Ember Data 2.0 Serializer: - */ - class JSONSerializer extends Serializer { - /** - * The `primaryKey` is used when serializing and deserializing - * data. Ember Data always uses the `id` property to store the id of - * the record. The external source may not always follow this - * convention. In these cases it is useful to override the - * `primaryKey` property to match the `primaryKey` of your external - * store. - */ - primaryKey: string; - /** - * The `attrs` object can be used to declare a simple mapping between - * property names on `DS.Model` records and payload keys in the - * serialized JSON object representing the record. An object with the - * property `key` can also be used to designate the attribute's key on - * the response payload. - */ - attrs: {}; - /** - * The `normalizeResponse` method is used to normalize a payload from the - * server to a JSON-API Document. - */ - normalizeResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeFindRecordResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeQueryRecordResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeFindAllResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeFindBelongsToResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeFindHasManyResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeFindManyResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeQueryResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeCreateRecordResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeDeleteRecordResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeUpdateRecordResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeSaveResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeSingleResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - normalizeArrayResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - /** - * Normalizes a part of the JSON payload returned by - * the server. You should override this method, munge the hash - * and call super if you have generic normalization to do. - */ - normalize(typeClass: Model, hash: {}): {}; - /** - * Returns the resource's ID. - */ - extractId(modelClass: {}, resourceHash: {}): string; - /** - * Returns the resource's attributes formatted as a JSON-API "attributes object". - */ - extractAttributes(modelClass: {}, resourceHash: {}): {}; - /** - * Returns a relationship formatted as a JSON-API "relationship object". - */ - extractRelationship(relationshipModelName: {}, relationshipHash: {}): {}; - /** - * Returns a polymorphic relationship formatted as a JSON-API "relationship object". - */ - extractPolymorphicRelationship(relationshipModelName: {}, relationshipHash: {}, relationshipOptions: {}): {}; - /** - * Returns the resource's relationships formatted as a JSON-API "relationships object". - */ - extractRelationships(modelClass: {}, resourceHash: {}): {}; - modelNameFromPayloadKey(key: string): string; - /** - * Check if the given hasMany relationship should be serialized - */ - shouldSerializeHasMany(snapshot: Snapshot, key: string, relationshipType: string): boolean; - /** - * Called when a record is saved in order to convert the - * record into JSON. - */ - serialize(snapshot: Snapshot, options: {}): {}; - /** - * You can use this method to customize how a serialized record is added to the complete - * JSON hash to be sent to the server. By default the JSON Serializer does not namespace - * the payload and just sends the raw serialized JSON object. - * If your server expects namespaced keys, you should consider using the RESTSerializer. - * Otherwise you can override this method to customize how the record is added to the hash. - * The hash property should be modified by reference. - */ - serializeIntoHash(hash: {}, typeClass: Model, snapshot: Snapshot, options: {}): any; - /** - * `serializeAttribute` can be used to customize how `DS.attr` - * properties are serialized - */ - serializeAttribute(snapshot: Snapshot, json: {}, key: string, attribute: {}): any; - /** - * `serializeBelongsTo` can be used to customize how `DS.belongsTo` - * properties are serialized. - */ - serializeBelongsTo(snapshot: Snapshot, json: {}, relationship: {}): any; - /** - * `serializeHasMany` can be used to customize how `DS.hasMany` - * properties are serialized. - */ - serializeHasMany(snapshot: Snapshot, json: {}, relationship: {}): any; - /** - * You can use this method to customize how polymorphic objects are - * serialized. Objects are considered to be polymorphic if - * `{ polymorphic: true }` is pass as the second argument to the - * `DS.belongsTo` function. - */ - serializePolymorphicType(snapshot: Snapshot, json: {}, relationship: {}): any; - /** - * `extractMeta` is used to deserialize any meta information in the - * adapter payload. By default Ember Data expects meta information to - * be located on the `meta` property of the payload object. - */ - extractMeta(store: Store, modelClass: Model, payload: {}): any; - /** - * `extractErrors` is used to extract model errors when a call - * to `DS.Model#save` fails with an `InvalidError`. By default - * Ember Data expects error information to be located on the `errors` - * property of the payload object. - */ - extractErrors(store: Store, typeClass: Model, payload: {}, id: string|number): {}; - /** - * `keyForAttribute` can be used to define rules for how to convert an - * attribute name in your model to a key in your JSON. - */ - keyForAttribute(key: string, method: string): string; - /** - * `keyForRelationship` can be used to define a custom key when - * serializing and deserializing relationship properties. By default - * `JSONSerializer` does not provide an implementation of this method. - */ - keyForRelationship(key: string, typeClass: string, method: string): string; - /** - * `keyForLink` can be used to define a custom key when deserializing link - * properties. - */ - keyForLink(key: string, kind: string): string; - modelNameFromPayloadType(type: string): string; - /** - * serializeId can be used to customize how id is serialized - * For example, your server may expect integer datatype of id - */ - serializeId(snapshot: Snapshot, json: {}, primaryKey: string): any; - } - /** - * Normally, applications will use the `RESTSerializer` by implementing - * the `normalize` method. - */ - class RESTSerializer extends JSONSerializer { - /** - * `keyForPolymorphicType` can be used to define a custom key when - * serializing and deserializing a polymorphic type. By default, the - * returned key is `${key}Type`. - */ - keyForPolymorphicType(key: string, typeClass: string, method: string): string; - /** - * Normalizes a part of the JSON payload returned by - * the server. You should override this method, munge the hash - * and call super if you have generic normalization to do. - */ - normalize(modelClass: Model, resourceHash: {}, prop?: string): {}; - /** - * This method allows you to push a payload containing top-level - * collections of records organized per type. - */ - pushPayload(store: Store, payload: {}): any; - /** - * This method is used to convert each JSON root key in the payload - * into a modelName that it can use to look up the appropriate model for - * that part of the payload. - */ - modelNameFromPayloadKey(key: string): string; - /** - * Called when a record is saved in order to convert the - * record into JSON. - */ - serialize(snapshot: Snapshot, options: {}): {}; - /** - * You can use this method to customize the root keys serialized into the JSON. - * The hash property should be modified by reference (possibly using something like _.extend) - * By default the REST Serializer sends the modelName of a model, which is a camelized - * version of the name. - */ - serializeIntoHash(hash: {}, typeClass: Model, snapshot: Snapshot, options: {}): any; - /** - * You can use `payloadKeyFromModelName` to override the root key for an outgoing - * request. By default, the RESTSerializer returns a camelized version of the - * model's name. - */ - payloadKeyFromModelName(modelName: string): string; - /** - * You can use this method to customize how polymorphic objects are serialized. - * By default the REST Serializer creates the key by appending `Type` to - * the attribute and value from the model's camelcased model name. - */ - serializePolymorphicType(snapshot: Snapshot, json: {}, relationship: {}): any; - /** - * You can use this method to customize how a polymorphic relationship should - * be extracted. - */ - extractPolymorphicRelationship(relationshipType: {}, relationshipHash: {}, relationshipOptions: {}): {}; - /** - * `modelNameFromPayloadType` can be used to change the mapping for a DS model - * name, taken from the value in the payload. - */ - modelNameFromPayloadType(payloadType: string): string; - /** - * `payloadTypeFromModelName` can be used to change the mapping for the type in - * the payload, taken from the model name. - */ - payloadTypeFromModelName(modelName: string): string; - } - /** - * The `DS.BooleanTransform` class is used to serialize and deserialize - * boolean attributes on Ember Data record objects. This transform is - * used when `boolean` is passed as the type parameter to the - * [DS.attr](../../data#method_attr) function. - */ - class BooleanTransform extends Transform { - } - /** - * The `DS.DateTransform` class is used to serialize and deserialize - * date attributes on Ember Data record objects. This transform is used - * when `date` is passed as the type parameter to the - * [DS.attr](../../data#method_attr) function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601) - * standard. - */ - class DateTransform extends Transform { - } - /** - * The `DS.NumberTransform` class is used to serialize and deserialize - * numeric attributes on Ember Data record objects. This transform is - * used when `number` is passed as the type parameter to the - * [DS.attr](../../data#method_attr) function. - */ - class NumberTransform extends Transform { - } - /** - * The `DS.StringTransform` class is used to serialize and deserialize - * string attributes on Ember Data record objects. This transform is - * used when `string` is passed as the type parameter to the - * [DS.attr](../../data#method_attr) function. - */ - class StringTransform extends Transform { - } - /** - * The `DS.Transform` class is used to serialize and deserialize model - * attributes when they are saved or loaded from an - * adapter. Subclassing `DS.Transform` is useful for creating custom - * attributes. All subclasses of `DS.Transform` must implement a - * `serialize` and a `deserialize` method. - */ - class Transform extends Ember.Object { - /** - * When given a deserialized value from a record attribute this - * method must return the serialized value. - */ - serialize(deserialized: any, options: AttrOptions): any; - /** - * When given a serialize value from a JSON object this method must - * return the deserialized value for the record attribute. - */ - deserialize(serialized: any, options: AttrOptions): any; - } - /** - * An adapter is an object that receives requests from a store and - * translates them into the appropriate action to take against your - * persistence layer. The persistence layer is usually an HTTP API, but - * may be anything, such as the browser's local storage. Typically the - * adapter is not invoked directly instead its functionality is accessed - * through the `store`. - */ - class Adapter extends Ember.Object { - /** - * If you would like your adapter to use a custom serializer you can - * set the `defaultSerializer` property to be the name of the custom - * serializer. - */ - defaultSerializer: string; - /** - * The `findRecord()` method is invoked when the store is asked for a record that - * has not previously been loaded. In response to `findRecord()` being called, you - * should query your persistence layer for a record with the given ID. The `findRecord` - * method should return a promise that will resolve to a JavaScript object that will be - * normalized by the serializer. - */ - findRecord(store: Store, type: Model, id: string, snapshot: Snapshot): Promise; - /** - * The `findAll()` method is used to retrieve all records for a given type. - */ - findAll(store: Store, type: Model, sinceToken: string, snapshotRecordArray: SnapshotRecordArray): Promise; - /** - * This method is called when you call `query` on the store. - */ - query(store: Store, type: Model, query: {}, recordArray: AdapterPopulatedRecordArray): Promise; - /** - * The `queryRecord()` method is invoked when the store is asked for a single - * record through a query object. - */ - queryRecord(store: Store, type: Model, query: {}): Promise; - /** - * If the globally unique IDs for your records should be generated on the client, - * implement the `generateIdForRecord()` method. This method will be invoked - * each time you create a new record, and the value returned from it will be - * assigned to the record's `primaryKey`. - */ - generateIdForRecord(store: Store, type: Model, inputProperties: {}): string|number; - /** - * Proxies to the serializer's `serialize` method. - */ - serialize(snapshot: Snapshot, options: {}): {}; - /** - * Implement this method in a subclass to handle the creation of - * new records. - */ - createRecord(store: Store, type: Model, snapshot: Snapshot): Promise; - /** - * Implement this method in a subclass to handle the updating of - * a record. - */ - updateRecord(store: Store, type: Model, snapshot: Snapshot): Promise; - /** - * Implement this method in a subclass to handle the deletion of - * a record. - */ - deleteRecord(store: Store, type: Model, snapshot: Snapshot): Promise; - /** - * By default the store will try to coalesce all `fetchRecord` calls within the same runloop - * into as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call. - * You can opt out of this behaviour by either not implementing the findMany hook or by setting - * coalesceFindRequests to false. - */ - coalesceFindRequests: boolean; - /** - * The store will call `findMany` instead of multiple `findRecord` - * requests to find multiple records at once if coalesceFindRequests - * is true. - */ - findMany(store: Store, type: Model, ids: any[], snapshots: any[]): Promise; - /** - * Organize records into groups, each of which is to be passed to separate - * calls to `findMany`. - */ - groupRecordsForFindMany(store: Store, snapshots: any[]): any[]; - /** - * This method is used by the store to determine if the store should - * reload a record from the adapter when a record is requested by - * `store.findRecord`. - */ - shouldReloadRecord(store: Store, snapshot: Snapshot): boolean; - /** - * This method is used by the store to determine if the store should - * reload all records from the adapter when records are requested by - * `store.findAll`. - */ - shouldReloadAll(store: Store, snapshotRecordArray: SnapshotRecordArray): boolean; - /** - * This method is used by the store to determine if the store should - * reload a record after the `store.findRecord` method resolves a - * cached record. - */ - shouldBackgroundReloadRecord(store: Store, snapshot: Snapshot): boolean; - /** - * This method is used by the store to determine if the store should - * reload a record array after the `store.findAll` method resolves - * with a cached record array. - */ - shouldBackgroundReloadAll(store: Store, snapshotRecordArray: SnapshotRecordArray): boolean; - } - /** - * `DS.Serializer` is an abstract base class that you should override in your - * application to customize it for your backend. The minimum set of methods - * that you should implement is: - */ - class Serializer extends Ember.Object { - /** - * The `store` property is the application's `store` that contains - * all records. It can be used to look up serializers for other model - * types that may be nested inside the payload response. - */ - store: Store; - /** - * The `normalizeResponse` method is used to normalize a payload from the - * server to a JSON-API Document. - */ - normalizeResponse(store: Store, primaryModelClass: Model, payload: {}, id: string|number, requestType: string): {}; - /** - * The `serialize` method is used when a record is saved in order to convert - * the record into the form that your external data source expects. - */ - serialize(snapshot: Snapshot, options: {}): {}; - /** - * The `normalize` method is used to convert a payload received from your - * external data source into the normalized form `store.push()` expects. You - * should override this method, munge the hash and return the normalized - * payload. - */ - normalize(typeClass: Model, hash: {}): {}; - } + /** + * `DS.attr` defines an attribute on a [DS.Model](/api/data/classes/DS.Model.html). + * By default, attributes are passed through as-is, however you can specify an + * optional type to have the value automatically transformed. + * Ember Data ships with four basic transform types: `string`, `number`, + * `boolean` and `date`. You can define your own transforms by subclassing + * [DS.Transform](/api/data/classes/DS.Transform.html). + */ + function attr( + type: "string", + options?: AttrOptions + ): Ember.ComputedProperty; + function attr( + type: "boolean", + options?: AttrOptions + ): Ember.ComputedProperty; + function attr( + type: "number", + options?: AttrOptions + ): Ember.ComputedProperty; + function attr( + type: "date", + options?: AttrOptions + ): Ember.ComputedProperty; + function attr( + type: string, + options?: AttrOptions + ): Ember.ComputedProperty; + function attr(options?: AttrOptions): Ember.ComputedProperty; + /** + * WARNING: This interface is likely to change in order to accomodate https://github.com/emberjs/rfcs/pull/4 + * ## Using BuildURLMixin + * To use url building, include the mixin when extending an adapter, and call `buildURL` where needed. + * The default behaviour is designed for RESTAdapter. + * ### Example + * ```javascript + * export default DS.Adapter.extend(BuildURLMixin, { + * findRecord: function(store, type, id, snapshot) { + * var url = this.buildURL(type.modelName, id, snapshot, 'findRecord'); + * return this.ajax(url, 'GET'); + * } + * }); + * ``` + * ### Attributes + * The `host` and `namespace` attributes will be used if defined, and are optional. + */ + class BuildURLMixin { + /** + * Builds a URL for a given type and optional ID. + */ + buildURL( + modelName: string, + id: string | any[] | {}, + snapshot: Snapshot | any[], + requestType: string, + query: {} + ): string; + /** + * Builds a URL for a `store.findRecord(type, id)` call. + */ + urlForFindRecord( + id: string, + modelName: string, + snapshot: Snapshot + ): string; + /** + * Builds a URL for a `store.findAll(type)` call. + */ + urlForFindAll( + modelName: string, + snapshot: SnapshotRecordArray + ): string; + /** + * Builds a URL for a `store.query(type, query)` call. + */ + urlForQuery(query: {}, modelName: string): string; + /** + * Builds a URL for a `store.queryRecord(type, query)` call. + */ + urlForQueryRecord(query: {}, modelName: string): string; + /** + * Builds a URL for coalesceing multiple `store.findRecord(type, id)` + * records into 1 request when the adapter's `coalesceFindRequests` + * property is true. + */ + urlForFindMany( + ids: any[], + modelName: string, + snapshots: any[] + ): string; + /** + * Builds a URL for fetching a async hasMany relationship when a url + * is not provided by the server. + */ + urlForFindHasMany( + id: string, + modelName: string, + snapshot: Snapshot + ): string; + /** + * Builds a URL for fetching a async belongsTo relationship when a url + * is not provided by the server. + */ + urlForFindBelongsTo( + id: string, + modelName: string, + snapshot: Snapshot + ): string; + /** + * Builds a URL for a `record.save()` call when the record was created + * locally using `store.createRecord()`. + */ + urlForCreateRecord(modelName: string, snapshot: Snapshot): string; + /** + * Builds a URL for a `record.save()` call when the record has been update locally. + */ + urlForUpdateRecord( + id: string, + modelName: string, + snapshot: Snapshot + ): string; + /** + * Builds a URL for a `record.save()` call when the record has been deleted locally. + */ + urlForDeleteRecord( + id: string, + modelName: string, + snapshot: Snapshot + ): string; + /** + * Determines the pathname for a given type. + */ + pathForType(modelName: string): string; + } + /** + * A `DS.AdapterError` is used by an adapter to signal that an error occurred + * during a request to an external API. It indicates a generic error, and + * subclasses are used to indicate specific error states. The following + * subclasses are provided: + */ + class AdapterError {} + /** + * A `DS.InvalidError` is used by an adapter to signal the external API + * was unable to process a request because the content was not + * semantically correct or meaningful per the API. Usually this means a + * record failed some form of server side validation. When a promise + * from an adapter is rejected with a `DS.InvalidError` the record will + * transition to the `invalid` state and the errors will be set to the + * `errors` property on the record. + */ + class InvalidError {} + /** + * A `DS.TimeoutError` is used by an adapter to signal that a request + * to the external API has timed out. I.e. no response was received from + * the external API within an allowed time period. + */ + class TimeoutError {} + /** + * A `DS.AbortError` is used by an adapter to signal that a request to + * the external API was aborted. For example, this can occur if the user + * navigates away from the current page after a request to the external API + * has been initiated but before a response has been received. + */ + class AbortError {} + /** + * A `DS.UnauthorizedError` equates to a HTTP `401 Unauthorized` response + * status. It is used by an adapter to signal that a request to the external + * API was rejected because authorization is required and has failed or has not + * yet been provided. + */ + class UnauthorizedError {} + /** + * A `DS.ForbiddenError` equates to a HTTP `403 Forbidden` response status. + * It is used by an adapter to signal that a request to the external API was + * valid but the server is refusing to respond to it. If authorization was + * provided and is valid, then the authenticated user does not have the + * necessary permissions for the request. + */ + class ForbiddenError {} + /** + * A `DS.NotFoundError` equates to a HTTP `404 Not Found` response status. + * It is used by an adapter to signal that a request to the external API + * was rejected because the resource could not be found on the API. + */ + class NotFoundError {} + /** + * A `DS.ConflictError` equates to a HTTP `409 Conflict` response status. + * It is used by an adapter to indicate that the request could not be processed + * because of a conflict in the request. An example scenario would be when + * creating a record with a client generated id but that id is already known + * to the external API. + */ + class ConflictError {} + /** + * A `DS.ServerError` equates to a HTTP `500 Internal Server Error` response + * status. It is used by the adapter to indicate that a request has failed + * because of an error in the external API. + */ + class ServerError {} + /** + * Holds validation errors for a given record, organized by attribute names. + */ + interface Errors extends Ember.Enumerable, Ember.Evented {} + class Errors extends Ember.Object { + /** + * DEPRECATED: + * Register with target handler + */ + registerHandlers( + target: {}, + becameInvalid: Function, + becameValid: Function + ): any; + /** + * Returns errors for a given attribute + */ + errorsFor(attribute: string): any[]; + /** + * An array containing all of the error messages for this + * record. This is useful for displaying all errors to the user. + */ + messages: Ember.ComputedProperty; + /** + * Total number of errors. + */ + length: Ember.ComputedProperty; + isEmpty: Ember.ComputedProperty; + /** + * DEPRECATED: + * Adds error messages to a given attribute and sends + * `becameInvalid` event to the record. + */ + add(attribute: string, messages: any[] | string): any; + /** + * DEPRECATED: + * Removes all error messages from the given attribute and sends + * `becameValid` event to the record if there no more errors left. + */ + remove(attribute: string): any; + /** + * DEPRECATED: + * Removes all error messages and sends `becameValid` event + * to the record. + */ + clear(): any; + /** + * Checks if there is error messages for the given attribute. + */ + has(attribute: string): boolean; + } + /** + * The model class that all Ember Data records descend from. + * This is the public API of Ember Data models. If you are using Ember Data + * in your application, this is the class you should use. + * If you are working on Ember Data internals, you most likely want to be dealing + * with `InternalModel` + */ + class Model extends Ember.Object { + /** + * If this property is `true` the record is in the `empty` + * state. Empty is the first state all records enter after they have + * been created. Most records created by the store will quickly + * transition to the `loading` state if data needs to be fetched from + * the server or the `created` state if the record is created on the + * client. A record can also enter the empty state if the adapter is + * unable to locate the record. + */ + isEmpty: Ember.ComputedProperty; + /** + * If this property is `true` the record is in the `loading` state. A + * record enters this state when the store asks the adapter for its + * data. It remains in this state until the adapter provides the + * requested data. + */ + isLoading: Ember.ComputedProperty; + /** + * If this property is `true` the record is in the `loaded` state. A + * record enters this state when its data is populated. Most of a + * record's lifecycle is spent inside substates of the `loaded` + * state. + */ + isLoaded: Ember.ComputedProperty; + /** + * If this property is `true` the record is in the `dirty` state. The + * record has local changes that have not yet been saved by the + * adapter. This includes records that have been created (but not yet + * saved) or deleted. + */ + hasDirtyAttributes: Ember.ComputedProperty; + /** + * If this property is `true` the record is in the `saving` state. A + * record enters the saving state when `save` is called, but the + * adapter has not yet acknowledged that the changes have been + * persisted to the backend. + */ + isSaving: Ember.ComputedProperty; + /** + * If this property is `true` the record is in the `deleted` state + * and has been marked for deletion. When `isDeleted` is true and + * `hasDirtyAttributes` is true, the record is deleted locally but the deletion + * was not yet persisted. When `isSaving` is true, the change is + * in-flight. When both `hasDirtyAttributes` and `isSaving` are false, the + * change has persisted. + */ + isDeleted: Ember.ComputedProperty; + /** + * If this property is `true` the record is in the `new` state. A + * record will be in the `new` state when it has been created on the + * client and the adapter has not yet report that it was successfully + * saved. + */ + isNew: Ember.ComputedProperty; + /** + * If this property is `true` the record is in the `valid` state. + */ + isValid: Ember.ComputedProperty; + /** + * If the record is in the dirty state this property will report what + * kind of change has caused it to move into the dirty + * state. Possible values are: + */ + dirtyType: Ember.ComputedProperty; + /** + * If `true` the adapter reported that it was unable to save local + * changes to the backend for any reason other than a server-side + * validation error. + */ + isError: boolean; + /** + * If `true` the store is attempting to reload the record from the adapter. + */ + isReloading: boolean; + /** + * All ember models have an id property. This is an identifier + * managed by an external source. These are always coerced to be + * strings before being used internally. Note when declaring the + * attributes for a model it is an error to declare an id + * attribute. + */ + id: string; + /** + * When the record is in the `invalid` state this object will contain + * any errors returned by the adapter. When present the errors hash + * contains keys corresponding to the invalid property names + * and values which are arrays of Javascript objects with two keys: + */ + errors: Ember.ComputedProperty; + /** + * This property holds the `DS.AdapterError` object with which + * last adapter operation was rejected. + */ + adapterError: AdapterError; + /** + * Create a JSON representation of the record, using the serialization + * strategy of the store's adapter. + */ + serialize(options: {}): {}; + /** + * Use [DS.JSONSerializer](DS.JSONSerializer.html) to + * get the JSON representation of a record. + */ + toJSON(options: {}): {}; + /** + * Fired when the record is ready to be interacted with, + * that is either loaded from the server or created locally. + */ + ready(): void; + /** + * Fired when the record is loaded from the server. + */ + didLoad(): void; + /** + * Fired when the record is updated. + */ + didUpdate(): void; + /** + * Fired when a new record is commited to the server. + */ + didCreate(): void; + /** + * Fired when the record is deleted. + */ + didDelete(): void; + /** + * Fired when the record becomes invalid. + */ + becameInvalid(): void; + /** + * Fired when the record enters the error state. + */ + becameError(): void; + /** + * Fired when the record is rolled back. + */ + rolledBack(): void; + /** + * Marks the record as deleted but does not save it. You must call + * `save` afterwards if you want to persist it. You might use this + * method if you want to allow the user to still `rollbackAttributes()` + * after a delete was made. + */ + deleteRecord(): any; + /** + * Same as `deleteRecord`, but saves the record immediately. + */ + destroyRecord(options: {}): Promise; + /** + * Unloads the record from the store. This will cause the record to be destroyed and freed up for garbage collection. + */ + unloadRecord(): any; + /** + * Returns an object, whose keys are changed properties, and value is + * an [oldProp, newProp] array. + */ + changedAttributes(): {}; + /** + * If the model `hasDirtyAttributes` this function will discard any unsaved + * changes. If the model `isNew` it will be removed from the store. + */ + rollbackAttributes(): any; + /** + * Save the record and persist any changes to the record to an + * external source via the adapter. + */ + save(options?: {}): Promise; + /** + * Reload the record from the adapter. + */ + reload(): Promise; + /** + * Get the reference for the specified belongsTo relationship. + */ + belongsTo(name: string): BelongsToReference; + /** + * Get the reference for the specified hasMany relationship. + */ + hasMany(name: string): HasManyReference; + /** + * Given a callback, iterates over each of the relationships in the model, + * invoking the callback with the name of each relationship and its relationship + * descriptor. + */ + eachRelationship(callback: Function, binding: any): any; + /** + * Represents the model's class name as a string. This can be used to look up the model's class name through + * `DS.Store`'s modelFor method. + */ + static modelName: string; + /** + * For a given relationship name, returns the model type of the relationship. + */ + static typeForRelationship(name: string, store: Store): Model; + /** + * Find the relationship which is the inverse of the one asked for. + */ + static inverseFor(name: string, store: Store): {}; + /** + * The model's relationships as a map, keyed on the type of the + * relationship. The value of each entry is an array containing a descriptor + * for each relationship with that type, describing the name of the relationship + * as well as the type. + */ + static relationships: Ember.ComputedProperty; + /** + * A hash containing lists of the model's relationships, grouped + * by the relationship kind. For example, given a model with this + * definition: + */ + static relationshipNames: Ember.ComputedProperty<{}>; + /** + * An array of types directly related to a model. Each type will be + * included once, regardless of the number of relationships it has with + * the model. + */ + static relatedTypes: Ember.ComputedProperty< + Ember.NativeArray + >; + /** + * A map whose keys are the relationships of a model and whose values are + * relationship descriptors. + */ + static relationshipsByName: Ember.ComputedProperty; + /** + * A map whose keys are the fields of the model and whose values are strings + * describing the kind of the field. A model's fields are the union of all of its + * attributes and relationships. + */ + static fields: Ember.ComputedProperty; + /** + * Given a callback, iterates over each of the relationships in the model, + * invoking the callback with the name of each relationship and its relationship + * descriptor. + */ + static eachRelationship(callback: Function, binding: any): any; + /** + * Given a callback, iterates over each of the types related to a model, + * invoking the callback with the related type's class. Each type will be + * returned just once, regardless of how many different relationships it has + * with a model. + */ + static eachRelatedType(callback: Function, binding: any): any; + /** + * A map whose keys are the attributes of the model (properties + * described by DS.attr) and whose values are the meta object for the + * property. + */ + static attributes: Ember.ComputedProperty; + /** + * A map whose keys are the attributes of the model (properties + * described by DS.attr) and whose values are type of transformation + * applied to each attribute. This map does not include any + * attributes that do not have an transformation type. + */ + static transformedAttributes: Ember.ComputedProperty; + /** + * Iterates through the attributes of the model, calling the passed function on each + * attribute. + */ + static eachAttribute(callback: Function, binding: {}): any; + /** + * Iterates through the transformedAttributes of the model, calling + * the passed function on each attribute. Note the callback will not be + * called for any attributes that do not have an transformation type. + */ + static eachTransformedAttribute( + callback: Function, + binding: {} + ): any; + /** + * Discards any unsaved changes to the given attribute. This feature is not enabled by default. You must enable `ds-rollback-attribute` and be running a canary build. + */ + rollbackAttribute(): any; + /** + * This Ember.js hook allows an object to be notified when a property + * is defined. + */ + didDefineProperty( + proto: {}, + key: string, + value: Ember.ComputedProperty + ): any; + } + /** + * ### State + */ + class RootState {} + /** + * Represents an ordered list of records whose order and membership is + * determined by the adapter. For example, a query sent to the adapter + * may trigger a search on the server, whose results would be loaded + * into an instance of the `AdapterPopulatedRecordArray`. + */ + class AdapterPopulatedRecordArray extends RecordArray {} + /** + * Represents a list of records whose membership is determined by the + * store. As records are created, loaded, or modified, the store + * evaluates them to determine if they should be part of the record + * array. + */ + class FilteredRecordArray extends RecordArray { + /** + * The filterFunction is a function used to test records from the store to + * determine if they should be part of the record array. + */ + filterFunction(record: Model): boolean; + } + /** + * A record array is an array that contains records of a certain modelName. The record + * array materializes records as needed when they are retrieved for the first + * time. You should not create record arrays yourself. Instead, an instance of + * `DS.RecordArray` or its subclasses will be returned by your application's store + * in response to queries. + */ + interface RecordArray extends Ember.ArrayProxy, Ember.Evented {} + class RecordArray { + /** + * The flag to signal a `RecordArray` is finished loading data. + */ + isLoaded: boolean; + /** + * The flag to signal a `RecordArray` is currently loading data. + */ + isUpdating: boolean; + /** + * The modelClass represented by this record array. + */ + type: Ember.ComputedProperty; + /** + * Used to get the latest version of all of the records in this array + * from the adapter. + */ + update(): any; + /** + * Saves all of the records in the `RecordArray`. + */ + save(): PromiseArray; + } + /** + * A BelongsToReference is a low level API that allows users and + * addon author to perform meta-operations on a belongs-to + * relationship. + */ + class BelongsToReference { + /** + * This returns a string that represents how the reference will be + * looked up when it is loaded. If the relationship has a link it will + * use the "link" otherwise it defaults to "id". + */ + remoteType(): string; + /** + * The `id` of the record that this reference refers to. Together, the + * `type()` and `id()` methods form a composite key for the identity + * map. This can be used to access the id of an async relationship + * without triggering a fetch that would normally happen if you + * attempted to use `record.get('relationship.id')`. + */ + id(): string; + /** + * The link Ember Data will use to fetch or reload this belongs-to + * relationship. + */ + link(): string; + /** + * The meta data for the belongs-to relationship. + */ + meta(): {}; + /** + * `push` can be used to update the data in the relationship and Ember + * Data will treat the new data as the conanical value of this + * relationship on the backend. + */ + push(objectOrPromise: {} | Promise): Promise; + /** + * `value()` synchronously returns the current value of the belongs-to + * relationship. Unlike `record.get('relationshipName')`, calling + * `value()` on a reference does not trigger a fetch if the async + * relationship is not yet loaded. If the relationship is not loaded + * it will always return `null`. + */ + value(objectOrPromise: {} | Promise): Model; + /** + * Loads a record in a belongs to relationship if it is not already + * loaded. If the relationship is already loaded this method does not + * trigger a new load. + */ + load(): Promise; + /** + * Triggers a reload of the value in this relationship. If the + * remoteType is `"link"` Ember Data will use the relationship link to + * reload the relationship. Otherwise it will reload the record by its + * id. + */ + reload(): Promise; + } + /** + * A HasManyReference is a low level API that allows users and addon + * author to perform meta-operations on a has-many relationship. + */ + class HasManyReference { + /** + * This returns a string that represents how the reference will be + * looked up when it is loaded. If the relationship has a link it will + * use the "link" otherwise it defaults to "id". + */ + remoteType(): string; + /** + * The link Ember Data will use to fetch or reload this has-many + * relationship. + */ + link(): string; + /** + * `ids()` returns an array of the record ids in this relationship. + */ + ids(): any[]; + /** + * The meta data for the has-many relationship. + */ + meta(): {}; + /** + * `push` can be used to update the data in the relationship and Ember + * Data will treat the new data as the canonical value of this + * relationship on the backend. + */ + push(objectOrPromise: T[] | Promise): ManyArray; + /** + * `value()` synchronously returns the current value of the has-many + * relationship. Unlike `record.get('relationshipName')`, calling + * `value()` on a reference does not trigger a fetch if the async + * relationship is not yet loaded. If the relationship is not loaded + * it will always return `null`. + */ + value(): ManyArray; + /** + * Loads the relationship if it is not already loaded. If the + * relationship is already loaded this method does not trigger a new + * load. + */ + load(): Promise; + /** + * Reloads this has-many relationship. + */ + reload(): Promise; + } + /** + * An RecordReference is a low level API that allows users and + * addon author to perform meta-operations on a record. + */ + class RecordReference { + /** + * The `id` of the record that this reference refers to. + */ + id(): string; + /** + * How the reference will be looked up when it is loaded: Currently + * this always return `identity` to signifying that a record will be + * loaded by the `type` and `id`. + */ + remoteType(): string; + /** + * This API allows you to provide a reference with new data. The + * simplest usage of this API is similar to `store.push`: you provide a + * normalized hash of data and the object represented by the reference + * will update. + */ + push(payload: Promise | {}): PromiseObject & T; + /** + * If the entity referred to by the reference is already loaded, it is + * present as `reference.value`. Otherwise the value returned by this function + * is `null`. + */ + value(): T | null; + /** + * Triggers a fetch for the backing entity based on its `remoteType` + * (see `remoteType` definitions per reference type). + */ + load(): PromiseObject & T; + /** + * Reloads the record if it is already loaded. If the record is not + * loaded it will load the record via `store.findRecord` + */ + reload(): PromiseObject & T; + } + /** + * A `ManyArray` is a `MutableArray` that represents the contents of a has-many + * relationship. + */ + interface ManyArray extends Ember.MutableArray {} + class ManyArray extends Ember.Object.extend( + Ember.MutableArray as {}, + Ember.Evented + ) { + /** + * The loading state of this array + */ + isLoaded: boolean; + /** + * Metadata associated with the request for async hasMany relationships. + */ + meta: {}; + /** + * Reloads all of the records in the manyArray. If the manyArray + * holds a relationship that was originally fetched using a links url + * Ember Data will revisit the original links url to repopulate the + * relationship. + */ + reload(): PromiseArray; + /** + * Saves all of the records in the `ManyArray`. + */ + save(): PromiseArray; + /** + * Create a child record within the owner + */ + createRecord(inputProperties?: {}): T; + } + /** + * A `PromiseArray` is an object that acts like both an `Ember.Array` + * and a promise. When the promise is resolved the resulting value + * will be set to the `PromiseArray`'s `content` property. This makes + * it easy to create data bindings with the `PromiseArray` that will be + * updated when the promise resolves. + */ + interface PromiseArray + extends Ember.ArrayProxy, + Ember.PromiseProxyMixin> {} + class PromiseArray {} + /** + * A `PromiseObject` is an object that acts like both an `Ember.Object` + * and a promise. When the promise is resolved, then the resulting value + * will be set to the `PromiseObject`'s `content` property. This makes + * it easy to create data bindings with the `PromiseObject` that will + * be updated when the promise resolves. + */ + interface PromiseObject + extends Ember.ObjectProxy, + Ember.PromiseProxyMixin> {} + class PromiseObject {} + /** + * A PromiseManyArray is a PromiseArray that also proxies certain method calls + * to the underlying manyArray. + * Right now we proxy: + */ + class PromiseManyArray extends PromiseArray { + /** + * Reloads all of the records in the manyArray. If the manyArray + * holds a relationship that was originally fetched using a links url + * Ember Data will revisit the original links url to repopulate the + * relationship. + */ + reload(): PromiseManyArray; + /** + * Create a child record within the owner + */ + createRecord(inputProperties?: {}): T; + } + class SnapshotRecordArray { + /** + * Number of records in the array + */ + length: number; + /** + * Meta objects for the record array. + */ + meta: {}; + /** + * A hash of adapter options passed into the store method for this request. + */ + adapterOptions: {}; + /** + * The relationships to include for this request. + */ + include: string | any[]; + /** + * The type of the underlying records for the snapshots in the array, as a DS.Model + */ + type: Model; + /** + * Get snapshots of the underlying record array + */ + snapshots(): any[]; + } + class Snapshot { + /** + * The underlying record for this snapshot. Can be used to access methods and + * properties defined on the record. + */ + record: Model; + /** + * The id of the snapshot's underlying record + */ + id: string; + /** + * A hash of adapter options + */ + adapterOptions: {}; + /** + * The name of the type of the underlying record for this snapshot, as a string. + */ + modelName: string; + /** + * The type of the underlying record for this snapshot, as a DS.Model. + */ + type: Model; + /** + * Returns the value of an attribute. + */ + attr(keyName: string): {}; + /** + * Returns all attributes and their corresponding values. + */ + attributes(): {}; + /** + * Returns all changed attributes and their old and new values. + */ + changedAttributes(): {}; + /** + * Returns the current value of a belongsTo relationship. + */ + belongsTo( + keyName: string, + options: {} + ): Snapshot | string | null | undefined; + /** + * Returns the current value of a hasMany relationship. + */ + hasMany(keyName: string, options: {}): any[] | undefined; + /** + * Iterates through all the attributes of the model, calling the passed + * function on each attribute. + */ + eachAttribute(callback: Function, binding: {}): any; + /** + * Iterates through all the relationships of the model, calling the passed + * function on each relationship. + */ + eachRelationship(callback: Function, binding: {}): any; + /** + * Serializes the snapshot using the serializer for the model. + */ + serialize(options: {}): {}; + } + /** + * The store contains all of the data for records loaded from the server. + * It is also responsible for creating instances of `DS.Model` that wrap + * the individual data for a record, so that they can be bound to in your + * Handlebars templates. + */ + class Store { + /** + * The default adapter to use to communicate to a backend server or + * other persistence layer. This will be overridden by an application + * adapter if present. + */ + adapter: string; + /** + * Create a new record in the current store. The properties passed + * to this method are set on the newly created record. + */ + createRecord( + modelName: string, + inputProperties?: {} + ): T; + /** + * For symmetry, a record can be deleted via the store. + */ + deleteRecord(record: Model): void; + /** + * For symmetry, a record can be unloaded via the store. + * This will cause the record to be destroyed and freed up for garbage collection. + */ + unloadRecord(record: Model): void; + /** + * This method returns a record for a given type and id combination. + */ + findRecord( + modelName: string, + id: string | number, + options?: {} + ): PromiseObject & T; + /** + * Get the reference for the specified record. + */ + getReference( + modelName: string, + id: string | number + ): RecordReference; + /** + * Get a record by a given type and ID without triggering a fetch. + */ + peekRecord( + modelName: string, + id: string | number + ): T | null; + /** + * This method returns true if a record for a given modelName and id is already + * loaded in the store. Use this function to know beforehand if a findRecord() + * will result in a request or that it will be a cache hit. + */ + hasRecordForId(modelName: string, id: string | number): boolean; + /** + * This method delegates a query to the adapter. This is the one place where + * adapter-level semantics are exposed to the application. + */ + query( + modelName: string, + query: any + ): AdapterPopulatedRecordArray & PromiseArray; + /** + * This method makes a request for one record, where the `id` is not known + * beforehand (if the `id` is known, use [`findRecord`](#method_findRecord) + * instead). + */ + queryRecord( + modelName: string, + query: any + ): Promise; + /** + * `findAll` asks the adapter's `findAll` method to find the records for the + * given type, and returns a promise which will resolve with all records of + * this type present in the store, even if the adapter only returns a subset + * of them. + */ + findAll( + modelName: string, + options?: { + reload?: boolean; + backgroundReload?: boolean; + include?: string; + adapterOptions?: any; + } + ): PromiseArray; + /** + * This method returns a filtered array that contains all of the + * known records for a given type in the store. + */ + peekAll(modelName: string): RecordArray; + /** + * This method unloads all records in the store. + * It schedules unloading to happen during the next run loop. + */ + unloadAll(modelName: string): void; + /** + * DEPRECATED: + * This method has been deprecated and is an alias for store.hasRecordForId, which should + * be used instead. + */ + recordIsLoaded(modelName: string, id: string): boolean; + /** + * Returns the model class for the particular `modelName`. + */ + modelFor(modelName: string): Model; + /** + * Push some data for a given type into the store. + */ + push(data: {}): Model | any[]; + /** + * Push some raw data into the store. + */ + pushPayload(modelName: string, inputPayload: {}): any; + pushPayload(inputPayload: {}): any; + /** + * `normalize` converts a json payload into the normalized form that + * [push](#method_push) expects. + */ + normalize(modelName: string, payload: {}): {}; + /** + * Returns an instance of the adapter for a given type. For + * example, `adapterFor('person')` will return an instance of + * `App.PersonAdapter`. + */ + adapterFor(modelName: string): Adapter; + /** + * Returns an instance of the serializer for a given type. For + * example, `serializerFor('person')` will return an instance of + * `App.PersonSerializer`. + */ + serializerFor(modelName: string): Serializer; + } + /** + * The `JSONAPIAdapter` is the default adapter used by Ember Data. It + * is responsible for transforming the store's requests into HTTP + * requests that follow the [JSON API](http://jsonapi.org/format/) + * format. + */ + class JSONAPIAdapter extends RESTAdapter { + /** + * By default the JSONAPIAdapter will send each find request coming from a `store.find` + * or from accessing a relationship separately to the server. If your server supports passing + * ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests + * within a single runloop. + */ + coalesceFindRequests: boolean; + } + /** + * The REST adapter allows your store to communicate with an HTTP server by + * transmitting JSON via XHR. Most Ember.js apps that consume a JSON API + * should use the REST adapter. + */ + class RESTAdapter extends Adapter implements BuildURLMixin { + /** + * Takes a URL, an HTTP method and a hash of data, and makes an HTTP request. + */ + ajax(url: string, type: string, options?: object): Promise; + /** + * Generate ajax options + */ + ajaxOptions(url: string, type: string, options?: object): object; + /** + * By default, the RESTAdapter will send the query params sorted alphabetically to the + * server. + */ + sortQueryParams(obj: {}): {}; + /** + * By default the RESTAdapter will send each find request coming from a `store.find` + * or from accessing a relationship separately to the server. If your server supports passing + * ids as a query string, you can set coalesceFindRequests to true to coalesce all find requests + * within a single runloop. + */ + coalesceFindRequests: boolean; + /** + * Endpoint paths can be prefixed with a `namespace` by setting the namespace + * property on the adapter: + */ + namespace: string; + /** + * An adapter can target other hosts by setting the `host` property. + */ + host: string; + /** + * Some APIs require HTTP headers, e.g. to provide an API + * key. Arbitrary headers can be set as key/value pairs on the + * `RESTAdapter`'s `headers` object and Ember Data will send them + * along with each ajax request. For dynamic headers see [headers + * customization](/api/data/classes/DS.RESTAdapter.html#toc_headers-customization). + */ + headers: {}; + /** + * Called by the store in order to fetch the JSON for a given + * type and ID. + */ + findRecord( + store: Store, + type: Model, + id: string, + snapshot: Snapshot + ): Promise; + /** + * Called by the store in order to fetch a JSON array for all + * of the records for a given type. + */ + findAll( + store: Store, + type: Model, + sinceToken: string, + snapshotRecordArray: SnapshotRecordArray + ): Promise; + /** + * Called by the store in order to fetch a JSON array for + * the records that match a particular query. + */ + query(store: Store, type: Model, query: {}): Promise; + /** + * Called by the store in order to fetch a JSON object for + * the record that matches a particular query. + */ + queryRecord(store: Store, type: Model, query: {}): Promise; + /** + * Called by the store in order to fetch several records together if `coalesceFindRequests` is true + */ + findMany( + store: Store, + type: Model, + ids: any[], + snapshots: any[] + ): Promise; + /** + * Called by the store in order to fetch a JSON array for + * the unloaded records in a has-many relationship that were originally + * specified as a URL (inside of `links`). + */ + findHasMany( + store: Store, + snapshot: Snapshot, + url: string, + relationship: {} + ): Promise; + /** + * Called by the store in order to fetch the JSON for the unloaded record in a + * belongs-to relationship that was originally specified as a URL (inside of + * `links`). + */ + findBelongsTo( + store: Store, + snapshot: Snapshot, + url: string + ): Promise; + /** + * Called by the store when a newly created record is + * saved via the `save` method on a model record instance. + */ + createRecord( + store: Store, + type: Model, + snapshot: Snapshot + ): Promise; + /** + * Called by the store when an existing record is saved + * via the `save` method on a model record instance. + */ + updateRecord( + store: Store, + type: Model, + snapshot: Snapshot + ): Promise; + /** + * Called by the store when a record is deleted. + */ + deleteRecord( + store: Store, + type: Model, + snapshot: Snapshot + ): Promise; + /** + * Organize records into groups, each of which is to be passed to separate + * calls to `findMany`. + */ + groupRecordsForFindMany(store: Store, snapshots: any[]): any[]; + /** + * Takes an ajax response, and returns the json payload or an error. + */ + handleResponse( + status: number, + headers: {}, + payload: {}, + requestData: {} + ): {}; + /** + * Default `handleResponse` implementation uses this hook to decide if the + * response is a success. + */ + isSuccess(status: number, headers: {}, payload: {}): boolean; + /** + * Default `handleResponse` implementation uses this hook to decide if the + * response is an invalid error. + */ + isInvalid(status: number, headers: {}, payload: {}): boolean; + /** + * Get the data (body or query params) for a request. + */ + dataForRequest(params: {}): {}; + /** + * Get the HTTP method for a request. + */ + methodForRequest(params: {}): string; + /** + * Get the URL for a request. + */ + urlForRequest(params: {}): string; + /** + * Get the headers for a request. + */ + headersForRequest(params: {}): {}; + /** + * Builds a URL for a given type and optional ID. + */ + buildURL( + modelName: string, + id: string | any[] | {}, + snapshot: Snapshot | any[], + requestType: string, + query: {} + ): string; + /** + * Builds a URL for a `store.findRecord(type, id)` call. + */ + urlForFindRecord( + id: string, + modelName: string, + snapshot: Snapshot + ): string; + /** + * Builds a URL for a `store.findAll(type)` call. + */ + urlForFindAll( + modelName: string, + snapshot: SnapshotRecordArray + ): string; + /** + * Builds a URL for a `store.query(type, query)` call. + */ + urlForQuery(query: {}, modelName: string): string; + /** + * Builds a URL for a `store.queryRecord(type, query)` call. + */ + urlForQueryRecord(query: {}, modelName: string): string; + /** + * Builds a URL for coalesceing multiple `store.findRecord(type, id)` + * records into 1 request when the adapter's `coalesceFindRequests` + * property is true. + */ + urlForFindMany( + ids: any[], + modelName: string, + snapshots: any[] + ): string; + /** + * Builds a URL for fetching a async hasMany relationship when a url + * is not provided by the server. + */ + urlForFindHasMany( + id: string, + modelName: string, + snapshot: Snapshot + ): string; + /** + * Builds a URL for fetching a async belongsTo relationship when a url + * is not provided by the server. + */ + urlForFindBelongsTo( + id: string, + modelName: string, + snapshot: Snapshot + ): string; + /** + * Builds a URL for a `record.save()` call when the record was created + * locally using `store.createRecord()`. + */ + urlForCreateRecord(modelName: string, snapshot: Snapshot): string; + /** + * Builds a URL for a `record.save()` call when the record has been update locally. + */ + urlForUpdateRecord( + id: string, + modelName: string, + snapshot: Snapshot + ): string; + /** + * Builds a URL for a `record.save()` call when the record has been deleted locally. + */ + urlForDeleteRecord( + id: string, + modelName: string, + snapshot: Snapshot + ): string; + /** + * Determines the pathname for a given type. + */ + pathForType(modelName: string): string; + } + /** + * ## Using Embedded Records + */ + class EmbeddedRecordsMixin { + /** + * Normalize the record and recursively normalize/extract all the embedded records + * while pushing them into the store as they are encountered + */ + normalize(typeClass: Model, hash: {}, prop: string): {}; + /** + * Serialize `belongsTo` relationship when it is configured as an embedded object. + */ + serializeBelongsTo( + snapshot: Snapshot, + json: {}, + relationship: {} + ): any; + /** + * Serializes `hasMany` relationships when it is configured as embedded objects. + */ + serializeHasMany( + snapshot: Snapshot, + json: {}, + relationship: {} + ): any; + /** + * When serializing an embedded record, modify the property (in the json payload) + * that refers to the parent record (foreign key for relationship). + */ + removeEmbeddedForeignKey( + snapshot: Snapshot, + embeddedSnapshot: Snapshot, + relationship: {}, + json: {} + ): any; + } + /** + * Ember Data 2.0 Serializer: + */ + class JSONAPISerializer extends JSONSerializer { + pushPayload(store: Store, payload: {}): any; + /** + * Dasherizes and singularizes the model name in the payload to match + * the format Ember Data uses internally for the model name. + */ + modelNameFromPayloadKey(key: string): string; + /** + * Converts the model name to a pluralized version of the model name. + */ + payloadKeyFromModelName(modelName: string): string; + /** + * `keyForAttribute` can be used to define rules for how to convert an + * attribute name in your model to a key in your JSON. + * By default `JSONAPISerializer` follows the format used on the examples of + * http://jsonapi.org/format and uses dashes as the word separator in the JSON + * attribute keys. + */ + keyForAttribute(key: string, method: string): string; + /** + * `keyForRelationship` can be used to define a custom key when + * serializing and deserializing relationship properties. + * By default `JSONAPISerializer` follows the format used on the examples of + * http://jsonapi.org/format and uses dashes as word separators in + * relationship properties. + */ + keyForRelationship( + key: string, + typeClass: string, + method: string + ): string; + /** + * `modelNameFromPayloadType` can be used to change the mapping for a DS model + * name, taken from the value in the payload. + */ + modelNameFromPayloadType(payloadType: string): string; + /** + * `payloadTypeFromModelName` can be used to change the mapping for the type in + * the payload, taken from the model name. + */ + payloadTypeFromModelName(modelname: string): string; + } + /** + * Ember Data 2.0 Serializer: + */ + class JSONSerializer extends Serializer { + /** + * The `primaryKey` is used when serializing and deserializing + * data. Ember Data always uses the `id` property to store the id of + * the record. The external source may not always follow this + * convention. In these cases it is useful to override the + * `primaryKey` property to match the `primaryKey` of your external + * store. + */ + primaryKey: string; + /** + * The `attrs` object can be used to declare a simple mapping between + * property names on `DS.Model` records and payload keys in the + * serialized JSON object representing the record. An object with the + * property `key` can also be used to designate the attribute's key on + * the response payload. + */ + attrs: {}; + /** + * The `normalizeResponse` method is used to normalize a payload from the + * server to a JSON-API Document. + */ + normalizeResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeFindRecordResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeQueryRecordResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeFindAllResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeFindBelongsToResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeFindHasManyResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeFindManyResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeQueryResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeCreateRecordResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeDeleteRecordResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeUpdateRecordResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeSaveResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeSingleResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + normalizeArrayResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + /** + * Normalizes a part of the JSON payload returned by + * the server. You should override this method, munge the hash + * and call super if you have generic normalization to do. + */ + normalize(typeClass: Model, hash: {}): {}; + /** + * Returns the resource's ID. + */ + extractId(modelClass: {}, resourceHash: {}): string; + /** + * Returns the resource's attributes formatted as a JSON-API "attributes object". + */ + extractAttributes(modelClass: {}, resourceHash: {}): {}; + /** + * Returns a relationship formatted as a JSON-API "relationship object". + */ + extractRelationship( + relationshipModelName: {}, + relationshipHash: {} + ): {}; + /** + * Returns a polymorphic relationship formatted as a JSON-API "relationship object". + */ + extractPolymorphicRelationship( + relationshipModelName: {}, + relationshipHash: {}, + relationshipOptions: {} + ): {}; + /** + * Returns the resource's relationships formatted as a JSON-API "relationships object". + */ + extractRelationships(modelClass: {}, resourceHash: {}): {}; + modelNameFromPayloadKey(key: string): string; + /** + * Check if the given hasMany relationship should be serialized + */ + shouldSerializeHasMany( + snapshot: Snapshot, + key: string, + relationshipType: string + ): boolean; + /** + * Called when a record is saved in order to convert the + * record into JSON. + */ + serialize(snapshot: Snapshot, options: {}): {}; + /** + * You can use this method to customize how a serialized record is added to the complete + * JSON hash to be sent to the server. By default the JSON Serializer does not namespace + * the payload and just sends the raw serialized JSON object. + * If your server expects namespaced keys, you should consider using the RESTSerializer. + * Otherwise you can override this method to customize how the record is added to the hash. + * The hash property should be modified by reference. + */ + serializeIntoHash( + hash: {}, + typeClass: Model, + snapshot: Snapshot, + options: {} + ): any; + /** + * `serializeAttribute` can be used to customize how `DS.attr` + * properties are serialized + */ + serializeAttribute( + snapshot: Snapshot, + json: {}, + key: string, + attribute: {} + ): any; + /** + * `serializeBelongsTo` can be used to customize how `DS.belongsTo` + * properties are serialized. + */ + serializeBelongsTo( + snapshot: Snapshot, + json: {}, + relationship: {} + ): any; + /** + * `serializeHasMany` can be used to customize how `DS.hasMany` + * properties are serialized. + */ + serializeHasMany( + snapshot: Snapshot, + json: {}, + relationship: {} + ): any; + /** + * You can use this method to customize how polymorphic objects are + * serialized. Objects are considered to be polymorphic if + * `{ polymorphic: true }` is pass as the second argument to the + * `DS.belongsTo` function. + */ + serializePolymorphicType( + snapshot: Snapshot, + json: {}, + relationship: {} + ): any; + /** + * `extractMeta` is used to deserialize any meta information in the + * adapter payload. By default Ember Data expects meta information to + * be located on the `meta` property of the payload object. + */ + extractMeta(store: Store, modelClass: Model, payload: {}): any; + /** + * `extractErrors` is used to extract model errors when a call + * to `DS.Model#save` fails with an `InvalidError`. By default + * Ember Data expects error information to be located on the `errors` + * property of the payload object. + */ + extractErrors( + store: Store, + typeClass: Model, + payload: {}, + id: string | number + ): {}; + /** + * `keyForAttribute` can be used to define rules for how to convert an + * attribute name in your model to a key in your JSON. + */ + keyForAttribute(key: string, method: string): string; + /** + * `keyForRelationship` can be used to define a custom key when + * serializing and deserializing relationship properties. By default + * `JSONSerializer` does not provide an implementation of this method. + */ + keyForRelationship( + key: string, + typeClass: string, + method: string + ): string; + /** + * `keyForLink` can be used to define a custom key when deserializing link + * properties. + */ + keyForLink(key: string, kind: string): string; + modelNameFromPayloadType(type: string): string; + /** + * serializeId can be used to customize how id is serialized + * For example, your server may expect integer datatype of id + */ + serializeId(snapshot: Snapshot, json: {}, primaryKey: string): any; + } + /** + * Normally, applications will use the `RESTSerializer` by implementing + * the `normalize` method. + */ + class RESTSerializer extends JSONSerializer { + /** + * `keyForPolymorphicType` can be used to define a custom key when + * serializing and deserializing a polymorphic type. By default, the + * returned key is `${key}Type`. + */ + keyForPolymorphicType( + key: string, + typeClass: string, + method: string + ): string; + /** + * Normalizes a part of the JSON payload returned by + * the server. You should override this method, munge the hash + * and call super if you have generic normalization to do. + */ + normalize(modelClass: Model, resourceHash: {}, prop?: string): {}; + /** + * This method allows you to push a payload containing top-level + * collections of records organized per type. + */ + pushPayload(store: Store, payload: {}): any; + /** + * This method is used to convert each JSON root key in the payload + * into a modelName that it can use to look up the appropriate model for + * that part of the payload. + */ + modelNameFromPayloadKey(key: string): string; + /** + * Called when a record is saved in order to convert the + * record into JSON. + */ + serialize(snapshot: Snapshot, options: {}): {}; + /** + * You can use this method to customize the root keys serialized into the JSON. + * The hash property should be modified by reference (possibly using something like _.extend) + * By default the REST Serializer sends the modelName of a model, which is a camelized + * version of the name. + */ + serializeIntoHash( + hash: {}, + typeClass: Model, + snapshot: Snapshot, + options: {} + ): any; + /** + * You can use `payloadKeyFromModelName` to override the root key for an outgoing + * request. By default, the RESTSerializer returns a camelized version of the + * model's name. + */ + payloadKeyFromModelName(modelName: string): string; + /** + * You can use this method to customize how polymorphic objects are serialized. + * By default the REST Serializer creates the key by appending `Type` to + * the attribute and value from the model's camelcased model name. + */ + serializePolymorphicType( + snapshot: Snapshot, + json: {}, + relationship: {} + ): any; + /** + * You can use this method to customize how a polymorphic relationship should + * be extracted. + */ + extractPolymorphicRelationship( + relationshipType: {}, + relationshipHash: {}, + relationshipOptions: {} + ): {}; + /** + * `modelNameFromPayloadType` can be used to change the mapping for a DS model + * name, taken from the value in the payload. + */ + modelNameFromPayloadType(payloadType: string): string; + /** + * `payloadTypeFromModelName` can be used to change the mapping for the type in + * the payload, taken from the model name. + */ + payloadTypeFromModelName(modelName: string): string; + } + /** + * The `DS.BooleanTransform` class is used to serialize and deserialize + * boolean attributes on Ember Data record objects. This transform is + * used when `boolean` is passed as the type parameter to the + * [DS.attr](../../data#method_attr) function. + */ + class BooleanTransform extends Transform {} + /** + * The `DS.DateTransform` class is used to serialize and deserialize + * date attributes on Ember Data record objects. This transform is used + * when `date` is passed as the type parameter to the + * [DS.attr](../../data#method_attr) function. It uses the [`ISO 8601`](https://en.wikipedia.org/wiki/ISO_8601) + * standard. + */ + class DateTransform extends Transform {} + /** + * The `DS.NumberTransform` class is used to serialize and deserialize + * numeric attributes on Ember Data record objects. This transform is + * used when `number` is passed as the type parameter to the + * [DS.attr](../../data#method_attr) function. + */ + class NumberTransform extends Transform {} + /** + * The `DS.StringTransform` class is used to serialize and deserialize + * string attributes on Ember Data record objects. This transform is + * used when `string` is passed as the type parameter to the + * [DS.attr](../../data#method_attr) function. + */ + class StringTransform extends Transform {} + /** + * The `DS.Transform` class is used to serialize and deserialize model + * attributes when they are saved or loaded from an + * adapter. Subclassing `DS.Transform` is useful for creating custom + * attributes. All subclasses of `DS.Transform` must implement a + * `serialize` and a `deserialize` method. + */ + class Transform extends Ember.Object { + /** + * When given a deserialized value from a record attribute this + * method must return the serialized value. + */ + serialize(deserialized: any, options: AttrOptions): any; + /** + * When given a serialize value from a JSON object this method must + * return the deserialized value for the record attribute. + */ + deserialize(serialized: any, options: AttrOptions): any; + } + /** + * An adapter is an object that receives requests from a store and + * translates them into the appropriate action to take against your + * persistence layer. The persistence layer is usually an HTTP API, but + * may be anything, such as the browser's local storage. Typically the + * adapter is not invoked directly instead its functionality is accessed + * through the `store`. + */ + class Adapter extends Ember.Object { + /** + * If you would like your adapter to use a custom serializer you can + * set the `defaultSerializer` property to be the name of the custom + * serializer. + */ + defaultSerializer: string; + /** + * The `findRecord()` method is invoked when the store is asked for a record that + * has not previously been loaded. In response to `findRecord()` being called, you + * should query your persistence layer for a record with the given ID. The `findRecord` + * method should return a promise that will resolve to a JavaScript object that will be + * normalized by the serializer. + */ + findRecord( + store: Store, + type: Model, + id: string, + snapshot: Snapshot + ): Promise; + /** + * The `findAll()` method is used to retrieve all records for a given type. + */ + findAll( + store: Store, + type: Model, + sinceToken: string, + snapshotRecordArray: SnapshotRecordArray + ): Promise; + /** + * This method is called when you call `query` on the store. + */ + query( + store: Store, + type: Model, + query: {}, + recordArray: AdapterPopulatedRecordArray + ): Promise; + /** + * The `queryRecord()` method is invoked when the store is asked for a single + * record through a query object. + */ + queryRecord(store: Store, type: Model, query: {}): Promise; + /** + * If the globally unique IDs for your records should be generated on the client, + * implement the `generateIdForRecord()` method. This method will be invoked + * each time you create a new record, and the value returned from it will be + * assigned to the record's `primaryKey`. + */ + generateIdForRecord( + store: Store, + type: Model, + inputProperties: {} + ): string | number; + /** + * Proxies to the serializer's `serialize` method. + */ + serialize(snapshot: Snapshot, options: {}): {}; + /** + * Implement this method in a subclass to handle the creation of + * new records. + */ + createRecord( + store: Store, + type: Model, + snapshot: Snapshot + ): Promise; + /** + * Implement this method in a subclass to handle the updating of + * a record. + */ + updateRecord( + store: Store, + type: Model, + snapshot: Snapshot + ): Promise; + /** + * Implement this method in a subclass to handle the deletion of + * a record. + */ + deleteRecord( + store: Store, + type: Model, + snapshot: Snapshot + ): Promise; + /** + * By default the store will try to coalesce all `fetchRecord` calls within the same runloop + * into as few requests as possible by calling groupRecordsForFindMany and passing it into a findMany call. + * You can opt out of this behaviour by either not implementing the findMany hook or by setting + * coalesceFindRequests to false. + */ + coalesceFindRequests: boolean; + /** + * The store will call `findMany` instead of multiple `findRecord` + * requests to find multiple records at once if coalesceFindRequests + * is true. + */ + findMany( + store: Store, + type: Model, + ids: any[], + snapshots: any[] + ): Promise; + /** + * Organize records into groups, each of which is to be passed to separate + * calls to `findMany`. + */ + groupRecordsForFindMany(store: Store, snapshots: any[]): any[]; + /** + * This method is used by the store to determine if the store should + * reload a record from the adapter when a record is requested by + * `store.findRecord`. + */ + shouldReloadRecord(store: Store, snapshot: Snapshot): boolean; + /** + * This method is used by the store to determine if the store should + * reload all records from the adapter when records are requested by + * `store.findAll`. + */ + shouldReloadAll( + store: Store, + snapshotRecordArray: SnapshotRecordArray + ): boolean; + /** + * This method is used by the store to determine if the store should + * reload a record after the `store.findRecord` method resolves a + * cached record. + */ + shouldBackgroundReloadRecord( + store: Store, + snapshot: Snapshot + ): boolean; + /** + * This method is used by the store to determine if the store should + * reload a record array after the `store.findAll` method resolves + * with a cached record array. + */ + shouldBackgroundReloadAll( + store: Store, + snapshotRecordArray: SnapshotRecordArray + ): boolean; + } + /** + * `DS.Serializer` is an abstract base class that you should override in your + * application to customize it for your backend. The minimum set of methods + * that you should implement is: + */ + class Serializer extends Ember.Object { + /** + * The `store` property is the application's `store` that contains + * all records. It can be used to look up serializers for other model + * types that may be nested inside the payload response. + */ + store: Store; + /** + * The `normalizeResponse` method is used to normalize a payload from the + * server to a JSON-API Document. + */ + normalizeResponse( + store: Store, + primaryModelClass: Model, + payload: {}, + id: string | number, + requestType: string + ): {}; + /** + * The `serialize` method is used when a record is saved in order to convert + * the record into the form that your external data source expects. + */ + serialize(snapshot: Snapshot, options: {}): {}; + /** + * The `normalize` method is used to convert a payload received from your + * external data source into the normalized form `store.push()` expects. You + * should override this method, munge the hash and return the normalized + * payload. + */ + normalize(typeClass: Model, hash: {}): {}; + } + } + export default DS; } -export default DS; -declare module 'ember' { +declare module "ember" { + import DS from "ember-data"; namespace Ember { /* - * The store is automatically injected into these objects - * - * https://github.com/emberjs/data/blob/05e95280e11c411177f2fbcb65fd83488d6a9d89/addon/setup-container.js#L71-L78 - */ + * The store is automatically injected into these objects + * + * https://github.com/emberjs/data/blob/05e95280e11c411177f2fbcb65fd83488d6a9d89/addon/setup-container.js#L71-L78 + */ interface Route { store: DS.Store; } @@ -1692,3 +2067,90 @@ declare module 'ember' { } } } +declare module 'ember-data/adapter' { + import DS from 'ember-data'; + export default DS.Adapter; +} +declare module 'ember-data/adapters/errors' { + import DS from 'ember-data'; + const AdapterError: typeof DS.AdapterError; + const InvalidError: typeof DS.InvalidError; + const UnauthorizedError: typeof DS.UnauthorizedError; + const ForbiddenError: typeof DS.ForbiddenError; + const NotFoundError: typeof DS.NotFoundError; + const ConflictError: typeof DS.ConflictError; + const ServerError: typeof DS.ServerError; + const TimeoutError: typeof DS.TimeoutError; + const AbortError: typeof DS.AbortError; + const errorsHashToArray: typeof DS.errorsHashToArray; + const errorsArrayToHash: typeof DS.errorsArrayToHash; +} +declare module 'ember-data/adapters/json-api' { + import DS from 'ember-data'; + export default DS.JSONAPIAdapter; +} +declare module 'ember-data/adapters/rest' { + import DS from 'ember-data'; + export default DS.RESTAdapter; +} +declare module 'ember-data/attr' { + import DS from 'ember-data'; + export default DS.attr; +} +declare module 'ember-data/model' { + import DS from 'ember-data'; + export default DS.Model; +} +declare module 'ember-data/relationships' { + import DS from 'ember-data'; + const hasMany: typeof DS.hasMany; + const belongsTo: typeof DS.belongsTo; +} +declare module 'ember-data/serializer' { + import DS from 'ember-data'; + export default DS.Serializer; +} +declare module 'ember-data/serializers/embedded-records-mixin' { + import DS from 'ember-data'; + export default DS.EmbeddedRecordsMixin; +} +declare module 'ember-data/serializers/json-api' { + import DS from 'ember-data'; + export default DS.JSONAPISerializer; +} +declare module 'ember-data/serializers/json' { + import DS from 'ember-data'; + export default DS.JSONSerializer; +} +declare module 'ember-data/serializers/rest' { + import DS from 'ember-data'; + export default DS.RESTSerializer; +} +declare module "ember-data/store" { + import DS from "ember-data"; + export default DS.Store; +} +declare module "ember-data/transform" { + import DS from "ember-data"; + export default DS.Transform; +} +declare module "ember-data/transforms/boolean" { + import DS from "ember-data"; + export default DS.BooleanTransform; +} +declare module "ember-data/transforms/date" { + import DS from "ember-data"; + export default DS.DateTransform; +} +declare module "ember-data/transforms/number" { + import DS from "ember-data"; + export default DS.NumberTransform; +} +declare module "ember-data/transforms/string" { + import DS from "ember-data"; + export default DS.StringTransform; +} +declare module "ember-data/transforms/transform" { + import DS from "ember-data"; + export default DS.Transform; +} diff --git a/types/ember-data/model.d.ts b/types/ember-data/model.d.ts deleted file mode 100644 index ccb8a8f6b4..0000000000 --- a/types/ember-data/model.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from './index'; -export default DS.Model; diff --git a/types/ember-data/relationships.d.ts b/types/ember-data/relationships.d.ts deleted file mode 100644 index 2a789a206a..0000000000 --- a/types/ember-data/relationships.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import DS from './index'; -export const hasMany: typeof DS.hasMany; -export const belongsTo: typeof DS.belongsTo; diff --git a/types/ember-data/serializer.d.ts b/types/ember-data/serializer.d.ts deleted file mode 100644 index 2195771c81..0000000000 --- a/types/ember-data/serializer.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from './index'; -export default DS.Serializer; diff --git a/types/ember-data/serializers/embedded-records-mixin.d.ts b/types/ember-data/serializers/embedded-records-mixin.d.ts deleted file mode 100644 index 6223a4e143..0000000000 --- a/types/ember-data/serializers/embedded-records-mixin.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from '../index'; -export default DS.EmbeddedRecordsMixin; diff --git a/types/ember-data/serializers/json-api.d.ts b/types/ember-data/serializers/json-api.d.ts deleted file mode 100644 index 0260008eca..0000000000 --- a/types/ember-data/serializers/json-api.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from '../index'; -export default DS.JSONAPISerializer; diff --git a/types/ember-data/serializers/json.d.ts b/types/ember-data/serializers/json.d.ts deleted file mode 100644 index d19c16b9df..0000000000 --- a/types/ember-data/serializers/json.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from '../index'; -export default DS.JSONSerializer; diff --git a/types/ember-data/serializers/rest.d.ts b/types/ember-data/serializers/rest.d.ts deleted file mode 100644 index 8cbbe82467..0000000000 --- a/types/ember-data/serializers/rest.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from '../index'; -export default DS.RESTSerializer; diff --git a/types/ember-data/store.d.ts b/types/ember-data/store.d.ts deleted file mode 100644 index 948f477e7c..0000000000 --- a/types/ember-data/store.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from './index'; -export default DS.Store; diff --git a/types/ember-data/transform.d.ts b/types/ember-data/transform.d.ts deleted file mode 100644 index 0dc2e2cd88..0000000000 --- a/types/ember-data/transform.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from './index'; -export default DS.Transform; diff --git a/types/ember-data/transforms/boolean.d.ts b/types/ember-data/transforms/boolean.d.ts deleted file mode 100644 index aae3eb4872..0000000000 --- a/types/ember-data/transforms/boolean.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from '../index'; -export default DS.BooleanTransform; diff --git a/types/ember-data/transforms/date.d.ts b/types/ember-data/transforms/date.d.ts deleted file mode 100644 index fb56f582df..0000000000 --- a/types/ember-data/transforms/date.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from '../index'; -export default DS.DateTransform; diff --git a/types/ember-data/transforms/number.d.ts b/types/ember-data/transforms/number.d.ts deleted file mode 100644 index 331a42fe22..0000000000 --- a/types/ember-data/transforms/number.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from '../index'; -export default DS.NumberTransform; diff --git a/types/ember-data/transforms/string.d.ts b/types/ember-data/transforms/string.d.ts deleted file mode 100644 index 5f8756f2cf..0000000000 --- a/types/ember-data/transforms/string.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from '../index'; -export default DS.StringTransform; diff --git a/types/ember-data/transforms/transform.d.ts b/types/ember-data/transforms/transform.d.ts deleted file mode 100644 index a980eb6940..0000000000 --- a/types/ember-data/transforms/transform.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -import DS from '../index'; -export default DS.Transform; diff --git a/types/ember-data/tsconfig.json b/types/ember-data/tsconfig.json index 3eaaeb0509..5f7c297ec7 100644 --- a/types/ember-data/tsconfig.json +++ b/types/ember-data/tsconfig.json @@ -15,28 +15,8 @@ "noEmit": true, "forceConsistentCasingInFileNames": true }, - "files": [ - "adapters/errors.d.ts", - "adapters/json-api.d.ts", - "adapters/rest.d.ts", - "serializers/embedded-records-mixin.d.ts", - "serializers/json-api.d.ts", - "serializers/json.d.ts", - "serializers/rest.d.ts", - "transforms/boolean.d.ts", - "transforms/date.d.ts", - "transforms/number.d.ts", - "transforms/string.d.ts", - "transforms/transform.d.ts", - "adapter.d.ts", - "attr.d.ts", "index.d.ts", - "model.d.ts", - "relationships.d.ts", - "serializer.d.ts", - "store.d.ts", - "transform.d.ts", "test/lib/assert.ts", "test/model.ts", "test/module-api.ts", diff --git a/types/ember-data/tslint.json b/types/ember-data/tslint.json index dd3a7f529c..6d765664cf 100644 --- a/types/ember-data/tslint.json +++ b/types/ember-data/tslint.json @@ -11,6 +11,8 @@ "only-arrow-functions": false, "no-empty-interface": false, "prefer-const": false, - "no-unnecessary-generics": false + "no-unnecessary-generics": false, + "no-declare-current-package": false, + "no-self-import": false } } From 39d8d03a0f4fec92203fd815690c0b0bbdd19d05 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Wed, 13 Dec 2017 22:27:07 -0300 Subject: [PATCH 142/298] Move v16 types to ./v16 folder. --- types/hapi/index.d.ts | 2763 +---------------- types/hapi/test/request/event-types.ts | 70 +- types/hapi/test/request/get-log.ts | 33 +- types/hapi/test/response/error.ts | 46 +- types/hapi/test/route/config.ts | 38 +- types/hapi/tsconfig.json | 113 +- types/hapi/v16/index.d.ts | 2723 ++++++++++++++++ types/hapi/{ => v16}/test/connection/table.ts | 2 +- .../{ => v16}/test/continuation/errors.ts | 4 +- .../getting-started/01-creating-a-server.ts | 0 .../test/getting-started/02-adding-routes.ts | 0 .../03-serving-static-content.ts | 0 .../test/getting-started/04-using-plugins.ts | 0 types/hapi/{ => v16}/test/path/catch-all.ts | 2 +- types/hapi/{ => v16}/test/path/parameters.ts | 2 +- types/hapi/{ => v16}/test/plugins/options.ts | 2 +- types/hapi/{ => v16}/test/reply/continue.ts | 2 +- types/hapi/{ => v16}/test/reply/entity.ts | 2 +- types/hapi/{ => v16}/test/reply/redirect.ts | 2 +- types/hapi/{ => v16}/test/reply/reply.ts | 4 +- .../hapi/{ => v16}/test/reply/state_cookie.ts | 2 +- types/hapi/v16/test/request/event-types.ts | 30 + .../test/request/generate-response.ts | 2 +- types/hapi/v16/test/request/get-log.ts | 12 + types/hapi/{ => v16}/test/request/log.ts | 2 +- types/hapi/v16/test/request/query.ts | 14 + .../hapi/{ => v16}/test/request/set-method.ts | 2 +- types/hapi/{ => v16}/test/request/set-url.ts | 4 +- types/hapi/{ => v16}/test/request/tail.ts | 2 +- .../test/response/error-representation.ts | 6 +- types/hapi/v16/test/response/error.ts | 25 + types/hapi/{ => v16}/test/response/events.ts | 2 +- .../{ => v16}/test/response/flow-control.ts | 2 +- .../test/route/additional-options.ts | 2 +- types/hapi/{ => v16}/test/route/auth.ts | 2 +- types/hapi/v16/test/route/config.ts | 46 + types/hapi/v16/test/route/handler.ts | 10 + types/hapi/{ => v16}/test/route/plugins.ts | 4 +- .../{ => v16}/test/route/prerequisites.ts | 2 +- .../{ => v16}/test/route/public-interface.ts | 2 +- types/hapi/{ => v16}/test/route/validate.ts | 4 +- types/hapi/{ => v16}/test/server/app.ts | 2 +- types/hapi/{ => v16}/test/server/auth.ts | 4 +- types/hapi/{ => v16}/test/server/bind.ts | 2 +- types/hapi/{ => v16}/test/server/cache.ts | 2 +- .../test/server/connection-options.ts | 2 +- .../hapi/{ => v16}/test/server/connections.ts | 2 +- types/hapi/{ => v16}/test/server/decoder.ts | 2 +- types/hapi/{ => v16}/test/server/decorate.ts | 8 +- .../hapi/{ => v16}/test/server/dependency.ts | 2 +- types/hapi/{ => v16}/test/server/emit.ts | 2 +- types/hapi/{ => v16}/test/server/encoder.ts | 2 +- types/hapi/{ => v16}/test/server/event.ts | 2 +- types/hapi/{ => v16}/test/server/expose.ts | 2 +- types/hapi/{ => v16}/test/server/ext.ts | 2 +- types/hapi/{ => v16}/test/server/handler.ts | 4 +- types/hapi/{ => v16}/test/server/info.ts | 2 +- .../hapi/{ => v16}/test/server/initialize.ts | 4 +- types/hapi/{ => v16}/test/server/inject.ts | 2 +- types/hapi/{ => v16}/test/server/listener.ts | 2 +- types/hapi/{ => v16}/test/server/load.ts | 2 +- types/hapi/{ => v16}/test/server/log.ts | 2 +- types/hapi/{ => v16}/test/server/lookup.ts | 2 +- types/hapi/{ => v16}/test/server/match.ts | 2 +- types/hapi/{ => v16}/test/server/method.ts | 2 +- types/hapi/{ => v16}/test/server/methods.ts | 2 +- types/hapi/{ => v16}/test/server/mime.ts | 2 +- types/hapi/{ => v16}/test/server/new.ts | 4 +- types/hapi/{ => v16}/test/server/on.ts | 2 +- types/hapi/{ => v16}/test/server/once.ts | 2 +- types/hapi/{ => v16}/test/server/path.ts | 2 +- types/hapi/{ => v16}/test/server/plugins.ts | 2 +- types/hapi/{ => v16}/test/server/realm.ts | 2 +- types/hapi/{ => v16}/test/server/register.ts | 2 +- types/hapi/{ => v16}/test/server/route.ts | 2 +- types/hapi/{ => v16}/test/server/select.ts | 2 +- types/hapi/{ => v16}/test/server/settings.ts | 2 +- types/hapi/{ => v16}/test/server/start.ts | 4 +- types/hapi/{ => v16}/test/server/state.ts | 2 +- types/hapi/{ => v16}/test/server/stop.ts | 2 +- types/hapi/{ => v16}/test/server/table.ts | 2 +- types/hapi/{ => v16}/test/server/version.ts | 2 +- types/hapi/v16/tsconfig.json | 102 + types/hapi/{v17 => v16}/tslint.json | 0 84 files changed, 3270 insertions(+), 2915 deletions(-) create mode 100644 types/hapi/v16/index.d.ts rename types/hapi/{ => v16}/test/connection/table.ts (94%) rename types/hapi/{ => v16}/test/continuation/errors.ts (95%) rename types/hapi/{ => v16}/test/getting-started/01-creating-a-server.ts (100%) rename types/hapi/{ => v16}/test/getting-started/02-adding-routes.ts (100%) rename types/hapi/{ => v16}/test/getting-started/03-serving-static-content.ts (100%) rename types/hapi/{ => v16}/test/getting-started/04-using-plugins.ts (100%) rename types/hapi/{ => v16}/test/path/catch-all.ts (89%) rename types/hapi/{ => v16}/test/path/parameters.ts (95%) rename types/hapi/{ => v16}/test/plugins/options.ts (95%) rename types/hapi/{ => v16}/test/reply/continue.ts (91%) rename types/hapi/{ => v16}/test/reply/entity.ts (93%) rename types/hapi/{ => v16}/test/reply/redirect.ts (84%) rename types/hapi/{ => v16}/test/reply/reply.ts (92%) rename types/hapi/{ => v16}/test/reply/state_cookie.ts (95%) create mode 100644 types/hapi/v16/test/request/event-types.ts rename types/hapi/{ => v16}/test/request/generate-response.ts (93%) create mode 100644 types/hapi/v16/test/request/get-log.ts rename types/hapi/{ => v16}/test/request/log.ts (93%) create mode 100644 types/hapi/v16/test/request/query.ts rename types/hapi/{ => v16}/test/request/set-method.ts (91%) rename types/hapi/{ => v16}/test/request/set-url.ts (90%) rename types/hapi/{ => v16}/test/request/tail.ts (94%) rename types/hapi/{ => v16}/test/response/error-representation.ts (84%) create mode 100644 types/hapi/v16/test/response/error.ts rename types/hapi/{ => v16}/test/response/events.ts (95%) rename types/hapi/{ => v16}/test/response/flow-control.ts (88%) rename types/hapi/{ => v16}/test/route/additional-options.ts (98%) rename types/hapi/{ => v16}/test/route/auth.ts (94%) create mode 100644 types/hapi/v16/test/route/config.ts create mode 100644 types/hapi/v16/test/route/handler.ts rename types/hapi/{ => v16}/test/route/plugins.ts (92%) rename types/hapi/{ => v16}/test/route/prerequisites.ts (97%) rename types/hapi/{ => v16}/test/route/public-interface.ts (93%) rename types/hapi/{ => v16}/test/route/validate.ts (96%) rename types/hapi/{ => v16}/test/server/app.ts (87%) rename types/hapi/{ => v16}/test/server/auth.ts (96%) rename types/hapi/{ => v16}/test/server/bind.ts (93%) rename types/hapi/{ => v16}/test/server/cache.ts (96%) rename types/hapi/{ => v16}/test/server/connection-options.ts (96%) rename types/hapi/{ => v16}/test/server/connections.ts (89%) rename types/hapi/{ => v16}/test/server/decoder.ts (90%) rename types/hapi/{ => v16}/test/server/decorate.ts (92%) rename types/hapi/{ => v16}/test/server/dependency.ts (93%) rename types/hapi/{ => v16}/test/server/emit.ts (90%) rename types/hapi/{ => v16}/test/server/encoder.ts (90%) rename types/hapi/{ => v16}/test/server/event.ts (90%) rename types/hapi/{ => v16}/test/server/expose.ts (92%) rename types/hapi/{ => v16}/test/server/ext.ts (96%) rename types/hapi/{ => v16}/test/server/handler.ts (94%) rename types/hapi/{ => v16}/test/server/info.ts (92%) rename types/hapi/{ => v16}/test/server/initialize.ts (72%) rename types/hapi/{ => v16}/test/server/inject.ts (93%) rename types/hapi/{ => v16}/test/server/listener.ts (95%) rename types/hapi/{ => v16}/test/server/load.ts (82%) rename types/hapi/{ => v16}/test/server/log.ts (89%) rename types/hapi/{ => v16}/test/server/lookup.ts (91%) rename types/hapi/{ => v16}/test/server/match.ts (91%) rename types/hapi/{ => v16}/test/server/method.ts (98%) rename types/hapi/{ => v16}/test/server/methods.ts (91%) rename types/hapi/{ => v16}/test/server/mime.ts (94%) rename types/hapi/{ => v16}/test/server/new.ts (96%) rename types/hapi/{ => v16}/test/server/on.ts (96%) rename types/hapi/{ => v16}/test/server/once.ts (91%) rename types/hapi/{ => v16}/test/server/path.ts (91%) rename types/hapi/{ => v16}/test/server/plugins.ts (90%) rename types/hapi/{ => v16}/test/server/realm.ts (86%) rename types/hapi/{ => v16}/test/server/register.ts (90%) rename types/hapi/{ => v16}/test/server/route.ts (93%) rename types/hapi/{ => v16}/test/server/select.ts (91%) rename types/hapi/{ => v16}/test/server/settings.ts (84%) rename types/hapi/{ => v16}/test/server/start.ts (76%) rename types/hapi/{ => v16}/test/server/state.ts (95%) rename types/hapi/{ => v16}/test/server/stop.ts (87%) rename types/hapi/{ => v16}/test/server/table.ts (89%) rename types/hapi/{ => v16}/test/server/version.ts (77%) create mode 100644 types/hapi/v16/tsconfig.json rename types/hapi/{v17 => v16}/tslint.json (100%) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index a97a9f1edb..151246f5e9 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for hapi 16.1 +// Type definitions for hapi 17.0 // Project: https://github.com/hapijs/hapi -// Definitions by: Jason Swearingen , AJP +// Definitions by: Marc Bornträger +// Rafael Souza Fijalkowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -12,2712 +13,58 @@ + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * - * - * Removal of IPromise replaced with Promise - * Removal of IReplyStrict<> - * Removal of IReply replaced with different interfaces like: - * ReplyWithContinue - * ReplyNoContinue, etc. - * Renaming of all interfaces to remove preceding I in preparation of dtslint - */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ /// -import Events = require("events"); -import stream = require("stream"); -import http = require("http"); -import https = require("https"); -import url = require("url"); -import zlib = require("zlib"); -import domain = require("domain"); - -import * as Boom from 'boom'; -import { - ValidationOptions as JoiValidationOptions, - SchemaMap as JoiSchemaMap, - Schema as JoiSchema, -} from 'joi'; -// TODO check JoiValidationObject is correct for "a Joi validation object" -type JoiValidationObject = JoiSchema | JoiSchemaMap | (JoiSchema | JoiSchemaMap)[]; - -import * as Catbox from 'catbox'; -import { MimosOptions } from 'mimos'; -import Podium = require('podium'); -import * as Shot from 'shot'; - -export interface Dictionary { - [key: string]: T; -} - -/** - * Server - * The Server object is the main application container. The server manages all incoming connections along with all the facilities provided by the framework. A server can contain more than one connection (e.g. listen to port 80 and 8080). - * [See docs](https://hapijs.com/api/16.1.1#server) - * [See docs](https://hapijs.com/api/16.1.1#server-properties) - * [See docs](https://hapijs.com/api/16.1.1#server-events) - */ -export class Server extends Podium { - /** - * Creates a new Server object - */ - constructor(options?: ServerOptions); - - /** - * Provides a safe place to store server-specific run-time application data without potential conflicts with the framework internals. The data can be accessed whenever the server is accessible. Initialized with an empty object. - * [See docs](https://hapijs.com/api/16.1.1#serverapp) - */ - app?: any; - /** - * An array containing the server's connections. When the server object is returned from server.select(), the connections array only includes the connections matching the selection criteria. - * [See docs](https://hapijs.com/api/16.1.1#serverconnections) - */ - connections: ServerConnection[]; - /** - * When the server contains exactly one connection, info is an object containing information about the sole connection - * When the server contains more than one connection, each server.connections array member provides its own connection.info. - * [See docs](https://hapijs.com/api/16.1.1#serverinfo) - */ - info: ServerConnectionInfo | null; - /** - * An object containing the process load metrics (when load.sampleInterval is enabled): - * [See docs](https://hapijs.com/api/16.1.1#serverload) - */ - load: { - /** event loop delay milliseconds. */ - eventLoopDelay: number; - /** V8 heap usage. */ - heapUsed: number; - /** RSS memory usage. */ - rss: number; - }; - /** - * When the server contains exactly one connection, listener is the node HTTP server object of the sole connection. - * When the server contains more than one connection, each server.connections array member provides its own connection.listener. - * [See docs](https://hapijs.com/api/16.1.1#serverlistener) - */ - listener: ServerListener | null; - /** - * An object providing access to the server methods cs://hapijs.com/api/16.1.1#servermethodname-method-options} where each server method name is an object property. - * [See docs](https://hapijs.com/api/16.1.1#servermethods) - */ - methods: Dictionary; - /** - * Provides access to the server MIME database used for setting content-type information. The object must not be modified directly but only through the mime server setting. - * [See docs](https://hapijs.com/api/16.1.1#servermime) - */ - readonly mime: {path(path: string): {type: string}}; - /** - * An object containing the values exposed by each plugin registered where each key is a plugin name and the values are the exposed properties by each plugin using server.expose(). Plugins may set the value of the server.plugins[name] object directly or via the server.expose() method. - * [See docs](https://hapijs.com/api/16.1.1#serverplugins) - */ - plugins: PluginsStates; - /** - * The realm object contains server-wide or plugin-specific state that can be shared across various methods. For example, when calling server.bind(), the active realm settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). Realms are a limited version of a sandbox where plugins can maintain state used by the framework when adding routes, extensions, and other properties. - * [See docs](https://hapijs.com/api/16.1.1#serverrealm) - */ - readonly realm: ServerRealm; - /** - * When the server contains exactly one connection, registrations is an object where each key is a registered plugin name - * When the server contains more than one connection, each server.connections array member provides its own connection.registrations. - * TODO check and offer PR to update Hapi docs: Assuming readonly. - * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) - */ - readonly registrations: ServerRegisteredPlugins; - /** - * The root server object containing all the connections and the root server methods (e.g. start(), stop(), connection()). - * TODO, check and offer PR to update Hapi docs: Marked as optional as presumably root server does not reference itself. - * [See docs](https://hapijs.com/api/16.1.1#serverroot) - */ - root?: Server; - /** - * The server configuration object after defaults applied. - * [See docs](https://hapijs.com/api/16.1.1#serversettings) - */ - settings: ServerOptions; - /** - * The hapi module version number. - * [See docs](https://hapijs.com/api/16.1.1#serverversion) - */ - version: string; - - /** - * [See docs](https://hapijs.com/api/16.1.1#serverauthapi) - * [See docs](https://hapijs.com/api/16.1.1#serverauthdefaultoptions) - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) - * [See docs](https://hapijs.com/api/16.1.1#serverauthstrategyname-scheme-mode-options) - * [See docs](https://hapijs.com/api/16.1.1#serverauthteststrategy-request-next) - */ - auth: ServerAuth; - - /** - * Sets a global context used as the default bind object when adding a route or an extension - * When setting context inside a plugin, the context is applied only to methods set up by the plugin. Note that the context applies only to routes and extensions added after it has been set. Ignored if the method being bound is an arrow function. - * @param context the object used to bind this in handler and extension methods. - * [See docs](https://hapijs.com/api/16.1.1#serverbindcontext) - */ - bind(context: any): void; - /** - * [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) - * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) - */ - cache: ServerCacheMethod; - /** - * Adds an incoming server connection - * Returns a server object with the new connections selected. - * Must be called before any other server method that modifies connections is called for it to apply to the new connection (e.g. server.state()) - * Note that the options object is deeply cloned (with the exception of listener which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on. - * - * [See docs](https://hapijs.com/api/16.1.1#serverconnectionoptions) for various advantage topics covering usage and caveats around use of the function in plugin register(), connectionless plugins calling connection(), etc. - * @param connection a connection configuration object or array of objects - */ - connection(options?: ServerConnectionOptions[]): Server; - connection(options?: ServerConnectionOptions): Server; - // connection: (options: ServerConnectionOptions[] | ServerConnectionOptions) => Server; - /** - * Registers a custom content decoding compressor to extend the built-in support for 'gzip' and 'deflate' - * [See docs](https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder) - * @param encoding the decoder name string. - * @param decoder a function using the signature function(options) where options are the encoding specific options configured in the route payload.compression configuration option, and the return value is an object compatible with the output of node's zlib.createGunzip(). - */ - decoder(encoding: string, decoder: ((options: CompressionDecoderSettings) => zlib.Gunzip)): void; - /** - * Extends various framework interfaces with custom methods - * Note that decorations apply to the entire server and all its connections regardless of current selection. - * [See docs](https://hapijs.com/api/16.1.1#serverdecoratetype-property-method-options) - * - * NOTE: it's not possible to type the result of this action. - * It's advised that in a custom definition file, you extend the ReplyNoContinue - * and ReplyWithContinue functions. See Inert `.file` for an example. - * Or if it is not part of a library / plugin then you use a namespace within - * your code to type the request, server and or reply. See - * [tests/server/decorate.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hapi/tests/server/decorate.ts) - * for examples. - * @param type the interface being decorated. Supported types: - * * 'request' - adds methods to the Request object. - * * 'reply' - adds methods to the reply interface. - * * 'server' - adds methods to the Server object. - * @param property the object decoration key name. - * @param method the extension function or other value. - * @param options if the type is 'request', supports the following optional settings: - * * apply - if true, the method function is invoked using the signature function(request) where request is the current request object and the returned value is assigned as the decoration. - */ - decorate(type: 'request' | 'reply' | 'server', property: string, method: Function): void; - decorate(type: 'request', property: string, method: Function, options?: {apply: false}): void; - decorate(type: 'request', property: string, method: (request: Request) => Function, options: {apply: true}): void; - /** - * The server.decorate('server', ...) method can modify this prototype/interface. - * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts - * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) - */ - // [index: string]: any; - /** - * Used within a plugin to declare a required dependency on other plugins - * The after method is identical to setting a server extension point on 'onPreStart'. Connectionless plugins (those with attributes.connections set to false) can only depend on other connectionless plugins (server initialization will fail even of the dependency is loaded but is not connectionless). - * Dependencies can also be set via the register attributes property (does not support setting after). - * [See docs](https://hapijs.com/api/16.1.1#serverdependencydependencies-after) - * @param dependencies a single string or array of plugin name strings which must be registered in order for this plugin to operate. Plugins listed must be registered before the server is initialized or started. Does not provide version dependency which should be implemented using npm peer dependencies. - * @param after an optional function called after all the specified dependencies have been registered and before the server starts. The function is only called if the server is initialized or started. If a circular dependency is detected, an exception is thrown (e.g. two plugins each has an after function to be called after the other). The function signature is function(server, next) - */ - dependency(dependencies: string | string[], after?: AfterDependencyLoadCallback): void; - /** - * Emits a custom application event update to all the subscribed listeners - * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. - * [See docs](https://hapijs.com/api/16.1.1#serveremitcriteria-data-callback) - * @param criteria the event update criteria which if an object can have the following optional keys (unless noted otherwise): - * * name - the event name string (required). - * * channel - the channel name string. - * * tags - a tag string or array of tag strings. - * @param data the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. - * @param callback an optional callback method invoked when all subscribers have been notified using the signature function(). The callback is called only after all the listeners have been notified, including any event updates emitted earlier (the order of event updates are guaranteed to be in the order they were emitted). - */ - emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: any, callback?: () => void): void; - /** - * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' - * [See docs](https://hapijs.com/api/16.1.1#serverencoderencoding-encoder) - * @param encoding the encoder name string. - * @param encoder a function using the signature function(options) where options are the encoding specific options configured in the route compression configuration option, and the return value is an object compatible with the output of node's zlib.createGzip(). - */ - encoder(encoding: string, encoder: ((options: CompressionEncoderSettings) => zlib.Gzip)): void; - /** - * Register custom application events - * [See docs](https://hapijs.com/api/16.1.1#servereventevents) - * @param events see ApplicationEvent - */ - event(events: ApplicationEvent[]): void; - event(events: ApplicationEvent): void; - /** - * Used within a plugin to expose a property via server.plugins[name] - * [See docs](https://hapijs.com/api/16.1.1#serverexposekey-value) - * @param key the key assigned (server.plugins[name][key]). - * @param value the value assigned. - */ - expose(key: string, value: any): void; - /** - * Merges an object into to the existing content of server.plugins[name] - * Note that all properties of obj are deeply cloned into server.plugins[name], so you should avoid using this method for exposing large objects that may be expensive to clone or singleton objects such as database client objects. Instead favor the server.expose(key, value) form, which only copies a reference to value. - * [See docs](https://hapijs.com/api/16.1.1#serverexposeobj) - * @param obj the object merged into the exposed properties container. - */ - expose(obj: Object): void; - /** - * Registers an extension function in one of the available extension points - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * @param events see @ServerExtConfigurationObject - */ - ext(events: ServerStartExtConfigurationObject): void; - ext(events: ServerStartExtConfigurationObject[]): void; - ext(events: ServerRequestExtConfigurationObjectWithRequest): void; - ext(events: ServerRequestExtConfigurationObjectWithRequest[]): void; - /** - * Registers a single extension event using the same properties as used in server.ext(events), but passed as arguments. - * [See docs](https://hapijs.com/api/16.1.1#serverextevent-method-options) - * @param event the extension point event name. - * @param method a function or an array of functions to be executed at a specified point during request processing. - * @param options - */ - ext(event: ServerStartExtPoints, method: ServerExtFunction[], options?: ServerExtOptions): void; - ext(event: ServerStartExtPoints, method: ServerExtFunction, options?: ServerExtOptions): void; - ext(event: ServerRequestExtPoints, method: ServerExtRequestHandler[], options?: ServerExtOptions): void; - ext(event: ServerRequestExtPoints, method: ServerExtRequestHandler, options?: ServerExtOptions): void; - /** - * Registers a new handler type to be used in routes - * The method function can have a defaults object or function property. If the property is set to an object, that object is used as the default route config for routes using this handler. If the property is set to a function, the function uses the signature function(method) and returns the route default configuration. - * [See docs](https://hapijs.com/api/16.1.1#serverhandlername-method) - * @param name string name for the handler being registered. Cannot override any previously registered type. - * @param method the function used to generate the route handler using the signature function(route, options) where: - * * route - the route public interface object. - * * options - the configuration object provided in the handler config. - */ - handler(name: string, method: MakeRouteHandler): void; - /** - * Initializes the server (starts the caches, finalizes plugin registration) but does not start listening on the connection ports - * Note that if the method fails and the callback includes an error, the server is considered to be in an undefined state and should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and other event listeners will get confused by repeated attempts to start the server or make assumptions about the healthy state of the environment. It is recommended to assert that no error has been returned after calling initialize() to abort the process when the server fails to start properly. If you must try to resume after an error, call server.stop() first to reset the server state. - * [See docs](https://hapijs.com/api/16.1.1#serverinitializecallback) - * @param callback the callback method when server initialization is completed or failed with the signature function(err) - */ - initialize(callback: (err: Error) => void): void; - initialize(): Promise; - /** - * When the server contains exactly one connection, injects a request into the sole connection simulating an incoming HTTP request without making an actual socket connection. Injection is useful for testing purposes as well as for invoking routing logic internally without the overhead or limitations of the network stack. Utilizes the shot module for performing injections, with some additional options and response properties - * If no callback is provided, a Promise object is returned. - * When the server contains more than one connection, each server.connections array member provides its own connection.inject(). - * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) - * @param options can be assigned a string with the requested URI, or an object - * @param callback the callback function with signature function(res) - */ - inject(options: string | InjectedRequestOptions, callback: (res: InjectedResponseObject) => void): void; - inject(options: string | InjectedRequestOptions, ): Promise; - /** - * Logs server events that cannot be associated with a specific request. When called the server emits a 'log' event which can be used by other listeners or plugins to record the information or output to the console. - * [See docs](https://hapijs.com/api/16.1.1#serverlogtags-data-timestamp) - * @param tags a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. Any logs generated by the server internally include the 'hapi' tag along with event-specific information. - * @param data an optional message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. - * @param timestamp an optional timestamp expressed in milliseconds. Defaults to Date.now() (now). - */ - log(tags: string | string[], data?: string | Object | Function, timestamp?: number): void; - /** - * When the server contains exactly one connection, looks up a route configuration. - * When the server contains more than one connection, each server.connections array member provides its own connection.lookup() method. - * [See docs](https://hapijs.com/api/16.1.1#serverlookupid) - * @param id the route identifier as set in the route options. - * @return the route public interface object if found, otherwise null. - */ - lookup(id: string): RoutePublicInterface | null; - /** - * When the server contains exactly one connection, looks up a route configuration - * When the server contains more than one connection, each server.connections array member provides its own connection.match() method. - * [See docs](https://hapijs.com/api/16.1.1#servermatchmethod-path-host) - * @param method the HTTP method (e.g. 'GET', 'POST'). TODO check if it allows HEAD - * @param path the requested path (must begin with '/'). - * @param host optional hostname (to match against routes with vhost). - * @return the route public interface object if found, otherwise null. - */ - match(method: HTTP_METHODS, path: string, host?: string): RoutePublicInterface | null; - /** - * Registers a server method. Server methods are functions registered with the server and used throughout the application as a common utility. Their advantage is in the ability to configure them to use the built-in cache and share across multiple request handlers without having to create a common module. - * [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) - * @param name a unique method name used to invoke the method via server.methods[name]. Supports using nested names such as utils.users.get which will automatically create the missing path under server.methods and can be accessed for the previous example via server.methods.utils.users.get. When configured with caching enabled, server.methods[name].cache will be an object see ServerMethodNameCacheObject - * @param method the method function - * @param options optional configuration - */ - method(name: string, method: ServerMethod, options?: ServerMethodOptions): void; - /** - * Registers a server method function as described in server.method() using a configuration object - * [See docs](https://hapijs.com/api/16.1.1#servermethodmethods) - */ - method(methods: ServerMethodConfigurationObject[]): void; - method(methods: ServerMethodConfigurationObject): void; - /** - * Subscribe a handler to an event - * [See docs](https://hapijs.com/api/16.1.1#serveroncriteria-listener) - * @param criteria the subscription criteria which can be an event name string which can be any of the built-in server events or a custom application event registered with server.event(events). - * Or an see ServerEventCriteria. - * If 'start' - emitted when the server is started using server.start(). - * If 'stop' - emitted when the server is stopped using server.stop(). - * @param listener - */ - on(criteria: 'start' | 'stop' | string | ServerEventCriteria, listener: Function): void; - /** - * The 'log' event includes the event object and a tags object (where each tag is a key with the value true) - * [See docs](https://hapijs.com/api/16.1.1#server-events) - */ - on(criteria: 'log', listener: (event: ServerEventObject, tags: Podium.Tags) => void): void; - /** - * The 'request' and 'request-internal' events include the request object, the event object, and a tags object (where each tag is a key with the value true) - * [See docs](https://hapijs.com/api/16.1.1#server-events) - * TODO submit issue to TypeScript. Using 'request' | 'request-internal' removes the type - * interference when using code like: `server.on('request', (request, event, tags) => {...}` - * Same for 'response' | 'tail'. - */ - on(criteria: 'request', listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void): void; - on(criteria: 'request-internal', listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void): void; - /** - * The 'request-error' event includes the request object and the causing error err object - * [See docs](https://hapijs.com/api/16.1.1#server-events) - */ - on(criteria: 'request-error', listener: (request: Request, err: Error) => void): void; - /** - * The 'response' and 'tail' events include the request object - * [See docs](https://hapijs.com/api/16.1.1#server-events) - * See 'request' and 'request-internal' - */ - on(criteria: 'response', listener: (request: Request) => void): void; - on(criteria: 'tail', listener: (request: Request) => void): void; - /** - * The 'route' event includes the route public interface, the connection, and the server object used to add the route (e.g. the result of a plugin select operation) - * [See docs](https://hapijs.com/api/16.1.1#server-events) - */ - on(criteria: 'route', listener: (route: RoutePublicInterface, connection: ServerConnection, server: Server) => void): void; - /** - * Same as calling server.on() with the count option set to 1. - * TODO type this to copy the server.on specific types for 'route', 'tail', etc. - * [See docs](https://hapijs.com/api/16.1.1#serveroncecriteria-listener) - * @param criteria - * @param listener - */ - once(criteria: string | ServerEventCriteria, listener: Function): void; - /** - * Sets the path prefix used to locate static resources (files and view templates) when relative paths are used - * Note that setting a path within a plugin only applies to resources accessed by plugin methods. If no path is set, the connection files.relativeTo configuration is used. The path only applies to routes added after it has been set. - * [See docs](https://hapijs.com/api/16.1.1#serverpathrelativeto) - * @param relativeTo the path prefix added to any relative file path starting with '.'. - */ - path(relativeTo: string): void; - /** - * Registers a plugin - * If no callback is provided, a Promise object is returned. - * Note that plugin registration are recorded on each of the available connections. When plugins express a dependency on other plugins, both have to be loaded into the same connections for the dependency requirement to be fulfilled. It is recommended that plugin registration happen after all the server connections are created via server.connection(). - * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) - * @param plugins - * @param options - * @param callback with signature function(err) where err an error returned from the registration function. Note that exceptions thrown by the registration function are not handled by the framework. - * A note on typings. Common use case is: - * register(Plugin, (err) => {// do more stuff}) - * so these typings save passing empty `options` object or having to - * explicity type the Error in the Callback e.g.: - * register(Plugin, {}, (err) => {// do more stuff}) or - * register(Plugin, (err: Error) => {// do more stuff}) - */ - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, callback: (err: Error | null) => void): void; - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>): Promise; - register(plugins: PluginFunction | PluginRegistrationObject, callback: (err: Error | null) => void): void; - register(plugins: PluginFunction | PluginRegistrationObject): Promise; - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, options: PluginRegistrationOptions, callback: (err: Error | null) => void): void; - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, options: PluginRegistrationOptions): Promise; - register(plugins: PluginFunction | PluginRegistrationObject, options: PluginRegistrationOptions, callback: (err: Error | null) => void): void; - register(plugins: PluginFunction | PluginRegistrationObject, options: PluginRegistrationOptions): Promise; - /** - * Adds a connection route - * [See docs](https://hapijs.com/api/16.1.1#serverrouteoptions) - * @param options a route configuration object [See docs](https://hapijs.com/api/16.1.1#route-configuration) or an array of configuration objects. - */ - route(options: RouteConfiguration[]): void; - route(options: RouteConfiguration): void; - /** - * Selects a subset of the server's connections - * Returns a server object with connections set to the requested subset. Selecting again on a selection operates as a logic AND statement between the individual selections. - * [See docs](https://hapijs.com/api/16.1.1#serverselectlabels) - * @param labels a single string or array of strings of labels used as a logical OR statement to select all the connections with matching labels in their configuration. - */ - select(labels: string | string[]): Server; - /** - * Starts the server connections by listening for incoming requests on the configured port of each listener (unless the connection was configured with autoListen set to false) - * If no callback is provided, a Promise object is returned. - * Note that if the method fails and the callback includes an error, the server is considered to be in an undefined state and should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and other event listeners will get confused by repeated attempts to start the server or make assumptions about the healthy state of the environment. It is recommended to assert that no error has been returned after calling start() to abort the process when the server fails to start properly. If you must try to resume after a start error, call server.stop() first to reset the server state. - * If a started server is started again, the second call to start() will only start new connections added after the initial start() was called. No events will be emitted and no extension points invoked. - * [See docs](https://hapijs.com/api/16.1.1#serverstartcallback) - * @param callback the callback method when server startup is completed or failed with the signature function(err) where: - * * err - any startup error condition. - */ - start(callback: (err?: Error) => void): void; - start(): Promise; - /** - * HTTP state management [See docs](https://tools.ietf.org/html/rfc6265) uses client cookies to persist a state across multiple requests. Registers a cookie definitions - * [See docs](https://hapijs.com/api/16.1.1#serverstatename-options) - * @param name the cookie name string. - * @param options optional cookie settings - */ - state(name: string, options?: ServerStateCookieConfiguationObject): void; - /** - * Stops the server's connections by refusing to accept any new connections or requests (existing connections will continue until closed or timeout) - * If no callback is provided, a Promise object is returned. - * [See docs](https://hapijs.com/api/16.1.1#serverstopoptions-callback) - * @param options options object with: - * * timeout - overrides the timeout in millisecond before forcefully terminating a connection. Defaults to 5000 (5 seconds). - * @param callback optional callback method which is called once all the connections have ended and it is safe to exit the process with signature function(err) where: - * * err - any termination error condition. - */ - stop(options: {timeout: number} | null, callback: (err?: Error) => void): void; - stop(options?: {timeout: number}): Promise; - /** - * Returns a copy of the routing table - * Note that if the server has not been started and multiple connections use port 0, the table items will override each other and will produce an incomplete result. - * When calling connection.table() directly on each connection, the return value is the same as the array table item value of an individual connection - * [See docs](https://hapijs.com/api/16.1.1#servertablehost) - * @param host optional host to filter routes matching a specific virtual host. Defaults to all virtual hosts. - */ - table(host?: string): RoutingTableEntry[]; -} - -export interface PluginSpecificConfiguration {} - -/** - * Server Options - * Note that the options object is deeply cloned and cannot contain any values that are unsafe to perform deep copy on. - * [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) - */ -export interface ServerOptions { - /** app - application-specific configuration which can later be accessed via server.settings.app. Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. Defaults to {}. */ - app?: any; - /** - * cache - sets up server-side caching. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and capabilities. hapi uses catbox for its cache which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. The server cache configuration only defines the storage container itself. cache can be assigned: - * * a prototype function (usually obtained by calling require() on a catbox strategy such as require('catbox-redis')). A new catbox client will be created internally using this function. - * * a CatboxServerOptionsCacheConfiguration configuration object - * * an array of the above object for configuring multiple cache instances, each with a unique name. When an array of objects is provided, multiple cache connections are established and each array item (except one) must include a name. - */ - cache?: Catbox.EnginePrototype | CatboxServerOptionsCacheConfiguration | CatboxServerOptionsCacheConfiguration[]; - /** sets the default connections configuration which can be overridden by each connection */ - connections?: ConnectionConfigurationServerDefaults; - /** determines which logged events are sent to the console (this should only be used for development and does not affect which events are actually logged internally and recorded). Set to false to disable all console logging, or to an object with: */ - debug?: false | { - /** a string array of server log tags to be displayed via console.error() when the events are logged via server.log() as well as internally generated server logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. */ - log?: string[] | false; - /** a string array of request log tags to be displayed via console.error() when the events are logged via request.log() as well as internally generated request logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. */ - request?: string[] | false; - }; - /** process load monitoring */ - load?: { - /** the frequency of sampling in milliseconds. Defaults to 0 (no sampling). */ - sampleInterval?: number; - }; - /** options passed to the mimos module (https://github.com/hapijs/mimos) when generating the mime database used by the server and accessed via server.mime. */ - mime?: MimosOptions; - /** plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state. Defaults to {}. */ - plugins?: PluginSpecificConfiguration; - /** if false, will not use node domains to protect against exceptions thrown in handlers and other external code. Defaults to true. */ - useDomains?: boolean; -} - -/** - * The server event object - * [See docs](https://hapijs.com/api/16.1.1#server-events) - */ -export interface ServerEventObject { - /** the event timestamp. */ - timestamp: number; - /** if the event relates to a request, the request id. */ - request: string; - /** if the event relates to a server, the server.info.uri. */ - server: string; - /** an array of tags (e.g. ['error', 'http']). */ - tags: string[]; - /** optional event-specific information. */ - data: any; - /** true if the event was generated internally by the framework. */ - internal: boolean; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serveroncriteria-listener) - */ -export interface ServerEventCriteria { - /** the event name string (required). */ - name: string; - /** if true, the listener method receives an additional callback argument which must be called when the method completes. No other event will be emitted until the callback methods is called. The method signature is function(). If block is set to a positive integer, the value is used to set a timeout after which any pending events will be emitted, ignoring the eventual call to callback. Defaults to false (non blocking). */ - block?: boolean; - /** a string or array of strings specifying the event channels to subscribe to. If the event registration specified a list of allowed channels, the channels array must match the allowed channels. If channels are specified, event updates without any channel designation will not be included in the subscription. Defaults to no channels filter. */ - channels?: string | string[]; - /** if true, the data object passed to server.emit() is cloned before it is passed to the listener method. Defaults to the event registration option (which defaults to false). */ - clone?: boolean; - /** a positive integer indicating the number of times the listener can be called after which the subscription is automatically removed. A count of 1 is the same as calling server.once(). Defaults to no limit. */ - count?: number; - /** - * the event tags (if present) to subscribe to - * If the object is given: - * * tags - a tag string or array of tag strings. - * * all - if true, all tags must be present for the event update to match the subscription. Defaults to false (at least one matching tag). - */ - filter?: string | string[] | {tags: string | string[], all?: boolean}; - /** if true, and the data object passed to server.emit() is an array, the listener method is called with each array element passed as a separate argument. This should only be used when the emitted data structure is known and predictable. Defaults to the event registration option (which defaults to false). */ - spread?: boolean; - /** if true and the criteria object passed to server.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end (but before the callback argument if block is set). Defaults to the event registration option (which defaults to false). */ - tags?: boolean; -} - -/** - * Server methods, user configured - * Related to [See docs](https://hapijs.com/api/16.1.1#servermethods) - * Related to [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) - */ -export interface ServerMethod { - /** the method must return a value (result, Error, or a promise) or throw an Error. */ - (...args: any[]): any | Error | Promise; - /** Not possible to improve this typing due to this unresolvable issue: https://github.com/Microsoft/TypeScript/issues/15190 */ - (...args: (any | ServerMethodNext)[]): void; - /** When configured with caching enabled, server.methods[name].cache will be an object see ServerMethodNameCacheObject */ - cache?: ServerMethodNameCacheObject; -} - -/** - * Related to [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) - * @param err error response if the method failed. - * @param result the return value. - * @param ttl 0 if result is valid but cannot be cached. Defaults to cache policy. - */ -export interface ServerMethodNext { - (err: Error | null, result: any, ttl?: number): void; -} - -/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) */ -export interface ServerMethodNameCacheObject { - /** - * function that can be used to clear the cache for a given key. - * @param ...args any number of string, number or boolean. If other types then generateKey function must be specified. - * @param callback last argument is a callback. - * Not possible to improve this typing due to this unresolvable issue: https://github.com/Microsoft/TypeScript/issues/15190 - */ - drop(...args: (any | Function)[]): void; - /** an object with cache statistics, see stats documentation for catbox. */ - stats: Catbox.CacheStatisticsObject; -} - -/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) */ -export interface ServerMethodOptions { - /** a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. Ignored if the method is an arrow function. */ - bind?: any; - /** the same cache configuration used in server.cache(). The generateTimeout option is required. */ - cache?: CatboxServerCacheConfiguration; - /** - * if false, expects the method to be a synchronous function. Note that using a synchronous function with caching will convert the method interface to require a callback as an additional argument with the signature function(err, result, cached, report) since the cache interface cannot return values synchronously. Defaults to true. - * TODO: understand and type "an additional argument with the signature function(err, result, cached, report)" if appropriate. - */ - callback?: boolean; - /** a function used to generate a unique key (for caching) from the arguments passed to the method function (the callback argument is not passed as input). The server will automatically generate a unique key if the function's arguments are all of types 'string', 'number', or 'boolean'. However if the method uses other types of arguments, a key generation function must be provided which takes the same arguments as the function and returns a unique string (or null if no key can be generated). */ - generateKey?(args: any[]): string | null; -} - -/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodmethods) */ -export interface ServerMethodConfigurationObject { - name: string; - method: ServerMethod; - options: ServerMethodOptions; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Caching with Catbox + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * TODO confirm this is the same as CatboxServerCacheConfiguration - * - * ** - * Server instantiation options configuration for Catbox cache - * TODO: check it extends Catbox.PolicyOptions and this is what "other options passed to the catbox strategy used." means. - * For context [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) under: options > cache > a configuration object - * ** - * export interface CatboxServerOptionsCacheConfiguration extends Catbox.IPolicyOptions { - * // a prototype function or catbox engine object. - * engine: Catbox.EnginePrototypeOrObject; - * // an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. - * name?: string; - * // if true, allows multiple cache users to share the same segment (e.g. multiple methods using the same cache storage container). Default to false. - * shared?: boolean; - * } - */ -export type CatboxServerOptionsCacheConfiguration = CatboxServerCacheConfiguration; - -/** - * Server cache method configuration for Catbox cache - * Used for "Provisions a cache segment within the server cache facility" - * For context [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) - * Also used in [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) > options.cache - */ -export interface CatboxServerCacheConfiguration extends Catbox.PolicyOptions { - /** the cache name configured in server.cache. Defaults to the default cache. */ - cache?: string; - /** string segment name, used to isolate cached items within the cache partition. When called within a plugin, defaults to '!name' where 'name' is the plugin name. When called within a server method, defaults to '#name' where 'name' is the server method name. Required when called outside of a plugin. */ - segment?: string; - /** if true, allows multiple cache provisions to share the same segment. Default to false. */ - shared?: boolean; - /** - * a prototype function or catbox engine object. - * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) example code includes use of `engine` option. But server.cache.provision of `options` says "same as the server cache configuration options.". - * TODO confirm once PR to hapi docs accepted / rejected. - */ - engine?: Catbox.EnginePrototypeOrObject; - /** - * an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. - * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) example code includes use of `name` option. But server.cache.provision of `options` says "same as the server cache configuration options.". - */ - name?: string; - /** - * Additional options to be passed to the Catbox strategy - */ - [s: string]: any; -} - -/** - * Additional notes - * payload - In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided. - * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) - */ -export interface InjectedRequestOptions extends Shot.RequestOptions { - /** an optional credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials. */ - credentials?: any; - /** an optional artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts. */ - artifacts?: any; - /** sets the initial value of request.app. */ - app?: any; - /** sets the initial value of request.plugins. */ - plugins?: PluginsStates; - /** allows access to routes with config.isInternal set to true. Defaults to false. */ - allowInternals?: boolean; -} - -/** - * the response object from server.inject - * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) - */ -export interface InjectedResponseObject extends Shot.ResponseObject { - /** the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the internal objects returned (instead of parsing the response string). */ - result: Object | string; - /** the request object. */ - request: InjectedRequestOptions; -} - -/** - * For context [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) under: options > connections - */ -export interface ConnectionConfigurationServerDefaults { - /** application-specific connection configuration which can be accessed via connection.settings.app. Provides a safe place to store application configuration without potential conflicts with the framework internals. Should not be used to configure plugins which should use plugins[name]. Note the difference between connection.settings.app which is used to store configuration values and connection.app which is meant for storing run-time state. */ - app?: any; - /** if false, response content encoding is disabled. Defaults to true */ - compression?: boolean; - /** connection load limits configuration where: */ - load?: { - /** maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ - maxHeapUsedBytes?: number; - /** maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ - maxRssBytes?: number; - /** maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ - maxEventLoopDelay?: number; - }; - /** plugin-specific configuration which can later be accessed via connection.settings.plugins. Provides a place to store and pass connection-specific plugin configuration. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between connection.settings.plugins which is used to store configuration values and connection.plugins which is meant for storing run-time state. */ - plugins?: PluginSpecificConfiguration; - /** controls how incoming request URIs are matched against the routing table: */ - router?: { - /** determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true. */ - isCaseSensitive?: boolean; - /** removes trailing slashes on incoming paths. Defaults to false. */ - stripTrailingSlash?: boolean; - }; - /** a route options object used to set the default configuration for every route. */ - routes?: RouteAdditionalConfigurationOptions; - /** sets the default configuration for every state (cookie) set explicitly via server.state() or implicitly (without definition) using the [state configuration object](https://hapijs.com/api/16.1.1#serverstatename-options). */ - state?: ServerStateCookieConfiguationObject; -} - -/** - * a connection configuration object or array of objects with the following optional keys. - * Any connections configuration server defaults can be included to override and customize the individual connection. - * [See docs](https://hapijs.com/api/16.1.1#serverconnectionoptions) - */ -export interface ServerConnectionOptions extends ConnectionConfigurationServerDefaults { - /** host - the public hostname or IP address. Used only to set server.info.host and server.info.uri. If not configured, defaults to the operating system hostname and if not available, to 'localhost'. */ - host?: string; - /** address - sets the host name or IP address the connection will listen on. If not configured, defaults to host if present, otherwise to all available network interfaces (i.e. '0.0.0.0'). Set to 127.0.0.1 or localhost to restrict connection to only those coming from the same machine. */ - address?: string; - /** port - the TCP port the connection will listen to. Defaults to an ephemeral port (0) which uses an available port when the server is started (and assigned to server.info.port). If port is a string containing a '/' character, it is used as a UNIX domain socket path and if it starts with '\.\pipe' as a Windows named pipe. */ - port?: string | number; - /** uri - the full public URI without the path (e.g. 'http://example.com:8080'). If present, used as the connection info.uri otherwise constructed from the connection settings. */ - uri?: string; - /** listener - optional node.js HTTP (or HTTPS) http.Server object or any compatible object. If the listener needs to be manually started, set autoListen to false. If the listener uses TLS, set tls to true. */ - listener?: http.Server; - /** autoListen - indicates that the connection.listener will be started manually outside the framework. Cannot be specified with a port setting. Defaults to true. */ - autoListen?: boolean; - /** labels - a string or string array of labels used to server.select() specific connections matching the specified labels. Defaults to an empty array [] (no labels). */ - labels?: string | string[]; - /** tls - used to create an HTTPS connection. The tls object is passed unchanged as options to the node.js HTTPS server as described in the node.js HTTPS [documentation](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener}) . Set to true when passing a listener object that has been configured to use TLS directly. */ - tls?: true | https.RequestOptions; -} - -/** - * For context see RouteAdditionalConfigurationOptions > compression - * For context [See docs](https://hapijs.com/api/16.1.1#serverencoderencoding-encoder) - */ -export type CompressionEncoderSettings = any; - -/** - * For context see RouteAdditionalConfigurationOptions > payload > compression - * For context [See docs](https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder) - */ -export type CompressionDecoderSettings = any; - -/** - * an optional function called after all the specified dependencies have been registered and before the server starts. The function is only called if the server is initialized or started. If a circular dependency is detected, an exception is thrown (e.g. two plugins each has an after function to be called after the other). The function signature is function(server, next) where: - * [See docs](https://hapijs.com/api/16.1.1#serverdependencydependencies-after) - * Also see Server.dependency - * @param server the server the dependency() method was called on. - * @param next the callback function the method must call to return control over to the application and complete the registration process. The function signature is function(err) where: - * * err - internal error condition, which is returned back via the server.initialize() or server.start() callback. - */ -export interface AfterDependencyLoadCallback { - (server: Server, next: (err?: Error) => void): void; -} - -/** For context see RouteAdditionalConfigurationOptions > auth */ -export interface AuthOptions { - /** - * the authentication mode. Defaults to 'required' if a server authentication strategy is configured, otherwise defaults to no authentication. Available values: - * * 'required' - authentication is required. - * * 'optional' - authentication is optional (must be valid if present). - * * 'try' - same as 'optional' but allows for invalid authentication. - */ - mode?: 'required' | 'optional' | 'try'; - /** a string array of strategy names in order they should be attempted. If only one strategy is used, strategy can be used instead with the single string value. Defaults to the default authentication strategy which is available only when a single strategy is configured. */ - strategies?: string[]; - strategy?: string; - /** - * if set, the payload (in requests other than 'GET' and 'HEAD') is authenticated after it is processed. Requires a strategy with payload authentication support (e.g. Hawk). Cannot be set to a value other than 'required' when the scheme sets the options.payload to true. Available values: - * * false - no payload authentication. This is the default value. - * * 'required' - payload authentication required. This is the default value when the scheme sets options.payload to true. - * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). - */ - payload?: false | 'required' | 'optional'; - /** specifying the route access rules. */ - access?: RouteAuthAccessConfiguationObject | RouteAuthAccessConfiguationObject[]; - /** (undocumented) Convenience way of setting access.scope, will over write all values in `access` */ - scope?: false | string | string[]; - /** (undocumented) Convenience way of setting access.entity, will over write all values in `access` */ - entity?: 'any' | 'user' | 'app'; -} - -/** - * Each rule is evaluated against an incoming request and access is granted if at least one rule matches. Each rule object must include at least one of: - * For context see RouteAdditionalConfigurationOptions > auth > an object > access - */ -export interface RouteAuthAccessConfiguationObject { - /** the application scope required to access the route. Value can be a scope string or an array of scope strings. The authenticated credentials object scope property must contain at least one of the scopes defined to access the route. If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' scope must not include 'a', must include 'b', and must include one of 'c' or 'd'. You may also access properties on the request object (query and params) to populate a dynamic scope by using {} characters around the property name, such as 'user-{params.id}'. Defaults to false (no scope requirements). */ - scope?: false | string | string[]; - /** - * the required authenticated entity type. If set, must match the entity value of the authentication credentials. Available values: - * * any - the authentication can be on behalf of a user or application. This is the default value. - * * user - the authentication must be on behalf of a user which is identified by the presence of a user attribute in the credentials object returned by the authentication strategy. - * * app - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. - */ - entity?: 'any' | 'user' | 'app'; -} - -/** - * For context see RouteAdditionalConfigurationOptions > cache - */ -export type RouteCacheOptions = { - /** - * determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are: - * * 'default' - no privacy flag. This is the default setting. - * * 'public' - mark the response as suitable for public caching. - * * 'private' - mark the response as suitable only for private caching. - */ - privacy?: 'default' | 'public' | 'private'; - /** an array of HTTP response status codes (e.g. 200) which are allowed to include a valid caching directive. Defaults to [200]. */ - statuses?: number[]; - /** a string with the value of the 'Cache-Control' header when caching is disabled. Defaults to 'no-cache'. */ - otherwise?: string; -} & ({ - /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ - expiresIn?: number; - /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ - expiresAt?: undefined; -} | { - /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ - expiresIn?: undefined; - /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ - expiresAt?: string; -} | { - /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ - expiresIn?: undefined; - /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ - expiresAt?: undefined; -}); - -/** - * For context see RouteAdditionalConfigurationOptions > cors - */ -export interface CorsConfigurationObject { - /** a strings array of allowed origin servers ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a wildcard '*' character, or a single '*' origin string. Defaults to any origin ['*']. */ - origin?: string[] | '*'; - /** number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. Defaults to 86400 (one day). */ - maxAge?: number; - /** a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match'] */ - headers?: string[]; - /** a strings array of additional headers to headers. Use this to keep the default headers in place. */ - additionalHeaders?: string[]; - /** a strings array of exposed headers ('Access-Control-Expose-Headers'). Defaults to ['WWW-Authenticate', 'Server-Authorization']. */ - exposedHeaders?: string[]; - /** a strings array of additional headers to exposedHeaders. Use this to keep the default headers in place. */ - additionalExposedHeaders?: string[]; - /** if true, allows user credentials to be sent ('Access-Control-Allow-Credentials'). Defaults to false. */ - credentials?: boolean; -} - -/** - * An object describing the extension function used whilst registering the extension function in one of the available extension points - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * For context see RouteAdditionalConfigurationOptions > ext - */ -export interface ServerStartExtConfigurationObject { - /** the extension point event name. */ - type: ServerStartExtPoints; - /** - * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler - */ - method: ServerExtFunction | ServerExtFunction[]; - options?: ServerExtOptions; -} - -/** - * An object describing the extension function used whilst registering the extension function in one of the available extension points - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * For context see RouteAdditionalConfigurationOptions > ext - */ -export interface ServerRequestExtConfigurationObject { - /** the extension point event name. */ - type: ServerRequestExtPointsBase; - /** - * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler - */ - method: ServerExtRequestHandler | ServerExtRequestHandler[] - options?: ServerExtOptions; -} - -/** - * An object describing the extension function used whilst registering the extension function in one of the available extension points - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * For context see RouteAdditionalConfigurationOptions > ext - */ -export interface ServerRequestExtConfigurationObjectWithRequest { - /** the extension point event name. */ - type: ServerRequestExtPoints; - /** - * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler - */ - method: ServerExtRequestHandler | ServerExtRequestHandler[]; - options?: ServerExtOptions; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#route-configuration) > ext - */ -export type RouteExtConfigurationObject = ServerStartExtConfigurationObject | ServerRequestExtConfigurationObject; - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > method - */ -export type ServerExtMethod = ServerExtFunction | ServerExtRequestHandler; - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > options - */ -export interface ServerExtOptions { - /** before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. */ - before: string | string[]; - /** after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. */ - after: string | string[]; - /** bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. */ - bind: any; - /** sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'connection' which applies to any route added to the connection the extension is added to. */ - sandbox?: 'connection' | 'plugin'; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > type - * * 'onPreStart' - called before the connection listeners are started. - * * 'onPostStart' - called after the connection listeners are started. - * * 'onPreStop' - called before the connection listeners are stopped. - * * 'onPostStop' - called after the connection listeners are stopped. - */ -export type ServerStartExtPoints = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; -/** - * [See docs](https://hapijs.com/api/16.1.1#request-lifecycle) - * * The available extension points include the request extension points as well as the following server extension points: - */ -export type ServerRequestExtPointsBase = 'onPreResponse' | 'onPreAuth' | 'onPostAuth' | 'onPreHandler' | 'onPostHandler' | 'onPreResponse'; - -export type ServerRequestExtPoints = ServerRequestExtPointsBase | 'onRequest'; - -/** - * Server extension function registered an one of the server extension points - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * For context see ServerExtConfigurationObject - * @param server - the server object. - * @param next - the continuation method with signature function(err). - * @param this - the object provided via options.bind or the current active context set with server.bind(). - */ -export interface ServerExtFunction { - (server: Server, next: ContinuationFunction): void; -} - -/** - * For context see RouteAdditionalConfigurationOptions > payload - */ -export interface RoutePayloadConfigurationObject { - /** - * the type of payload representation requested. The value must be one of: - * * 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, the raw Buffer is returned. This is the default value except when a proxy handler is used. - * * 'stream' - the incoming payload is made available via a Stream.Readable interface. If the payload is 'multipart/form-data' and parse is true, fields values are presented as text while files are provided as streams. File streams from a 'multipart/form-data' upload will also have a property hapi containing filename and headers properties. - * * 'file' - the incoming payload is written to temporary file in the directory specified by the server's payload.uploads settings. If the payload is 'multipart/form-data' and parse is true, fields values are presented as text while files are saved. Note that it is the sole responsibility of the application to clean up the files generated by the framework. This can be done by keeping track of which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform any needed cleanup. - */ - output?: PayLoadOutputOption; - /** - * can be true, false, or gunzip; determines if the incoming payload is processed or presented raw. true and gunzip includes gunzipping when the appropriate 'Content-Encoding' is specified on the received request. If parsing is enabled and the 'Content-Type' is known (for the whole payload as well as parts), the payload is converted into an object when possible. If the format is unknown, a Bad Request (400) error response is sent. Defaults to true, except when a proxy handler is used. The supported mime types are: - * * 'application/json' - * * 'application/x-www-form-urlencoded' - * * 'application/octet-stream' - * * 'text/*' - * * 'multipart/form-data' - */ - parse?: 'gunzip' | boolean; - /** - * overrides payload processing for multipart requests. Value can be one of: - * * false - disables multipart processing. - * * object with the following required options: - * * output - same as the payload.output option with an additional value option: - * * annotated - wraps each multipart part in an object with the following keys: // TODO type this? - * * headers - the part headers. - * * filename - the part file name. - * * payload - the processed part payload. - */ - multipart?: false | { - output: PayLoadOutputOption | 'annotated'; - }; - /** a string or an array of strings with the allowed mime types for the endpoint. Defaults to any of the supported mime types listed above. Note that allowing other mime types not listed will not enable them to be parsed, and that if parsing mode is 'parse', the request will result in an error response. */ - allow?: string | string[]; - /** a mime type string overriding the 'Content-Type' header value received. Defaults to no override. */ - override?: string; - /** limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory. Defaults to 1048576 (1MB). */ - maxBytes?: number; - /** payload reception timeout in milliseconds. Sets the maximum time allowed for the client to transmit the request payload (body) before giving up and responding with a Request Timeout (408) error response. Set to false to disable. Defaults to 10000 (10 seconds). */ - timeout?: number | false; - /** the directory used for writing file uploads. Defaults to os.tmpdir(). */ - uploads?: string; - /** - * determines how to handle payload parsing errors. Allowed values are: - * * 'error' - return a Bad Request (400) error response. This is the default value. - * * 'log' - report the error but continue processing the request. - * * 'ignore' - take no action and continue processing the request. - */ - failAction?: 'error' | 'log' | 'ignore'; - /** the default 'Content-Type' HTTP header value is not present. Defaults to 'application/json'. */ - defaultContentType?: string; - /** an object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in the root option compression. */ - compression?: Dictionary; -} - -export type PayLoadOutputOption = 'data' | 'stream' | 'file'; - -/** - * events must be one of: - * * an event name string. - * * an event options object see ApplicationEventOptionsObject - * * a podium [See docs](https://github.com/hapijs/podium) emitter object. - * For context [See docs](https://hapijs.com/api/16.1.1#servereventevents) > events parameter - */ -export type ApplicationEvent = string | ApplicationEventOptionsObject | Podium; - -/** - * an event options object - * For context see ApplicationEvent - * For context [See docs](https://hapijs.com/api/16.1.1#servereventevents) > events parameter - */ -export interface ApplicationEventOptionsObject { - /** the event name string (required). */ - name: string; - /** a string or array of strings specifying the event channels available. Defaults to no channel restrictions (event updates can specify a channel or not). */ - channels?: string | string[]; - /** if true, the data object passed to server.emit() is cloned before it is passed to the listeners (unless an override specified by each listener). Defaults to false (data is passed as-is). */ - clone?: boolean; - /** if true, the data object passed to server.emit() must be an array and the listener method is called with each array element passed as a separate argument (unless an override specified by each listener). This should only be used when the emitted data structure is known and predictable. Defaults to false (data is emitted as a single argument regardless of its type). */ - spread?: boolean; - /** if true and the criteria object passed to server.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end (but before the callback argument if block is set). A configuration override can be set by each listener. Defaults to false. */ - tags?: boolean; - /** if true, the same event name can be registered multiple times where the second registration is ignored. Note that if the registration config is changed between registrations, only the first configuration is used. Defaults to false (a duplicate registration will throw an error). */ - shared?: boolean; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Route + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Route configuration - * The route configuration object - * - * [See docs](https://hapijs.com/api/16.1.1#route-configuration) - * - * TODO typings check that the following refers to RouteAdditionalConfigurationOptions "Note that the options object is deeply cloned (with the exception of bind which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on." - */ -export interface RouteConfiguration { - /** the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the connection router configuration option. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. */ - path: string; - /** the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. */ - method: HTTP_METHODS_PARTIAL | '*' | (HTTP_METHODS_PARTIAL | '*')[]; - /** an optional domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. */ - vhost?: string; - /** the function called to generate the response after successful authentication and validation. The handler function is described in Route handler. If set to a string, the value is parsed the same way a prerequisite server method string shortcut is processed. Alternatively, handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler. */ - handler?: string | RouteHandler | RouteHandlerPlugins; - /** additional route options. The config value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. */ - config?: RouteAdditionalConfigurationOptions | ((server: Server) => RouteAdditionalConfigurationOptions); -} - -/** - * Route options - * Each route can be customize to change the default behavior of the request lifecycle using the following options: - * [See docs](https://hapijs.com/api/16.1.1#route-options) - */ -export interface RouteAdditionalConfigurationOptions { - /** application specific configuration.Should not be used by plugins which should use plugins[name] instead. */ - app?: any; - /** - * Authentication configuration. Value can be: - * * false to disable authentication if a default strategy is set. - * * a string with the name of an authentication strategy registered with server.auth.strategy(). - * * an object - */ - auth?: false | string | AuthOptions; - /** an object passed back to the provided handler (via this) when called. Ignored if the method is an arrow function. */ - bind?: any; - /** - * Route cache options - * if the route method is 'GET', the route can be configured to include caching directives in the response. The default Cache-Control: no-cache header can be disabled by setting cache to false. Caching can be customized using an object - * TODO check: the default is to have 'Cache-Control: no-cache', but on first reading is a contridiction as you can disabled cache and disabled no-cache by setting RouteCacheOptions to false? - */ - cache?: boolean | RouteCacheOptions; - /** an object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in payload.compression. */ - compression?: Dictionary; - /** the Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. CORS headers are disabled by default (false). To enable, set cors to true, or to an object */ - cors?: boolean | CorsConfigurationObject; - /** defined a route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the [server.ext(events)](https://hapijs.com/api/16.1.1#serverextevents) event argument. */ - ext?: RouteExtConfigurationObject | RouteExtConfigurationObject[]; - /** defines the behavior for accessing files: */ - files?: { - /** determines the folder relative paths are resolved against. */ - relativeTo: string; - }; - /** an alternative location for the route.handler option. */ - handler?: string | RouteHandler; - /** an optional unique identifier used to look up the route using server.lookup(). Cannot be assigned to routes with an array of methods. */ - id?: string; - /** if true, the route cannot be accessed through the HTTP connection but only through the server.inject() interface with the allowInternals option set to true. Used for internal routes that should not be accessible to the outside world. Defaults to false. */ - isInternal?: boolean; - /** optional arguments passed to JSON.stringify() when converting an object or error response to a string payload. Supports the following: */ - json?: Json.StringifyArguments & { - /** string suffix added after conversion to JSON string. Defaults to no suffix. */ - suffix?: string; - }; - /** enables JSONP support by setting the value to the query parameter name containing the function name used to wrap the response payload. For example, if the value is 'callback', a request comes in with 'callback=me', and the JSON response is '{ "a":"b" }', the payload will be 'me({ "a":"b" });'. Does not work with stream responses. Headers content-type and x-content-type-options are set to text/javascript and nosniff respectively, and will override those headers even if explicitly set by response.type() */ - jsonp?: string; - /** if true, request level logging is enabled (accessible via request.getLog()). */ - log?: boolean; - /** - * determines how the request payload is processed - * [See docs](https://hapijs.com/api/16.1.1#route-options) - */ - payload?: RoutePayloadConfigurationObject; - /** plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. */ - plugins?: PluginSpecificConfiguration; - /** an array with [route prerequisites](https://hapijs.com/api/16.1.1#route-prerequisites) methods which are executed in serial or in parallel before the handler is called. */ - pre?: RoutePrerequisitesArray; - /** processing rules for the outgoing response */ - response?: RouteResponseConfigurationObject; - /** sets common security headers (disabled by default). To enable set security to true or to an object with the following options: See RouteSecurityConfigurationObject */ - security?: boolean | RouteSecurityConfigurationObject; - /** HTTP state management (cookies) allows the server to store information on the client which is sent back to the server with every request (as defined in RFC 6265). state supports the following options: */ - state?: { - /** determines if incoming 'Cookie' headers are parsed and stored in the request.state object. Defaults to true. */ - parse?: boolean; - /** - * determines how to handle cookie parsing errors. Allowed values are: - * * 'error' - return a Bad Request (400) error response. This is the default value. - * * 'log' - report the error but continue processing the request. - * * 'ignore' - take no action. - */ - failAction: 'error' | 'log' | 'ignore'; - }; - /** request input validation rules for various request components. When using a Joi validation object, the values of the other inputs (i.e. headers, query, params, payload, and auth) are made available under the validation context (accessible in rules as Joi.ref('$query.key')). Note that validation is performed in order (i.e. headers, params, query, payload) and if type casting is used (converting a string to number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. If the validation rules for headers, params, query, and payload are defined at both the routes defaults level and an individual route, the individual route settings override the routes defaults (the rules are not merged). The validate object supports: */ - validate?: RouteValidationConfigurationObject; - /** define timeouts for processing durations: */ - timeout?: { - /** response timeout in milliseconds. Sets the maximum time allowed for the server to respond to an incoming client request before giving up and responding with a Service Unavailable (503) error response. Disabled by default (false). */ - server?: boolean | number; - /** by default, node sockets automatically timeout after 2 minutes. Use this option to override this behavior. Defaults to undefined which leaves the node default unchanged. Set to false to disable socket timeouts. */ - socket?: boolean | number; - }; - - /** - * TODO decide on moving these to an extended interface of RouteAdditionalConfigurationOptions - */ - /** - * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - * route description used for generating documentation - */ - description?: string; - /** - * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - * route notes used for generating documentation - */ - notes?: string | string[]; - /** - * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - * route tags used for generating documentation - */ - tags?: string[]; -} - -/** - * Route public interface - * When route information is returned or made available as a property, it is an object with the following: - * [See docs](https://hapijs.com/api/16.1.1#route-public-interface) - */ -export interface RoutePublicInterface { - /** the route HTTP method. */ - method: string; - /** the route path. */ - path: string; - /** the route vhost option if configured. */ - vhost?: string | string[]; - /** the [active realm] [See docs](https://hapijs.com/api/16.1.1#serverrealm) associated with the route.*/ - realm: ServerRealm; - /** the [route options] [See docs](https://hapijs.com/api/16.1.1#route-options) object with all defaults applied. */ - settings: RouteAdditionalConfigurationOptions; - /** the route internal normalized string representing the normalized path. */ - fingerprint: string; - /** route authentication utilities: */ - auth: { - /** authenticates the passed request argument against the route's authentication access configuration. Returns true if the request would have passed the route's access requirements. Note that the route's authentication mode and strategies are ignored. The only match is made between the request.auth.credentials scope and entity information and the route access configuration. Also, if the route uses dynamic scopes, the scopes are constructed against the request.query and request.params which may or may not match between the route and the request's route. If this method is called using a request that has not been authenticated (yet or at all), it will return false if the route requires any authentication. */ - access(request: Request): boolean; - }; -} - -export type RouteHandlerConfig = any; - -/** - * For context [See docs](https://hapijs.com/api/16.1.1#serverhandlername-method) - * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/handler.js#L103) - * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/route.js#L56-L60) - * TODO check the type of `RouteHandlerConfig` is correct for `defaults`. - */ -export interface MakeRouteHandler { - (route: RoutePublicInterface, options: RouteHandlerConfig): RouteHandler; - defaults?: RouteHandlerConfig | ((method: HTTP_METHODS_PARTIAL_lowercase) => RouteHandlerConfig); -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#servertablehost) > return value - */ -export interface RoutingTableEntry { - /** the connection.info the connection the table was generated for. */ - info: ServerConnectionInfo; - /** the connection labels. */ - labels: string[]; - /** an array of routes where each route contains: */ - table: Route[]; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#servertablehost) > return value - * For source [See source](https://github.com/hapijs/hapi/blob/v16.1.1/lib/route.js#L71) - */ -export interface Route { - /** - * the route config with defaults applied. - * TODO check type of RouteConfiguration here is correct - */ - settings: RouteAdditionalConfigurationOptions; - /** - * the HTTP method in lower case. - * TODO, check if it can contain 'head' or not. - */ - method: HTTP_METHODS_PARTIAL_lowercase; - /** the route path. */ - path: string; - - params: string[]; - - connection: ServerConnection; - - fingerprint: string; - - plugin?: any; - - public: RoutePublicInterface; - - server: Server; -} - -/** - * Route Prerequisites - * It is often necessary to perform prerequisite actions before the handler is called (e.g. load required reference data from a database). The route pre option allows defining such pre-handler methods. The methods are called in order. If the pre array contains another array, those methods are called in parallel. pre can be assigned a mixed array of: - * * arrays containing the elements listed below, which are executed in parallel. - * * objects see RoutePrerequisiteObjects - * * functions - same as including an object with a single method key. - * * strings - special short-hand notation for registered server methods using the format 'name(args)' (e.g. 'user(params.id)') where: - * * 'name' - the method name. The name is also used as the default value of assign. - * * 'args' - the method arguments (excluding next) where each argument is a property of the request object - * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) - * For context see RouteAdditionalConfigurationOptions > pre - * - * TODO follow up on "server methods" in "special short-hand notation for registered server methods" at https://hapijs.com/api/16.1.1#servermethodname-method-options - * TODO follow up on "request object" in "each argument is a property of the request object" at https://hapijs.com/api/16.1.1#request-object - */ -export type RoutePrerequisitesArray = RoutePrerequisitesPart[] | (RoutePrerequisitesPart[] | RoutePrerequisitesPart)[]; -export type RoutePrerequisitesPart = RoutePrerequisiteObjects | RoutePrerequisiteRequestHandler | string; - -/** - * see RoutePrerequisites > objects - */ -export interface RoutePrerequisiteObjects { - /** the function to call (or short-hand method string as described below [see RoutePrerequisitesArray]). the function signature is identical to a route handler as described in Route handler. */ - method: RoutePrerequisiteRequestHandler | string; - /** key name to assign the result of the function to within request.pre. */ - assign: string; - /* - * determines how to handle errors returned by the method. Allowed values are: - * * 'error' - returns the error response back to the client. This is the default value. - * * 'log' - logs the error but continues processing the request. If assign is used, the error will be assigned. - * * 'ignore' - takes no special action. If assign is used, the error will be assigned. - */ - failAction?: 'error' | 'log' | 'ignore'; -} - -/** - * For context see RouteAdditionalConfigurationOptions > response - */ -export interface RouteResponseConfigurationObject { - /** the default HTTP status code when the payload is empty. Value can be 200 or 204. Note that a 200 status code is converted to a 204 only at the time or response transmission (the response status code will remain 200 throughout the request lifecycle unless manually set). Defaults to 200. */ - emptyStatusCode?: number; - /** - * defines what to do when a response fails payload validation. Options are: - * * 'error' - return an Internal Server Error (500) error response. This is the default value. - * * 'log' - log the error but send the response. - * * a custom error handler function with the signature function(request, reply, source, error) where: - * * 'request' - the request object. - * * 'reply' - the continuation reply interface. - * * 'error' - the error returned from the validation schema. - * TODO update type of source once PR to hapi is concluded. - */ - failAction?: 'error' | 'log' | ((request: Request, reply: ReplyWithContinue, source: string, error: Boom.BoomError) => void); - /** if true, applies the validation rule changes to the response payload. Defaults to false. */ - modify?: boolean; - /** - * options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is available [here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback) ). - * If a custom validation function (see `schema` or `status` below) is defined then `options` can an arbitrary object that will be passed to this function as the second parameter. - * Defaults to no options. - */ - options?: ValidationOptions; - /** if false, payload range support is disabled. Defaults to true. */ - ranges?: boolean; - /** the percent of response payloads validated (0 - 100). Set to 0 to disable all validation. Defaults to 100 (all response payloads). */ - sample?: number; - /** the default response payload validation rules (for all non-error responses) */ - schema?: RouteResponseConfigurationScheme; - /** HTTP status-code-specific payload validation rules. The status key is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. If a response status code is not present in the status object, the schema definition is used, except for errors which are not validated by default. */ - status?: Dictionary>; -} - -/** - * the default response payload validation rules (for all non-error responses) expressed as one of: - * * true - any payload allowed (no validation performed). This is the default. - * * false - no payload allowed. - * * a Joi validation object. This will receive the request's headers, params, query, payload, and auth credentials and isAuthenticated flags as context. - * * a validation function - * - * TODO check JoiValidationObject is correct for "a Joi validation object" - * - * For context see RouteAdditionalConfigurationOptions > response > schema - * and - * For context see RouteAdditionalConfigurationOptions > response > status - */ -export type RouteResponseConfigurationScheme = boolean | JoiValidationObject | ValidationFunctionForRouteResponse; - -/** - * see RouteResponseConfigurationScheme - * - * a validation function using the signature function(value, options, next) where: - * * value - the value of the response passed to `reply(value)` in the handler. - * * options - the server validation options, merged with an object containing the request's headers, params, payload, and auth credentials object and `isAuthenticated` flag. - * * next([err, [value]]) - the callback function called when validation is completed. `value` will be used as the response value when `err` is falsy, when `value` is not `undefined`, and when `route.settings.response.modify` is `true`. If the response is already a `Boom` error it will be set as its `message` value. - */ -export interface ValidationFunctionForRouteResponse { - (value: any, options: RouteResponseValidationContext & ValidationOptions, next: ContinuationValueFunction): void; -} - -/** - * A context for route input validation via a Joi schema or validation function. - * - * This object is merged with the route response options and passed into the validation function. - * - * See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L217 - */ -export interface RouteResponseValidationContext { - context: { - /** The request headers */ - headers: Dictionary; - /** The request path parameters */ - params: any; - /** The request query parameters */ - query: any; - /** The request payload parameters */ - payload: any; - - /** Partial request authentication information */ - auth: { - /** true if the request has been successfully authenticated, otherwise false. */ - isAuthenticated: boolean; - /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ - credentials: AuthenticatedCredentials; - }; - } -} - -/** - * For context see RouteAdditionalConfigurationOptions > security - */ -export interface RouteSecurityConfigurationObject { - /** controls the 'Strict-Transport-Security' header. If set to true the header will be set to max-age=15768000, if specified as a number the maxAge parameter will be set to that number. Defaults to true. You may also specify an object with the following fields: */ - hsts?: boolean | number | { - /** the max-age portion of the header, as a number. Default is 15768000. */ - maxAge?: number; - /** a boolean specifying whether to add the includeSubDomains flag to the header. */ - includeSubdomains?: boolean; - /** a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. */ - preload?: boolean; - }; - /** controls the 'X-Frame-Options' header. When set to true the header will be set to DENY, you may also specify a string value of 'deny' or 'sameorigin'. Defaults to true. To use the 'allow-from' rule, you must set this to an object with the following fields: */ - xframe?: true | 'deny' | 'sameorigin' | { - /** may also be 'deny' or 'sameorigin' but set directly as a string for xframe */ - rule: 'allow-from'; - /** when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. */ - source: string; - }; - /** boolean that controls the 'X-XSS-PROTECTION' header for IE. Defaults to true which sets the header to equal '1; mode=block'. NOTE: This setting can create a security vulnerability in versions of IE below 8, as well as unpatched versions of IE8. See [here](https://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities/) and [here](https://technet.microsoft.com/library/security/ms10-002) for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. [Kept typing non optional to force this security related documentation to be read.] */ - xss: boolean; - /** boolean controlling the 'X-Download-Options' header for IE, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. */ - noOpen?: boolean; - /** boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff' */ - noSniff?: boolean; -} - -/** - * request input validation rules for various request components. When using a Joi validation object, the values of the other inputs (i.e. headers, query, params, payload, and auth) are made available under the validation context (accessible in rules as Joi.ref('$query.key')). Note that validation is performed in order (i.e. headers, params, query, payload) and if type casting is used (converting a string to number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. If the validation rules for headers, params, query, and payload are defined at both the routes defaults level and an individual route, the individual route settings override the routes defaults (the rules are not merged). The validate object supports: - * For context see RouteAdditionalConfigurationOptions > validate - * TODO check JoiValidationObject is correct for "a Joi validation object" - */ -export interface RouteValidationConfigurationObject { - /** - * validation rules for incoming request headers (note that all header field names must be in lowercase to match the headers normalized by node). Values allowed: - * * true - any headers allowed (no validation performed). This is the default. - * * false - no headers allowed (this will cause all valid HTTP requests to fail). - * * a Joi validation object. - * * a validation function using the signature function(value, options, next) where: - * * value - the object containing the request headers. - * * options - the server validation options. - * * next(err, value) - the callback function called when validation is completed. `value` will be used as the `headers` value when `err` is falsy. If `next` is called with `undefined` or no arguments then the original value of `value` will be used. - */ - headers?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; - /** - * validation rules for incoming request path parameters, after matching the path against the route and extracting any parameters then stored in request.params. Values allowed: - * Same as `headers`, see above. - */ - params?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; - /** - * validation rules for an incoming request URI query component (the key-value part of the URI between '?' and '#'). The query is parsed into its individual key-value pairs and stored in request.query prior to validation. Values allowed: - * Same as `headers`, see above. - */ - query?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; - /** - * validation rules for an incoming request payload (request body). Values allowed: - * Same as `headers`, see above, with the addition that: - * * a Joi validation object. Note that empty payloads are represented by a null value. If a validation schema is provided and empty payload are supported, it must be explicitly defined by setting the payload value to a joi schema with null allowed (e.g. Joi.object({ /* keys here * / }).allow(null)). - */ - payload?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; - /** an optional object with error fields copied into every validation error response. */ - errorFields?: any; - /** - * determines how to handle invalid requests. Allowed values are: - * * 'error' - return a Bad Request (400) error response. This is the default value. - * * 'log' - log the error but continue processing the request. - * * 'ignore' - take no action. - * * a custom error handler function with the signature function(request, reply, source, error) see RouteFailFunction - */ - failAction?: 'error' | 'log' | 'ignore' | RouteFailFunction; - /** - * options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is [available here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback)). - * If a custom validation function (see `headers`, `params`, `query`, or `payload` above) is defined then `options` can an arbitrary object that will be passed to this function as the second parameter. - * Defaults to no options. - */ - options?: ValidationOptions; -} - -/** - * a validation function using the signature function(value, options, next) where: - * For context see RouteAdditionalConfigurationOptions > validate (RouteValidationConfigurationObject) - * - * Also see ValidationFunctionForRouteResponse - * @param value - the object containing the request headers, query, path params or payload. - * @param options - the server validation options. - * @param next([err, [value]]) - the callback function called when validation is completed. - */ -export interface ValidationFunctionForRouteInput { - (value: any, options: RouteInputValidationContext & ValidationOptions, next: ContinuationValueFunction): void; -} - -/** - * A context for route input validation via a Joi schema or validation function. - * - * This object is merged with the route validation options and passed into the validation function. - * - * See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L122 - */ -export interface RouteInputValidationContext { - context: { - // These are only set when *not* validating the respective source (e.g. params, query and payload are set when validating headers): - // See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L132 - headers?: Dictionary; - params?: any; - query?: any; - payload?: any; - - /** The request authentication information */ - auth: RequestAuthenticationInformation; - } -} - -/** - * a custom error handler function with the signature 'function(request, reply, source, error)` - * @param request - the request object. - * @param reply - the continuation reply interface. - * @param source - the source of the invalid field (e.g. 'headers', 'params', 'query', 'payload'). - * @param error - the error object prepared for the client response (including the validation function error under error.data). - */ -export interface RouteFailFunction { - (request: Request, reply: ReplyWithContinue, source: string, error: any): void; -} - -/** - * optional cookie settings - * [See docs](https://hapijs.com/api/16.1.1#serverstatename-options) - * Related to see ConnectionConfigurationServerDefaults - */ -export interface ServerStateCookieConfiguationObject { - /** time-to-live in milliseconds. Defaults to null (session time-life - cookies are deleted when the browser is closed). */ - ttl?: number | null; - /** sets the 'Secure' flag. Defaults to true. */ - isSecure?: boolean; - /** sets the 'HttpOnly' flag. Defaults to true. */ - isHttpOnly?: boolean; - /** - * sets the 'SameSite' flag where the value must be one of: - * * false - no flag. - * * 'Strict' - sets the value to 'Strict' (this is the default value). - * * 'Lax' - sets the value to 'Lax'. - */ - isSameSite?: false | 'Strict' | 'Lax'; - /** the path scope. Defaults to null (no path). */ - path?: string | null; - /** the domain scope. Defaults to null (no domain). */ - domain?: string | null; - /** - * if present and the cookie was not received from the client or explicitly set by the route handler, the cookie is automatically added to the response with the provided value. The value can be a function with signature function(request, next) where: - * * request - the request object. - * * next - the continuation function using the function(err, value) signature. - */ - autoValue?(request: Request, next: ContinuationValueFunction): void; - /** - * encoding performs on the provided value before serialization. Options are: - * * 'none' - no encoding. When used, the cookie value must be a string. This is the default value. - * * 'base64' - string value is encoded using Base64. - * * 'base64json' - object value is JSON-stringified then encoded using Base64. - * * 'form' - object value is encoded using the x-www-form-urlencoded method. - * * 'iron' - Encrypts and sign the value using iron. - */ - encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron'; - /** - * an object used to calculate an HMAC for cookie integrity validation. This does not provide privacy, only a mean to verify that the cookie value was generated by the server. Redundant when 'iron' encoding is used. Options are: - * * integrity - algorithm options. Defaults to require('iron').defaults.integrity. - * * password - password used for HMAC key generation (must be at least 32 characters long). - */ - sign?: { - integrity?: any; // TODO make iron definitions and getting typing from iron - password: string; - }; - /** password used for 'iron' encoding (must be at least 32 characters long). */ - password?: string; - /** options for 'iron' encoding. Defaults to require('iron').defaults. */ - iron?: any; // TODO make iron definitions and getting typing from iron - /** if true, errors are ignored and treated as missing cookies. */ - ignoreErrors?: boolean; - /** if true, automatically instruct the client to remove invalid cookies. Defaults to false. */ - clearInvalid?: boolean; - /** if false, allows any cookie value including values in violation of RFC 6265. Defaults to true. */ - strictHeader?: boolean; - /** used by proxy plugins (e.g. h2o2). */ - passThrough?: any; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverconnections) - */ -export interface ServerConnection { - /** settings - the connection configuration object passed to server.connection() after applying the server defaults. */ - settings: ServerConnectionOptions; - /** server - the connection's Server object. */ - server: Server; - /** type - set to 'tcp' is the connection is listening on a TCP port, otherwise to 'socket'(a UNIX domain socket or a Windows named pipe). */ - type: 'tcp' | 'socket'; - /** - * registrations - * Described [See docs](https://hapijs.com/api/16.1.1#serverregistrations) "When the server contains more than one connection, each server.connections array member provides its own connection.registrations." - */ - registrations: ServerRegisteredPlugins; - /** states - TODO contribute docs to hapi if they want, and then update type here */ - states: any; - /** auth - TODO contribute docs to hapi if they want, and then update type here */ - auth: any; - /** - * plugins - * TODO contribute docs to hapi if they want. Assuming similar to `registrations`, `listener`, `info`, etc - */ - plugins: PluginsStates; - /** - * app - * TODO contribute docs to hapi if they want. Assuming similar to `registrations`, `listener`, `info`, etc - */ - app: any; - /** Described in server.listener [See docs](https://hapijs.com/api/16.1.1#serverlistener) */ - listener: ServerListener; - /** Described in server.info [See docs](https://hapijs.com/api/16.1.1#serverinfo) */ - info: ServerConnectionInfo; - /** Described in server.inject [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) */ - inject(options: string | InjectedRequestOptions, callback: (res: InjectedResponseObject) => void): void; - inject(options: string | InjectedRequestOptions, ): Promise; - /** Mentioned but not documented under server.connections [See docs](https://hapijs.com/api/16.1.1#serverconnections) */ - table(host?: string): Route[]; - /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#serverlookupid) */ - lookup(id: string): RoutePublicInterface | null; - /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#servermatchmethod-path-host) */ - match(method: HTTP_METHODS, path: string, host?: string): RoutePublicInterface | null; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverinfo) - */ -export interface ServerConnectionInfo { - /** a unique connection identifier (using the format '{hostname}:{pid}:{now base36}'). */ - id: string; - /** the connection creation timestamp. */ - created: number; - /** the connection start timestamp (0 when stopped). */ - started: number; - /** - * the connection port based on the following rules: - * * the configured port value before the server has been started. - * * the actual port assigned when no port is configured or set to 0 after the server has been started. - * TODO check this type. What happens when socket is a UNIX domain socket or Windows named pipe? - */ - port: number | string; - /** the host name the connection was configured to. Defaults to the operating system hostname when available, otherwise 'localhost'. */ - host: string; - /** the active IP address the connection was bound to after starting. Set to undefined until the server has been started or when using a non TCP port (e.g. UNIX domain socket). */ - address: undefined | string; - /** the protocol used. 'socket' when UNIX domain socket or Windows named pipe. */ - protocol: 'http' | 'https' | 'socket'; - /** a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains the uri setting if provided, otherwise constructed from the available settings. If no port is available or set to 0, the uri will not include a port component. */ - uri: string; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverlistener) - */ -export type ServerListener = http.Server; - -/** - * server.realm - * The realm object contains server-wide or plugin-specific state that can be shared across various methods. For example, when calling server.bind(), the active realm settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). Realms are a limited version of a sandbox where plugins can maintain state used by the framework when adding routes, extensions, and other properties. - * [See docs](https://hapijs.com/api/16.1.1#serverrealm) - */ -export interface ServerRealm { - /** when the server object is provided as an argument to the plugin register() method, modifiers provides the registration preferences passed the server.register() method and includes: */ - modifiers: { - /** routes preferences: */ - route: { - /** the route path prefix used by any calls to server.route() from the server. Note that if a prefix is used and the route path is set to '/', the resulting path will not include the trailing slash. */ - prefix: string; - /** the route virtual host settings used by any calls to server.route() from the server. */ - vhost: string; - } - }; - /** the active plugin name (empty string if at the server root). */ - plugin: string; - /** the plugin options object passed at registration. */ - pluginOptions: any; // OptionsPassedToPlugin; - /** plugin-specific state to be shared only among activities sharing the same active state. plugins is an object where each key is a plugin name and the value is the plugin state. */ - plugins: PluginsStates; - /** settings overrides (from RouteAdditionalConfigurationOptions) */ - settings: { - files: { - relativeTo: string; - }; - bind: any; - }; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) - */ -export interface ServerRegisteredPlugins { - [pluginName: string]: ServerRegisteredPlugin; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) - */ -export interface ServerRegisteredPlugin { - /** the plugin version. */ - version: string; - /** the plugin name. */ - name: string; - /** - * options used to register the plugin. - * TODO update with outcome of: https://github.com/hapijs/hapi/pull/3479 - */ - options: any; // OptionsPassedToPlugin; - /** plugin registration attributes. */ - attributes: PluginAttributes; -} - -export interface ServerAuth { - /** - * server.auth.api - * An object where each key is a strategy name and the value is the exposed strategy API. Available on when the authentication scheme exposes an API by returning an api key in the object returned from its implementation function. - * When the server contains more than one connection, each server.connections array member provides its own connection.auth.api object. - * [See docs](https://hapijs.com/api/16.1.1#serverauthapi) - */ - api: Dictionary; - /** - * server.auth.default - * Sets a default strategy which is applied to every route - * The default does not apply when the route config specifies auth as false, or has an authentication strategy configured (contains the strategy or strategies authentication settings). Otherwise, the route authentication config is applied to the defaults. - * Note that if the route has authentication config, the default only applies at the time of adding the route, not at runtime. This means that calling default() after adding a route with some authentication config will have no impact on the routes added prior. However, the default will apply to routes added before default() is called if those routes lack any authentication config. - * The default auth strategy configuration can be accessed via connection.auth.settings.default. To obtain the active authentication configuration of a route, use connection.auth.lookup(request.route). - * [See docs](https://hapijs.com/api/16.1.1#serverauthdefaultoptions) - */ - default(options: string | AuthOptions): void; - /** - * server.auth.scheme - * Registers an authentication scheme - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) - * @param name the scheme name. - * @param scheme the method implementing the scheme with signature function(server, options) see ServerAuthScheme - */ - scheme(name: string, scheme: ServerAuthScheme): void; - /** - * Registers an authentication strategy - * [See docs](https://hapijs.com/api/16.1.1#serverauthstrategyname-scheme-mode-options) - * @param name the strategy name. - * @param scheme the scheme name (must be previously registered using server.auth.scheme()). - * @param mode if set to true (which is the same as 'required') or to a valid authentication mode ('required', 'optional', 'try'), the scheme is automatically assigned as the default strategy for any route without an auth config. Can only be assigned to a single server strategy. Defaults to false (no default settings). - * @param options scheme options based on the scheme requirements. - */ - strategy(name: string, scheme: string, options?: any): void; - strategy(name: string, scheme: string, mode: boolean | 'required' | 'optional' | 'try', options?: any): void; - /** - * Tests a request against an authentication strategy - * Note that the test() method does not take into account the route authentication configuration. It also does not perform payload authentication. It is limited to the basic strategy authentication execution. It does not include verifying scope, entity, or other route properties. - * [See docs](https://hapijs.com/api/16.1.1#serverauthteststrategy-request-next) - * @param strategy - the strategy name registered with server.auth.strategy(). - * @param request - the request object. - * @param next - the callback function with signature function(err, credentials) where: - * * err - the error if authentication failed. - * * credentials - the authentication credentials object if authentication was successful. - */ - test(strategy: string, request: Request, next: (err: Error | null, credentials: AuthenticatedCredentials) => void): void; -} - -export type Strategy = any; -export type SchemeSettings = any; - -/** - * the method implementing the scheme with signature function(server, options) where: - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) - * @param server a reference to the server object the scheme is added to. - * @param options optional scheme settings used to instantiate a strategy. - */ -export interface ServerAuthScheme { - (server: Server, options: SchemeSettings): SchemeMethodResult; -} - -/** - * The scheme method must return an object with the following - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) - */ -export interface SchemeMethodResult { - /** optional object which is exposed via the server.auth.api object. */ - api?: Strategy; - /** - * required function called on each incoming request configured with the authentication scheme - * When the scheme authenticate() method implementation calls reply() with an error condition, the specifics of the error affect whether additional authentication strategies will be attempted (if configured for the route). If the err passed to the reply() method includes a message, no additional strategies will be attempted. If the err does not include a message but does include the scheme name (e.g. Boom.unauthorized(null, 'Custom')), additional strategies will be attempted in the order of preference (defined in the route configuration). If authentication fails the scheme names will be present in the 'WWW-Authenticate' header. - * @param request the request object. - * @param reply the reply interface the authentication method must call when done authenticating the request - */ - authenticate(request: Request, reply: ReplySchemeAuth): void; - /** - * optional function called to authenticate the request payload - * When the scheme payload() method returns an error with a message, it means payload validation failed due to bad payload. If the error has no message but includes a scheme name (e.g. Boom.unauthorized(null, 'Custom')), authentication may still be successful if the route auth.payload configuration is set to 'optional'. - * @param request the request object. - * @param reply is called if authentication failed - */ - payload?(request: Request, reply: ReplySchemeAuthOfPayload): void; - /** - * optional function called to decorate the response with authentication headers before the response headers or payload is written where: - * @param request the request object. - * @param reply is called if an error occured - */ - response?(request: Request, reply: ReplySchemeAuthDecorateResponse): void; - /** an optional object with the following keys: */ - options?: { - /** if true, requires payload validation as part of the scheme and forbids routes from disabling payload auth validation. Defaults to false. */ - payload?: boolean; - }; -} - -export interface ServerCacheMethod { - /** - * Provisions a cache segment within the server cache facility - * [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) - */ - (options: CatboxServerCacheConfiguration): Catbox.Policy; - /** - * Provisions a server cache as described in server.cache - * If no callback is provided, a Promise object is returned. - * Note that if the server has been initialized or started, the cache will be automatically started to match the state of any other provisioned server cache. - * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) - * @param options same as the server cache configuration options. - * @param callback the callback method when cache provisioning is completed or failed with the signature function(err) where: - * * err - any cache startup error condition. - */ - provision(options: CatboxServerCacheConfiguration): Promise; - provision(options: CatboxServerCacheConfiguration, callback: (err?: Error) => void): void; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Request + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Request object - * The request object is created internally for each incoming request. It is different from the node.js request object received from the HTTP server callback (which is available in request.raw.req). The request object methods and properties change throughout the request lifecycle. - * [See docs](https://hapijs.com/api/16.1.1#request-object) - * [See docs](https://hapijs.com/api/16.1.1#request-properties) - */ -export class Request extends Podium { - /** application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. */ - app: any; - /** authentication information */ - auth: RequestAuthenticationInformation; - /** the connection the request was received by. */ - connection: ServerConnection; - /** the node domain object used to protect against exceptions thrown in extensions, handlers and route prerequisites. Can be used to manually bind callback functions otherwise bound to other domains. Set to null when the server useDomains options is false. */ - domain: domain.Domain | null; - /** the raw request headers (references request.raw.headers). */ - headers: Dictionary; - /** a unique request identifier (using the format '{now}:{connection.info.id}:{5 digits counter}').*/ - id: string; - /** request information */ - info: { - /** the request preferred encoding. */ - acceptEncoding: string; - /** if CORS is enabled for the route, contains the following: */ - cors: { - /** - * true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. - * Note: marking as optional as "... this is only available after ..." - */ - isOriginMatch?: boolean; - }; - /** content of the HTTP 'Host' header (e.g. 'example.com:8080'). */ - host: string; - /** the hostname part of the 'Host' header (e.g. 'example.com'). */ - hostname: string; - /** request reception timestamp. */ - received: number; - /** content of the HTTP 'Referrer' (or 'Referer') header. */ - referrer: string; - /** remote client IP address. */ - remoteAddress: string; - /** - * remote client port. - * Set to string in casethey're requesting from a UNIX domain socket. - * TODO, what type does Hapi return, should this be number | string? - */ - remotePort: string; - /** request response timestamp (0 is not responded yet). */ - responded: number; - }; - /** the request method in lower case (e.g. 'get', 'post'). */ - method: string; - /** the parsed content-type header. Only available when payload parsing enabled and no payload error occurred. */ - mime: string; - /** an object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. */ - orig: { - params: any; - query: any; - payload: any; - }; - /** an object where each key is a path parameter name with matching value as described in Path parameters [See docs](https://hapijs.com/api/16.1.1#path-parameters). */ - params: Dictionary; - /** an array containing all the path params values in the order they appeared in the path. */ - paramsArray: string[]; - /** the request URI's pathname [See docs](https://nodejs.org/api/url.html#url_urlobject_pathname) component. */ - path: string; - /** - * the request payload based on the route payload.output and payload.parse settings. - * TODO check this typing and add references / links. - */ - payload: stream.Readable | Buffer | any; - /** plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. */ - plugins: PluginsStates; - /** an object where each key is the name assigned by a route prerequisites function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. */ - pre: Object; - /** the response object when set. The object can be modified but must not be assigned another object. To replace the response with another from within an extension point, use reply(response) to override with a different response. Contains null when no response has been set (e.g. when a request terminates prematurely when the client disconnects). */ - response: Response | null; - /** same as pre but represented as the response object created by the pre method. */ - preResponses: Object; - /** - * by default the object outputted from [node's URL parse()](https://nodejs.org/docs/latest/api/url.html#url_urlobject_query) method. - * Might also be set indirectly via [request.setUrl](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17354#requestseturlurl-striptrailingslash) in which case it may be - * a string (if url is set to an object with the query attribute as an unparsed string). - */ - query: any; - /** an object containing the Node HTTP server objects. **Direct interaction with these raw objects is not recommended.** */ - raw: { - req: http.IncomingMessage; // Or http.ClientRequest http://www.apetuts.com/tutorial/node-js-http-client-request-class/ ? - res: http.ServerResponse; - }; - /** - * the route public interface. - * Optional due to "request.route is not yet populated at this point." [See docs](https://hapijs.com/api/16.1.1#request-lifecycle) - */ - route?: RoutePublicInterface; - /** the server object. */ - server: Server; - /** an object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. */ - state: Dictionary; - /** the parsed request URI */ - url: url.Url; - - /** - * request.setUrl(url, [stripTrailingSlash]) - * Available only in 'onRequest' extension methods. - * Changes the request URI before the router begins processing the request - * [See docs](https://hapijs.com/api/16.1.1#requestseturlurl-striptrailingslash) - * @param url the new request URI. If url is a string, it is parsed with node's URL parse() method. url can also be set to an object compatible with node's URL parse() method output. - * @param stripTrailingSlash if true, strip the trailing slash from the path. Defaults to false. - */ - setUrl(url: string | url.Url, stripTrailingSlash?: boolean): void; - /** - * request.setMethod(method) - * Available only in 'onRequest' extension methods. - * Changes the request method before the router begins processing the request - * [See docs](https://hapijs.com/api/16.1.1#requestsetmethodmethod) - * @param method is the request HTTP method (e.g. 'GET'). - */ - setMethod(method: HTTP_METHODS): void; - /** - * request.generateResponse(source, [options]) - * Always available. - * Returns a response which you can pass into the reply interface where: - * [See docs](https://hapijs.com/api/16.1.1#requestgenerateresponsesource-options) - * @param source the object to set as the source of the reply interface. TODO, submit a PR to clarify this doc, from the source code it's clear that "the object to set" refers to something of type `ReplyValue` i.e. that can be null, string, number, object, Stream, Promise, or Buffer. - * @param options options for the method, optional. Not documented yet, perhaps not very important. - */ - generateResponse(source?: ReplyValue, options?: {marshal?: any; prepare?: any; close?: any; variety?: any}): Response; - /** - * request.log(tags, [data, [timestamp]]) - * Always available. - * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. - * Any logs generated by the server internally will be emitted only on the 'request-internal' channel and will include the event.internal flag set to true. - * [See docs](https://hapijs.com/api/16.1.1#requestlogtags-data-timestamp) - * @param tags a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. - * @param data an optional message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. - * @param timestamp an optional timestamp expressed in milliseconds. Defaults to Date.now() (now). - */ - log(tags: string | string[], data?: string | Object | (() => string | Object), timestamp?: number): void; - /** - * request.getLog([tags], [internal]) - * Always available. - * Returns an array containing the events matching any of the tags specified (logical OR) - * Note that this methods requires the route log configuration set to true. - * [See docs](https://hapijs.com/api/16.1.1#requestgetlogtags-internal) - * @param tags is a single tag string or array of tag strings. If no tags specified, returns all events. - * @param internal filters the events to only those with a matching event.internal value. If true, only internal logs are included. If false, only user event are included. Defaults to all events (undefined). - */ - getLog(tags?: string | string[], internal?: boolean): string[]; - getLog(internal?: boolean): string[]; - /** - * request.tail([name]) - * Available until immediately after the 'response' event is emitted. - * Adds a request tail which has to complete before the request lifecycle is complete. - * Returns a tail function which must be called when the tail activity is completed. - * Tails are actions performed throughout the request lifecycle, but which may end after a response is sent back to the client. For example, a request may trigger a database update which should not delay sending back a response. However, it is still desirable to associate the activity with the request when logging it (or an error associated with it). - * When all tails completed, the server emits a 'tail' event. - * [See docs](https://hapijs.com/api/16.1.1#requesttailname) - * @param name an optional tail name used for logging purposes. - */ - tail(name?: string): (() => void); - /** - * The server.decorate('request', ...) method can modify this prototype/interface. - * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts - * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) - */ - // [index: string]: any; -} - -export interface RequestAuthenticationInformation { - /** true if the request has been successfully authenticated, otherwise false. */ - isAuthenticated: boolean; - /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ - credentials: any; - /** an artifact object received from the authentication strategy and used in authentication-related actions. */ - artifacts: any; - /** the route authentication mode. */ - mode: string; - /** the authentication error is failed and mode set to 'try'. */ - error: Error; -} - -export type HTTP_METHODS_PARTIAL_lowercase = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; -export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_lowercase; -export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; - -/** - * Request events - * The request object supports the following events: - * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). - * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). - * * 'disconnect' - emitted when a request errors or aborts unexpectedly. - * [See docs](https://hapijs.com/api/16.1.1#request-events) - */ -export type RequestEventTypes = 'peek' | 'finish' | 'disconnect'; - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Handler functions + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Extending RouteConfiguration.handler - * - * The hapi documentation allows for the RouteConfiguration.handler type to have - * `{[pluginName: string]: pluginOptions}` - * "handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler" - * This can be provided by extending the hapi module definition as follows, - * see h2o2 for example: - * - * declare module 'hapi' { - * interface RouteHandlerPlugins { - * proxy?: ... - */ -export interface RouteHandlerPlugins { -} -/** - * The route handler function uses the signature function(request, reply) (NOTE: do not use a fat arrow style function for route handlers as they do not allow context binding and will cause problems when used in conjunction with server.bind) where: - * * request - is the incoming request object (this is not the node.js request object). - * * reply - the reply interface the handler must call to set a response and return control back to the framework. - * [See docs](https://hapijs.com/api/16.1.1#route-handler) - * Same function signature used by request extension point used in server.ext(event), see ServerExtConfigurationObject.method - */ -export interface RouteHandler { - (request: Request, reply: ReplyNoContinue): void; - // (request: Request, reply: StrictReply): void; -} - -/** - * "the function to call, the function signature is identical to a route handler as described in Route handler." - * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) Route prerequisites - */ -export type RoutePrerequisiteRequestHandler = RouteHandler; - -/** - * request extension points: function(request, reply) where - * this - the object provided via options.bind or the current active context set with server.bind(). - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * @param request the request object. - * @param reply the reply interface which is used to return control back to the framework. To continue normal execution of the request lifecycle, reply.continue() must be called. If the extension type is 'onPostHandler' or 'onPreResponse', a single argument passed to reply.continue() will override the current set response (including all headers) but will not stop the request lifecycle execution. To abort processing and return a response to the client, call reply(value) where value is an error or any other valid response. - */ -export interface ServerExtRequestHandler { - (request: Request, reply: ReplyWithContinue): void; -} - -/** - * Used by various extensions to handle a request and - * synchronously return a result of some form. - * - * Left in for backwards compatibility of typings but according to the - * [DefinitelyTyped Readme under common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes) - * it talks about not using generic types unless the type was used in typing one - * or more of the function arguments. Using it to type the return was suggested - * to be the same as a type assertion. - */ -export interface RequestHandler { - (request: Request): T; -} - -/** - * Used by server extension points - * err can be `Boom` error or Error that will be wrapped as a `Boom` error - * For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/reply.js#L109-L118) - * For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65) - */ -export interface ContinuationFunction { - (err?: Boom.BoomError): void; -} -/** - * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65) - * TODO Can value be typed with a useful generic? - */ -export interface ContinuationValueFunction { - (err: Boom.BoomError): void; - (err: null | undefined, value: any): void; - (): void; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Reply functions + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Typings listed explicitly here [See docs](https://hapijs.com/api/16.1.1#replyerr-result) - * Typings also described in part here [See docs](https://hapijs.com/api/16.1.1#response-object) - */ -export type ReplyValue = _ReplyValue | Promise<_ReplyValue>; -export type _ReplyValue = null | undefined | string | number | boolean | Buffer | Error | stream.Stream | Object; // | array; - -/** - * Reply interface - * reply([err], [result]) - * Concludes the handler activity by setting a response and returning control over to the framework - * When reply() is called with an error or result response, that value is used as the response sent to the client. When reply() is called within a prerequisite, the value is saved for future use and is not used as the response. In all other places except for the handler, calling reply() will be considered an error and will abort the request lifecycle, jumping directly to the 'onPreResponse' event. - * To return control to the framework within an extension or other places other than the handler, without setting a response, the method reply.continue() must be called. Except when used within an authentication strategy, or in an 'onPostHandler' or 'onPreResponse' extension, the reply.continue() must not be passed any argument or an exception is thrown. - * [See docs](https://hapijs.com/api/16.1.1#reply-interface) - * [See docs](https://hapijs.com/api/16.1.1#replyerr-result) - * - * NOTE: modules should extend this interface to expose reply.Nnn methods - */ -export interface Base_Reply { - (err?: ReplyValue): Response; - (err: null, result?: ReplyValue): Response; - /** the active realm associated with the route. */ - realm: ServerRealm; - /** the request object */ - request: Request; - - /** - * reply.entity(options) - * Sets the response 'ETag' and 'Last-Modified' headers and checks for any conditional request headers to decide if the response is going to qualify for an HTTP 304 (Not Modified). If the entity values match the request conditions, reply.entity() returns control back to the framework with a 304 response. Otherwise, it sets the provided entity headers and returns null. - * Returns a response object if the reply is unmodified or null if the response has changed. If null is returned, the developer must call reply() to continue execution. If the response is not null, the developer must not call reply(). - * [See docs](https://hapijs.com/api/16.1.1#replyentityoptions) - * @param options a required configuration object with: - * * etag - the ETag string. Required if modified is not present. Defaults to no header. - * * modified - the Last-Modified header value. Required if etag is not present. Defaults to no header. - * * vary - same as the response.etag() option. Defaults to true. - */ - entity(options: {etag?: string, modified?: string, vary?: boolean}): Response | null; - /** - * reply.close([options]) - * Concludes the handler activity by returning control over to the router and informing the router that a response has already been sent back directly via request.raw.res and that no further response action is needed. Supports the following optional options: - * The response flow control rules do not apply. - * [See docs](https://hapijs.com/api/16.1.1#replycloseoptions) - * @param options options object: - * * end - if false, the router will not call request.raw.res.end()) to ensure the response was ended. Defaults to true. - */ - close(options?: {end?: boolean}): void; - /** - * reply.redirect(uri) - * Redirects the client to the specified uri. Same as calling reply().redirect(uri). - * The response flow control rules apply. - * Sets an HTTP redirection response (302) and decorates the response with additional methods for - * changing to a permanent or non-rewritable redirect is also available see response object redirect for more information. - * [See docs](https://hapijs.com/api/16.1.1#replyredirecturi) - * @param uri an absolute or relative URI used to redirect the client to another resource. - */ - redirect(uri: string): ResponseRedirect; - /** - * reply.response(result) - * Shorthand for calling `reply(null, result)`, replies with the response set to `result`. - * [See docs](https://hapijs.com/api/16.1.1#replyresponseresult) - * TODO likely to change. Await approval of pull request to Hapi docs. - */ - response(result: ReplyValue): Response; - /** - * Sets a cookie on the response - * [See docs](https://hapijs.com/api/16.1.1#reply) - * TODO likely to change. Await approval of pull request to Hapi docs. - */ - state(name: string, value: any, options?: any): void; - /** - * Clears a cookie on the response - * [See docs](https://hapijs.com/api/16.1.1#reply) - * TODO likely to change. Await approval of pull request to Hapi docs. - */ - unstate(name: string, options?: any): void; - /** - * The server.decorate('reply', ...) method can modify this prototype/interface. - * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts - * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) - */ - // [index: string]: any; -} -/** - * reply.continue([result]) - * Returns control back to the framework without ending the request lifecycle - * [See docs](https://hapijs.com/api/16.1.1#replycontinueresult) - * [See docs](https://hapijs.com/api/16.1.1#replyerr-result) "With the exception of the handler function, all other methods provide the reply.continue() method which instructs the framework to continue processing the request without setting a response." - * @param result if called in the handler, prerequisites, or extension points other than the 'onPreHandler' and 'onPreResponse', the result argument is not allowed and will throw an exception if present. If called within an authentication strategy, it sets the authenticated credentials. If called by the 'onPreHandler' or 'onPreResponse' extensions, the result argument overrides the current response including all headers, and returns control back to the framework to continue processing any remaining extensions. - */ -export interface Continue_Reply { - continue(result?: ReplyValue): Response | undefined; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > authenticate. - * Also [See docs](https://hapijs.com/api/16.1.1#replyerr-result). - * TODO check it has Base_Reply methods and properties - */ -export interface ReplySchemeAuth extends Base_Reply { - /** - * This function is called if authentication failed. - * TODO, check type the `response` parameter. In https://hapijs.com/api/16.1.1#replyerr-result it is referred to as "null" but this seems to be for a third scenario where it is "used to return both an error and credentials in the authentication methods" then "reply() must be called with three arguments function(err, null, data)" - * @param err any authentication error. - * @param response any authentication response action such as redirection. Ignored if err is present, otherwise required. - * @param result an object containing: - * * credentials the authenticated credentials. - * * artifacts optional authentication artifacts. - */ - (err: Error | null, response: AnyAuthenticationResponseAction | null, result: AuthenticationResult): void; - /** - * is called if authentication succeeded - * @param result same object as result above. - */ - continue(result: AuthenticationResult): void; -} -/** - * Typing as any as it's not yet clear what type this argument takes. - * "any authentication response action such as redirection" is it equivalent to - * `ReplyValue` ? - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) - * TODO research hapi source and type this. - */ -export type AnyAuthenticationResponseAction = any; -/** [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) */ -export interface AuthenticationResult { - credentials?: AuthenticatedCredentials; - artifacts?: any; -} -export interface AuthenticatedCredentials { - // Disabled to allow typing within a project - // [index: string]: any; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > payload - * TODO check it has Base_Reply methods and properties - */ -export interface ReplySchemeAuthOfPayload extends Base_Reply { - /** - * function called to authenticate the request payload where: - * @param err any authentication error. - * @param response any authentication response action such as redirection. Ignored if err is present, otherwise required. - */ - (err: Error | null, response: AnyAuthenticationResponseAction): void; - /** is called if payload authentication succeeded */ - continue(): void; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > response - * TODO check it has Base_Reply methods and properties - */ -export interface ReplySchemeAuthDecorateResponse extends Base_Reply { - /** - * is called if an error occurred - * @param err any authentication error. - * @param response any authentication response to send instead of the current response. Ignored if err is present, otherwise required. - */ - (err?: Error, response?: ReplyValue): void; - /** is called if the operation succeeded. */ - continue(): void; -} - -export interface ReplyWithContinue extends Continue_Reply, Base_Reply {} - -export interface ReplyNoContinue extends Base_Reply {} - -// TODO assess use and usefulness of StrictReply - -// Concludes the handler activity by setting a response and returning control over to the framework where: -// erran optional error response. -// result an optional response payload. -// Since an request can only have one response regardless if it is an error or success, the reply() method can only result in a single response value. This means that passing both an err and result will only use the err. There is no requirement for either err or result to be (or not) an Error object. The framework will simply use the first argument if present, otherwise the second. The method supports two arguments to be compatible with the common callback pattern of error first. -// FLOW CONTROL: -// When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() -/** - * - */ -// export interface Reply { // extends ReplyMethods { -// (err: Error, -// result?: string | number | boolean | Buffer | stream.Stream | Promise | T, -// /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ -// credentialData?: any): BoomError; -// /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ -// (result: string | number | boolean | Buffer | stream.Stream | Promise | T): Response; -// } - -/** Concludes the handler activity by setting a response and returning control over to the framework where: - erran optional error response. - result an optional response payload. - Since an request can only have one response regardless if it is an error or success, the reply() method can only result in a single response value. This means that passing both an err and result will only use the err. There is no requirement for either err or result to be (or not) an Error object. The framework will simply use the first argument if present, otherwise the second. The method supports two arguments to be compatible with the common callback pattern of error first. - FLOW CONTROL: - When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() */ -// export interface StrictReply extends ReplyMethods { -// (err: Error, -// result?: Promise | T, -// /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ -// credentialData?: any): BoomError; -// /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ -// (result: Promise | T): Response; -// } - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Response + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Response object - * [See docs](https://hapijs.com/api/16.1.1#response-object) - * - * TODO, check extending from Podium is correct. Extending because of "The response object supports the following events" [See docs](https://hapijs.com/api/16.1.1#response-events) - * * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). - * * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). - */ -export interface Response extends Podium { - /** the HTTP response status code. Defaults to 200 (except for errors). */ - statusCode: number; - /** an object containing the response headers where each key is a header field name. Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission. */ - headers: Dictionary; - /** the value provided using the reply interface. */ - source: ReplyValue; - /** - * a string indicating the type of source with available values: - * * 'plain' - a plain response such as string, number, null, or simple object (e.g. not a Stream, Buffer, or view). - * * 'buffer' - a Buffer. - * * 'stream' - a Stream. - * * 'promise' - a Promise object. - */ - variety: 'plain' | 'buffer' | 'stream' | 'promise'; - /** application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. */ - app: any; - /** plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. */ - plugins: PluginsStates; - /** response handling flags: */ - settings: { - /** the 'Content-Type' HTTP header 'charset' property. Defaults to 'utf-8'. */ - charset: string; - /** the string encoding scheme used to serial data into the HTTP payload when source is a string or marshals into a string. Defaults to 'utf8'. */ - encoding: string; - /** if true and source is a Stream, copies the statusCode and headers of the stream to the outbound response. Defaults to true. */ - passThrough: boolean; - /** options used for source value requiring stringification. Defaults to no replacer and no space padding. */ - stringify: Json.StringifyArguments; - /** if set, overrides the route cache expiration milliseconds value set in the route config. Defaults to no override. */ - ttl: number | null; - /** if true, a suffix will be automatically added to the 'ETag' header at transmission time (separated by a '-' character) when the HTTP 'Vary' header is present. */ - varyEtag: boolean; - }; - - /** - * The following attribute is present in one or more of the examples - * TODO update once Hapi docs describes explicitly - */ - isBoom?: boolean; - /** - * The following attribute is present in one or more of the examples - * TODO update once Hapi docs describes explicitly - */ - isMissing?: boolean; - /** - * The following attribute is present in one or more of the examples - * TODO update once Hapi docs describes explicitly - */ - output?: Boom.Output; - - /** - * sets the HTTP 'Content-Length' header (to avoid chunked transfer encoding) - * @param length the header value. Must match the actual payload size. - */ - bytes(length: number): Response; - /** - * sets the 'Content-Type' HTTP header 'charset' property - * @param charset the charset property value. - */ - charset(charset: string): Response; - /** - * sets the HTTP status code - * @param statusCode the HTTP status code (e.g. 200). - */ - code(statusCode: number): Response; - /** - * sets the HTTP status message - * @param httpMessage the HTTP status message (e.g. 'Ok' for status code 200). - */ - message(httpMessage: string): Response; - /** - * sets the HTTP status code to Created (201) and the HTTP 'Location' header - * @param uri an absolute or relative URI used as the 'Location' header value. - */ - created(uri: string): Response; - /** - * sets the string encoding scheme used to serial data into the HTTP payload - * @param encoding the encoding property value (see node Buffer encoding [See docs](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings)). - * * 'ascii' - for 7-bit ASCII data only. This encoding is fast and will strip the high bit if set. - * * 'utf8' - Multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8. - * * 'utf16le' - 2 or 4 bytes, little-endian encoded Unicode characters. Surrogate pairs (U+10000 to U+10FFFF) are supported. - * * 'ucs2' - Alias of 'utf16le'. - * * 'base64' - Base64 encoding. When creating a Buffer from a string, this encoding will also correctly accept "URL and Filename Safe Alphabet" as specified in RFC4648, Section 5. - * * 'latin1' - A way of encoding the Buffer into a one-byte encoded string (as defined by the IANA in RFC1345, page 63, to be the Latin-1 supplement block and C0/C1 control codes). - * * 'binary' - Alias for 'latin1'. - * * 'hex' - Encode each byte as two hexadecimal characters. - */ - encoding(encoding: 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex'): Response; - /** - * sets the representation entity tag - * @param tag the entity tag string without the double-quote. - * @param options options object - * * weak - if true, the tag will be prefixed with the 'W/' weak signifier. Weak tags will fail to match identical tags for the purpose of determining 304 response status. Defaults to false. - * * vary - if true and content encoding is set or applied to the response (e.g 'gzip' or 'deflate'), the encoding name will be automatically added to the tag at transmission time (separated by a '-' character). Ignored when weak is true. Defaults to true. - */ - etag(tag: string, options?: {weak: boolean, vary: boolean}): Response; - /** - * sets an HTTP header - * @param name the header name. - * @param value the header value. - */ - header(name: string, value: string, options?: ResponseHeaderOptionsObject): Response; - /** - * sets the HTTP 'Location' header - * @param uri an absolute or relative URI used as the 'Location' header value. - */ - location(uri: string): Response; - /** - * sets an HTTP redirection response (302) and decorates the response with additional methods listed below, - * @param uri an absolute or relative URI used to redirect the client to another resource. - */ - redirect(uri: string): Response; - /** - * sets the JSON.stringify() replacer argument - * @param method the replacer function or array. Defaults to none. - */ - replacer(method: Json.StringifyReplacer): Response; - /** - * sets the JSON.stringify() space argument - * @param count the number of spaces to indent nested object keys. Defaults to no indentation. - */ - spaces(count: Json.StringifySpace): Response; - /** - * sets an HTTP cookie - * @param name the cookie name. - * @param value the cookie value. If no encoding is defined, must be a string. - * @param options optional configuration. If the state was previously registered with the server using server.state(), the specified keys in options override those same keys in the server definition (but not others). - */ - state(name: string, value: string | Object | any[], options?: ServerStateCookieConfiguationObject): Response; - /** - * sets a string suffix when the response is process via JSON.stringify(). - */ - suffix(suffix: string): Response; - /** - * overrides the default route cache expiration rule for this response instance - * @param msec the time-to-live value in milliseconds. - */ - ttl(msec: number): Response; - /** - * sets the HTTP 'Content-Type' header - * @param mimeType is the mime type. Should only be used to override the built-in default for each response type. - */ - type(mimeType: string): Response; - /** - * clears the HTTP cookie by setting an expired value - * @param name the cookie name. - * @param options optional configuration for expiring cookie. If the state was previously registered with the server using server.state(), the specified keys in options override those same keys in the server definition (but not others). - */ - unstate(name: string, options?: ServerStateCookieConfiguationObject): Response; - /** - * adds the provided header to the list of inputs affected the response generation via the HTTP 'Vary' header - * @param header the HTTP request header name. - */ - vary(header: string): Response; - - /** - * Flow control - hold() - * When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: - * puts the response on hold until response.send() is called. Available only after reply() is called and until response.hold() is invoked once. - * [See docs](https://hapijs.com/api/16.1.1#flow-control) - */ - hold(): Response; - /** - * Flow control - send() - * When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: - * immediately resume the response. Available only after response.hold() is called and until response.send() is invoked once. - * [See docs](https://hapijs.com/api/16.1.1#flow-control) - */ - send(): Response; - - /** - * Mentioned here: "Note that prerequisites do not follow the same rules of the normal reply interface. In all other cases, calling reply() with or without a value will use the result as the response sent back to the client. In a prerequisite method, calling reply() will assign the returned value to the provided assign key. If the returned value is an error, the failAction setting determines the behavior. To force the return value as the response and skip any other prerequisites and the handler, use the reply().takeover() method." - * TODO prepare documentation PR and submit to hapi. - * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) - */ - takeover(): Response; -} - -/** - * Response Object Redirect Methods - * When using the redirect() method, the response object provides these additional methods: - * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) - */ -export interface ResponseRedirect extends Response { - /** - * temporary - * sets the status code to 302 or 307 (based on the rewritable() setting) where: - * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) - * @param isTemporary if false, sets status to permanent. Defaults to true. - */ - temporary(isTemporary: boolean): Response; - /** - * permanent - * sets the status code to 301 or 308 (based on the rewritable() setting) where: - * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) - * @param isPermanent if false, sets status to temporary. Defaults to true. - */ - permanent(isPermanent: boolean): Response; - /** - * rewritable - * sets the status code to 301/302 for rewritable (allows changing the request method from 'POST' to 'GET') or 307/308 for non-rewritable (does not allow changing the request method from 'POST' to 'GET'). Exact code based on the temporary() or permanent() setting. Arguments: - * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) - * @param isRewritable if false, sets to non-rewritable. Defaults to true. - */ - rewritable(isRewritable: boolean): Response; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#response-object) under "response object provides the following methods" > header > options - */ -export interface ResponseHeaderOptionsObject { - /** if true, the value is appended to any existing header value using separator. Defaults to false. */ - append?: boolean; - /** string used as separator when appending to an existing value. Defaults to ','. */ - separator?: string; - /** if false, the header value is not set if an existing value present. Defaults to true. */ - override?: boolean; - /** if false, the header value is not modified if the provided value is already included. Does not apply when append is false or if the name is 'set-cookie'. Defaults to true. */ - duplicate?: boolean; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Plugins and register + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Plugins - * Plugins provide a way to organize the application code by splitting the server logic into smaller components. Each plugin can manipulate the server and its connections through the standard server interface, but with the added ability to sandbox certain properties. - * [See docs](https://hapijs.com/api/16.1.1#plugins) - * @param server the server object the plugin is being registered to. - * @param options an options object passed to the plugin during registration. - * @param next a callback method the function must call to return control back to the framework to complete the registration process with signature function(err) - */ -export interface PluginFunction { - (server: Server, options: OptionsPassedToPlugin, next: (err?: Error) => void): void; - /** - * Note attributes is NOT optional but this type is easier to use. - */ - attributes?: PluginAttributes; -} - -/** - * see Plugin - * [See docs](https://hapijs.com/api/16.1.1#plugins) - */ -export interface PluginAttributes { - /** - * required plugin name string. The name is used as a unique key. Published plugins should use the same name as the name field in the 'package.json' file. Names must be unique within each application. - * NOTE: marked as optional as `pkg` can be used instead. - */ - name?: string; - /** optional plugin version. The version is only used informatively to enable other plugins to find out the versions loaded. The version should be the same as the one specified in the plugin's 'package.json' file. */ - version?: string; - /** Alternatively, the name and version can be included via the pkg attribute containing the 'package.json' file for the module which already has the name and version included */ - pkg?: any; - /** if true, allows the plugin to be registered multiple times with the same server. Defaults to false. */ - multiple?: boolean; - /** optional string or array of string indicating a plugin dependency. Same as setting dependencies via server.dependency(). */ - dependencies?: string | string[]; - /** if false, does not allow the plugin to call server APIs that modify the connections such as adding a route or configuring state. This flag allows the plugin to be registered before connections are added and to pass dependency requirements. When set to 'conditional', the mode is based on the presence of selected connections (if the server has connections, it is the same as true, but if no connections are available, it is the same as false). Defaults to true. */ - connections?: boolean | 'conditional'; - /** if true, will only register the plugin once per connection (or once per server for a connectionless plugin). If set, overrides the once option passed to server.register(). Defaults to undefined (registration will be based on the server.register() option once). */ - once?: boolean; -} - -/** - * Plugins State - * Related [See docs](https://hapijs.com/api/16.1.1#serverplugins) - * Related [See docs](https://hapijs.com/api/16.1.1#serverrealm) - */ -export interface PluginsStates { - [pluginName: string]: any; -} - -/** - * once, select, routes - optional plugin-specific registration options as defined see PluginRegistrationOptions - * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) - */ -export interface PluginRegistrationObject extends PluginRegistrationOptions { - /** the plugin registration function. */ - register: PluginFunction; - /** optional options passed to the registration function when called. */ - options?: OptionsPassedToPlugin; -} - -/** - * registration options (different from the options passed to the registration function): - * * once - if true, the registration is skipped for any connection already registered with. Cannot be used with plugin options. If the plugin does not have a connections attribute set to false and the registration selection is empty, registration will be skipped as no connections are available to register once. Defaults to false. - * * routes - modifiers applied to each route added by the plugin: - * * prefix - string added as prefix to any route path (must begin with '/'). If a plugin registers a child plugin the prefix is passed on to the child or is added in front of the child-specific prefix. - * * vhost - virtual host string (or array of strings) applied to every route. The outer-most vhost overrides the any nested configuration. - * * select - a string or array of string labels used to pre-select connections for plugin registration. - * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) - */ -export interface PluginRegistrationOptions { - once?: boolean; - routes?: {prefix?: string, vhost?: string | string[]}; - select?: string | string[]; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + JSON + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// This was in a seperate file and perhaps should move to some of the lib typings? -// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/16065#issuecomment-299443673 -// -// json/json-tests.ts -// -// import * as JSON from './index'; -// -// var a: JSON.StringifyReplacer = function(key, value) { -// if (key === "do not include") { -// return undefined; -// } -// return value; -// }; -// - -export namespace Json { - /** - * @see {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter} - */ - export type StringifyReplacer = ((key: string, value: any) => any) | (string | number)[] | undefined; - - /** - * Any value greater than 10 is truncated. - */ - export type StringifySpace = number | string; - - export interface StringifyArguments { - /** the replacer function or array. Defaults to no action. */ - replacer?: StringifyReplacer; - /** number of spaces to indent nested object keys. Defaults to no indentation. */ - space?: StringifySpace; - } -} +/** PLUGIN */ +export * from './definitions/plugin/plugin' +export * from './definitions/plugin/plugin-registered' + +/** REQUEST */ +export * from './definitions/request/request' +export * from './definitions/request/request-auth' +export * from './definitions/request/request-events' +export * from './definitions/request/request-info' +export * from './definitions/request/request-route' + +/** RESPONSE */ +export * from './definitions/response/response-events' +export * from './definitions/response/response-object' +export * from './definitions/response/response-settings' +export * from './definitions/response/response-toolkit' + +/** ROUTE */ +export * from './definitions/route/route-options' +export * from './definitions/route/route-options-access' +export * from './definitions/route/route-options-access-scope' +export * from './definitions/route/route-options-cache' +export * from './definitions/route/route-options-cors' +export * from './definitions/route/route-options-payload' +export * from './definitions/route/route-options-pre' +export * from './definitions/route/route-options-response' +export * from './definitions/route/route-options-secure' +export * from './definitions/route/route-options-validate' + +/** SERVER */ +export * from './definitions/server/server' +export * from './definitions/server/server-auth' +export * from './definitions/server/server-auth-scheme' +export * from './definitions/server/server-cache' +export * from './definitions/server/server-events' +export * from './definitions/server/server-ext' +export * from './definitions/server/server-info' +export * from './definitions/server/server-inject' +export * from './definitions/server/server-method' +export * from './definitions/server/server-options' +export * from './definitions/server/server-options-cache' +export * from './definitions/server/server-realm' +export * from './definitions/server/server-register' +export * from './definitions/server/server-route' +export * from './definitions/server/server-state' +export * from './definitions/server/server-state-options' + +/** UTIL */ +export * from './definitions/util/json' +export * from './definitions/util/lifecycle' +export * from './definitions/util/util' diff --git a/types/hapi/test/request/event-types.ts b/types/hapi/test/request/event-types.ts index 0946f0a0ed..894e4dcf39 100644 --- a/types/hapi/test/request/event-types.ts +++ b/types/hapi/test/request/event-types.ts @@ -1,30 +1,76 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents +// https://github.com/hapijs/hapi/blob/master/API.md#-requestevents +import { + Lifecycle, + Request, + ResponseToolkit, + RouteOptions, + Server, + ServerOptions, + ServerRoute +} from "hapi"; +import * as Crypto from 'crypto'; -// From https://hapijs.com/api/16.1.1#requestsetmethodmethod +const options: ServerOptions = { + port: 8000, +}; -import * as Hapi from 'hapi'; -const Crypto = require('crypto'); -const server = new Hapi.Server(); -server.connection({ port: 80 }); +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: (request: Request, h: ResponseToolkit) => { + return 'ok: ' + request.path; + } +}; -const onRequest: Hapi.ServerExtRequestHandler = function (request, reply) { +const onRequest: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { + /* + * Server events + */ + request.server.events.on('request', (request: Request, event: any, tags: any) => { + console.log(request.paramsArray); + console.log(event); + console.log(tags); + }); + + request.server.events.on('response', (request: Request) => { + console.log('Response sent for request: ' + request.path); + }); + + request.server.events.on('start', (route: RouteOptions) => { + console.log('Server started'); + }); + + request.server.events.once('stop', (route: RouteOptions) => { + console.log('Server stoped'); + }); + + /* + * Request events + */ const hash = Crypto.createHash('sha1'); - request.on('peek', (chunk) => { + request.events.on("peek", (chunk: any) => { hash.update(chunk); }); - request.once('finish', () => { - + request.events.once("finish", () => { console.log(hash.digest('hex')); }); - request.once('disconnect', () => { - + request.events.once("disconnect", () => { console.error('request aborted'); }); - return reply.continue(); + return h.continue; + }; +const server = new Server(options); +server.route(serverRoute); server.ext('onRequest', onRequest); + +server.start(); +console.log('Server started at: ' + server.info.uri); + diff --git a/types/hapi/test/request/get-log.ts b/types/hapi/test/request/get-log.ts index 289bdd3282..007d396fe5 100644 --- a/types/hapi/test/request/get-log.ts +++ b/types/hapi/test/request/get-log.ts @@ -1,12 +1,29 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data +import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; -// From https://hapijs.com/api/16.1.1#requestgetlogtags-internal +const options: ServerOptions = { + port: 8000, +}; -import * as Hapi from 'hapi'; +const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { + request.log(['test', 'error'], 'Test event'); + return 'path: ' + request.path; +}; -var request: Hapi.Request = {}; +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: handler +}; -request.getLog(); -request.getLog('error'); -request.getLog(['error', 'auth']); -request.getLog(['error'], true); -request.getLog(false); +const server = new Server(options); +server.route(serverRoute); +server.start(); +console.log('Server started at: ' + server.info.uri); + +server.events.on('request', (request: Request, event: any, tags: any) => { + console.log(tags); + if (tags.error) { + console.log(event); + } +}); diff --git a/types/hapi/test/response/error.ts b/types/hapi/test/response/error.ts index 0ef503df12..6cc92acbdb 100644 --- a/types/hapi/test/response/error.ts +++ b/types/hapi/test/response/error.ts @@ -1,25 +1,31 @@ +// https://github.com/hapijs/hapi/blob/master/API.md#errors +import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; +import * as Boom from "boom"; -// From https://hapijs.com/api/16.1.1#error-response +const options: ServerOptions = { + port: 8000, +}; -import * as Hapi from 'hapi'; -const Boom = require('boom'); +const serverRoutes: ServerRoute[] = [ + { + path: '/badRequest', + method: 'GET', + handler: (request: Request, h: ResponseToolkit) => { + throw Boom.badRequest('Unsupported parameter'); + } + }, + { + path: '/internal', + method: 'GET', + handler: (request: Request, h: ResponseToolkit) => { + throw new Error('unexpect error'); + } + }, +]; -const server = new Hapi.Server(); -server.route({ - method: 'GET', - path: '/badRequest', - handler: function (request, reply) { +const server = new Server(options); +server.route(serverRoutes); - return reply(Boom.badRequest('Unsupported parameter')); - } -}); - -server.route({ - method: 'GET', - path: '/internal', - handler: function (request, reply) { - - return reply(new Error('unexpect error')); - } -}); +server.start(); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/test/route/config.ts b/types/hapi/test/route/config.ts index 16457395f8..1f36cd51b3 100644 --- a/types/hapi/test/route/config.ts +++ b/types/hapi/test/route/config.ts @@ -1,46 +1,52 @@ -'use strict'; +import {Request, ResponseToolkit, RouteOptions, Server, ServerOptions, ServerRoute} from "hapi"; -import * as Hapi from 'hapi'; +const options: ServerOptions = { + port: 8000, +}; // different methods -var routeConfig: Hapi.RouteConfiguration = { +var routeConfig: ServerRoute = { path: '/signin', method: 'PUT', vhost: 'site.coms', }; -var routeConfig: Hapi.RouteConfiguration = { +var routeConfig: ServerRoute = { path: '/signin', method: '*' }; -var routeConfig: Hapi.RouteConfiguration = { +var routeConfig: ServerRoute = { path: '/signin', method: ['OPTIONS', '*'] }; // different handlers -var routeConfig: Hapi.RouteConfiguration = { +var routeConfig: ServerRoute = { path: '/signin', method: 'PUT', - handler: 'some registered handler' + handler: (request: Request, h: ResponseToolkit) => { + return 'ok'; + } }; -var routeConfig: Hapi.RouteConfiguration = { +var routeConfig: ServerRoute = { path: '/signin', method: 'PUT', - handler: function (request, reply) { - return reply('ok'); + handler: (request: Request, h: ResponseToolkit) => { + return 'ok'; } }; -const server = new Hapi.Server(); +const server = new Server(options); server.route(routeConfig); // Handler in config -const user: Hapi.RouteAdditionalConfigurationOptions = { +const user: RouteOptions = { cache: { expiresIn: 5000 }, - handler: function (request, reply) { - - return reply({ name: 'John' }); + handler: (request: Request, h: ResponseToolkit) => { + return { name: 'John' }; } }; -server.route({method: 'GET', path: '/user', config: user }); +server.route({method: 'GET', path: '/user', options: user }); + +server.start(); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/tsconfig.json b/types/hapi/tsconfig.json index 2a3f7dbd5d..2358b83959 100644 --- a/types/hapi/tsconfig.json +++ b/types/hapi/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": true, + "strictNullChecks": false, "strictFunctionTypes": false, "baseUrl": "../", "typeRoots": [ @@ -18,80 +18,51 @@ }, "files": [ "index.d.ts", - "test/connection/table.ts", - "test/continuation/errors.ts", - "test/getting-started/01-creating-a-server.ts", - "test/getting-started/02-adding-routes.ts", - "test/getting-started/03-serving-static-content.ts", - "test/getting-started/04-using-plugins.ts", - "test/path/catch-all.ts", - "test/path/parameters.ts", - "test/plugins/options.ts", - "test/reply/continue.ts", - "test/reply/entity.ts", - "test/reply/redirect.ts", - "test/reply/reply.ts", - "test/reply/state_cookie.ts", + "test/request/catch-all.ts", "test/request/event-types.ts", - "test/request/generate-response.ts", "test/request/get-log.ts", - "test/request/log.ts", + "test/request/parameters.ts", "test/request/query.ts", - "test/request/set-method.ts", - "test/request/set-url.ts", - "test/request/tail.ts", - "test/response/error-representation.ts", + "test/response/continue.ts", "test/response/error.ts", - "test/response/events.ts", - "test/response/flow-control.ts", - "test/route/additional-options.ts", - "test/route/auth.ts", + "test/response/redirect.ts", + "test/response/response.ts", + "test/response/response-events.ts", + "test/route/adding-routes.ts", "test/route/config.ts", "test/route/handler.ts", - "test/route/plugins.ts", - "test/route/prerequisites.ts", - "test/route/public-interface.ts", - "test/route/validate.ts", - "test/server/app.ts", - "test/server/auth.ts", - "test/server/bind.ts", - "test/server/cache.ts", - "test/server/connection-options.ts", - "test/server/connections.ts", - "test/server/decoder.ts", - "test/server/decorate.ts", - "test/server/dependency.ts", - "test/server/emit.ts", - "test/server/encoder.ts", - "test/server/event.ts", - "test/server/expose.ts", - "test/server/ext.ts", - "test/server/handler.ts", - "test/server/info.ts", - "test/server/initialize.ts", - "test/server/inject.ts", - "test/server/listener.ts", - "test/server/load.ts", - "test/server/log.ts", - "test/server/lookup.ts", - "test/server/match.ts", - "test/server/method.ts", - "test/server/methods.ts", - "test/server/mime.ts", - "test/server/new.ts", - "test/server/on.ts", - "test/server/once.ts", - "test/server/path.ts", - "test/server/plugins.ts", - "test/server/realm.ts", - "test/server/register.ts", - "test/server/route.ts", - "test/server/select.ts", - "test/server/settings.ts", - "test/server/start.ts", - "test/server/state.ts", - "test/server/stop.ts", - "test/server/table.ts", - "test/server/version.ts" + "test/route/route-options.ts", + "test/route/route-options-pre.ts", + "test/server/server-app.ts", + "test/server/server-auth-api.ts", + "test/server/server-auth-default.ts", + "test/server/server-auth-test.ts", + "test/server/server-bind.ts", + "test/server/server-cache.ts", + "test/server/server-cache-provision.ts", + "test/server/server-decoder.ts", + "test/server/server-decorations.ts", + "test/server/server-encoder.ts", + "test/server/server-events.ts", + "test/server/server-events-once.ts", + "test/server/server-expose.ts", + "test/server/server-info.ts", + "test/server/server-inject.ts", + "test/server/server-listener.ts", + "test/server/server-load.ts", + "test/server/server-lookup.ts", + "test/server/server-match.ts", + "test/server/server-method.ts", + "test/server/server-methods.ts", + "test/server/server-mime.ts", + "test/server/server-options.ts", + "test/server/server-path.ts", + "test/server/server-plugins.ts", + "test/server/server-settings.ts", + "test/server/server-start.ts", + "test/server/server-state.ts", + "test/server/server-stop.ts", + "test/server/server-table.ts", + "test/server/server-version.ts" ] -} \ No newline at end of file +} diff --git a/types/hapi/v16/index.d.ts b/types/hapi/v16/index.d.ts new file mode 100644 index 0000000000..ee22f1dea7 --- /dev/null +++ b/types/hapi/v16/index.d.ts @@ -0,0 +1,2723 @@ +// Type definitions for hapi 16.1 +// Project: https://github.com/hapijs/hapi +// Definitions by: Jason Swearingen , AJP +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + WARNING: BACKWARDS INCOMPATIBLE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * + * + * Removal of IPromise replaced with Promise + * Removal of IReplyStrict<> + * Removal of IReply replaced with different interfaces like: + * ReplyWithContinue + * ReplyNoContinue, etc. + * Renaming of all interfaces to remove preceding I in preparation of dtslint + */ + +/// + +import Events = require("events"); +import stream = require("stream"); +import http = require("http"); +import https = require("https"); +import url = require("url"); +import zlib = require("zlib"); +import domain = require("domain"); + +import * as Boom from 'boom'; +import { + ValidationOptions as JoiValidationOptions, + SchemaMap as JoiSchemaMap, + Schema as JoiSchema, +} from 'joi'; +// TODO check JoiValidationObject is correct for "a Joi validation object" +type JoiValidationObject = JoiSchema | JoiSchemaMap | (JoiSchema | JoiSchemaMap)[]; + +import * as Catbox from 'catbox'; +import { MimosOptions } from 'mimos'; +import Podium = require('podium'); +import * as Shot from 'shot'; + +export interface Dictionary { + [key: string]: T; +} + +/** + * Server + * The Server object is the main application container. The server manages all incoming connections along with all the facilities provided by the framework. A server can contain more than one connection (e.g. listen to port 80 and 8080). + * [See docs](https://hapijs.com/api/16.1.1#server) + * [See docs](https://hapijs.com/api/16.1.1#server-properties) + * [See docs](https://hapijs.com/api/16.1.1#server-events) + */ +export class Server extends Podium { + /** + * Creates a new Server object + */ + constructor(options?: ServerOptions); + + /** + * Provides a safe place to store server-specific run-time application data without potential conflicts with the framework internals. The data can be accessed whenever the server is accessible. Initialized with an empty object. + * [See docs](https://hapijs.com/api/16.1.1#serverapp) + */ + app?: any; + /** + * An array containing the server's connections. When the server object is returned from server.select(), the connections array only includes the connections matching the selection criteria. + * [See docs](https://hapijs.com/api/16.1.1#serverconnections) + */ + connections: ServerConnection[]; + /** + * When the server contains exactly one connection, info is an object containing information about the sole connection + * When the server contains more than one connection, each server.connections array member provides its own connection.info. + * [See docs](https://hapijs.com/api/16.1.1#serverinfo) + */ + info: ServerConnectionInfo | null; + /** + * An object containing the process load metrics (when load.sampleInterval is enabled): + * [See docs](https://hapijs.com/api/16.1.1#serverload) + */ + load: { + /** event loop delay milliseconds. */ + eventLoopDelay: number; + /** V8 heap usage. */ + heapUsed: number; + /** RSS memory usage. */ + rss: number; + }; + /** + * When the server contains exactly one connection, listener is the node HTTP server object of the sole connection. + * When the server contains more than one connection, each server.connections array member provides its own connection.listener. + * [See docs](https://hapijs.com/api/16.1.1#serverlistener) + */ + listener: ServerListener | null; + /** + * An object providing access to the server methods cs://hapijs.com/api/16.1.1#servermethodname-method-options} where each server method name is an object property. + * [See docs](https://hapijs.com/api/16.1.1#servermethods) + */ + methods: Dictionary; + /** + * Provides access to the server MIME database used for setting content-type information. The object must not be modified directly but only through the mime server setting. + * [See docs](https://hapijs.com/api/16.1.1#servermime) + */ + readonly mime: {path(path: string): {type: string}}; + /** + * An object containing the values exposed by each plugin registered where each key is a plugin name and the values are the exposed properties by each plugin using server.expose(). Plugins may set the value of the server.plugins[name] object directly or via the server.expose() method. + * [See docs](https://hapijs.com/api/16.1.1#serverplugins) + */ + plugins: PluginsStates; + /** + * The realm object contains server-wide or plugin-specific state that can be shared across various methods. For example, when calling server.bind(), the active realm settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). Realms are a limited version of a sandbox where plugins can maintain state used by the framework when adding routes, extensions, and other properties. + * [See docs](https://hapijs.com/api/16.1.1#serverrealm) + */ + readonly realm: ServerRealm; + /** + * When the server contains exactly one connection, registrations is an object where each key is a registered plugin name + * When the server contains more than one connection, each server.connections array member provides its own connection.registrations. + * TODO check and offer PR to update Hapi docs: Assuming readonly. + * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) + */ + readonly registrations: ServerRegisteredPlugins; + /** + * The root server object containing all the connections and the root server methods (e.g. start(), stop(), connection()). + * TODO, check and offer PR to update Hapi docs: Marked as optional as presumably root server does not reference itself. + * [See docs](https://hapijs.com/api/16.1.1#serverroot) + */ + root?: Server; + /** + * The server configuration object after defaults applied. + * [See docs](https://hapijs.com/api/16.1.1#serversettings) + */ + settings: ServerOptions; + /** + * The hapi module version number. + * [See docs](https://hapijs.com/api/16.1.1#serverversion) + */ + version: string; + + /** + * [See docs](https://hapijs.com/api/16.1.1#serverauthapi) + * [See docs](https://hapijs.com/api/16.1.1#serverauthdefaultoptions) + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) + * [See docs](https://hapijs.com/api/16.1.1#serverauthstrategyname-scheme-mode-options) + * [See docs](https://hapijs.com/api/16.1.1#serverauthteststrategy-request-next) + */ + auth: ServerAuth; + + /** + * Sets a global context used as the default bind object when adding a route or an extension + * When setting context inside a plugin, the context is applied only to methods set up by the plugin. Note that the context applies only to routes and extensions added after it has been set. Ignored if the method being bound is an arrow function. + * @param context the object used to bind this in handler and extension methods. + * [See docs](https://hapijs.com/api/16.1.1#serverbindcontext) + */ + bind(context: any): void; + /** + * [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) + * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) + */ + cache: ServerCacheMethod; + /** + * Adds an incoming server connection + * Returns a server object with the new connections selected. + * Must be called before any other server method that modifies connections is called for it to apply to the new connection (e.g. server.state()) + * Note that the options object is deeply cloned (with the exception of listener which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on. + * + * [See docs](https://hapijs.com/api/16.1.1#serverconnectionoptions) for various advantage topics covering usage and caveats around use of the function in plugin register(), connectionless plugins calling connection(), etc. + * @param connection a connection configuration object or array of objects + */ + connection(options?: ServerConnectionOptions[]): Server; + connection(options?: ServerConnectionOptions): Server; + // connection: (options: ServerConnectionOptions[] | ServerConnectionOptions) => Server; + /** + * Registers a custom content decoding compressor to extend the built-in support for 'gzip' and 'deflate' + * [See docs](https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder) + * @param encoding the decoder name string. + * @param decoder a function using the signature function(options) where options are the encoding specific options configured in the route payload.compression configuration option, and the return value is an object compatible with the output of node's zlib.createGunzip(). + */ + decoder(encoding: string, decoder: ((options: CompressionDecoderSettings) => zlib.Gunzip)): void; + /** + * Extends various framework interfaces with custom methods + * Note that decorations apply to the entire server and all its connections regardless of current selection. + * [See docs](https://hapijs.com/api/16.1.1#serverdecoratetype-property-method-options) + * + * NOTE: it's not possible to type the result of this action. + * It's advised that in a custom definition file, you extend the ReplyNoContinue + * and ReplyWithContinue functions. See Inert `.file` for an example. + * Or if it is not part of a library / plugin then you use a namespace within + * your code to type the request, server and or reply. See + * [tests/server/decorate.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hapi/tests/server/decorate.ts) + * for examples. + * @param type the interface being decorated. Supported types: + * * 'request' - adds methods to the Request object. + * * 'reply' - adds methods to the reply interface. + * * 'server' - adds methods to the Server object. + * @param property the object decoration key name. + * @param method the extension function or other value. + * @param options if the type is 'request', supports the following optional settings: + * * apply - if true, the method function is invoked using the signature function(request) where request is the current request object and the returned value is assigned as the decoration. + */ + decorate(type: 'request' | 'reply' | 'server', property: string, method: Function): void; + decorate(type: 'request', property: string, method: Function, options?: {apply: false}): void; + decorate(type: 'request', property: string, method: (request: Request) => Function, options: {apply: true}): void; + /** + * The server.decorate('server', ...) method can modify this prototype/interface. + * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts + * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) + */ + // [index: string]: any; + /** + * Used within a plugin to declare a required dependency on other plugins + * The after method is identical to setting a server extension point on 'onPreStart'. Connectionless plugins (those with attributes.connections set to false) can only depend on other connectionless plugins (server initialization will fail even of the dependency is loaded but is not connectionless). + * Dependencies can also be set via the register attributes property (does not support setting after). + * [See docs](https://hapijs.com/api/16.1.1#serverdependencydependencies-after) + * @param dependencies a single string or array of plugin name strings which must be registered in order for this plugin to operate. Plugins listed must be registered before the server is initialized or started. Does not provide version dependency which should be implemented using npm peer dependencies. + * @param after an optional function called after all the specified dependencies have been registered and before the server starts. The function is only called if the server is initialized or started. If a circular dependency is detected, an exception is thrown (e.g. two plugins each has an after function to be called after the other). The function signature is function(server, next) + */ + dependency(dependencies: string | string[], after?: AfterDependencyLoadCallback): void; + /** + * Emits a custom application event update to all the subscribed listeners + * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. + * [See docs](https://hapijs.com/api/16.1.1#serveremitcriteria-data-callback) + * @param criteria the event update criteria which if an object can have the following optional keys (unless noted otherwise): + * * name - the event name string (required). + * * channel - the channel name string. + * * tags - a tag string or array of tag strings. + * @param data the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. + * @param callback an optional callback method invoked when all subscribers have been notified using the signature function(). The callback is called only after all the listeners have been notified, including any event updates emitted earlier (the order of event updates are guaranteed to be in the order they were emitted). + */ + emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: any, callback?: () => void): void; + /** + * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' + * [See docs](https://hapijs.com/api/16.1.1#serverencoderencoding-encoder) + * @param encoding the encoder name string. + * @param encoder a function using the signature function(options) where options are the encoding specific options configured in the route compression configuration option, and the return value is an object compatible with the output of node's zlib.createGzip(). + */ + encoder(encoding: string, encoder: ((options: CompressionEncoderSettings) => zlib.Gzip)): void; + /** + * Register custom application events + * [See docs](https://hapijs.com/api/16.1.1#servereventevents) + * @param events see ApplicationEvent + */ + event(events: ApplicationEvent[]): void; + event(events: ApplicationEvent): void; + /** + * Used within a plugin to expose a property via server.plugins[name] + * [See docs](https://hapijs.com/api/16.1.1#serverexposekey-value) + * @param key the key assigned (server.plugins[name][key]). + * @param value the value assigned. + */ + expose(key: string, value: any): void; + /** + * Merges an object into to the existing content of server.plugins[name] + * Note that all properties of obj are deeply cloned into server.plugins[name], so you should avoid using this method for exposing large objects that may be expensive to clone or singleton objects such as database client objects. Instead favor the server.expose(key, value) form, which only copies a reference to value. + * [See docs](https://hapijs.com/api/16.1.1#serverexposeobj) + * @param obj the object merged into the exposed properties container. + */ + expose(obj: Object): void; + /** + * Registers an extension function in one of the available extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * @param events see @ServerExtConfigurationObject + */ + ext(events: ServerStartExtConfigurationObject): void; + ext(events: ServerStartExtConfigurationObject[]): void; + ext(events: ServerRequestExtConfigurationObjectWithRequest): void; + ext(events: ServerRequestExtConfigurationObjectWithRequest[]): void; + /** + * Registers a single extension event using the same properties as used in server.ext(events), but passed as arguments. + * [See docs](https://hapijs.com/api/16.1.1#serverextevent-method-options) + * @param event the extension point event name. + * @param method a function or an array of functions to be executed at a specified point during request processing. + * @param options + */ + ext(event: ServerStartExtPoints, method: ServerExtFunction[], options?: ServerExtOptions): void; + ext(event: ServerStartExtPoints, method: ServerExtFunction, options?: ServerExtOptions): void; + ext(event: ServerRequestExtPoints, method: ServerExtRequestHandler[], options?: ServerExtOptions): void; + ext(event: ServerRequestExtPoints, method: ServerExtRequestHandler, options?: ServerExtOptions): void; + /** + * Registers a new handler type to be used in routes + * The method function can have a defaults object or function property. If the property is set to an object, that object is used as the default route config for routes using this handler. If the property is set to a function, the function uses the signature function(method) and returns the route default configuration. + * [See docs](https://hapijs.com/api/16.1.1#serverhandlername-method) + * @param name string name for the handler being registered. Cannot override any previously registered type. + * @param method the function used to generate the route handler using the signature function(route, options) where: + * * route - the route public interface object. + * * options - the configuration object provided in the handler config. + */ + handler(name: string, method: MakeRouteHandler): void; + /** + * Initializes the server (starts the caches, finalizes plugin registration) but does not start listening on the connection ports + * Note that if the method fails and the callback includes an error, the server is considered to be in an undefined state and should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and other event listeners will get confused by repeated attempts to start the server or make assumptions about the healthy state of the environment. It is recommended to assert that no error has been returned after calling initialize() to abort the process when the server fails to start properly. If you must try to resume after an error, call server.stop() first to reset the server state. + * [See docs](https://hapijs.com/api/16.1.1#serverinitializecallback) + * @param callback the callback method when server initialization is completed or failed with the signature function(err) + */ + initialize(callback: (err: Error) => void): void; + initialize(): Promise; + /** + * When the server contains exactly one connection, injects a request into the sole connection simulating an incoming HTTP request without making an actual socket connection. Injection is useful for testing purposes as well as for invoking routing logic internally without the overhead or limitations of the network stack. Utilizes the shot module for performing injections, with some additional options and response properties + * If no callback is provided, a Promise object is returned. + * When the server contains more than one connection, each server.connections array member provides its own connection.inject(). + * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) + * @param options can be assigned a string with the requested URI, or an object + * @param callback the callback function with signature function(res) + */ + inject(options: string | InjectedRequestOptions, callback: (res: InjectedResponseObject) => void): void; + inject(options: string | InjectedRequestOptions, ): Promise; + /** + * Logs server events that cannot be associated with a specific request. When called the server emits a 'log' event which can be used by other listeners or plugins to record the information or output to the console. + * [See docs](https://hapijs.com/api/16.1.1#serverlogtags-data-timestamp) + * @param tags a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. Any logs generated by the server internally include the 'hapi' tag along with event-specific information. + * @param data an optional message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. + * @param timestamp an optional timestamp expressed in milliseconds. Defaults to Date.now() (now). + */ + log(tags: string | string[], data?: string | Object | Function, timestamp?: number): void; + /** + * When the server contains exactly one connection, looks up a route configuration. + * When the server contains more than one connection, each server.connections array member provides its own connection.lookup() method. + * [See docs](https://hapijs.com/api/16.1.1#serverlookupid) + * @param id the route identifier as set in the route options. + * @return the route public interface object if found, otherwise null. + */ + lookup(id: string): RoutePublicInterface | null; + /** + * When the server contains exactly one connection, looks up a route configuration + * When the server contains more than one connection, each server.connections array member provides its own connection.match() method. + * [See docs](https://hapijs.com/api/16.1.1#servermatchmethod-path-host) + * @param method the HTTP method (e.g. 'GET', 'POST'). TODO check if it allows HEAD + * @param path the requested path (must begin with '/'). + * @param host optional hostname (to match against routes with vhost). + * @return the route public interface object if found, otherwise null. + */ + match(method: HTTP_METHODS, path: string, host?: string): RoutePublicInterface | null; + /** + * Registers a server method. Server methods are functions registered with the server and used throughout the application as a common utility. Their advantage is in the ability to configure them to use the built-in cache and share across multiple request handlers without having to create a common module. + * [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) + * @param name a unique method name used to invoke the method via server.methods[name]. Supports using nested names such as utils.users.get which will automatically create the missing path under server.methods and can be accessed for the previous example via server.methods.utils.users.get. When configured with caching enabled, server.methods[name].cache will be an object see ServerMethodNameCacheObject + * @param method the method function + * @param options optional configuration + */ + method(name: string, method: ServerMethod, options?: ServerMethodOptions): void; + /** + * Registers a server method function as described in server.method() using a configuration object + * [See docs](https://hapijs.com/api/16.1.1#servermethodmethods) + */ + method(methods: ServerMethodConfigurationObject[]): void; + method(methods: ServerMethodConfigurationObject): void; + /** + * Subscribe a handler to an event + * [See docs](https://hapijs.com/api/16.1.1#serveroncriteria-listener) + * @param criteria the subscription criteria which can be an event name string which can be any of the built-in server events or a custom application event registered with server.event(events). + * Or an see ServerEventCriteria. + * If 'start' - emitted when the server is started using server.start(). + * If 'stop' - emitted when the server is stopped using server.stop(). + * @param listener + */ + on(criteria: 'start' | 'stop' | string | ServerEventCriteria, listener: Function): void; + /** + * The 'log' event includes the event object and a tags object (where each tag is a key with the value true) + * [See docs](https://hapijs.com/api/16.1.1#server-events) + */ + on(criteria: 'log', listener: (event: ServerEventObject, tags: Podium.Tags) => void): void; + /** + * The 'request' and 'request-internal' events include the request object, the event object, and a tags object (where each tag is a key with the value true) + * [See docs](https://hapijs.com/api/16.1.1#server-events) + * TODO submit issue to TypeScript. Using 'request' | 'request-internal' removes the type + * interference when using code like: `server.on('request', (request, event, tags) => {...}` + * Same for 'response' | 'tail'. + */ + on(criteria: 'request', listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void): void; + on(criteria: 'request-internal', listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void): void; + /** + * The 'request-error' event includes the request object and the causing error err object + * [See docs](https://hapijs.com/api/16.1.1#server-events) + */ + on(criteria: 'request-error', listener: (request: Request, err: Error) => void): void; + /** + * The 'response' and 'tail' events include the request object + * [See docs](https://hapijs.com/api/16.1.1#server-events) + * See 'request' and 'request-internal' + */ + on(criteria: 'response', listener: (request: Request) => void): void; + on(criteria: 'tail', listener: (request: Request) => void): void; + /** + * The 'route' event includes the route public interface, the connection, and the server object used to add the route (e.g. the result of a plugin select operation) + * [See docs](https://hapijs.com/api/16.1.1#server-events) + */ + on(criteria: 'route', listener: (route: RoutePublicInterface, connection: ServerConnection, server: Server) => void): void; + /** + * Same as calling server.on() with the count option set to 1. + * TODO type this to copy the server.on specific types for 'route', 'tail', etc. + * [See docs](https://hapijs.com/api/16.1.1#serveroncecriteria-listener) + * @param criteria + * @param listener + */ + once(criteria: string | ServerEventCriteria, listener: Function): void; + /** + * Sets the path prefix used to locate static resources (files and view templates) when relative paths are used + * Note that setting a path within a plugin only applies to resources accessed by plugin methods. If no path is set, the connection files.relativeTo configuration is used. The path only applies to routes added after it has been set. + * [See docs](https://hapijs.com/api/16.1.1#serverpathrelativeto) + * @param relativeTo the path prefix added to any relative file path starting with '.'. + */ + path(relativeTo: string): void; + /** + * Registers a plugin + * If no callback is provided, a Promise object is returned. + * Note that plugin registration are recorded on each of the available connections. When plugins express a dependency on other plugins, both have to be loaded into the same connections for the dependency requirement to be fulfilled. It is recommended that plugin registration happen after all the server connections are created via server.connection(). + * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) + * @param plugins + * @param options + * @param callback with signature function(err) where err an error returned from the registration function. Note that exceptions thrown by the registration function are not handled by the framework. + * A note on typings. Common use case is: + * register(Plugin, (err) => {// do more stuff}) + * so these typings save passing empty `options` object or having to + * explicity type the Error in the Callback e.g.: + * register(Plugin, {}, (err) => {// do more stuff}) or + * register(Plugin, (err: Error) => {// do more stuff}) + */ + register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, callback: (err: Error | null) => void): void; + register(plugins: Array<(PluginFunction | PluginRegistrationObject)>): Promise; + register(plugins: PluginFunction | PluginRegistrationObject, callback: (err: Error | null) => void): void; + register(plugins: PluginFunction | PluginRegistrationObject): Promise; + register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, options: PluginRegistrationOptions, callback: (err: Error | null) => void): void; + register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, options: PluginRegistrationOptions): Promise; + register(plugins: PluginFunction | PluginRegistrationObject, options: PluginRegistrationOptions, callback: (err: Error | null) => void): void; + register(plugins: PluginFunction | PluginRegistrationObject, options: PluginRegistrationOptions): Promise; + /** + * Adds a connection route + * [See docs](https://hapijs.com/api/16.1.1#serverrouteoptions) + * @param options a route configuration object [See docs](https://hapijs.com/api/16.1.1#route-configuration) or an array of configuration objects. + */ + route(options: RouteConfiguration[]): void; + route(options: RouteConfiguration): void; + /** + * Selects a subset of the server's connections + * Returns a server object with connections set to the requested subset. Selecting again on a selection operates as a logic AND statement between the individual selections. + * [See docs](https://hapijs.com/api/16.1.1#serverselectlabels) + * @param labels a single string or array of strings of labels used as a logical OR statement to select all the connections with matching labels in their configuration. + */ + select(labels: string | string[]): Server; + /** + * Starts the server connections by listening for incoming requests on the configured port of each listener (unless the connection was configured with autoListen set to false) + * If no callback is provided, a Promise object is returned. + * Note that if the method fails and the callback includes an error, the server is considered to be in an undefined state and should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and other event listeners will get confused by repeated attempts to start the server or make assumptions about the healthy state of the environment. It is recommended to assert that no error has been returned after calling start() to abort the process when the server fails to start properly. If you must try to resume after a start error, call server.stop() first to reset the server state. + * If a started server is started again, the second call to start() will only start new connections added after the initial start() was called. No events will be emitted and no extension points invoked. + * [See docs](https://hapijs.com/api/16.1.1#serverstartcallback) + * @param callback the callback method when server startup is completed or failed with the signature function(err) where: + * * err - any startup error condition. + */ + start(callback: (err?: Error) => void): void; + start(): Promise; + /** + * HTTP state management [See docs](https://tools.ietf.org/html/rfc6265) uses client cookies to persist a state across multiple requests. Registers a cookie definitions + * [See docs](https://hapijs.com/api/16.1.1#serverstatename-options) + * @param name the cookie name string. + * @param options optional cookie settings + */ + state(name: string, options?: ServerStateCookieConfiguationObject): void; + /** + * Stops the server's connections by refusing to accept any new connections or requests (existing connections will continue until closed or timeout) + * If no callback is provided, a Promise object is returned. + * [See docs](https://hapijs.com/api/16.1.1#serverstopoptions-callback) + * @param options options object with: + * * timeout - overrides the timeout in millisecond before forcefully terminating a connection. Defaults to 5000 (5 seconds). + * @param callback optional callback method which is called once all the connections have ended and it is safe to exit the process with signature function(err) where: + * * err - any termination error condition. + */ + stop(options: {timeout: number} | null, callback: (err?: Error) => void): void; + stop(options?: {timeout: number}): Promise; + /** + * Returns a copy of the routing table + * Note that if the server has not been started and multiple connections use port 0, the table items will override each other and will produce an incomplete result. + * When calling connection.table() directly on each connection, the return value is the same as the array table item value of an individual connection + * [See docs](https://hapijs.com/api/16.1.1#servertablehost) + * @param host optional host to filter routes matching a specific virtual host. Defaults to all virtual hosts. + */ + table(host?: string): RoutingTableEntry[]; +} + +export interface PluginSpecificConfiguration {} + +/** + * Server Options + * Note that the options object is deeply cloned and cannot contain any values that are unsafe to perform deep copy on. + * [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) + */ +export interface ServerOptions { + /** app - application-specific configuration which can later be accessed via server.settings.app. Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. Defaults to {}. */ + app?: any; + /** + * cache - sets up server-side caching. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and capabilities. hapi uses catbox for its cache which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. The server cache configuration only defines the storage container itself. cache can be assigned: + * * a prototype function (usually obtained by calling require() on a catbox strategy such as require('catbox-redis')). A new catbox client will be created internally using this function. + * * a CatboxServerOptionsCacheConfiguration configuration object + * * an array of the above object for configuring multiple cache instances, each with a unique name. When an array of objects is provided, multiple cache connections are established and each array item (except one) must include a name. + */ + cache?: Catbox.EnginePrototype | CatboxServerOptionsCacheConfiguration | CatboxServerOptionsCacheConfiguration[]; + /** sets the default connections configuration which can be overridden by each connection */ + connections?: ConnectionConfigurationServerDefaults; + /** determines which logged events are sent to the console (this should only be used for development and does not affect which events are actually logged internally and recorded). Set to false to disable all console logging, or to an object with: */ + debug?: false | { + /** a string array of server log tags to be displayed via console.error() when the events are logged via server.log() as well as internally generated server logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. */ + log?: string[] | false; + /** a string array of request log tags to be displayed via console.error() when the events are logged via request.log() as well as internally generated request logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. */ + request?: string[] | false; + }; + /** process load monitoring */ + load?: { + /** the frequency of sampling in milliseconds. Defaults to 0 (no sampling). */ + sampleInterval?: number; + }; + /** options passed to the mimos module (https://github.com/hapijs/mimos) when generating the mime database used by the server and accessed via server.mime. */ + mime?: MimosOptions; + /** plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state. Defaults to {}. */ + plugins?: PluginSpecificConfiguration; + /** if false, will not use node domains to protect against exceptions thrown in handlers and other external code. Defaults to true. */ + useDomains?: boolean; +} + +/** + * The server event object + * [See docs](https://hapijs.com/api/16.1.1#server-events) + */ +export interface ServerEventObject { + /** the event timestamp. */ + timestamp: number; + /** if the event relates to a request, the request id. */ + request: string; + /** if the event relates to a server, the server.info.uri. */ + server: string; + /** an array of tags (e.g. ['error', 'http']). */ + tags: string[]; + /** optional event-specific information. */ + data: any; + /** true if the event was generated internally by the framework. */ + internal: boolean; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serveroncriteria-listener) + */ +export interface ServerEventCriteria { + /** the event name string (required). */ + name: string; + /** if true, the listener method receives an additional callback argument which must be called when the method completes. No other event will be emitted until the callback methods is called. The method signature is function(). If block is set to a positive integer, the value is used to set a timeout after which any pending events will be emitted, ignoring the eventual call to callback. Defaults to false (non blocking). */ + block?: boolean; + /** a string or array of strings specifying the event channels to subscribe to. If the event registration specified a list of allowed channels, the channels array must match the allowed channels. If channels are specified, event updates without any channel designation will not be included in the subscription. Defaults to no channels filter. */ + channels?: string | string[]; + /** if true, the data object passed to server.emit() is cloned before it is passed to the listener method. Defaults to the event registration option (which defaults to false). */ + clone?: boolean; + /** a positive integer indicating the number of times the listener can be called after which the subscription is automatically removed. A count of 1 is the same as calling server.once(). Defaults to no limit. */ + count?: number; + /** + * the event tags (if present) to subscribe to + * If the object is given: + * * tags - a tag string or array of tag strings. + * * all - if true, all tags must be present for the event update to match the subscription. Defaults to false (at least one matching tag). + */ + filter?: string | string[] | {tags: string | string[], all?: boolean}; + /** if true, and the data object passed to server.emit() is an array, the listener method is called with each array element passed as a separate argument. This should only be used when the emitted data structure is known and predictable. Defaults to the event registration option (which defaults to false). */ + spread?: boolean; + /** if true and the criteria object passed to server.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end (but before the callback argument if block is set). Defaults to the event registration option (which defaults to false). */ + tags?: boolean; +} + +/** + * Server methods, user configured + * Related to [See docs](https://hapijs.com/api/16.1.1#servermethods) + * Related to [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) + */ +export interface ServerMethod { + /** the method must return a value (result, Error, or a promise) or throw an Error. */ + (...args: any[]): any | Error | Promise; + /** Not possible to improve this typing due to this unresolvable issue: https://github.com/Microsoft/TypeScript/issues/15190 */ + (...args: (any | ServerMethodNext)[]): void; + /** When configured with caching enabled, server.methods[name].cache will be an object see ServerMethodNameCacheObject */ + cache?: ServerMethodNameCacheObject; +} + +/** + * Related to [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) + * @param err error response if the method failed. + * @param result the return value. + * @param ttl 0 if result is valid but cannot be cached. Defaults to cache policy. + */ +export interface ServerMethodNext { + (err: Error | null, result: any, ttl?: number): void; +} + +/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) */ +export interface ServerMethodNameCacheObject { + /** + * function that can be used to clear the cache for a given key. + * @param ...args any number of string, number or boolean. If other types then generateKey function must be specified. + * @param callback last argument is a callback. + * Not possible to improve this typing due to this unresolvable issue: https://github.com/Microsoft/TypeScript/issues/15190 + */ + drop(...args: (any | Function)[]): void; + /** an object with cache statistics, see stats documentation for catbox. */ + stats: Catbox.CacheStatisticsObject; +} + +/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) */ +export interface ServerMethodOptions { + /** a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. Ignored if the method is an arrow function. */ + bind?: any; + /** the same cache configuration used in server.cache(). The generateTimeout option is required. */ + cache?: CatboxServerCacheConfiguration; + /** + * if false, expects the method to be a synchronous function. Note that using a synchronous function with caching will convert the method interface to require a callback as an additional argument with the signature function(err, result, cached, report) since the cache interface cannot return values synchronously. Defaults to true. + * TODO: understand and type "an additional argument with the signature function(err, result, cached, report)" if appropriate. + */ + callback?: boolean; + /** a function used to generate a unique key (for caching) from the arguments passed to the method function (the callback argument is not passed as input). The server will automatically generate a unique key if the function's arguments are all of types 'string', 'number', or 'boolean'. However if the method uses other types of arguments, a key generation function must be provided which takes the same arguments as the function and returns a unique string (or null if no key can be generated). */ + generateKey?(args: any[]): string | null; +} + +/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodmethods) */ +export interface ServerMethodConfigurationObject { + name: string; + method: ServerMethod; + options: ServerMethodOptions; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Caching with Catbox + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * TODO confirm this is the same as CatboxServerCacheConfiguration + * + * ** + * Server instantiation options configuration for Catbox cache + * TODO: check it extends Catbox.PolicyOptions and this is what "other options passed to the catbox strategy used." means. + * For context [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) under: options > cache > a configuration object + * ** + * export interface CatboxServerOptionsCacheConfiguration extends Catbox.IPolicyOptions { + * // a prototype function or catbox engine object. + * engine: Catbox.EnginePrototypeOrObject; + * // an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. + * name?: string; + * // if true, allows multiple cache users to share the same segment (e.g. multiple methods using the same cache storage container). Default to false. + * shared?: boolean; + * } + */ +export type CatboxServerOptionsCacheConfiguration = CatboxServerCacheConfiguration; + +/** + * Server cache method configuration for Catbox cache + * Used for "Provisions a cache segment within the server cache facility" + * For context [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) + * Also used in [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) > options.cache + */ +export interface CatboxServerCacheConfiguration extends Catbox.PolicyOptions { + /** the cache name configured in server.cache. Defaults to the default cache. */ + cache?: string; + /** string segment name, used to isolate cached items within the cache partition. When called within a plugin, defaults to '!name' where 'name' is the plugin name. When called within a server method, defaults to '#name' where 'name' is the server method name. Required when called outside of a plugin. */ + segment?: string; + /** if true, allows multiple cache provisions to share the same segment. Default to false. */ + shared?: boolean; + /** + * a prototype function or catbox engine object. + * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) example code includes use of `engine` option. But server.cache.provision of `options` says "same as the server cache configuration options.". + * TODO confirm once PR to hapi docs accepted / rejected. + */ + engine?: Catbox.EnginePrototypeOrObject; + /** + * an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. + * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) example code includes use of `name` option. But server.cache.provision of `options` says "same as the server cache configuration options.". + */ + name?: string; + /** + * Additional options to be passed to the Catbox strategy + */ + [s: string]: any; +} + +/** + * Additional notes + * payload - In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided. + * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) + */ +export interface InjectedRequestOptions extends Shot.RequestOptions { + /** an optional credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials. */ + credentials?: any; + /** an optional artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts. */ + artifacts?: any; + /** sets the initial value of request.app. */ + app?: any; + /** sets the initial value of request.plugins. */ + plugins?: PluginsStates; + /** allows access to routes with config.isInternal set to true. Defaults to false. */ + allowInternals?: boolean; +} + +/** + * the response object from server.inject + * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) + */ +export interface InjectedResponseObject extends Shot.ResponseObject { + /** the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the internal objects returned (instead of parsing the response string). */ + result: Object | string; + /** the request object. */ + request: InjectedRequestOptions; +} + +/** + * For context [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) under: options > connections + */ +export interface ConnectionConfigurationServerDefaults { + /** application-specific connection configuration which can be accessed via connection.settings.app. Provides a safe place to store application configuration without potential conflicts with the framework internals. Should not be used to configure plugins which should use plugins[name]. Note the difference between connection.settings.app which is used to store configuration values and connection.app which is meant for storing run-time state. */ + app?: any; + /** if false, response content encoding is disabled. Defaults to true */ + compression?: boolean; + /** connection load limits configuration where: */ + load?: { + /** maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ + maxHeapUsedBytes?: number; + /** maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ + maxRssBytes?: number; + /** maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ + maxEventLoopDelay?: number; + }; + /** plugin-specific configuration which can later be accessed via connection.settings.plugins. Provides a place to store and pass connection-specific plugin configuration. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between connection.settings.plugins which is used to store configuration values and connection.plugins which is meant for storing run-time state. */ + plugins?: PluginSpecificConfiguration; + /** controls how incoming request URIs are matched against the routing table: */ + router?: { + /** determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true. */ + isCaseSensitive?: boolean; + /** removes trailing slashes on incoming paths. Defaults to false. */ + stripTrailingSlash?: boolean; + }; + /** a route options object used to set the default configuration for every route. */ + routes?: RouteAdditionalConfigurationOptions; + /** sets the default configuration for every state (cookie) set explicitly via server.state() or implicitly (without definition) using the [state configuration object](https://hapijs.com/api/16.1.1#serverstatename-options). */ + state?: ServerStateCookieConfiguationObject; +} + +/** + * a connection configuration object or array of objects with the following optional keys. + * Any connections configuration server defaults can be included to override and customize the individual connection. + * [See docs](https://hapijs.com/api/16.1.1#serverconnectionoptions) + */ +export interface ServerConnectionOptions extends ConnectionConfigurationServerDefaults { + /** host - the public hostname or IP address. Used only to set server.info.host and server.info.uri. If not configured, defaults to the operating system hostname and if not available, to 'localhost'. */ + host?: string; + /** address - sets the host name or IP address the connection will listen on. If not configured, defaults to host if present, otherwise to all available network interfaces (i.e. '0.0.0.0'). Set to 127.0.0.1 or localhost to restrict connection to only those coming from the same machine. */ + address?: string; + /** port - the TCP port the connection will listen to. Defaults to an ephemeral port (0) which uses an available port when the server is started (and assigned to server.info.port). If port is a string containing a '/' character, it is used as a UNIX domain socket path and if it starts with '\.\pipe' as a Windows named pipe. */ + port?: string | number; + /** uri - the full public URI without the path (e.g. 'http://example.com:8080'). If present, used as the connection info.uri otherwise constructed from the connection settings. */ + uri?: string; + /** listener - optional node.js HTTP (or HTTPS) http.Server object or any compatible object. If the listener needs to be manually started, set autoListen to false. If the listener uses TLS, set tls to true. */ + listener?: http.Server; + /** autoListen - indicates that the connection.listener will be started manually outside the framework. Cannot be specified with a port setting. Defaults to true. */ + autoListen?: boolean; + /** labels - a string or string array of labels used to server.select() specific connections matching the specified labels. Defaults to an empty array [] (no labels). */ + labels?: string | string[]; + /** tls - used to create an HTTPS connection. The tls object is passed unchanged as options to the node.js HTTPS server as described in the node.js HTTPS [documentation](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener}) . Set to true when passing a listener object that has been configured to use TLS directly. */ + tls?: true | https.RequestOptions; +} + +/** + * For context see RouteAdditionalConfigurationOptions > compression + * For context [See docs](https://hapijs.com/api/16.1.1#serverencoderencoding-encoder) + */ +export type CompressionEncoderSettings = any; + +/** + * For context see RouteAdditionalConfigurationOptions > payload > compression + * For context [See docs](https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder) + */ +export type CompressionDecoderSettings = any; + +/** + * an optional function called after all the specified dependencies have been registered and before the server starts. The function is only called if the server is initialized or started. If a circular dependency is detected, an exception is thrown (e.g. two plugins each has an after function to be called after the other). The function signature is function(server, next) where: + * [See docs](https://hapijs.com/api/16.1.1#serverdependencydependencies-after) + * Also see Server.dependency + * @param server the server the dependency() method was called on. + * @param next the callback function the method must call to return control over to the application and complete the registration process. The function signature is function(err) where: + * * err - internal error condition, which is returned back via the server.initialize() or server.start() callback. + */ +export interface AfterDependencyLoadCallback { + (server: Server, next: (err?: Error) => void): void; +} + +/** For context see RouteAdditionalConfigurationOptions > auth */ +export interface AuthOptions { + /** + * the authentication mode. Defaults to 'required' if a server authentication strategy is configured, otherwise defaults to no authentication. Available values: + * * 'required' - authentication is required. + * * 'optional' - authentication is optional (must be valid if present). + * * 'try' - same as 'optional' but allows for invalid authentication. + */ + mode?: 'required' | 'optional' | 'try'; + /** a string array of strategy names in order they should be attempted. If only one strategy is used, strategy can be used instead with the single string value. Defaults to the default authentication strategy which is available only when a single strategy is configured. */ + strategies?: string[]; + strategy?: string; + /** + * if set, the payload (in requests other than 'GET' and 'HEAD') is authenticated after it is processed. Requires a strategy with payload authentication support (e.g. Hawk). Cannot be set to a value other than 'required' when the scheme sets the options.payload to true. Available values: + * * false - no payload authentication. This is the default value. + * * 'required' - payload authentication required. This is the default value when the scheme sets options.payload to true. + * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). + */ + payload?: false | 'required' | 'optional'; + /** specifying the route access rules. */ + access?: RouteAuthAccessConfiguationObject | RouteAuthAccessConfiguationObject[]; + /** (undocumented) Convenience way of setting access.scope, will over write all values in `access` */ + scope?: false | string | string[]; + /** (undocumented) Convenience way of setting access.entity, will over write all values in `access` */ + entity?: 'any' | 'user' | 'app'; +} + +/** + * Each rule is evaluated against an incoming request and access is granted if at least one rule matches. Each rule object must include at least one of: + * For context see RouteAdditionalConfigurationOptions > auth > an object > access + */ +export interface RouteAuthAccessConfiguationObject { + /** the application scope required to access the route. Value can be a scope string or an array of scope strings. The authenticated credentials object scope property must contain at least one of the scopes defined to access the route. If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' scope must not include 'a', must include 'b', and must include one of 'c' or 'd'. You may also access properties on the request object (query and params) to populate a dynamic scope by using {} characters around the property name, such as 'user-{params.id}'. Defaults to false (no scope requirements). */ + scope?: false | string | string[]; + /** + * the required authenticated entity type. If set, must match the entity value of the authentication credentials. Available values: + * * any - the authentication can be on behalf of a user or application. This is the default value. + * * user - the authentication must be on behalf of a user which is identified by the presence of a user attribute in the credentials object returned by the authentication strategy. + * * app - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. + */ + entity?: 'any' | 'user' | 'app'; +} + +/** + * For context see RouteAdditionalConfigurationOptions > cache + */ +export type RouteCacheOptions = { + /** + * determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are: + * * 'default' - no privacy flag. This is the default setting. + * * 'public' - mark the response as suitable for public caching. + * * 'private' - mark the response as suitable only for private caching. + */ + privacy?: 'default' | 'public' | 'private'; + /** an array of HTTP response status codes (e.g. 200) which are allowed to include a valid caching directive. Defaults to [200]. */ + statuses?: number[]; + /** a string with the value of the 'Cache-Control' header when caching is disabled. Defaults to 'no-cache'. */ + otherwise?: string; +} & ({ + /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ + expiresIn?: number; + /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ + expiresAt?: undefined; +} | { + /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ + expiresIn?: undefined; + /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ + expiresAt?: string; +} | { + /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ + expiresIn?: undefined; + /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ + expiresAt?: undefined; +}); + +/** + * For context see RouteAdditionalConfigurationOptions > cors + */ +export interface CorsConfigurationObject { + /** a strings array of allowed origin servers ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a wildcard '*' character, or a single '*' origin string. Defaults to any origin ['*']. */ + origin?: string[] | '*'; + /** number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. Defaults to 86400 (one day). */ + maxAge?: number; + /** a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match'] */ + headers?: string[]; + /** a strings array of additional headers to headers. Use this to keep the default headers in place. */ + additionalHeaders?: string[]; + /** a strings array of exposed headers ('Access-Control-Expose-Headers'). Defaults to ['WWW-Authenticate', 'Server-Authorization']. */ + exposedHeaders?: string[]; + /** a strings array of additional headers to exposedHeaders. Use this to keep the default headers in place. */ + additionalExposedHeaders?: string[]; + /** if true, allows user credentials to be sent ('Access-Control-Allow-Credentials'). Defaults to false. */ + credentials?: boolean; +} + +/** + * An object describing the extension function used whilst registering the extension function in one of the available extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * For context see RouteAdditionalConfigurationOptions > ext + */ +export interface ServerStartExtConfigurationObject { + /** the extension point event name. */ + type: ServerStartExtPoints; + /** + * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler + */ + method: ServerExtFunction | ServerExtFunction[]; + options?: ServerExtOptions; +} + +/** + * An object describing the extension function used whilst registering the extension function in one of the available extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * For context see RouteAdditionalConfigurationOptions > ext + */ +export interface ServerRequestExtConfigurationObject { + /** the extension point event name. */ + type: ServerRequestExtPointsBase; + /** + * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler + */ + method: ServerExtRequestHandler | ServerExtRequestHandler[] + options?: ServerExtOptions; +} + +/** + * An object describing the extension function used whilst registering the extension function in one of the available extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * For context see RouteAdditionalConfigurationOptions > ext + */ +export interface ServerRequestExtConfigurationObjectWithRequest { + /** the extension point event name. */ + type: ServerRequestExtPoints; + /** + * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler + */ + method: ServerExtRequestHandler | ServerExtRequestHandler[]; + options?: ServerExtOptions; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#route-configuration) > ext + */ +export type RouteExtConfigurationObject = ServerStartExtConfigurationObject | ServerRequestExtConfigurationObject; + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > method + */ +export type ServerExtMethod = ServerExtFunction | ServerExtRequestHandler; + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > options + */ +export interface ServerExtOptions { + /** before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. */ + before: string | string[]; + /** after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. */ + after: string | string[]; + /** bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. */ + bind: any; + /** sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'connection' which applies to any route added to the connection the extension is added to. */ + sandbox?: 'connection' | 'plugin'; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > type + * * 'onPreStart' - called before the connection listeners are started. + * * 'onPostStart' - called after the connection listeners are started. + * * 'onPreStop' - called before the connection listeners are stopped. + * * 'onPostStop' - called after the connection listeners are stopped. + */ +export type ServerStartExtPoints = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; +/** + * [See docs](https://hapijs.com/api/16.1.1#request-lifecycle) + * * The available extension points include the request extension points as well as the following server extension points: + */ +export type ServerRequestExtPointsBase = 'onPreResponse' | 'onPreAuth' | 'onPostAuth' | 'onPreHandler' | 'onPostHandler' | 'onPreResponse'; + +export type ServerRequestExtPoints = ServerRequestExtPointsBase | 'onRequest'; + +/** + * Server extension function registered an one of the server extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * For context see ServerExtConfigurationObject + * @param server - the server object. + * @param next - the continuation method with signature function(err). + * @param this - the object provided via options.bind or the current active context set with server.bind(). + */ +export interface ServerExtFunction { + (server: Server, next: ContinuationFunction): void; +} + +/** + * For context see RouteAdditionalConfigurationOptions > payload + */ +export interface RoutePayloadConfigurationObject { + /** + * the type of payload representation requested. The value must be one of: + * * 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, the raw Buffer is returned. This is the default value except when a proxy handler is used. + * * 'stream' - the incoming payload is made available via a Stream.Readable interface. If the payload is 'multipart/form-data' and parse is true, fields values are presented as text while files are provided as streams. File streams from a 'multipart/form-data' upload will also have a property hapi containing filename and headers properties. + * * 'file' - the incoming payload is written to temporary file in the directory specified by the server's payload.uploads settings. If the payload is 'multipart/form-data' and parse is true, fields values are presented as text while files are saved. Note that it is the sole responsibility of the application to clean up the files generated by the framework. This can be done by keeping track of which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform any needed cleanup. + */ + output?: PayLoadOutputOption; + /** + * can be true, false, or gunzip; determines if the incoming payload is processed or presented raw. true and gunzip includes gunzipping when the appropriate 'Content-Encoding' is specified on the received request. If parsing is enabled and the 'Content-Type' is known (for the whole payload as well as parts), the payload is converted into an object when possible. If the format is unknown, a Bad Request (400) error response is sent. Defaults to true, except when a proxy handler is used. The supported mime types are: + * * 'application/json' + * * 'application/x-www-form-urlencoded' + * * 'application/octet-stream' + * * 'text/*' + * * 'multipart/form-data' + */ + parse?: 'gunzip' | boolean; + /** + * overrides payload processing for multipart requests. Value can be one of: + * * false - disables multipart processing. + * * object with the following required options: + * * output - same as the payload.output option with an additional value option: + * * annotated - wraps each multipart part in an object with the following keys: // TODO type this? + * * headers - the part headers. + * * filename - the part file name. + * * payload - the processed part payload. + */ + multipart?: false | { + output: PayLoadOutputOption | 'annotated'; + }; + /** a string or an array of strings with the allowed mime types for the endpoint. Defaults to any of the supported mime types listed above. Note that allowing other mime types not listed will not enable them to be parsed, and that if parsing mode is 'parse', the request will result in an error response. */ + allow?: string | string[]; + /** a mime type string overriding the 'Content-Type' header value received. Defaults to no override. */ + override?: string; + /** limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory. Defaults to 1048576 (1MB). */ + maxBytes?: number; + /** payload reception timeout in milliseconds. Sets the maximum time allowed for the client to transmit the request payload (body) before giving up and responding with a Request Timeout (408) error response. Set to false to disable. Defaults to 10000 (10 seconds). */ + timeout?: number | false; + /** the directory used for writing file uploads. Defaults to os.tmpdir(). */ + uploads?: string; + /** + * determines how to handle payload parsing errors. Allowed values are: + * * 'error' - return a Bad Request (400) error response. This is the default value. + * * 'log' - report the error but continue processing the request. + * * 'ignore' - take no action and continue processing the request. + */ + failAction?: 'error' | 'log' | 'ignore'; + /** the default 'Content-Type' HTTP header value is not present. Defaults to 'application/json'. */ + defaultContentType?: string; + /** an object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in the root option compression. */ + compression?: Dictionary; +} + +export type PayLoadOutputOption = 'data' | 'stream' | 'file'; + +/** + * events must be one of: + * * an event name string. + * * an event options object see ApplicationEventOptionsObject + * * a podium [See docs](https://github.com/hapijs/podium) emitter object. + * For context [See docs](https://hapijs.com/api/16.1.1#servereventevents) > events parameter + */ +export type ApplicationEvent = string | ApplicationEventOptionsObject | Podium; + +/** + * an event options object + * For context see ApplicationEvent + * For context [See docs](https://hapijs.com/api/16.1.1#servereventevents) > events parameter + */ +export interface ApplicationEventOptionsObject { + /** the event name string (required). */ + name: string; + /** a string or array of strings specifying the event channels available. Defaults to no channel restrictions (event updates can specify a channel or not). */ + channels?: string | string[]; + /** if true, the data object passed to server.emit() is cloned before it is passed to the listeners (unless an override specified by each listener). Defaults to false (data is passed as-is). */ + clone?: boolean; + /** if true, the data object passed to server.emit() must be an array and the listener method is called with each array element passed as a separate argument (unless an override specified by each listener). This should only be used when the emitted data structure is known and predictable. Defaults to false (data is emitted as a single argument regardless of its type). */ + spread?: boolean; + /** if true and the criteria object passed to server.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end (but before the callback argument if block is set). A configuration override can be set by each listener. Defaults to false. */ + tags?: boolean; + /** if true, the same event name can be registered multiple times where the second registration is ignored. Note that if the registration config is changed between registrations, only the first configuration is used. Defaults to false (a duplicate registration will throw an error). */ + shared?: boolean; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Route + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Route configuration + * The route configuration object + * + * [See docs](https://hapijs.com/api/16.1.1#route-configuration) + * + * TODO typings check that the following refers to RouteAdditionalConfigurationOptions "Note that the options object is deeply cloned (with the exception of bind which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on." + */ +export interface RouteConfiguration { + /** the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the connection router configuration option. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. */ + path: string; + /** the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. */ + method: HTTP_METHODS_PARTIAL | '*' | (HTTP_METHODS_PARTIAL | '*')[]; + /** an optional domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. */ + vhost?: string; + /** the function called to generate the response after successful authentication and validation. The handler function is described in Route handler. If set to a string, the value is parsed the same way a prerequisite server method string shortcut is processed. Alternatively, handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler. */ + handler?: string | RouteHandler | RouteHandlerPlugins; + /** additional route options. The config value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. */ + config?: RouteAdditionalConfigurationOptions | ((server: Server) => RouteAdditionalConfigurationOptions); +} + +/** + * Route options + * Each route can be customize to change the default behavior of the request lifecycle using the following options: + * [See docs](https://hapijs.com/api/16.1.1#route-options) + */ +export interface RouteAdditionalConfigurationOptions { + /** application specific configuration.Should not be used by plugins which should use plugins[name] instead. */ + app?: any; + /** + * Authentication configuration. Value can be: + * * false to disable authentication if a default strategy is set. + * * a string with the name of an authentication strategy registered with server.auth.strategy(). + * * an object + */ + auth?: false | string | AuthOptions; + /** an object passed back to the provided handler (via this) when called. Ignored if the method is an arrow function. */ + bind?: any; + /** + * Route cache options + * if the route method is 'GET', the route can be configured to include caching directives in the response. The default Cache-Control: no-cache header can be disabled by setting cache to false. Caching can be customized using an object + * TODO check: the default is to have 'Cache-Control: no-cache', but on first reading is a contridiction as you can disabled cache and disabled no-cache by setting RouteCacheOptions to false? + */ + cache?: boolean | RouteCacheOptions; + /** an object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in payload.compression. */ + compression?: Dictionary; + /** the Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. CORS headers are disabled by default (false). To enable, set cors to true, or to an object */ + cors?: boolean | CorsConfigurationObject; + /** defined a route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the [server.ext(events)](https://hapijs.com/api/16.1.1#serverextevents) event argument. */ + ext?: RouteExtConfigurationObject | RouteExtConfigurationObject[]; + /** defines the behavior for accessing files: */ + files?: { + /** determines the folder relative paths are resolved against. */ + relativeTo: string; + }; + /** an alternative location for the route.handler option. */ + handler?: string | RouteHandler; + /** an optional unique identifier used to look up the route using server.lookup(). Cannot be assigned to routes with an array of methods. */ + id?: string; + /** if true, the route cannot be accessed through the HTTP connection but only through the server.inject() interface with the allowInternals option set to true. Used for internal routes that should not be accessible to the outside world. Defaults to false. */ + isInternal?: boolean; + /** optional arguments passed to JSON.stringify() when converting an object or error response to a string payload. Supports the following: */ + json?: Json.StringifyArguments & { + /** string suffix added after conversion to JSON string. Defaults to no suffix. */ + suffix?: string; + }; + /** enables JSONP support by setting the value to the query parameter name containing the function name used to wrap the response payload. For example, if the value is 'callback', a request comes in with 'callback=me', and the JSON response is '{ "a":"b" }', the payload will be 'me({ "a":"b" });'. Does not work with stream responses. Headers content-type and x-content-type-options are set to text/javascript and nosniff respectively, and will override those headers even if explicitly set by response.type() */ + jsonp?: string; + /** if true, request level logging is enabled (accessible via request.getLog()). */ + log?: boolean; + /** + * determines how the request payload is processed + * [See docs](https://hapijs.com/api/16.1.1#route-options) + */ + payload?: RoutePayloadConfigurationObject; + /** plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. */ + plugins?: PluginSpecificConfiguration; + /** an array with [route prerequisites](https://hapijs.com/api/16.1.1#route-prerequisites) methods which are executed in serial or in parallel before the handler is called. */ + pre?: RoutePrerequisitesArray; + /** processing rules for the outgoing response */ + response?: RouteResponseConfigurationObject; + /** sets common security headers (disabled by default). To enable set security to true or to an object with the following options: See RouteSecurityConfigurationObject */ + security?: boolean | RouteSecurityConfigurationObject; + /** HTTP state management (cookies) allows the server to store information on the client which is sent back to the server with every request (as defined in RFC 6265). state supports the following options: */ + state?: { + /** determines if incoming 'Cookie' headers are parsed and stored in the request.state object. Defaults to true. */ + parse?: boolean; + /** + * determines how to handle cookie parsing errors. Allowed values are: + * * 'error' - return a Bad Request (400) error response. This is the default value. + * * 'log' - report the error but continue processing the request. + * * 'ignore' - take no action. + */ + failAction: 'error' | 'log' | 'ignore'; + }; + /** request input validation rules for various request components. When using a Joi validation object, the values of the other inputs (i.e. headers, query, params, payload, and auth) are made available under the validation context (accessible in rules as Joi.ref('$query.key')). Note that validation is performed in order (i.e. headers, params, query, payload) and if type casting is used (converting a string to number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. If the validation rules for headers, params, query, and payload are defined at both the routes defaults level and an individual route, the individual route settings override the routes defaults (the rules are not merged). The validate object supports: */ + validate?: RouteValidationConfigurationObject; + /** define timeouts for processing durations: */ + timeout?: { + /** response timeout in milliseconds. Sets the maximum time allowed for the server to respond to an incoming client request before giving up and responding with a Service Unavailable (503) error response. Disabled by default (false). */ + server?: boolean | number; + /** by default, node sockets automatically timeout after 2 minutes. Use this option to override this behavior. Defaults to undefined which leaves the node default unchanged. Set to false to disable socket timeouts. */ + socket?: boolean | number; + }; + + /** + * TODO decide on moving these to an extended interface of RouteAdditionalConfigurationOptions + */ + /** + * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). + * route description used for generating documentation + */ + description?: string; + /** + * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). + * route notes used for generating documentation + */ + notes?: string | string[]; + /** + * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). + * route tags used for generating documentation + */ + tags?: string[]; +} + +/** + * Route public interface + * When route information is returned or made available as a property, it is an object with the following: + * [See docs](https://hapijs.com/api/16.1.1#route-public-interface) + */ +export interface RoutePublicInterface { + /** the route HTTP method. */ + method: string; + /** the route path. */ + path: string; + /** the route vhost option if configured. */ + vhost?: string | string[]; + /** the [active realm] [See docs](https://hapijs.com/api/16.1.1#serverrealm) associated with the route.*/ + realm: ServerRealm; + /** the [route options] [See docs](https://hapijs.com/api/16.1.1#route-options) object with all defaults applied. */ + settings: RouteAdditionalConfigurationOptions; + /** the route internal normalized string representing the normalized path. */ + fingerprint: string; + /** route authentication utilities: */ + auth: { + /** authenticates the passed request argument against the route's authentication access configuration. Returns true if the request would have passed the route's access requirements. Note that the route's authentication mode and strategies are ignored. The only match is made between the request.auth.credentials scope and entity information and the route access configuration. Also, if the route uses dynamic scopes, the scopes are constructed against the request.query and request.params which may or may not match between the route and the request's route. If this method is called using a request that has not been authenticated (yet or at all), it will return false if the route requires any authentication. */ + access(request: Request): boolean; + }; +} + +export type RouteHandlerConfig = any; + +/** + * For context [See docs](https://hapijs.com/api/16.1.1#serverhandlername-method) + * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/handler.js#L103) + * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/route.js#L56-L60) + * TODO check the type of `RouteHandlerConfig` is correct for `defaults`. + */ +export interface MakeRouteHandler { + (route: RoutePublicInterface, options: RouteHandlerConfig): RouteHandler; + defaults?: RouteHandlerConfig | ((method: HTTP_METHODS_PARTIAL_lowercase) => RouteHandlerConfig); +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#servertablehost) > return value + */ +export interface RoutingTableEntry { + /** the connection.info the connection the table was generated for. */ + info: ServerConnectionInfo; + /** the connection labels. */ + labels: string[]; + /** an array of routes where each route contains: */ + table: Route[]; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#servertablehost) > return value + * For source [See source](https://github.com/hapijs/hapi/blob/v16.1.1/lib/route.js#L71) + */ +export interface Route { + /** + * the route config with defaults applied. + * TODO check type of RouteConfiguration here is correct + */ + settings: RouteAdditionalConfigurationOptions; + /** + * the HTTP method in lower case. + * TODO, check if it can contain 'head' or not. + */ + method: HTTP_METHODS_PARTIAL_lowercase; + /** the route path. */ + path: string; + + params: string[]; + + connection: ServerConnection; + + fingerprint: string; + + plugin?: any; + + public: RoutePublicInterface; + + server: Server; +} + +/** + * Route Prerequisites + * It is often necessary to perform prerequisite actions before the handler is called (e.g. load required reference data from a database). The route pre option allows defining such pre-handler methods. The methods are called in order. If the pre array contains another array, those methods are called in parallel. pre can be assigned a mixed array of: + * * arrays containing the elements listed below, which are executed in parallel. + * * objects see RoutePrerequisiteObjects + * * functions - same as including an object with a single method key. + * * strings - special short-hand notation for registered server methods using the format 'name(args)' (e.g. 'user(params.id)') where: + * * 'name' - the method name. The name is also used as the default value of assign. + * * 'args' - the method arguments (excluding next) where each argument is a property of the request object + * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) + * For context see RouteAdditionalConfigurationOptions > pre + * + * TODO follow up on "server methods" in "special short-hand notation for registered server methods" at https://hapijs.com/api/16.1.1#servermethodname-method-options + * TODO follow up on "request object" in "each argument is a property of the request object" at https://hapijs.com/api/16.1.1#request-object + */ +export type RoutePrerequisitesArray = RoutePrerequisitesPart[] | (RoutePrerequisitesPart[] | RoutePrerequisitesPart)[]; +export type RoutePrerequisitesPart = RoutePrerequisiteObjects | RoutePrerequisiteRequestHandler | string; + +/** + * see RoutePrerequisites > objects + */ +export interface RoutePrerequisiteObjects { + /** the function to call (or short-hand method string as described below [see RoutePrerequisitesArray]). the function signature is identical to a route handler as described in Route handler. */ + method: RoutePrerequisiteRequestHandler | string; + /** key name to assign the result of the function to within request.pre. */ + assign: string; + /* + * determines how to handle errors returned by the method. Allowed values are: + * * 'error' - returns the error response back to the client. This is the default value. + * * 'log' - logs the error but continues processing the request. If assign is used, the error will be assigned. + * * 'ignore' - takes no special action. If assign is used, the error will be assigned. + */ + failAction?: 'error' | 'log' | 'ignore'; +} + +/** + * For context see RouteAdditionalConfigurationOptions > response + */ +export interface RouteResponseConfigurationObject { + /** the default HTTP status code when the payload is empty. Value can be 200 or 204. Note that a 200 status code is converted to a 204 only at the time or response transmission (the response status code will remain 200 throughout the request lifecycle unless manually set). Defaults to 200. */ + emptyStatusCode?: number; + /** + * defines what to do when a response fails payload validation. Options are: + * * 'error' - return an Internal Server Error (500) error response. This is the default value. + * * 'log' - log the error but send the response. + * * a custom error handler function with the signature function(request, reply, source, error) where: + * * 'request' - the request object. + * * 'reply' - the continuation reply interface. + * * 'error' - the error returned from the validation schema. + * TODO update type of source once PR to hapi is concluded. + */ + failAction?: 'error' | 'log' | ((request: Request, reply: ReplyWithContinue, source: string, error: Boom.BoomError) => void); + /** if true, applies the validation rule changes to the response payload. Defaults to false. */ + modify?: boolean; + /** + * options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is available [here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback) ). + * If a custom validation function (see `schema` or `status` below) is defined then `options` can an arbitrary object that will be passed to this function as the second parameter. + * Defaults to no options. + */ + options?: ValidationOptions; + /** if false, payload range support is disabled. Defaults to true. */ + ranges?: boolean; + /** the percent of response payloads validated (0 - 100). Set to 0 to disable all validation. Defaults to 100 (all response payloads). */ + sample?: number; + /** the default response payload validation rules (for all non-error responses) */ + schema?: RouteResponseConfigurationScheme; + /** HTTP status-code-specific payload validation rules. The status key is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. If a response status code is not present in the status object, the schema definition is used, except for errors which are not validated by default. */ + status?: Dictionary>; +} + +/** + * the default response payload validation rules (for all non-error responses) expressed as one of: + * * true - any payload allowed (no validation performed). This is the default. + * * false - no payload allowed. + * * a Joi validation object. This will receive the request's headers, params, query, payload, and auth credentials and isAuthenticated flags as context. + * * a validation function + * + * TODO check JoiValidationObject is correct for "a Joi validation object" + * + * For context see RouteAdditionalConfigurationOptions > response > schema + * and + * For context see RouteAdditionalConfigurationOptions > response > status + */ +export type RouteResponseConfigurationScheme = boolean | JoiValidationObject | ValidationFunctionForRouteResponse; + +/** + * see RouteResponseConfigurationScheme + * + * a validation function using the signature function(value, options, next) where: + * * value - the value of the response passed to `reply(value)` in the handler. + * * options - the server validation options, merged with an object containing the request's headers, params, payload, and auth credentials object and `isAuthenticated` flag. + * * next([err, [value]]) - the callback function called when validation is completed. `value` will be used as the response value when `err` is falsy, when `value` is not `undefined`, and when `route.settings.response.modify` is `true`. If the response is already a `Boom` error it will be set as its `message` value. + */ +export interface ValidationFunctionForRouteResponse { + (value: any, options: RouteResponseValidationContext & ValidationOptions, next: ContinuationValueFunction): void; +} + +/** + * A context for route input validation via a Joi schema or validation function. + * + * This object is merged with the route response options and passed into the validation function. + * + * See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L217 + */ +export interface RouteResponseValidationContext { + context: { + /** The request headers */ + headers: Dictionary; + /** The request path parameters */ + params: any; + /** The request query parameters */ + query: any; + /** The request payload parameters */ + payload: any; + + /** Partial request authentication information */ + auth: { + /** true if the request has been successfully authenticated, otherwise false. */ + isAuthenticated: boolean; + /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ + credentials: AuthenticatedCredentials; + }; + } +} + +/** + * For context see RouteAdditionalConfigurationOptions > security + */ +export interface RouteSecurityConfigurationObject { + /** controls the 'Strict-Transport-Security' header. If set to true the header will be set to max-age=15768000, if specified as a number the maxAge parameter will be set to that number. Defaults to true. You may also specify an object with the following fields: */ + hsts?: boolean | number | { + /** the max-age portion of the header, as a number. Default is 15768000. */ + maxAge?: number; + /** a boolean specifying whether to add the includeSubDomains flag to the header. */ + includeSubdomains?: boolean; + /** a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. */ + preload?: boolean; + }; + /** controls the 'X-Frame-Options' header. When set to true the header will be set to DENY, you may also specify a string value of 'deny' or 'sameorigin'. Defaults to true. To use the 'allow-from' rule, you must set this to an object with the following fields: */ + xframe?: true | 'deny' | 'sameorigin' | { + /** may also be 'deny' or 'sameorigin' but set directly as a string for xframe */ + rule: 'allow-from'; + /** when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. */ + source: string; + }; + /** boolean that controls the 'X-XSS-PROTECTION' header for IE. Defaults to true which sets the header to equal '1; mode=block'. NOTE: This setting can create a security vulnerability in versions of IE below 8, as well as unpatched versions of IE8. See [here](https://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities/) and [here](https://technet.microsoft.com/library/security/ms10-002) for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. [Kept typing non optional to force this security related documentation to be read.] */ + xss: boolean; + /** boolean controlling the 'X-Download-Options' header for IE, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. */ + noOpen?: boolean; + /** boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff' */ + noSniff?: boolean; +} + +/** + * request input validation rules for various request components. When using a Joi validation object, the values of the other inputs (i.e. headers, query, params, payload, and auth) are made available under the validation context (accessible in rules as Joi.ref('$query.key')). Note that validation is performed in order (i.e. headers, params, query, payload) and if type casting is used (converting a string to number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. If the validation rules for headers, params, query, and payload are defined at both the routes defaults level and an individual route, the individual route settings override the routes defaults (the rules are not merged). The validate object supports: + * For context see RouteAdditionalConfigurationOptions > validate + * TODO check JoiValidationObject is correct for "a Joi validation object" + */ +export interface RouteValidationConfigurationObject { + /** + * validation rules for incoming request headers (note that all header field names must be in lowercase to match the headers normalized by node). Values allowed: + * * true - any headers allowed (no validation performed). This is the default. + * * false - no headers allowed (this will cause all valid HTTP requests to fail). + * * a Joi validation object. + * * a validation function using the signature function(value, options, next) where: + * * value - the object containing the request headers. + * * options - the server validation options. + * * next(err, value) - the callback function called when validation is completed. `value` will be used as the `headers` value when `err` is falsy. If `next` is called with `undefined` or no arguments then the original value of `value` will be used. + */ + headers?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; + /** + * validation rules for incoming request path parameters, after matching the path against the route and extracting any parameters then stored in request.params. Values allowed: + * Same as `headers`, see above. + */ + params?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; + /** + * validation rules for an incoming request URI query component (the key-value part of the URI between '?' and '#'). The query is parsed into its individual key-value pairs and stored in request.query prior to validation. Values allowed: + * Same as `headers`, see above. + */ + query?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; + /** + * validation rules for an incoming request payload (request body). Values allowed: + * Same as `headers`, see above, with the addition that: + * * a Joi validation object. Note that empty payloads are represented by a null value. If a validation schema is provided and empty payload are supported, it must be explicitly defined by setting the payload value to a joi schema with null allowed (e.g. Joi.object({ /* keys here * / }).allow(null)). + */ + payload?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; + /** an optional object with error fields copied into every validation error response. */ + errorFields?: any; + /** + * determines how to handle invalid requests. Allowed values are: + * * 'error' - return a Bad Request (400) error response. This is the default value. + * * 'log' - log the error but continue processing the request. + * * 'ignore' - take no action. + * * a custom error handler function with the signature function(request, reply, source, error) see RouteFailFunction + */ + failAction?: 'error' | 'log' | 'ignore' | RouteFailFunction; + /** + * options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is [available here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback)). + * If a custom validation function (see `headers`, `params`, `query`, or `payload` above) is defined then `options` can an arbitrary object that will be passed to this function as the second parameter. + * Defaults to no options. + */ + options?: ValidationOptions; +} + +/** + * a validation function using the signature function(value, options, next) where: + * For context see RouteAdditionalConfigurationOptions > validate (RouteValidationConfigurationObject) + * + * Also see ValidationFunctionForRouteResponse + * @param value - the object containing the request headers, query, path params or payload. + * @param options - the server validation options. + * @param next([err, [value]]) - the callback function called when validation is completed. + */ +export interface ValidationFunctionForRouteInput { + (value: any, options: RouteInputValidationContext & ValidationOptions, next: ContinuationValueFunction): void; +} + +/** + * A context for route input validation via a Joi schema or validation function. + * + * This object is merged with the route validation options and passed into the validation function. + * + * See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L122 + */ +export interface RouteInputValidationContext { + context: { + // These are only set when *not* validating the respective source (e.g. params, query and payload are set when validating headers): + // See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L132 + headers?: Dictionary; + params?: any; + query?: any; + payload?: any; + + /** The request authentication information */ + auth: RequestAuthenticationInformation; + } +} + +/** + * a custom error handler function with the signature 'function(request, reply, source, error)` + * @param request - the request object. + * @param reply - the continuation reply interface. + * @param source - the source of the invalid field (e.g. 'headers', 'params', 'query', 'payload'). + * @param error - the error object prepared for the client response (including the validation function error under error.data). + */ +export interface RouteFailFunction { + (request: Request, reply: ReplyWithContinue, source: string, error: any): void; +} + +/** + * optional cookie settings + * [See docs](https://hapijs.com/api/16.1.1#serverstatename-options) + * Related to see ConnectionConfigurationServerDefaults + */ +export interface ServerStateCookieConfiguationObject { + /** time-to-live in milliseconds. Defaults to null (session time-life - cookies are deleted when the browser is closed). */ + ttl?: number | null; + /** sets the 'Secure' flag. Defaults to true. */ + isSecure?: boolean; + /** sets the 'HttpOnly' flag. Defaults to true. */ + isHttpOnly?: boolean; + /** + * sets the 'SameSite' flag where the value must be one of: + * * false - no flag. + * * 'Strict' - sets the value to 'Strict' (this is the default value). + * * 'Lax' - sets the value to 'Lax'. + */ + isSameSite?: false | 'Strict' | 'Lax'; + /** the path scope. Defaults to null (no path). */ + path?: string | null; + /** the domain scope. Defaults to null (no domain). */ + domain?: string | null; + /** + * if present and the cookie was not received from the client or explicitly set by the route handler, the cookie is automatically added to the response with the provided value. The value can be a function with signature function(request, next) where: + * * request - the request object. + * * next - the continuation function using the function(err, value) signature. + */ + autoValue?(request: Request, next: ContinuationValueFunction): void; + /** + * encoding performs on the provided value before serialization. Options are: + * * 'none' - no encoding. When used, the cookie value must be a string. This is the default value. + * * 'base64' - string value is encoded using Base64. + * * 'base64json' - object value is JSON-stringified then encoded using Base64. + * * 'form' - object value is encoded using the x-www-form-urlencoded method. + * * 'iron' - Encrypts and sign the value using iron. + */ + encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron'; + /** + * an object used to calculate an HMAC for cookie integrity validation. This does not provide privacy, only a mean to verify that the cookie value was generated by the server. Redundant when 'iron' encoding is used. Options are: + * * integrity - algorithm options. Defaults to require('iron').defaults.integrity. + * * password - password used for HMAC key generation (must be at least 32 characters long). + */ + sign?: { + integrity?: any; // TODO make iron definitions and getting typing from iron + password: string; + }; + /** password used for 'iron' encoding (must be at least 32 characters long). */ + password?: string; + /** options for 'iron' encoding. Defaults to require('iron').defaults. */ + iron?: any; // TODO make iron definitions and getting typing from iron + /** if true, errors are ignored and treated as missing cookies. */ + ignoreErrors?: boolean; + /** if true, automatically instruct the client to remove invalid cookies. Defaults to false. */ + clearInvalid?: boolean; + /** if false, allows any cookie value including values in violation of RFC 6265. Defaults to true. */ + strictHeader?: boolean; + /** used by proxy plugins (e.g. h2o2). */ + passThrough?: any; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverconnections) + */ +export interface ServerConnection { + /** settings - the connection configuration object passed to server.connection() after applying the server defaults. */ + settings: ServerConnectionOptions; + /** server - the connection's Server object. */ + server: Server; + /** type - set to 'tcp' is the connection is listening on a TCP port, otherwise to 'socket'(a UNIX domain socket or a Windows named pipe). */ + type: 'tcp' | 'socket'; + /** + * registrations + * Described [See docs](https://hapijs.com/api/16.1.1#serverregistrations) "When the server contains more than one connection, each server.connections array member provides its own connection.registrations." + */ + registrations: ServerRegisteredPlugins; + /** states - TODO contribute docs to hapi if they want, and then update type here */ + states: any; + /** auth - TODO contribute docs to hapi if they want, and then update type here */ + auth: any; + /** + * plugins + * TODO contribute docs to hapi if they want. Assuming similar to `registrations`, `listener`, `info`, etc + */ + plugins: PluginsStates; + /** + * app + * TODO contribute docs to hapi if they want. Assuming similar to `registrations`, `listener`, `info`, etc + */ + app: any; + /** Described in server.listener [See docs](https://hapijs.com/api/16.1.1#serverlistener) */ + listener: ServerListener; + /** Described in server.info [See docs](https://hapijs.com/api/16.1.1#serverinfo) */ + info: ServerConnectionInfo; + /** Described in server.inject [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) */ + inject(options: string | InjectedRequestOptions, callback: (res: InjectedResponseObject) => void): void; + inject(options: string | InjectedRequestOptions, ): Promise; + /** Mentioned but not documented under server.connections [See docs](https://hapijs.com/api/16.1.1#serverconnections) */ + table(host?: string): Route[]; + /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#serverlookupid) */ + lookup(id: string): RoutePublicInterface | null; + /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#servermatchmethod-path-host) */ + match(method: HTTP_METHODS, path: string, host?: string): RoutePublicInterface | null; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverinfo) + */ +export interface ServerConnectionInfo { + /** a unique connection identifier (using the format '{hostname}:{pid}:{now base36}'). */ + id: string; + /** the connection creation timestamp. */ + created: number; + /** the connection start timestamp (0 when stopped). */ + started: number; + /** + * the connection port based on the following rules: + * * the configured port value before the server has been started. + * * the actual port assigned when no port is configured or set to 0 after the server has been started. + * TODO check this type. What happens when socket is a UNIX domain socket or Windows named pipe? + */ + port: number | string; + /** the host name the connection was configured to. Defaults to the operating system hostname when available, otherwise 'localhost'. */ + host: string; + /** the active IP address the connection was bound to after starting. Set to undefined until the server has been started or when using a non TCP port (e.g. UNIX domain socket). */ + address: undefined | string; + /** the protocol used. 'socket' when UNIX domain socket or Windows named pipe. */ + protocol: 'http' | 'https' | 'socket'; + /** a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains the uri setting if provided, otherwise constructed from the available settings. If no port is available or set to 0, the uri will not include a port component. */ + uri: string; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverlistener) + */ +export type ServerListener = http.Server; + +/** + * server.realm + * The realm object contains server-wide or plugin-specific state that can be shared across various methods. For example, when calling server.bind(), the active realm settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). Realms are a limited version of a sandbox where plugins can maintain state used by the framework when adding routes, extensions, and other properties. + * [See docs](https://hapijs.com/api/16.1.1#serverrealm) + */ +export interface ServerRealm { + /** when the server object is provided as an argument to the plugin register() method, modifiers provides the registration preferences passed the server.register() method and includes: */ + modifiers: { + /** routes preferences: */ + route: { + /** the route path prefix used by any calls to server.route() from the server. Note that if a prefix is used and the route path is set to '/', the resulting path will not include the trailing slash. */ + prefix: string; + /** the route virtual host settings used by any calls to server.route() from the server. */ + vhost: string; + } + }; + /** the active plugin name (empty string if at the server root). */ + plugin: string; + /** the plugin options object passed at registration. */ + pluginOptions: any; // OptionsPassedToPlugin; + /** plugin-specific state to be shared only among activities sharing the same active state. plugins is an object where each key is a plugin name and the value is the plugin state. */ + plugins: PluginsStates; + /** settings overrides (from RouteAdditionalConfigurationOptions) */ + settings: { + files: { + relativeTo: string; + }; + bind: any; + }; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) + */ +export interface ServerRegisteredPlugins { + [pluginName: string]: ServerRegisteredPlugin; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) + */ +export interface ServerRegisteredPlugin { + /** the plugin version. */ + version: string; + /** the plugin name. */ + name: string; + /** + * options used to register the plugin. + * TODO update with outcome of: https://github.com/hapijs/hapi/pull/3479 + */ + options: any; // OptionsPassedToPlugin; + /** plugin registration attributes. */ + attributes: PluginAttributes; +} + +export interface ServerAuth { + /** + * server.auth.api + * An object where each key is a strategy name and the value is the exposed strategy API. Available on when the authentication scheme exposes an API by returning an api key in the object returned from its implementation function. + * When the server contains more than one connection, each server.connections array member provides its own connection.auth.api object. + * [See docs](https://hapijs.com/api/16.1.1#serverauthapi) + */ + api: Dictionary; + /** + * server.auth.default + * Sets a default strategy which is applied to every route + * The default does not apply when the route config specifies auth as false, or has an authentication strategy configured (contains the strategy or strategies authentication settings). Otherwise, the route authentication config is applied to the defaults. + * Note that if the route has authentication config, the default only applies at the time of adding the route, not at runtime. This means that calling default() after adding a route with some authentication config will have no impact on the routes added prior. However, the default will apply to routes added before default() is called if those routes lack any authentication config. + * The default auth strategy configuration can be accessed via connection.auth.settings.default. To obtain the active authentication configuration of a route, use connection.auth.lookup(request.route). + * [See docs](https://hapijs.com/api/16.1.1#serverauthdefaultoptions) + */ + default(options: string | AuthOptions): void; + /** + * server.auth.scheme + * Registers an authentication scheme + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) + * @param name the scheme name. + * @param scheme the method implementing the scheme with signature function(server, options) see ServerAuthScheme + */ + scheme(name: string, scheme: ServerAuthScheme): void; + /** + * Registers an authentication strategy + * [See docs](https://hapijs.com/api/16.1.1#serverauthstrategyname-scheme-mode-options) + * @param name the strategy name. + * @param scheme the scheme name (must be previously registered using server.auth.scheme()). + * @param mode if set to true (which is the same as 'required') or to a valid authentication mode ('required', 'optional', 'try'), the scheme is automatically assigned as the default strategy for any route without an auth config. Can only be assigned to a single server strategy. Defaults to false (no default settings). + * @param options scheme options based on the scheme requirements. + */ + strategy(name: string, scheme: string, options?: any): void; + strategy(name: string, scheme: string, mode: boolean | 'required' | 'optional' | 'try', options?: any): void; + /** + * Tests a request against an authentication strategy + * Note that the test() method does not take into account the route authentication configuration. It also does not perform payload authentication. It is limited to the basic strategy authentication execution. It does not include verifying scope, entity, or other route properties. + * [See docs](https://hapijs.com/api/16.1.1#serverauthteststrategy-request-next) + * @param strategy - the strategy name registered with server.auth.strategy(). + * @param request - the request object. + * @param next - the callback function with signature function(err, credentials) where: + * * err - the error if authentication failed. + * * credentials - the authentication credentials object if authentication was successful. + */ + test(strategy: string, request: Request, next: (err: Error | null, credentials: AuthenticatedCredentials) => void): void; +} + +export type Strategy = any; +export type SchemeSettings = any; + +/** + * the method implementing the scheme with signature function(server, options) where: + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) + * @param server a reference to the server object the scheme is added to. + * @param options optional scheme settings used to instantiate a strategy. + */ +export interface ServerAuthScheme { + (server: Server, options: SchemeSettings): SchemeMethodResult; +} + +/** + * The scheme method must return an object with the following + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) + */ +export interface SchemeMethodResult { + /** optional object which is exposed via the server.auth.api object. */ + api?: Strategy; + /** + * required function called on each incoming request configured with the authentication scheme + * When the scheme authenticate() method implementation calls reply() with an error condition, the specifics of the error affect whether additional authentication strategies will be attempted (if configured for the route). If the err passed to the reply() method includes a message, no additional strategies will be attempted. If the err does not include a message but does include the scheme name (e.g. Boom.unauthorized(null, 'Custom')), additional strategies will be attempted in the order of preference (defined in the route configuration). If authentication fails the scheme names will be present in the 'WWW-Authenticate' header. + * @param request the request object. + * @param reply the reply interface the authentication method must call when done authenticating the request + */ + authenticate(request: Request, reply: ReplySchemeAuth): void; + /** + * optional function called to authenticate the request payload + * When the scheme payload() method returns an error with a message, it means payload validation failed due to bad payload. If the error has no message but includes a scheme name (e.g. Boom.unauthorized(null, 'Custom')), authentication may still be successful if the route auth.payload configuration is set to 'optional'. + * @param request the request object. + * @param reply is called if authentication failed + */ + payload?(request: Request, reply: ReplySchemeAuthOfPayload): void; + /** + * optional function called to decorate the response with authentication headers before the response headers or payload is written where: + * @param request the request object. + * @param reply is called if an error occured + */ + response?(request: Request, reply: ReplySchemeAuthDecorateResponse): void; + /** an optional object with the following keys: */ + options?: { + /** if true, requires payload validation as part of the scheme and forbids routes from disabling payload auth validation. Defaults to false. */ + payload?: boolean; + }; +} + +export interface ServerCacheMethod { + /** + * Provisions a cache segment within the server cache facility + * [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) + */ + (options: CatboxServerCacheConfiguration): Catbox.Policy; + /** + * Provisions a server cache as described in server.cache + * If no callback is provided, a Promise object is returned. + * Note that if the server has been initialized or started, the cache will be automatically started to match the state of any other provisioned server cache. + * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) + * @param options same as the server cache configuration options. + * @param callback the callback method when cache provisioning is completed or failed with the signature function(err) where: + * * err - any cache startup error condition. + */ + provision(options: CatboxServerCacheConfiguration): Promise; + provision(options: CatboxServerCacheConfiguration, callback: (err?: Error) => void): void; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Request + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Request object + * The request object is created internally for each incoming request. It is different from the node.js request object received from the HTTP server callback (which is available in request.raw.req). The request object methods and properties change throughout the request lifecycle. + * [See docs](https://hapijs.com/api/16.1.1#request-object) + * [See docs](https://hapijs.com/api/16.1.1#request-properties) + */ +export class Request extends Podium { + /** application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. */ + app: any; + /** authentication information */ + auth: RequestAuthenticationInformation; + /** the connection the request was received by. */ + connection: ServerConnection; + /** the node domain object used to protect against exceptions thrown in extensions, handlers and route prerequisites. Can be used to manually bind callback functions otherwise bound to other domains. Set to null when the server useDomains options is false. */ + domain: domain.Domain | null; + /** the raw request headers (references request.raw.headers). */ + headers: Dictionary; + /** a unique request identifier (using the format '{now}:{connection.info.id}:{5 digits counter}').*/ + id: string; + /** request information */ + info: { + /** the request preferred encoding. */ + acceptEncoding: string; + /** if CORS is enabled for the route, contains the following: */ + cors: { + /** + * true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. + * Note: marking as optional as "... this is only available after ..." + */ + isOriginMatch?: boolean; + }; + /** content of the HTTP 'Host' header (e.g. 'example.com:8080'). */ + host: string; + /** the hostname part of the 'Host' header (e.g. 'example.com'). */ + hostname: string; + /** request reception timestamp. */ + received: number; + /** content of the HTTP 'Referrer' (or 'Referer') header. */ + referrer: string; + /** remote client IP address. */ + remoteAddress: string; + /** + * remote client port. + * Set to string in casethey're requesting from a UNIX domain socket. + * TODO, what type does Hapi return, should this be number | string? + */ + remotePort: string; + /** request response timestamp (0 is not responded yet). */ + responded: number; + }; + /** the request method in lower case (e.g. 'get', 'post'). */ + method: string; + /** the parsed content-type header. Only available when payload parsing enabled and no payload error occurred. */ + mime: string; + /** an object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. */ + orig: { + params: any; + query: any; + payload: any; + }; + /** an object where each key is a path parameter name with matching value as described in Path parameters [See docs](https://hapijs.com/api/16.1.1#path-parameters). */ + params: Dictionary; + /** an array containing all the path params values in the order they appeared in the path. */ + paramsArray: string[]; + /** the request URI's pathname [See docs](https://nodejs.org/api/url.html#url_urlobject_pathname) component. */ + path: string; + /** + * the request payload based on the route payload.output and payload.parse settings. + * TODO check this typing and add references / links. + */ + payload: stream.Readable | Buffer | any; + /** plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. */ + plugins: PluginsStates; + /** an object where each key is the name assigned by a route prerequisites function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. */ + pre: Object; + /** the response object when set. The object can be modified but must not be assigned another object. To replace the response with another from within an extension point, use reply(response) to override with a different response. Contains null when no response has been set (e.g. when a request terminates prematurely when the client disconnects). */ + response: Response | null; + /** same as pre but represented as the response object created by the pre method. */ + preResponses: Object; + /** + * by default the object outputted from [node's URL parse()](https://nodejs.org/docs/latest/api/url.html#url_urlobject_query) method. + * Might also be set indirectly via [request.setUrl](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17354#requestseturlurl-striptrailingslash) in which case it may be + * a string (if url is set to an object with the query attribute as an unparsed string). + */ + query: any; + /** an object containing the Node HTTP server objects. **Direct interaction with these raw objects is not recommended.** */ + raw: { + req: http.IncomingMessage; // Or http.ClientRequest http://www.apetuts.com/tutorial/node-js-http-client-request-class/ ? + res: http.ServerResponse; + }; + /** + * the route public interface. + * Optional due to "request.route is not yet populated at this point." [See docs](https://hapijs.com/api/16.1.1#request-lifecycle) + */ + route?: RoutePublicInterface; + /** the server object. */ + server: Server; + /** an object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. */ + state: Dictionary; + /** the parsed request URI */ + url: url.Url; + + /** + * request.setUrl(url, [stripTrailingSlash]) + * Available only in 'onRequest' extension methods. + * Changes the request URI before the router begins processing the request + * [See docs](https://hapijs.com/api/16.1.1#requestseturlurl-striptrailingslash) + * @param url the new request URI. If url is a string, it is parsed with node's URL parse() method. url can also be set to an object compatible with node's URL parse() method output. + * @param stripTrailingSlash if true, strip the trailing slash from the path. Defaults to false. + */ + setUrl(url: string | url.Url, stripTrailingSlash?: boolean): void; + /** + * request.setMethod(method) + * Available only in 'onRequest' extension methods. + * Changes the request method before the router begins processing the request + * [See docs](https://hapijs.com/api/16.1.1#requestsetmethodmethod) + * @param method is the request HTTP method (e.g. 'GET'). + */ + setMethod(method: HTTP_METHODS): void; + /** + * request.generateResponse(source, [options]) + * Always available. + * Returns a response which you can pass into the reply interface where: + * [See docs](https://hapijs.com/api/16.1.1#requestgenerateresponsesource-options) + * @param source the object to set as the source of the reply interface. TODO, submit a PR to clarify this doc, from the source code it's clear that "the object to set" refers to something of type `ReplyValue` i.e. that can be null, string, number, object, Stream, Promise, or Buffer. + * @param options options for the method, optional. Not documented yet, perhaps not very important. + */ + generateResponse(source?: ReplyValue, options?: {marshal?: any; prepare?: any; close?: any; variety?: any}): Response; + /** + * request.log(tags, [data, [timestamp]]) + * Always available. + * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. + * Any logs generated by the server internally will be emitted only on the 'request-internal' channel and will include the event.internal flag set to true. + * [See docs](https://hapijs.com/api/16.1.1#requestlogtags-data-timestamp) + * @param tags a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. + * @param data an optional message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. + * @param timestamp an optional timestamp expressed in milliseconds. Defaults to Date.now() (now). + */ + log(tags: string | string[], data?: string | Object | (() => string | Object), timestamp?: number): void; + /** + * request.getLog([tags], [internal]) + * Always available. + * Returns an array containing the events matching any of the tags specified (logical OR) + * Note that this methods requires the route log configuration set to true. + * [See docs](https://hapijs.com/api/16.1.1#requestgetlogtags-internal) + * @param tags is a single tag string or array of tag strings. If no tags specified, returns all events. + * @param internal filters the events to only those with a matching event.internal value. If true, only internal logs are included. If false, only user event are included. Defaults to all events (undefined). + */ + getLog(tags?: string | string[], internal?: boolean): string[]; + getLog(internal?: boolean): string[]; + /** + * request.tail([name]) + * Available until immediately after the 'response' event is emitted. + * Adds a request tail which has to complete before the request lifecycle is complete. + * Returns a tail function which must be called when the tail activity is completed. + * Tails are actions performed throughout the request lifecycle, but which may end after a response is sent back to the client. For example, a request may trigger a database update which should not delay sending back a response. However, it is still desirable to associate the activity with the request when logging it (or an error associated with it). + * When all tails completed, the server emits a 'tail' event. + * [See docs](https://hapijs.com/api/16.1.1#requesttailname) + * @param name an optional tail name used for logging purposes. + */ + tail(name?: string): (() => void); + /** + * The server.decorate('request', ...) method can modify this prototype/interface. + * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts + * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) + */ + // [index: string]: any; +} + +export interface RequestAuthenticationInformation { + /** true if the request has been successfully authenticated, otherwise false. */ + isAuthenticated: boolean; + /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ + credentials: any; + /** an artifact object received from the authentication strategy and used in authentication-related actions. */ + artifacts: any; + /** the route authentication mode. */ + mode: string; + /** the authentication error is failed and mode set to 'try'. */ + error: Error; +} + +export type HTTP_METHODS_PARTIAL_lowercase = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; +export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_lowercase; +export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; + +/** + * Request events + * The request object supports the following events: + * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). + * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). + * * 'disconnect' - emitted when a request errors or aborts unexpectedly. + * [See docs](https://hapijs.com/api/16.1.1#request-events) + */ +export type RequestEventTypes = 'peek' | 'finish' | 'disconnect'; + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Handler functions + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Extending RouteConfiguration.handler + * + * The hapi documentation allows for the RouteConfiguration.handler type to have + * `{[pluginName: string]: pluginOptions}` + * "handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler" + * This can be provided by extending the hapi module definition as follows, + * see h2o2 for example: + * + * declare module 'hapi' { + * interface RouteHandlerPlugins { + * proxy?: ... + */ +export interface RouteHandlerPlugins { +} +/** + * The route handler function uses the signature function(request, reply) (NOTE: do not use a fat arrow style function for route handlers as they do not allow context binding and will cause problems when used in conjunction with server.bind) where: + * * request - is the incoming request object (this is not the node.js request object). + * * reply - the reply interface the handler must call to set a response and return control back to the framework. + * [See docs](https://hapijs.com/api/16.1.1#route-handler) + * Same function signature used by request extension point used in server.ext(event), see ServerExtConfigurationObject.method + */ +export interface RouteHandler { + (request: Request, reply: ReplyNoContinue): void; + // (request: Request, reply: StrictReply): void; +} + +/** + * "the function to call, the function signature is identical to a route handler as described in Route handler." + * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) Route prerequisites + */ +export type RoutePrerequisiteRequestHandler = RouteHandler; + +/** + * request extension points: function(request, reply) where + * this - the object provided via options.bind or the current active context set with server.bind(). + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * @param request the request object. + * @param reply the reply interface which is used to return control back to the framework. To continue normal execution of the request lifecycle, reply.continue() must be called. If the extension type is 'onPostHandler' or 'onPreResponse', a single argument passed to reply.continue() will override the current set response (including all headers) but will not stop the request lifecycle execution. To abort processing and return a response to the client, call reply(value) where value is an error or any other valid response. + */ +export interface ServerExtRequestHandler { + (request: Request, reply: ReplyWithContinue): void; +} + +/** + * Used by various extensions to handle a request and + * synchronously return a result of some form. + * + * Left in for backwards compatibility of typings but according to the + * [DefinitelyTyped Readme under common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes) + * it talks about not using generic types unless the type was used in typing one + * or more of the function arguments. Using it to type the return was suggested + * to be the same as a type assertion. + */ +export interface RequestHandler { + (request: Request): T; +} + +/** + * Used by server extension points + * err can be `Boom` error or Error that will be wrapped as a `Boom` error + * For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/reply.js#L109-L118) + * For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65) + */ +export interface ContinuationFunction { + (err?: Boom.BoomError): void; +} +/** + * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65) + * TODO Can value be typed with a useful generic? + */ +export interface ContinuationValueFunction { + (err: Boom.BoomError): void; + (err: null | undefined, value: any): void; + (): void; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Reply functions + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Typings listed explicitly here [See docs](https://hapijs.com/api/16.1.1#replyerr-result) + * Typings also described in part here [See docs](https://hapijs.com/api/16.1.1#response-object) + */ +export type ReplyValue = _ReplyValue | Promise<_ReplyValue>; +export type _ReplyValue = null | undefined | string | number | boolean | Buffer | Error | stream.Stream | Object; // | array; + +/** + * Reply interface + * reply([err], [result]) + * Concludes the handler activity by setting a response and returning control over to the framework + * When reply() is called with an error or result response, that value is used as the response sent to the client. When reply() is called within a prerequisite, the value is saved for future use and is not used as the response. In all other places except for the handler, calling reply() will be considered an error and will abort the request lifecycle, jumping directly to the 'onPreResponse' event. + * To return control to the framework within an extension or other places other than the handler, without setting a response, the method reply.continue() must be called. Except when used within an authentication strategy, or in an 'onPostHandler' or 'onPreResponse' extension, the reply.continue() must not be passed any argument or an exception is thrown. + * [See docs](https://hapijs.com/api/16.1.1#reply-interface) + * [See docs](https://hapijs.com/api/16.1.1#replyerr-result) + * + * NOTE: modules should extend this interface to expose reply.Nnn methods + */ +export interface Base_Reply { + (err?: ReplyValue): Response; + (err: null, result?: ReplyValue): Response; + /** the active realm associated with the route. */ + realm: ServerRealm; + /** the request object */ + request: Request; + + /** + * reply.entity(options) + * Sets the response 'ETag' and 'Last-Modified' headers and checks for any conditional request headers to decide if the response is going to qualify for an HTTP 304 (Not Modified). If the entity values match the request conditions, reply.entity() returns control back to the framework with a 304 response. Otherwise, it sets the provided entity headers and returns null. + * Returns a response object if the reply is unmodified or null if the response has changed. If null is returned, the developer must call reply() to continue execution. If the response is not null, the developer must not call reply(). + * [See docs](https://hapijs.com/api/16.1.1#replyentityoptions) + * @param options a required configuration object with: + * * etag - the ETag string. Required if modified is not present. Defaults to no header. + * * modified - the Last-Modified header value. Required if etag is not present. Defaults to no header. + * * vary - same as the response.etag() option. Defaults to true. + */ + entity(options: {etag?: string, modified?: string, vary?: boolean}): Response | null; + /** + * reply.close([options]) + * Concludes the handler activity by returning control over to the router and informing the router that a response has already been sent back directly via request.raw.res and that no further response action is needed. Supports the following optional options: + * The response flow control rules do not apply. + * [See docs](https://hapijs.com/api/16.1.1#replycloseoptions) + * @param options options object: + * * end - if false, the router will not call request.raw.res.end()) to ensure the response was ended. Defaults to true. + */ + close(options?: {end?: boolean}): void; + /** + * reply.redirect(uri) + * Redirects the client to the specified uri. Same as calling reply().redirect(uri). + * The response flow control rules apply. + * Sets an HTTP redirection response (302) and decorates the response with additional methods for + * changing to a permanent or non-rewritable redirect is also available see response object redirect for more information. + * [See docs](https://hapijs.com/api/16.1.1#replyredirecturi) + * @param uri an absolute or relative URI used to redirect the client to another resource. + */ + redirect(uri: string): ResponseRedirect; + /** + * reply.response(result) + * Shorthand for calling `reply(null, result)`, replies with the response set to `result`. + * [See docs](https://hapijs.com/api/16.1.1#replyresponseresult) + * TODO likely to change. Await approval of pull request to Hapi docs. + */ + response(result: ReplyValue): Response; + /** + * Sets a cookie on the response + * [See docs](https://hapijs.com/api/16.1.1#reply) + * TODO likely to change. Await approval of pull request to Hapi docs. + */ + state(name: string, value: any, options?: any): void; + /** + * Clears a cookie on the response + * [See docs](https://hapijs.com/api/16.1.1#reply) + * TODO likely to change. Await approval of pull request to Hapi docs. + */ + unstate(name: string, options?: any): void; + /** + * The server.decorate('reply', ...) method can modify this prototype/interface. + * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts + * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) + */ + // [index: string]: any; +} +/** + * reply.continue([result]) + * Returns control back to the framework without ending the request lifecycle + * [See docs](https://hapijs.com/api/16.1.1#replycontinueresult) + * [See docs](https://hapijs.com/api/16.1.1#replyerr-result) "With the exception of the handler function, all other methods provide the reply.continue() method which instructs the framework to continue processing the request without setting a response." + * @param result if called in the handler, prerequisites, or extension points other than the 'onPreHandler' and 'onPreResponse', the result argument is not allowed and will throw an exception if present. If called within an authentication strategy, it sets the authenticated credentials. If called by the 'onPreHandler' or 'onPreResponse' extensions, the result argument overrides the current response including all headers, and returns control back to the framework to continue processing any remaining extensions. + */ +export interface Continue_Reply { + continue(result?: ReplyValue): Response | undefined; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > authenticate. + * Also [See docs](https://hapijs.com/api/16.1.1#replyerr-result). + * TODO check it has Base_Reply methods and properties + */ +export interface ReplySchemeAuth extends Base_Reply { + /** + * This function is called if authentication failed. + * TODO, check type the `response` parameter. In https://hapijs.com/api/16.1.1#replyerr-result it is referred to as "null" but this seems to be for a third scenario where it is "used to return both an error and credentials in the authentication methods" then "reply() must be called with three arguments function(err, null, data)" + * @param err any authentication error. + * @param response any authentication response action such as redirection. Ignored if err is present, otherwise required. + * @param result an object containing: + * * credentials the authenticated credentials. + * * artifacts optional authentication artifacts. + */ + (err: Error | null, response: AnyAuthenticationResponseAction | null, result: AuthenticationResult): void; + /** + * is called if authentication succeeded + * @param result same object as result above. + */ + continue(result: AuthenticationResult): void; +} +/** + * Typing as any as it's not yet clear what type this argument takes. + * "any authentication response action such as redirection" is it equivalent to + * `ReplyValue` ? + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) + * TODO research hapi source and type this. + */ +export type AnyAuthenticationResponseAction = any; +/** [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) */ +export interface AuthenticationResult { + credentials?: AuthenticatedCredentials; + artifacts?: any; +} +export interface AuthenticatedCredentials { + // Disabled to allow typing within a project + // [index: string]: any; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > payload + * TODO check it has Base_Reply methods and properties + */ +export interface ReplySchemeAuthOfPayload extends Base_Reply { + /** + * function called to authenticate the request payload where: + * @param err any authentication error. + * @param response any authentication response action such as redirection. Ignored if err is present, otherwise required. + */ + (err: Error | null, response: AnyAuthenticationResponseAction): void; + /** is called if payload authentication succeeded */ + continue(): void; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > response + * TODO check it has Base_Reply methods and properties + */ +export interface ReplySchemeAuthDecorateResponse extends Base_Reply { + /** + * is called if an error occurred + * @param err any authentication error. + * @param response any authentication response to send instead of the current response. Ignored if err is present, otherwise required. + */ + (err?: Error, response?: ReplyValue): void; + /** is called if the operation succeeded. */ + continue(): void; +} + +export interface ReplyWithContinue extends Continue_Reply, Base_Reply {} + +export interface ReplyNoContinue extends Base_Reply {} + +// TODO assess use and usefulness of StrictReply + +// Concludes the handler activity by setting a response and returning control over to the framework where: +// erran optional error response. +// result an optional response payload. +// Since an request can only have one response regardless if it is an error or success, the reply() method can only result in a single response value. This means that passing both an err and result will only use the err. There is no requirement for either err or result to be (or not) an Error object. The framework will simply use the first argument if present, otherwise the second. The method supports two arguments to be compatible with the common callback pattern of error first. +// FLOW CONTROL: +// When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() +/** + * + */ +// export interface Reply { // extends ReplyMethods { +// (err: Error, +// result?: string | number | boolean | Buffer | stream.Stream | Promise | T, +// /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ +// credentialData?: any): BoomError; +// /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ +// (result: string | number | boolean | Buffer | stream.Stream | Promise | T): Response; +// } + +/** Concludes the handler activity by setting a response and returning control over to the framework where: + erran optional error response. + result an optional response payload. + Since an request can only have one response regardless if it is an error or success, the reply() method can only result in a single response value. This means that passing both an err and result will only use the err. There is no requirement for either err or result to be (or not) an Error object. The framework will simply use the first argument if present, otherwise the second. The method supports two arguments to be compatible with the common callback pattern of error first. + FLOW CONTROL: + When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() */ +// export interface StrictReply extends ReplyMethods { +// (err: Error, +// result?: Promise | T, +// /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ +// credentialData?: any): BoomError; +// /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ +// (result: Promise | T): Response; +// } + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Response + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Response object + * [See docs](https://hapijs.com/api/16.1.1#response-object) + * + * TODO, check extending from Podium is correct. Extending because of "The response object supports the following events" [See docs](https://hapijs.com/api/16.1.1#response-events) + * * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). + * * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). + */ +export interface Response extends Podium { + /** the HTTP response status code. Defaults to 200 (except for errors). */ + statusCode: number; + /** an object containing the response headers where each key is a header field name. Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission. */ + headers: Dictionary; + /** the value provided using the reply interface. */ + source: ReplyValue; + /** + * a string indicating the type of source with available values: + * * 'plain' - a plain response such as string, number, null, or simple object (e.g. not a Stream, Buffer, or view). + * * 'buffer' - a Buffer. + * * 'stream' - a Stream. + * * 'promise' - a Promise object. + */ + variety: 'plain' | 'buffer' | 'stream' | 'promise'; + /** application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. */ + app: any; + /** plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. */ + plugins: PluginsStates; + /** response handling flags: */ + settings: { + /** the 'Content-Type' HTTP header 'charset' property. Defaults to 'utf-8'. */ + charset: string; + /** the string encoding scheme used to serial data into the HTTP payload when source is a string or marshals into a string. Defaults to 'utf8'. */ + encoding: string; + /** if true and source is a Stream, copies the statusCode and headers of the stream to the outbound response. Defaults to true. */ + passThrough: boolean; + /** options used for source value requiring stringification. Defaults to no replacer and no space padding. */ + stringify: Json.StringifyArguments; + /** if set, overrides the route cache expiration milliseconds value set in the route config. Defaults to no override. */ + ttl: number | null; + /** if true, a suffix will be automatically added to the 'ETag' header at transmission time (separated by a '-' character) when the HTTP 'Vary' header is present. */ + varyEtag: boolean; + }; + + /** + * The following attribute is present in one or more of the examples + * TODO update once Hapi docs describes explicitly + */ + isBoom?: boolean; + /** + * The following attribute is present in one or more of the examples + * TODO update once Hapi docs describes explicitly + */ + isMissing?: boolean; + /** + * The following attribute is present in one or more of the examples + * TODO update once Hapi docs describes explicitly + */ + output?: Boom.Output; + + /** + * sets the HTTP 'Content-Length' header (to avoid chunked transfer encoding) + * @param length the header value. Must match the actual payload size. + */ + bytes(length: number): Response; + /** + * sets the 'Content-Type' HTTP header 'charset' property + * @param charset the charset property value. + */ + charset(charset: string): Response; + /** + * sets the HTTP status code + * @param statusCode the HTTP status code (e.g. 200). + */ + code(statusCode: number): Response; + /** + * sets the HTTP status message + * @param httpMessage the HTTP status message (e.g. 'Ok' for status code 200). + */ + message(httpMessage: string): Response; + /** + * sets the HTTP status code to Created (201) and the HTTP 'Location' header + * @param uri an absolute or relative URI used as the 'Location' header value. + */ + created(uri: string): Response; + /** + * sets the string encoding scheme used to serial data into the HTTP payload + * @param encoding the encoding property value (see node Buffer encoding [See docs](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings)). + * * 'ascii' - for 7-bit ASCII data only. This encoding is fast and will strip the high bit if set. + * * 'utf8' - Multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8. + * * 'utf16le' - 2 or 4 bytes, little-endian encoded Unicode characters. Surrogate pairs (U+10000 to U+10FFFF) are supported. + * * 'ucs2' - Alias of 'utf16le'. + * * 'base64' - Base64 encoding. When creating a Buffer from a string, this encoding will also correctly accept "URL and Filename Safe Alphabet" as specified in RFC4648, Section 5. + * * 'latin1' - A way of encoding the Buffer into a one-byte encoded string (as defined by the IANA in RFC1345, page 63, to be the Latin-1 supplement block and C0/C1 control codes). + * * 'binary' - Alias for 'latin1'. + * * 'hex' - Encode each byte as two hexadecimal characters. + */ + encoding(encoding: 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex'): Response; + /** + * sets the representation entity tag + * @param tag the entity tag string without the double-quote. + * @param options options object + * * weak - if true, the tag will be prefixed with the 'W/' weak signifier. Weak tags will fail to match identical tags for the purpose of determining 304 response status. Defaults to false. + * * vary - if true and content encoding is set or applied to the response (e.g 'gzip' or 'deflate'), the encoding name will be automatically added to the tag at transmission time (separated by a '-' character). Ignored when weak is true. Defaults to true. + */ + etag(tag: string, options?: {weak: boolean, vary: boolean}): Response; + /** + * sets an HTTP header + * @param name the header name. + * @param value the header value. + */ + header(name: string, value: string, options?: ResponseHeaderOptionsObject): Response; + /** + * sets the HTTP 'Location' header + * @param uri an absolute or relative URI used as the 'Location' header value. + */ + location(uri: string): Response; + /** + * sets an HTTP redirection response (302) and decorates the response with additional methods listed below, + * @param uri an absolute or relative URI used to redirect the client to another resource. + */ + redirect(uri: string): Response; + /** + * sets the JSON.stringify() replacer argument + * @param method the replacer function or array. Defaults to none. + */ + replacer(method: Json.StringifyReplacer): Response; + /** + * sets the JSON.stringify() space argument + * @param count the number of spaces to indent nested object keys. Defaults to no indentation. + */ + spaces(count: Json.StringifySpace): Response; + /** + * sets an HTTP cookie + * @param name the cookie name. + * @param value the cookie value. If no encoding is defined, must be a string. + * @param options optional configuration. If the state was previously registered with the server using server.state(), the specified keys in options override those same keys in the server definition (but not others). + */ + state(name: string, value: string | Object | any[], options?: ServerStateCookieConfiguationObject): Response; + /** + * sets a string suffix when the response is process via JSON.stringify(). + */ + suffix(suffix: string): Response; + /** + * overrides the default route cache expiration rule for this response instance + * @param msec the time-to-live value in milliseconds. + */ + ttl(msec: number): Response; + /** + * sets the HTTP 'Content-Type' header + * @param mimeType is the mime type. Should only be used to override the built-in default for each response type. + */ + type(mimeType: string): Response; + /** + * clears the HTTP cookie by setting an expired value + * @param name the cookie name. + * @param options optional configuration for expiring cookie. If the state was previously registered with the server using server.state(), the specified keys in options override those same keys in the server definition (but not others). + */ + unstate(name: string, options?: ServerStateCookieConfiguationObject): Response; + /** + * adds the provided header to the list of inputs affected the response generation via the HTTP 'Vary' header + * @param header the HTTP request header name. + */ + vary(header: string): Response; + + /** + * Flow control - hold() + * When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: + * puts the response on hold until response.send() is called. Available only after reply() is called and until response.hold() is invoked once. + * [See docs](https://hapijs.com/api/16.1.1#flow-control) + */ + hold(): Response; + /** + * Flow control - send() + * When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: + * immediately resume the response. Available only after response.hold() is called and until response.send() is invoked once. + * [See docs](https://hapijs.com/api/16.1.1#flow-control) + */ + send(): Response; + + /** + * Mentioned here: "Note that prerequisites do not follow the same rules of the normal reply interface. In all other cases, calling reply() with or without a value will use the result as the response sent back to the client. In a prerequisite method, calling reply() will assign the returned value to the provided assign key. If the returned value is an error, the failAction setting determines the behavior. To force the return value as the response and skip any other prerequisites and the handler, use the reply().takeover() method." + * TODO prepare documentation PR and submit to hapi. + * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) + */ + takeover(): Response; +} + +/** + * Response Object Redirect Methods + * When using the redirect() method, the response object provides these additional methods: + * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) + */ +export interface ResponseRedirect extends Response { + /** + * temporary + * sets the status code to 302 or 307 (based on the rewritable() setting) where: + * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) + * @param isTemporary if false, sets status to permanent. Defaults to true. + */ + temporary(isTemporary: boolean): Response; + /** + * permanent + * sets the status code to 301 or 308 (based on the rewritable() setting) where: + * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) + * @param isPermanent if false, sets status to temporary. Defaults to true. + */ + permanent(isPermanent: boolean): Response; + /** + * rewritable + * sets the status code to 301/302 for rewritable (allows changing the request method from 'POST' to 'GET') or 307/308 for non-rewritable (does not allow changing the request method from 'POST' to 'GET'). Exact code based on the temporary() or permanent() setting. Arguments: + * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) + * @param isRewritable if false, sets to non-rewritable. Defaults to true. + */ + rewritable(isRewritable: boolean): Response; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#response-object) under "response object provides the following methods" > header > options + */ +export interface ResponseHeaderOptionsObject { + /** if true, the value is appended to any existing header value using separator. Defaults to false. */ + append?: boolean; + /** string used as separator when appending to an existing value. Defaults to ','. */ + separator?: string; + /** if false, the header value is not set if an existing value present. Defaults to true. */ + override?: boolean; + /** if false, the header value is not modified if the provided value is already included. Does not apply when append is false or if the name is 'set-cookie'. Defaults to true. */ + duplicate?: boolean; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plugins and register + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Plugins + * Plugins provide a way to organize the application code by splitting the server logic into smaller components. Each plugin can manipulate the server and its connections through the standard server interface, but with the added ability to sandbox certain properties. + * [See docs](https://hapijs.com/api/16.1.1#plugins) + * @param server the server object the plugin is being registered to. + * @param options an options object passed to the plugin during registration. + * @param next a callback method the function must call to return control back to the framework to complete the registration process with signature function(err) + */ +export interface PluginFunction { + (server: Server, options: OptionsPassedToPlugin, next: (err?: Error) => void): void; + /** + * Note attributes is NOT optional but this type is easier to use. + */ + attributes?: PluginAttributes; +} + +/** + * see Plugin + * [See docs](https://hapijs.com/api/16.1.1#plugins) + */ +export interface PluginAttributes { + /** + * required plugin name string. The name is used as a unique key. Published plugins should use the same name as the name field in the 'package.json' file. Names must be unique within each application. + * NOTE: marked as optional as `pkg` can be used instead. + */ + name?: string; + /** optional plugin version. The version is only used informatively to enable other plugins to find out the versions loaded. The version should be the same as the one specified in the plugin's 'package.json' file. */ + version?: string; + /** Alternatively, the name and version can be included via the pkg attribute containing the 'package.json' file for the module which already has the name and version included */ + pkg?: any; + /** if true, allows the plugin to be registered multiple times with the same server. Defaults to false. */ + multiple?: boolean; + /** optional string or array of string indicating a plugin dependency. Same as setting dependencies via server.dependency(). */ + dependencies?: string | string[]; + /** if false, does not allow the plugin to call server APIs that modify the connections such as adding a route or configuring state. This flag allows the plugin to be registered before connections are added and to pass dependency requirements. When set to 'conditional', the mode is based on the presence of selected connections (if the server has connections, it is the same as true, but if no connections are available, it is the same as false). Defaults to true. */ + connections?: boolean | 'conditional'; + /** if true, will only register the plugin once per connection (or once per server for a connectionless plugin). If set, overrides the once option passed to server.register(). Defaults to undefined (registration will be based on the server.register() option once). */ + once?: boolean; +} + +/** + * Plugins State + * Related [See docs](https://hapijs.com/api/16.1.1#serverplugins) + * Related [See docs](https://hapijs.com/api/16.1.1#serverrealm) + */ +export interface PluginsStates { + [pluginName: string]: any; +} + +/** + * once, select, routes - optional plugin-specific registration options as defined see PluginRegistrationOptions + * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) + */ +export interface PluginRegistrationObject extends PluginRegistrationOptions { + /** the plugin registration function. */ + register: PluginFunction; + /** optional options passed to the registration function when called. */ + options?: OptionsPassedToPlugin; +} + +/** + * registration options (different from the options passed to the registration function): + * * once - if true, the registration is skipped for any connection already registered with. Cannot be used with plugin options. If the plugin does not have a connections attribute set to false and the registration selection is empty, registration will be skipped as no connections are available to register once. Defaults to false. + * * routes - modifiers applied to each route added by the plugin: + * * prefix - string added as prefix to any route path (must begin with '/'). If a plugin registers a child plugin the prefix is passed on to the child or is added in front of the child-specific prefix. + * * vhost - virtual host string (or array of strings) applied to every route. The outer-most vhost overrides the any nested configuration. + * * select - a string or array of string labels used to pre-select connections for plugin registration. + * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) + */ +export interface PluginRegistrationOptions { + once?: boolean; + routes?: {prefix?: string, vhost?: string | string[]}; + select?: string | string[]; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JSON + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// This was in a seperate file and perhaps should move to some of the lib typings? +// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/16065#issuecomment-299443673 +// +// json/json-tests.ts +// +// import * as JSON from './index'; +// +// var a: JSON.StringifyReplacer = function(key, value) { +// if (key === "do not include") { +// return undefined; +// } +// return value; +// }; +// + +export namespace Json { + /** + * @see {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter} + */ + export type StringifyReplacer = ((key: string, value: any) => any) | (string | number)[] | undefined; + + /** + * Any value greater than 10 is truncated. + */ + export type StringifySpace = number | string; + + export interface StringifyArguments { + /** the replacer function or array. Defaults to no action. */ + replacer?: StringifyReplacer; + /** number of spaces to indent nested object keys. Defaults to no indentation. */ + space?: StringifySpace; + } +} diff --git a/types/hapi/test/connection/table.ts b/types/hapi/v16/test/connection/table.ts similarity index 94% rename from types/hapi/test/connection/table.ts rename to types/hapi/v16/test/connection/table.ts index 24eaa28ddc..3ead170c90 100644 --- a/types/hapi/test/connection/table.ts +++ b/types/hapi/v16/test/connection/table.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servertablehost -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80, host: 'example.com' }); server.route({ method: 'GET', path: '/example', handler: function (request, reply) { return reply(); } }); diff --git a/types/hapi/test/continuation/errors.ts b/types/hapi/v16/test/continuation/errors.ts similarity index 95% rename from types/hapi/test/continuation/errors.ts rename to types/hapi/v16/test/continuation/errors.ts index 165e5214df..6bce66c58e 100644 --- a/types/hapi/test/continuation/errors.ts +++ b/types/hapi/v16/test/continuation/errors.ts @@ -1,6 +1,6 @@ -import * as Hapi from 'hapi'; -import * as Boom from 'boom'; +import * as Hapi from '../../'; +import * as Boom from '../../../../boom'; // Assignment of a typical function to ContinuationValueFunction is possible const handleError: Hapi.ContinuationValueFunction = (err?: Boom.BoomError | null, value?: any) => { diff --git a/types/hapi/test/getting-started/01-creating-a-server.ts b/types/hapi/v16/test/getting-started/01-creating-a-server.ts similarity index 100% rename from types/hapi/test/getting-started/01-creating-a-server.ts rename to types/hapi/v16/test/getting-started/01-creating-a-server.ts diff --git a/types/hapi/test/getting-started/02-adding-routes.ts b/types/hapi/v16/test/getting-started/02-adding-routes.ts similarity index 100% rename from types/hapi/test/getting-started/02-adding-routes.ts rename to types/hapi/v16/test/getting-started/02-adding-routes.ts diff --git a/types/hapi/test/getting-started/03-serving-static-content.ts b/types/hapi/v16/test/getting-started/03-serving-static-content.ts similarity index 100% rename from types/hapi/test/getting-started/03-serving-static-content.ts rename to types/hapi/v16/test/getting-started/03-serving-static-content.ts diff --git a/types/hapi/test/getting-started/04-using-plugins.ts b/types/hapi/v16/test/getting-started/04-using-plugins.ts similarity index 100% rename from types/hapi/test/getting-started/04-using-plugins.ts rename to types/hapi/v16/test/getting-started/04-using-plugins.ts diff --git a/types/hapi/test/path/catch-all.ts b/types/hapi/v16/test/path/catch-all.ts similarity index 89% rename from types/hapi/test/path/catch-all.ts rename to types/hapi/v16/test/path/catch-all.ts index c9002392b1..e38a67ec96 100644 --- a/types/hapi/test/path/catch-all.ts +++ b/types/hapi/v16/test/path/catch-all.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#catch-all-route -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/path/parameters.ts b/types/hapi/v16/test/path/parameters.ts similarity index 95% rename from types/hapi/test/path/parameters.ts rename to types/hapi/v16/test/path/parameters.ts index 62bbfcc638..6bbba522db 100644 --- a/types/hapi/test/path/parameters.ts +++ b/types/hapi/v16/test/path/parameters.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#path-parameters -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/plugins/options.ts b/types/hapi/v16/test/plugins/options.ts similarity index 95% rename from types/hapi/test/plugins/options.ts rename to types/hapi/v16/test/plugins/options.ts index cd192f1996..7f6ad6c13c 100644 --- a/types/hapi/test/plugins/options.ts +++ b/types/hapi/v16/test/plugins/options.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverinfo -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; // added in addition to code from docs interface PluginOptions { diff --git a/types/hapi/test/reply/continue.ts b/types/hapi/v16/test/reply/continue.ts similarity index 91% rename from types/hapi/test/reply/continue.ts rename to types/hapi/v16/test/reply/continue.ts index de6994fbd0..5f23cb039a 100644 --- a/types/hapi/test/reply/continue.ts +++ b/types/hapi/v16/test/reply/continue.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#replycontinueresult -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/reply/entity.ts b/types/hapi/v16/test/reply/entity.ts similarity index 93% rename from types/hapi/test/reply/entity.ts rename to types/hapi/v16/test/reply/entity.ts index cfcce6de25..5cb187fa1e 100644 --- a/types/hapi/test/reply/entity.ts +++ b/types/hapi/v16/test/reply/entity.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#replyentityoptions -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/reply/redirect.ts b/types/hapi/v16/test/reply/redirect.ts similarity index 84% rename from types/hapi/test/reply/redirect.ts rename to types/hapi/v16/test/reply/redirect.ts index 5baf892ac1..934092868b 100644 --- a/types/hapi/test/reply/redirect.ts +++ b/types/hapi/v16/test/reply/redirect.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#replyredirecturi -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const handler: Hapi.RouteHandler = function (request, reply) { return reply.redirect('http://example.com'); diff --git a/types/hapi/test/reply/reply.ts b/types/hapi/v16/test/reply/reply.ts similarity index 92% rename from types/hapi/test/reply/reply.ts rename to types/hapi/v16/test/reply/reply.ts index 31f3bff9b4..bf92621986 100644 --- a/types/hapi/test/reply/reply.ts +++ b/types/hapi/v16/test/reply/reply.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#replyerr-result -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; // verbose notation @@ -19,4 +19,4 @@ const handler2: Hapi.RouteHandler = function (request, reply) { return reply('success') .type('text/plain') .header('X-Custom', 'some-value'); -}; \ No newline at end of file +}; diff --git a/types/hapi/test/reply/state_cookie.ts b/types/hapi/v16/test/reply/state_cookie.ts similarity index 95% rename from types/hapi/test/reply/state_cookie.ts rename to types/hapi/v16/test/reply/state_cookie.ts index bf94219311..8a0be7da34 100644 --- a/types/hapi/test/reply/state_cookie.ts +++ b/types/hapi/v16/test/reply/state_cookie.ts @@ -1,7 +1,7 @@ // from https://hapijs.com/tutorials/cookies?lang=en_US -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/request/event-types.ts b/types/hapi/v16/test/request/event-types.ts new file mode 100644 index 0000000000..d9ee4dab33 --- /dev/null +++ b/types/hapi/v16/test/request/event-types.ts @@ -0,0 +1,30 @@ + +// From https://hapijs.com/api/16.1.1#requestsetmethodmethod + +import * as Hapi from '../../'; +const Crypto = require('crypto'); +const server = new Hapi.Server(); +server.connection({ port: 80 }); + +const onRequest: Hapi.ServerExtRequestHandler = function (request, reply) { + + const hash = Crypto.createHash('sha1'); + request.on('peek', (chunk) => { + + hash.update(chunk); + }); + + request.once('finish', () => { + + console.log(hash.digest('hex')); + }); + + request.once('disconnect', () => { + + console.error('request aborted'); + }); + + return reply.continue(); +}; + +server.ext('onRequest', onRequest); diff --git a/types/hapi/test/request/generate-response.ts b/types/hapi/v16/test/request/generate-response.ts similarity index 93% rename from types/hapi/test/request/generate-response.ts rename to types/hapi/v16/test/request/generate-response.ts index c30c3a7be5..f731961a68 100644 --- a/types/hapi/test/request/generate-response.ts +++ b/types/hapi/v16/test/request/generate-response.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#requestgenerateresponsesource-options -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; // Added in addition to code from docs function promiseMethod() { diff --git a/types/hapi/v16/test/request/get-log.ts b/types/hapi/v16/test/request/get-log.ts new file mode 100644 index 0000000000..53568ba734 --- /dev/null +++ b/types/hapi/v16/test/request/get-log.ts @@ -0,0 +1,12 @@ + +// From https://hapijs.com/api/16.1.1#requestgetlogtags-internal + +import * as Hapi from '../../'; + +var request: Hapi.Request = {}; + +request.getLog(); +request.getLog('error'); +request.getLog(['error', 'auth']); +request.getLog(['error'], true); +request.getLog(false); diff --git a/types/hapi/test/request/log.ts b/types/hapi/v16/test/request/log.ts similarity index 93% rename from types/hapi/test/request/log.ts rename to types/hapi/v16/test/request/log.ts index 1c2da1f3b0..f9b044eafc 100644 --- a/types/hapi/test/request/log.ts +++ b/types/hapi/v16/test/request/log.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#requestlogtags-data-timestamp -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80, routes: { log: true, security: false } }); diff --git a/types/hapi/v16/test/request/query.ts b/types/hapi/v16/test/request/query.ts new file mode 100644 index 0000000000..1aa801b69d --- /dev/null +++ b/types/hapi/v16/test/request/query.ts @@ -0,0 +1,14 @@ +// Added test in addition to docs, for request.query + +import * as Hapi from '../../'; + +interface GetThingQuery { + name: string; +} + +const handler: Hapi.RouteHandler = function (request, reply) { + + const query = request.query as GetThingQuery; + + return reply(`You asked for ${query.name}`); +}; diff --git a/types/hapi/test/request/set-method.ts b/types/hapi/v16/test/request/set-method.ts similarity index 91% rename from types/hapi/test/request/set-method.ts rename to types/hapi/v16/test/request/set-method.ts index 7269e6255f..aa78eeaecf 100644 --- a/types/hapi/test/request/set-method.ts +++ b/types/hapi/v16/test/request/set-method.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#requestsetmethodmethod -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/request/set-url.ts b/types/hapi/v16/test/request/set-url.ts similarity index 90% rename from types/hapi/test/request/set-url.ts rename to types/hapi/v16/test/request/set-url.ts index 4add3c5a17..1c3a0a047b 100644 --- a/types/hapi/test/request/set-url.ts +++ b/types/hapi/v16/test/request/set-url.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#requestseturlurl-striptrailingslash -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); @@ -17,7 +17,7 @@ server.ext('onRequest', onRequest); // Example 2 const Url = require('url'); -const Qs = require('qs'); +const Qs = require('../../../../qs'); onRequest = function (request, reply) { diff --git a/types/hapi/test/request/tail.ts b/types/hapi/v16/test/request/tail.ts similarity index 94% rename from types/hapi/test/request/tail.ts rename to types/hapi/v16/test/request/tail.ts index 9c68ccb8f2..426c0cd835 100644 --- a/types/hapi/test/request/tail.ts +++ b/types/hapi/v16/test/request/tail.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#requestsetmethodmethod -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/response/error-representation.ts b/types/hapi/v16/test/response/error-representation.ts similarity index 84% rename from types/hapi/test/response/error-representation.ts rename to types/hapi/v16/test/response/error-representation.ts index f0fb62eb30..7eacfdfaf3 100644 --- a/types/hapi/test/response/error-representation.ts +++ b/types/hapi/v16/test/response/error-representation.ts @@ -1,13 +1,13 @@ // From https://hapijs.com/api/16.1.1#error-transformation -import * as Hapi from 'hapi'; -import Vision from 'vision'; +import * as Hapi from '../../'; +import Vision from '../../../../vision'; const server = new Hapi.Server(); server.register(Vision, {}, (err) => { server.views({ engines: { - html: require('handlebars') + html: require('../../../../handlebars') } }); }); diff --git a/types/hapi/v16/test/response/error.ts b/types/hapi/v16/test/response/error.ts new file mode 100644 index 0000000000..f426de66e0 --- /dev/null +++ b/types/hapi/v16/test/response/error.ts @@ -0,0 +1,25 @@ + +// From https://hapijs.com/api/16.1.1#error-response + +import * as Hapi from '../../'; +const Boom = require('../../../../boom'); + +const server = new Hapi.Server(); + +server.route({ + method: 'GET', + path: '/badRequest', + handler: function (request, reply) { + + return reply(Boom.badRequest('Unsupported parameter')); + } +}); + +server.route({ + method: 'GET', + path: '/internal', + handler: function (request, reply) { + + return reply(new Error('unexpect error')); + } +}); diff --git a/types/hapi/test/response/events.ts b/types/hapi/v16/test/response/events.ts similarity index 95% rename from types/hapi/test/response/events.ts rename to types/hapi/v16/test/response/events.ts index 2d1658087b..07d4e0a65b 100644 --- a/types/hapi/test/response/events.ts +++ b/types/hapi/v16/test/response/events.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#response-events -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const Crypto = require('crypto'); const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/response/flow-control.ts b/types/hapi/v16/test/response/flow-control.ts similarity index 88% rename from types/hapi/test/response/flow-control.ts rename to types/hapi/v16/test/response/flow-control.ts index bc18a36aff..321d198825 100644 --- a/types/hapi/test/response/flow-control.ts +++ b/types/hapi/v16/test/response/flow-control.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#flow-control -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const handler = function (request: Hapi.Request, reply: Hapi.ReplyWithContinue) { diff --git a/types/hapi/test/route/additional-options.ts b/types/hapi/v16/test/route/additional-options.ts similarity index 98% rename from types/hapi/test/route/additional-options.ts rename to types/hapi/v16/test/route/additional-options.ts index 189dc488de..ccbb36af15 100644 --- a/types/hapi/test/route/additional-options.ts +++ b/types/hapi/v16/test/route/additional-options.ts @@ -1,6 +1,6 @@ 'use strict'; -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; var authConfig: Hapi.RouteAdditionalConfigurationOptions = { app: {}, diff --git a/types/hapi/test/route/auth.ts b/types/hapi/v16/test/route/auth.ts similarity index 94% rename from types/hapi/test/route/auth.ts rename to types/hapi/v16/test/route/auth.ts index e5239322da..e8d41cf47d 100644 --- a/types/hapi/test/route/auth.ts +++ b/types/hapi/v16/test/route/auth.ts @@ -1,6 +1,6 @@ 'use strict'; -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; var routeMoreConfig: Hapi.RouteAdditionalConfigurationOptions = { auth: false, diff --git a/types/hapi/v16/test/route/config.ts b/types/hapi/v16/test/route/config.ts new file mode 100644 index 0000000000..680ee4c043 --- /dev/null +++ b/types/hapi/v16/test/route/config.ts @@ -0,0 +1,46 @@ +'use strict'; + +import * as Hapi from '../../'; + +// different methods +var routeConfig: Hapi.RouteConfiguration = { + path: '/signin', + method: 'PUT', + vhost: 'site.coms', +}; +var routeConfig: Hapi.RouteConfiguration = { + path: '/signin', + method: '*' +}; +var routeConfig: Hapi.RouteConfiguration = { + path: '/signin', + method: ['OPTIONS', '*'] +}; + +// different handlers +var routeConfig: Hapi.RouteConfiguration = { + path: '/signin', + method: 'PUT', + handler: 'some registered handler' +}; +var routeConfig: Hapi.RouteConfiguration = { + path: '/signin', + method: 'PUT', + handler: function (request, reply) { + return reply('ok'); + } +}; + +const server = new Hapi.Server(); +server.route(routeConfig); + +// Handler in config +const user: Hapi.RouteAdditionalConfigurationOptions = { + cache: { expiresIn: 5000 }, + handler: function (request, reply) { + + return reply({ name: 'John' }); + } +}; + +server.route({method: 'GET', path: '/user', config: user }); diff --git a/types/hapi/v16/test/route/handler.ts b/types/hapi/v16/test/route/handler.ts new file mode 100644 index 0000000000..401bf35eab --- /dev/null +++ b/types/hapi/v16/test/route/handler.ts @@ -0,0 +1,10 @@ +'use strict'; + +import * as Hapi from '../../'; + +var handler: Hapi.RouteHandler = function(request, reply) { + reply('success'); +} +var strictHandler: Hapi.RouteHandler = function(request, reply) { + reply(123); +} diff --git a/types/hapi/test/route/plugins.ts b/types/hapi/v16/test/route/plugins.ts similarity index 92% rename from types/hapi/test/route/plugins.ts rename to types/hapi/v16/test/route/plugins.ts index 2449fc84c0..ba7abdb777 100644 --- a/types/hapi/test/route/plugins.ts +++ b/types/hapi/v16/test/route/plugins.ts @@ -1,9 +1,9 @@ // Added in addition to code from https://hapijs.com/api/16.1.1#route-options > plugins -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; // In the plugin code -declare module 'hapi' { +declare module '../../' { interface PluginSpecificConfiguration { coolPlugin: { optionA: string; diff --git a/types/hapi/test/route/prerequisites.ts b/types/hapi/v16/test/route/prerequisites.ts similarity index 97% rename from types/hapi/test/route/prerequisites.ts rename to types/hapi/v16/test/route/prerequisites.ts index c4ca7650fa..15a16af2c0 100644 --- a/types/hapi/test/route/prerequisites.ts +++ b/types/hapi/v16/test/route/prerequisites.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#route-prerequisites -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/route/public-interface.ts b/types/hapi/v16/test/route/public-interface.ts similarity index 93% rename from types/hapi/test/route/public-interface.ts rename to types/hapi/v16/test/route/public-interface.ts index e61fb8275f..f3878cea48 100644 --- a/types/hapi/test/route/public-interface.ts +++ b/types/hapi/v16/test/route/public-interface.ts @@ -1,6 +1,6 @@ 'use strict'; -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; var route = {}; diff --git a/types/hapi/test/route/validate.ts b/types/hapi/v16/test/route/validate.ts similarity index 96% rename from types/hapi/test/route/validate.ts rename to types/hapi/v16/test/route/validate.ts index cb5c5527ee..06fefcc62e 100644 --- a/types/hapi/test/route/validate.ts +++ b/types/hapi/v16/test/route/validate.ts @@ -1,8 +1,8 @@ // Added from: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/16065#issuecomment-302216131 -import * as Hapi from 'hapi'; -import * as Joi from 'joi'; +import * as Hapi from '../../'; +import * as Joi from '../../../../joi'; const validate: Hapi.RouteValidationConfigurationObject = { headers: true, diff --git a/types/hapi/test/server/app.ts b/types/hapi/v16/test/server/app.ts similarity index 87% rename from types/hapi/test/server/app.ts rename to types/hapi/v16/test/server/app.ts index dac8921c20..7ed57fe6e8 100644 --- a/types/hapi/test/server/app.ts +++ b/types/hapi/v16/test/server/app.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverapp -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; var server = new Hapi.Server(); server.app.key = 'value'; diff --git a/types/hapi/test/server/auth.ts b/types/hapi/v16/test/server/auth.ts similarity index 96% rename from types/hapi/test/server/auth.ts rename to types/hapi/v16/test/server/auth.ts index 3f28732d42..c699a63c1b 100644 --- a/types/hapi/test/server/auth.ts +++ b/types/hapi/v16/test/server/auth.ts @@ -1,8 +1,8 @@ // From https://hapijs.com/api/16.1.1#serverauthapi -import * as Hapi from 'hapi'; -import * as Boom from 'boom'; +import * as Hapi from '../../'; +import * as Boom from '../../../../boom'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/bind.ts b/types/hapi/v16/test/server/bind.ts similarity index 93% rename from types/hapi/test/server/bind.ts rename to types/hapi/v16/test/server/bind.ts index 2741e16c82..c8e0ba0016 100644 --- a/types/hapi/test/server/bind.ts +++ b/types/hapi/v16/test/server/bind.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverbindcontext -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; interface HandlerThis { message: string; diff --git a/types/hapi/test/server/cache.ts b/types/hapi/v16/test/server/cache.ts similarity index 96% rename from types/hapi/test/server/cache.ts rename to types/hapi/v16/test/server/cache.ts index 4cb9eaa4b7..18d7cbbd3a 100644 --- a/types/hapi/test/server/cache.ts +++ b/types/hapi/v16/test/server/cache.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servercacheoptions -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/connection-options.ts b/types/hapi/v16/test/server/connection-options.ts similarity index 96% rename from types/hapi/test/server/connection-options.ts rename to types/hapi/v16/test/server/connection-options.ts index 3a526307db..e4b5582598 100644 --- a/types/hapi/test/server/connection-options.ts +++ b/types/hapi/v16/test/server/connection-options.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverconnectionoptions -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); const web = server.connection({ port: 8000, host: 'example.com', labels: ['web'] }); diff --git a/types/hapi/test/server/connections.ts b/types/hapi/v16/test/server/connections.ts similarity index 89% rename from types/hapi/test/server/connections.ts rename to types/hapi/v16/test/server/connections.ts index fb2f9f303e..0674c3b72f 100644 --- a/types/hapi/test/server/connections.ts +++ b/types/hapi/v16/test/server/connections.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverconnections -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; var server = new Hapi.Server(); server.connection({ port: 80, labels: 'a' }); server.connection({ port: 8080, labels: 'b' }); diff --git a/types/hapi/test/server/decoder.ts b/types/hapi/v16/test/server/decoder.ts similarity index 90% rename from types/hapi/test/server/decoder.ts rename to types/hapi/v16/test/server/decoder.ts index edd52485ea..7a9eadd1e6 100644 --- a/types/hapi/test/server/decoder.ts +++ b/types/hapi/v16/test/server/decoder.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; import * as Zlib from 'zlib'; const server = new Hapi.Server(); server.connection({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } }); diff --git a/types/hapi/test/server/decorate.ts b/types/hapi/v16/test/server/decorate.ts similarity index 92% rename from types/hapi/test/server/decorate.ts rename to types/hapi/v16/test/server/decorate.ts index 540e29c951..d946f6132e 100644 --- a/types/hapi/test/server/decorate.ts +++ b/types/hapi/v16/test/server/decorate.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverdecoratetype-property-method-options -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); @@ -12,7 +12,7 @@ const success = function (this: Hapi.ReplyNoContinue) { server.decorate('reply', 'success', success); -declare module 'hapi' { +declare module '../../' { interface Base_Reply { success: () => Response; } @@ -36,7 +36,7 @@ server.decorate('request', 'some_request_method', (request) => { } }, {apply: true}); -declare module 'hapi' { +declare module '../../' { interface Request { some_request_method(): void; } @@ -59,7 +59,7 @@ server.decorate('server', 'some_server_method', (server: Hapi.Server) => { } }); -declare module 'hapi' { +declare module '../../' { interface Server { some_server_method(arg1: number): string; } diff --git a/types/hapi/test/server/dependency.ts b/types/hapi/v16/test/server/dependency.ts similarity index 93% rename from types/hapi/test/server/dependency.ts rename to types/hapi/v16/test/server/dependency.ts index 1d63397cf2..175b3242b9 100644 --- a/types/hapi/test/server/dependency.ts +++ b/types/hapi/v16/test/server/dependency.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverdependencydependencies-after -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const after: Hapi.AfterDependencyLoadCallback = function (server, next) { diff --git a/types/hapi/test/server/emit.ts b/types/hapi/v16/test/server/emit.ts similarity index 90% rename from types/hapi/test/server/emit.ts rename to types/hapi/v16/test/server/emit.ts index d248f7d4ab..0f1f37de2d 100644 --- a/types/hapi/test/server/emit.ts +++ b/types/hapi/v16/test/server/emit.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serveremitcriteria-data-callback -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/encoder.ts b/types/hapi/v16/test/server/encoder.ts similarity index 90% rename from types/hapi/test/server/encoder.ts rename to types/hapi/v16/test/server/encoder.ts index f35102b776..cacc5f2c8b 100644 --- a/types/hapi/test/server/encoder.ts +++ b/types/hapi/v16/test/server/encoder.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverencoderencoding-encoder -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; import * as Zlib from 'zlib'; const server = new Hapi.Server(); server.connection({ port: 80, routes: { compression: { special: { chunkSize: 16 * 1024 } } } }); diff --git a/types/hapi/test/server/event.ts b/types/hapi/v16/test/server/event.ts similarity index 90% rename from types/hapi/test/server/event.ts rename to types/hapi/v16/test/server/event.ts index f0c2215f12..cbe7128de3 100644 --- a/types/hapi/test/server/event.ts +++ b/types/hapi/v16/test/server/event.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servereventevents -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/expose.ts b/types/hapi/v16/test/server/expose.ts similarity index 92% rename from types/hapi/test/server/expose.ts rename to types/hapi/v16/test/server/expose.ts index effbc1ae49..abaade677c 100644 --- a/types/hapi/test/server/expose.ts +++ b/types/hapi/v16/test/server/expose.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverexposekey-value -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; var register: Hapi.PluginFunction<{}> = function (server, options, next) { server.expose('util', function () { console.log('something'); }); diff --git a/types/hapi/test/server/ext.ts b/types/hapi/v16/test/server/ext.ts similarity index 96% rename from types/hapi/test/server/ext.ts rename to types/hapi/v16/test/server/ext.ts index 500ac1d4af..318fe3fe0b 100644 --- a/types/hapi/test/server/ext.ts +++ b/types/hapi/v16/test/server/ext.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverextevents -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/handler.ts b/types/hapi/v16/test/server/handler.ts similarity index 94% rename from types/hapi/test/server/handler.ts rename to types/hapi/v16/test/server/handler.ts index 713fe7f114..20fb003ce4 100644 --- a/types/hapi/test/server/handler.ts +++ b/types/hapi/v16/test/server/handler.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverhandlername-method -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ host: 'localhost', port: 8000 }); @@ -20,7 +20,7 @@ interface TestPluginConfig { msg: string; } -declare module 'hapi' { +declare module '../../' { interface RouteHandlerPlugins { test?: TestPluginConfig; } diff --git a/types/hapi/test/server/info.ts b/types/hapi/v16/test/server/info.ts similarity index 92% rename from types/hapi/test/server/info.ts rename to types/hapi/v16/test/server/info.ts index eaf1b39747..aa0bc7014d 100644 --- a/types/hapi/test/server/info.ts +++ b/types/hapi/v16/test/server/info.ts @@ -2,7 +2,7 @@ // From https://hapijs.com/api/16.1.1#serverinfo import assert = require('assert'); -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); var options: Hapi.ServerConnectionOptions = { port: 80 }; server.connection(options); diff --git a/types/hapi/test/server/initialize.ts b/types/hapi/v16/test/server/initialize.ts similarity index 72% rename from types/hapi/test/server/initialize.ts rename to types/hapi/v16/test/server/initialize.ts index 7ef4b51527..f7a1482fac 100644 --- a/types/hapi/test/server/initialize.ts +++ b/types/hapi/v16/test/server/initialize.ts @@ -1,8 +1,8 @@ // From https://hapijs.com/api/16.1.1#serverinitializecallback -import * as Hapi from 'hapi'; -const Hoek = require('hoek'); +import * as Hapi from '../../'; +const Hoek = require('../../../../hoek'); const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/inject.ts b/types/hapi/v16/test/server/inject.ts similarity index 93% rename from types/hapi/test/server/inject.ts rename to types/hapi/v16/test/server/inject.ts index 7010faa3dc..a9fc0bdf5e 100644 --- a/types/hapi/test/server/inject.ts +++ b/types/hapi/v16/test/server/inject.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverinjectoptions-callback -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/listener.ts b/types/hapi/v16/test/server/listener.ts similarity index 95% rename from types/hapi/test/server/listener.ts rename to types/hapi/v16/test/server/listener.ts index d7bb6fc5ea..85ddb18bc6 100644 --- a/types/hapi/test/server/listener.ts +++ b/types/hapi/v16/test/server/listener.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverlistener -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; import SocketIO = require('socket.io'); const server = new Hapi.Server(); diff --git a/types/hapi/test/server/load.ts b/types/hapi/v16/test/server/load.ts similarity index 82% rename from types/hapi/test/server/load.ts rename to types/hapi/v16/test/server/load.ts index ee204c864f..7ecb25fce7 100644 --- a/types/hapi/test/server/load.ts +++ b/types/hapi/v16/test/server/load.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverload -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server({ load: { sampleInterval: 1000 } }); var d: number = server.load.rss; diff --git a/types/hapi/test/server/log.ts b/types/hapi/v16/test/server/log.ts similarity index 89% rename from types/hapi/test/server/log.ts rename to types/hapi/v16/test/server/log.ts index 4507358d60..1a89b2149b 100644 --- a/types/hapi/test/server/log.ts +++ b/types/hapi/v16/test/server/log.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverlogtags-data-timestamp -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/lookup.ts b/types/hapi/v16/test/server/lookup.ts similarity index 91% rename from types/hapi/test/server/lookup.ts rename to types/hapi/v16/test/server/lookup.ts index 89ce852700..2d3729b210 100644 --- a/types/hapi/test/server/lookup.ts +++ b/types/hapi/v16/test/server/lookup.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverlookupid -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection(); server.route({ diff --git a/types/hapi/test/server/match.ts b/types/hapi/v16/test/server/match.ts similarity index 91% rename from types/hapi/test/server/match.ts rename to types/hapi/v16/test/server/match.ts index f322a31494..f446dd0e7e 100644 --- a/types/hapi/test/server/match.ts +++ b/types/hapi/v16/test/server/match.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servermatchmethod-path-host -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection(); server.route({ diff --git a/types/hapi/test/server/method.ts b/types/hapi/v16/test/server/method.ts similarity index 98% rename from types/hapi/test/server/method.ts rename to types/hapi/v16/test/server/method.ts index e1cc2ce487..9e3efbf7c7 100644 --- a/types/hapi/test/server/method.ts +++ b/types/hapi/v16/test/server/method.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servermethodname-method-options -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/methods.ts b/types/hapi/v16/test/server/methods.ts similarity index 91% rename from types/hapi/test/server/methods.ts rename to types/hapi/v16/test/server/methods.ts index 1e2060c3e8..0595d522de 100644 --- a/types/hapi/test/server/methods.ts +++ b/types/hapi/v16/test/server/methods.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servermethods -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); const add = function (a: number, b: number, next: (err: Error | null, result: number) => void) { diff --git a/types/hapi/test/server/mime.ts b/types/hapi/v16/test/server/mime.ts similarity index 94% rename from types/hapi/test/server/mime.ts rename to types/hapi/v16/test/server/mime.ts index e2dd25529b..a97af5de7a 100644 --- a/types/hapi/test/server/mime.ts +++ b/types/hapi/v16/test/server/mime.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servermime -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const options: Hapi.ServerOptions = { mime: { diff --git a/types/hapi/test/server/new.ts b/types/hapi/v16/test/server/new.ts similarity index 96% rename from types/hapi/test/server/new.ts rename to types/hapi/v16/test/server/new.ts index 95f1ce9006..59f0a8f189 100644 --- a/types/hapi/test/server/new.ts +++ b/types/hapi/v16/test/server/new.ts @@ -1,6 +1,6 @@ 'use strict'; -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; new Hapi.Server(); new Hapi.Server({ @@ -45,7 +45,7 @@ new Hapi.Server({ }); //+ Code added in addition to docs -declare module 'hapi' { +declare module '../../' { interface PluginSpecificConfiguration { // Set this to non optional if plugin config is non optional 'some-plugin-name'?: {options: string;}; diff --git a/types/hapi/test/server/on.ts b/types/hapi/v16/test/server/on.ts similarity index 96% rename from types/hapi/test/server/on.ts rename to types/hapi/v16/test/server/on.ts index 08802fda96..301cc0b423 100644 --- a/types/hapi/test/server/on.ts +++ b/types/hapi/v16/test/server/on.ts @@ -2,7 +2,7 @@ // From https://hapijs.com/api/16.1.1#serveroncriteria-listener // From https://hapijs.com/api/16.1.1#server-events -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/once.ts b/types/hapi/v16/test/server/once.ts similarity index 91% rename from types/hapi/test/server/once.ts rename to types/hapi/v16/test/server/once.ts index 55fdb08ec2..59465a41ec 100644 --- a/types/hapi/test/server/once.ts +++ b/types/hapi/v16/test/server/once.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serveroncecriteria-listener -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/path.ts b/types/hapi/v16/test/server/path.ts similarity index 91% rename from types/hapi/test/server/path.ts rename to types/hapi/v16/test/server/path.ts index 20479a795f..cdbf8a14a9 100644 --- a/types/hapi/test/server/path.ts +++ b/types/hapi/v16/test/server/path.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverpathrelativeto -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; var register: Hapi.PluginFunction<{}> = function (server, options, next) { diff --git a/types/hapi/test/server/plugins.ts b/types/hapi/v16/test/server/plugins.ts similarity index 90% rename from types/hapi/test/server/plugins.ts rename to types/hapi/v16/test/server/plugins.ts index 2ce13ffb2f..02488a1d5a 100644 --- a/types/hapi/test/server/plugins.ts +++ b/types/hapi/v16/test/server/plugins.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverplugins -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; var registerFunction: Hapi.PluginFunction<{}> = function(server, options, next) { diff --git a/types/hapi/test/server/realm.ts b/types/hapi/v16/test/server/realm.ts similarity index 86% rename from types/hapi/test/server/realm.ts rename to types/hapi/v16/test/server/realm.ts index 31f764b7ef..4a2eceffd0 100644 --- a/types/hapi/test/server/realm.ts +++ b/types/hapi/v16/test/server/realm.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverrealm -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; var registerFunction: Hapi.PluginFunction<{}> = function(server, options, next) { diff --git a/types/hapi/test/server/register.ts b/types/hapi/v16/test/server/register.ts similarity index 90% rename from types/hapi/test/server/register.ts rename to types/hapi/v16/test/server/register.ts index c04e0b16bc..1d0ab5a2e7 100644 --- a/types/hapi/test/server/register.ts +++ b/types/hapi/v16/test/server/register.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); diff --git a/types/hapi/test/server/route.ts b/types/hapi/v16/test/server/route.ts similarity index 93% rename from types/hapi/test/server/route.ts rename to types/hapi/v16/test/server/route.ts index 0402fd3e89..0fa9fd8cc8 100644 --- a/types/hapi/test/server/route.ts +++ b/types/hapi/v16/test/server/route.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverrouteoptions -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/select.ts b/types/hapi/v16/test/server/select.ts similarity index 91% rename from types/hapi/test/server/select.ts rename to types/hapi/v16/test/server/select.ts index 8a25f45abd..03af599fcc 100644 --- a/types/hapi/test/server/select.ts +++ b/types/hapi/v16/test/server/select.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverselectlabels -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80, labels: ['a', 'b'] }); server.connection({ port: 8080, labels: ['a', 'c'] }); diff --git a/types/hapi/test/server/settings.ts b/types/hapi/v16/test/server/settings.ts similarity index 84% rename from types/hapi/test/server/settings.ts rename to types/hapi/v16/test/server/settings.ts index c2ec9ce3ed..f250c8e8fd 100644 --- a/types/hapi/test/server/settings.ts +++ b/types/hapi/v16/test/server/settings.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serversettings -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server({ app: { key: 'value' diff --git a/types/hapi/test/server/start.ts b/types/hapi/v16/test/server/start.ts similarity index 76% rename from types/hapi/test/server/start.ts rename to types/hapi/v16/test/server/start.ts index a15bb79740..a9408a57aa 100644 --- a/types/hapi/test/server/start.ts +++ b/types/hapi/v16/test/server/start.ts @@ -1,8 +1,8 @@ // From https://hapijs.com/api/16.1.1#serverstartcallback -import * as Hapi from 'hapi'; -import * as Hoek from 'hoek'; +import * as Hapi from '../../'; +import * as Hoek from '../../../../hoek'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/state.ts b/types/hapi/v16/test/server/state.ts similarity index 95% rename from types/hapi/test/server/state.ts rename to types/hapi/v16/test/server/state.ts index 2035343a17..19c10cfae3 100644 --- a/types/hapi/test/server/state.ts +++ b/types/hapi/v16/test/server/state.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverstatename-options -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/stop.ts b/types/hapi/v16/test/server/stop.ts similarity index 87% rename from types/hapi/test/server/stop.ts rename to types/hapi/v16/test/server/stop.ts index ddfd07aa8f..ca14a70dfa 100644 --- a/types/hapi/test/server/stop.ts +++ b/types/hapi/v16/test/server/stop.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverstopoptions-callback -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/server/table.ts b/types/hapi/v16/test/server/table.ts similarity index 89% rename from types/hapi/test/server/table.ts rename to types/hapi/v16/test/server/table.ts index abe0707c76..c1410f95db 100644 --- a/types/hapi/test/server/table.ts +++ b/types/hapi/v16/test/server/table.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servertablehost -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.connection({ port: 80, host: 'example.com' }); server.route({ method: 'GET', path: '/example', handler: function (request, reply) { return reply(); } }); diff --git a/types/hapi/test/server/version.ts b/types/hapi/v16/test/server/version.ts similarity index 77% rename from types/hapi/test/server/version.ts rename to types/hapi/v16/test/server/version.ts index 064e87e3cd..2ee1f57841 100644 --- a/types/hapi/test/server/version.ts +++ b/types/hapi/v16/test/server/version.ts @@ -1,6 +1,6 @@ // From http://hapijs.com/api#serversettings -import * as Hapi from 'hapi'; +import * as Hapi from '../../'; const server = new Hapi.Server(); server.version === '8.0.0' diff --git a/types/hapi/v16/tsconfig.json b/types/hapi/v16/tsconfig.json new file mode 100644 index 0000000000..f77f7d4abe --- /dev/null +++ b/types/hapi/v16/tsconfig.json @@ -0,0 +1,102 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "hapi": [ + "hapi/v16" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "test/connection/table.ts", + "test/continuation/errors.ts", + "test/getting-started/01-creating-a-server.ts", + "test/getting-started/02-adding-routes.ts", + "test/getting-started/03-serving-static-content.ts", + "test/getting-started/04-using-plugins.ts", + "test/path/catch-all.ts", + "test/path/parameters.ts", + "test/plugins/options.ts", + "test/reply/continue.ts", + "test/reply/entity.ts", + "test/reply/redirect.ts", + "test/reply/reply.ts", + "test/reply/state_cookie.ts", + "test/request/event-types.ts", + "test/request/generate-response.ts", + "test/request/get-log.ts", + "test/request/log.ts", + "test/request/query.ts", + "test/request/set-method.ts", + "test/request/set-url.ts", + "test/request/tail.ts", + "test/response/error-representation.ts", + "test/response/error.ts", + "test/response/events.ts", + "test/response/flow-control.ts", + "test/route/additional-options.ts", + "test/route/auth.ts", + "test/route/config.ts", + "test/route/handler.ts", + "test/route/plugins.ts", + "test/route/prerequisites.ts", + "test/route/public-interface.ts", + "test/route/validate.ts", + "test/server/app.ts", + "test/server/auth.ts", + "test/server/bind.ts", + "test/server/cache.ts", + "test/server/connection-options.ts", + "test/server/connections.ts", + "test/server/decoder.ts", + "test/server/decorate.ts", + "test/server/dependency.ts", + "test/server/emit.ts", + "test/server/encoder.ts", + "test/server/event.ts", + "test/server/expose.ts", + "test/server/ext.ts", + "test/server/handler.ts", + "test/server/info.ts", + "test/server/initialize.ts", + "test/server/inject.ts", + "test/server/listener.ts", + "test/server/load.ts", + "test/server/log.ts", + "test/server/lookup.ts", + "test/server/match.ts", + "test/server/method.ts", + "test/server/methods.ts", + "test/server/mime.ts", + "test/server/new.ts", + "test/server/on.ts", + "test/server/once.ts", + "test/server/path.ts", + "test/server/plugins.ts", + "test/server/realm.ts", + "test/server/register.ts", + "test/server/route.ts", + "test/server/select.ts", + "test/server/settings.ts", + "test/server/start.ts", + "test/server/state.ts", + "test/server/stop.ts", + "test/server/table.ts", + "test/server/version.ts" + ] +} diff --git a/types/hapi/v17/tslint.json b/types/hapi/v16/tslint.json similarity index 100% rename from types/hapi/v17/tslint.json rename to types/hapi/v16/tslint.json From 3e29b6e832466a72e5fc91a34ca405294e9acfa8 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Wed, 13 Dec 2017 22:32:26 -0300 Subject: [PATCH 143/298] Move v17 definitions and tests to "types/hapi" root folder and delete v17 temp folder. --- .../definitions/plugin/plugin-registered.d.ts | 0 .../{v17 => }/definitions/plugin/plugin.d.ts | 0 .../definitions/request/request-auth.d.ts | 0 .../definitions/request/request-events.d.ts | 0 .../definitions/request/request-info.d.ts | 0 .../definitions/request/request-route.d.ts | 0 .../definitions/request/request.d.ts | 0 .../definitions/response/response-events.d.ts | 0 .../definitions/response/response-object.d.ts | 0 .../response/response-settings.d.ts | 0 .../response/response-toolkit.d.ts | 0 .../route/route-options-access-scope.d.ts | 0 .../route/route-options-access.d.ts | 0 .../route/route-options-cache.d.ts | 0 .../definitions/route/route-options-cors.d.ts | 0 .../route/route-options-payload.d.ts | 0 .../definitions/route/route-options-pre.d.ts | 0 .../route/route-options-response.d.ts | 0 .../route/route-options-secure.d.ts | 0 .../route/route-options-validate.d.ts | 0 .../definitions/route/route-options.d.ts | 0 .../server/server-auth-scheme.d.ts | 0 .../definitions/server/server-auth.d.ts | 0 .../definitions/server/server-cache.d.ts | 0 .../definitions/server/server-events.d.ts | 0 .../definitions/server/server-ext.d.ts | 0 .../definitions/server/server-info.d.ts | 0 .../definitions/server/server-inject.d.ts | 0 .../definitions/server/server-method.d.ts | 0 .../server/server-options-cache.d.ts | 0 .../definitions/server/server-options.d.ts | 0 .../definitions/server/server-realm.d.ts | 0 .../definitions/server/server-register.d.ts | 0 .../definitions/server/server-route.d.ts | 0 .../server/server-state-options.d.ts | 0 .../definitions/server/server-state.d.ts | 0 .../{v17 => }/definitions/server/server.d.ts | 0 .../hapi/{v17 => }/definitions/util/json.d.ts | 0 .../{v17 => }/definitions/util/lifecycle.d.ts | 0 .../hapi/{v17 => }/definitions/util/util.d.ts | 0 .../hapi/{v17 => }/test/request/catch-all.ts | 0 .../hapi/{v17 => }/test/request/parameters.ts | 0 types/hapi/test/request/query.ts | 27 +++++-- .../hapi/{v17 => }/test/response/continue.ts | 0 .../hapi/{v17 => }/test/response/redirect.ts | 0 .../test/response/response-events.ts | 0 .../hapi/{v17 => }/test/response/response.ts | 0 .../{v17 => }/test/route/adding-routes.ts | 0 types/hapi/test/route/handler.ts | 13 ++-- .../{v17 => }/test/route/route-options-pre.ts | 0 .../{v17 => }/test/route/route-options.ts | 0 .../hapi/{v17 => }/test/server/server-app.ts | 0 .../{v17 => }/test/server/server-auth-api.ts | 0 .../test/server/server-auth-default.ts | 0 .../{v17 => }/test/server/server-auth-test.ts | 0 .../hapi/{v17 => }/test/server/server-bind.ts | 0 .../test/server/server-cache-provision.ts | 0 .../{v17 => }/test/server/server-cache.ts | 0 .../{v17 => }/test/server/server-decoder.ts | 0 .../test/server/server-decorations.ts | 0 .../{v17 => }/test/server/server-encoder.ts | 0 .../test/server/server-events-once.ts | 0 .../{v17 => }/test/server/server-events.ts | 0 .../{v17 => }/test/server/server-expose.ts | 0 .../hapi/{v17 => }/test/server/server-info.ts | 0 .../{v17 => }/test/server/server-inject.ts | 0 .../{v17 => }/test/server/server-listener.ts | 0 .../hapi/{v17 => }/test/server/server-load.ts | 0 .../{v17 => }/test/server/server-lookup.ts | 0 .../{v17 => }/test/server/server-match.ts | 0 .../{v17 => }/test/server/server-method.ts | 0 .../{v17 => }/test/server/server-methods.ts | 0 .../hapi/{v17 => }/test/server/server-mime.ts | 0 .../{v17 => }/test/server/server-options.ts | 0 .../hapi/{v17 => }/test/server/server-path.ts | 0 .../{v17 => }/test/server/server-plugins.ts | 0 .../{v17 => }/test/server/server-settings.ts | 0 .../{v17 => }/test/server/server-start.ts | 0 .../{v17 => }/test/server/server-state.ts | 0 .../hapi/{v17 => }/test/server/server-stop.ts | 0 .../{v17 => }/test/server/server-table.ts | 0 .../{v17 => }/test/server/server-version.ts | 0 types/hapi/v17/index.d.ts | 61 --------------- types/hapi/v17/test/request/event-types.ts | 76 ------------------- types/hapi/v17/test/request/get-log.ts | 29 ------- types/hapi/v17/test/request/query.ts | 27 ------- types/hapi/v17/test/response/error.ts | 31 -------- types/hapi/v17/test/route/config.ts | 52 ------------- types/hapi/v17/test/route/handler.ts | 9 --- types/hapi/v17/tsconfig.json | 73 ------------------ 90 files changed, 26 insertions(+), 372 deletions(-) rename types/hapi/{v17 => }/definitions/plugin/plugin-registered.d.ts (100%) rename types/hapi/{v17 => }/definitions/plugin/plugin.d.ts (100%) rename types/hapi/{v17 => }/definitions/request/request-auth.d.ts (100%) rename types/hapi/{v17 => }/definitions/request/request-events.d.ts (100%) rename types/hapi/{v17 => }/definitions/request/request-info.d.ts (100%) rename types/hapi/{v17 => }/definitions/request/request-route.d.ts (100%) rename types/hapi/{v17 => }/definitions/request/request.d.ts (100%) rename types/hapi/{v17 => }/definitions/response/response-events.d.ts (100%) rename types/hapi/{v17 => }/definitions/response/response-object.d.ts (100%) rename types/hapi/{v17 => }/definitions/response/response-settings.d.ts (100%) rename types/hapi/{v17 => }/definitions/response/response-toolkit.d.ts (100%) rename types/hapi/{v17 => }/definitions/route/route-options-access-scope.d.ts (100%) rename types/hapi/{v17 => }/definitions/route/route-options-access.d.ts (100%) rename types/hapi/{v17 => }/definitions/route/route-options-cache.d.ts (100%) rename types/hapi/{v17 => }/definitions/route/route-options-cors.d.ts (100%) rename types/hapi/{v17 => }/definitions/route/route-options-payload.d.ts (100%) rename types/hapi/{v17 => }/definitions/route/route-options-pre.d.ts (100%) rename types/hapi/{v17 => }/definitions/route/route-options-response.d.ts (100%) rename types/hapi/{v17 => }/definitions/route/route-options-secure.d.ts (100%) rename types/hapi/{v17 => }/definitions/route/route-options-validate.d.ts (100%) rename types/hapi/{v17 => }/definitions/route/route-options.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-auth-scheme.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-auth.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-cache.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-events.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-ext.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-info.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-inject.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-method.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-options-cache.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-options.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-realm.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-register.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-route.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-state-options.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server-state.d.ts (100%) rename types/hapi/{v17 => }/definitions/server/server.d.ts (100%) rename types/hapi/{v17 => }/definitions/util/json.d.ts (100%) rename types/hapi/{v17 => }/definitions/util/lifecycle.d.ts (100%) rename types/hapi/{v17 => }/definitions/util/util.d.ts (100%) rename types/hapi/{v17 => }/test/request/catch-all.ts (100%) rename types/hapi/{v17 => }/test/request/parameters.ts (100%) rename types/hapi/{v17 => }/test/response/continue.ts (100%) rename types/hapi/{v17 => }/test/response/redirect.ts (100%) rename types/hapi/{v17 => }/test/response/response-events.ts (100%) rename types/hapi/{v17 => }/test/response/response.ts (100%) rename types/hapi/{v17 => }/test/route/adding-routes.ts (100%) rename types/hapi/{v17 => }/test/route/route-options-pre.ts (100%) rename types/hapi/{v17 => }/test/route/route-options.ts (100%) rename types/hapi/{v17 => }/test/server/server-app.ts (100%) rename types/hapi/{v17 => }/test/server/server-auth-api.ts (100%) rename types/hapi/{v17 => }/test/server/server-auth-default.ts (100%) rename types/hapi/{v17 => }/test/server/server-auth-test.ts (100%) rename types/hapi/{v17 => }/test/server/server-bind.ts (100%) rename types/hapi/{v17 => }/test/server/server-cache-provision.ts (100%) rename types/hapi/{v17 => }/test/server/server-cache.ts (100%) rename types/hapi/{v17 => }/test/server/server-decoder.ts (100%) rename types/hapi/{v17 => }/test/server/server-decorations.ts (100%) rename types/hapi/{v17 => }/test/server/server-encoder.ts (100%) rename types/hapi/{v17 => }/test/server/server-events-once.ts (100%) rename types/hapi/{v17 => }/test/server/server-events.ts (100%) rename types/hapi/{v17 => }/test/server/server-expose.ts (100%) rename types/hapi/{v17 => }/test/server/server-info.ts (100%) rename types/hapi/{v17 => }/test/server/server-inject.ts (100%) rename types/hapi/{v17 => }/test/server/server-listener.ts (100%) rename types/hapi/{v17 => }/test/server/server-load.ts (100%) rename types/hapi/{v17 => }/test/server/server-lookup.ts (100%) rename types/hapi/{v17 => }/test/server/server-match.ts (100%) rename types/hapi/{v17 => }/test/server/server-method.ts (100%) rename types/hapi/{v17 => }/test/server/server-methods.ts (100%) rename types/hapi/{v17 => }/test/server/server-mime.ts (100%) rename types/hapi/{v17 => }/test/server/server-options.ts (100%) rename types/hapi/{v17 => }/test/server/server-path.ts (100%) rename types/hapi/{v17 => }/test/server/server-plugins.ts (100%) rename types/hapi/{v17 => }/test/server/server-settings.ts (100%) rename types/hapi/{v17 => }/test/server/server-start.ts (100%) rename types/hapi/{v17 => }/test/server/server-state.ts (100%) rename types/hapi/{v17 => }/test/server/server-stop.ts (100%) rename types/hapi/{v17 => }/test/server/server-table.ts (100%) rename types/hapi/{v17 => }/test/server/server-version.ts (100%) delete mode 100644 types/hapi/v17/index.d.ts delete mode 100644 types/hapi/v17/test/request/event-types.ts delete mode 100644 types/hapi/v17/test/request/get-log.ts delete mode 100644 types/hapi/v17/test/request/query.ts delete mode 100644 types/hapi/v17/test/response/error.ts delete mode 100644 types/hapi/v17/test/route/config.ts delete mode 100644 types/hapi/v17/test/route/handler.ts delete mode 100644 types/hapi/v17/tsconfig.json diff --git a/types/hapi/v17/definitions/plugin/plugin-registered.d.ts b/types/hapi/definitions/plugin/plugin-registered.d.ts similarity index 100% rename from types/hapi/v17/definitions/plugin/plugin-registered.d.ts rename to types/hapi/definitions/plugin/plugin-registered.d.ts diff --git a/types/hapi/v17/definitions/plugin/plugin.d.ts b/types/hapi/definitions/plugin/plugin.d.ts similarity index 100% rename from types/hapi/v17/definitions/plugin/plugin.d.ts rename to types/hapi/definitions/plugin/plugin.d.ts diff --git a/types/hapi/v17/definitions/request/request-auth.d.ts b/types/hapi/definitions/request/request-auth.d.ts similarity index 100% rename from types/hapi/v17/definitions/request/request-auth.d.ts rename to types/hapi/definitions/request/request-auth.d.ts diff --git a/types/hapi/v17/definitions/request/request-events.d.ts b/types/hapi/definitions/request/request-events.d.ts similarity index 100% rename from types/hapi/v17/definitions/request/request-events.d.ts rename to types/hapi/definitions/request/request-events.d.ts diff --git a/types/hapi/v17/definitions/request/request-info.d.ts b/types/hapi/definitions/request/request-info.d.ts similarity index 100% rename from types/hapi/v17/definitions/request/request-info.d.ts rename to types/hapi/definitions/request/request-info.d.ts diff --git a/types/hapi/v17/definitions/request/request-route.d.ts b/types/hapi/definitions/request/request-route.d.ts similarity index 100% rename from types/hapi/v17/definitions/request/request-route.d.ts rename to types/hapi/definitions/request/request-route.d.ts diff --git a/types/hapi/v17/definitions/request/request.d.ts b/types/hapi/definitions/request/request.d.ts similarity index 100% rename from types/hapi/v17/definitions/request/request.d.ts rename to types/hapi/definitions/request/request.d.ts diff --git a/types/hapi/v17/definitions/response/response-events.d.ts b/types/hapi/definitions/response/response-events.d.ts similarity index 100% rename from types/hapi/v17/definitions/response/response-events.d.ts rename to types/hapi/definitions/response/response-events.d.ts diff --git a/types/hapi/v17/definitions/response/response-object.d.ts b/types/hapi/definitions/response/response-object.d.ts similarity index 100% rename from types/hapi/v17/definitions/response/response-object.d.ts rename to types/hapi/definitions/response/response-object.d.ts diff --git a/types/hapi/v17/definitions/response/response-settings.d.ts b/types/hapi/definitions/response/response-settings.d.ts similarity index 100% rename from types/hapi/v17/definitions/response/response-settings.d.ts rename to types/hapi/definitions/response/response-settings.d.ts diff --git a/types/hapi/v17/definitions/response/response-toolkit.d.ts b/types/hapi/definitions/response/response-toolkit.d.ts similarity index 100% rename from types/hapi/v17/definitions/response/response-toolkit.d.ts rename to types/hapi/definitions/response/response-toolkit.d.ts diff --git a/types/hapi/v17/definitions/route/route-options-access-scope.d.ts b/types/hapi/definitions/route/route-options-access-scope.d.ts similarity index 100% rename from types/hapi/v17/definitions/route/route-options-access-scope.d.ts rename to types/hapi/definitions/route/route-options-access-scope.d.ts diff --git a/types/hapi/v17/definitions/route/route-options-access.d.ts b/types/hapi/definitions/route/route-options-access.d.ts similarity index 100% rename from types/hapi/v17/definitions/route/route-options-access.d.ts rename to types/hapi/definitions/route/route-options-access.d.ts diff --git a/types/hapi/v17/definitions/route/route-options-cache.d.ts b/types/hapi/definitions/route/route-options-cache.d.ts similarity index 100% rename from types/hapi/v17/definitions/route/route-options-cache.d.ts rename to types/hapi/definitions/route/route-options-cache.d.ts diff --git a/types/hapi/v17/definitions/route/route-options-cors.d.ts b/types/hapi/definitions/route/route-options-cors.d.ts similarity index 100% rename from types/hapi/v17/definitions/route/route-options-cors.d.ts rename to types/hapi/definitions/route/route-options-cors.d.ts diff --git a/types/hapi/v17/definitions/route/route-options-payload.d.ts b/types/hapi/definitions/route/route-options-payload.d.ts similarity index 100% rename from types/hapi/v17/definitions/route/route-options-payload.d.ts rename to types/hapi/definitions/route/route-options-payload.d.ts diff --git a/types/hapi/v17/definitions/route/route-options-pre.d.ts b/types/hapi/definitions/route/route-options-pre.d.ts similarity index 100% rename from types/hapi/v17/definitions/route/route-options-pre.d.ts rename to types/hapi/definitions/route/route-options-pre.d.ts diff --git a/types/hapi/v17/definitions/route/route-options-response.d.ts b/types/hapi/definitions/route/route-options-response.d.ts similarity index 100% rename from types/hapi/v17/definitions/route/route-options-response.d.ts rename to types/hapi/definitions/route/route-options-response.d.ts diff --git a/types/hapi/v17/definitions/route/route-options-secure.d.ts b/types/hapi/definitions/route/route-options-secure.d.ts similarity index 100% rename from types/hapi/v17/definitions/route/route-options-secure.d.ts rename to types/hapi/definitions/route/route-options-secure.d.ts diff --git a/types/hapi/v17/definitions/route/route-options-validate.d.ts b/types/hapi/definitions/route/route-options-validate.d.ts similarity index 100% rename from types/hapi/v17/definitions/route/route-options-validate.d.ts rename to types/hapi/definitions/route/route-options-validate.d.ts diff --git a/types/hapi/v17/definitions/route/route-options.d.ts b/types/hapi/definitions/route/route-options.d.ts similarity index 100% rename from types/hapi/v17/definitions/route/route-options.d.ts rename to types/hapi/definitions/route/route-options.d.ts diff --git a/types/hapi/v17/definitions/server/server-auth-scheme.d.ts b/types/hapi/definitions/server/server-auth-scheme.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-auth-scheme.d.ts rename to types/hapi/definitions/server/server-auth-scheme.d.ts diff --git a/types/hapi/v17/definitions/server/server-auth.d.ts b/types/hapi/definitions/server/server-auth.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-auth.d.ts rename to types/hapi/definitions/server/server-auth.d.ts diff --git a/types/hapi/v17/definitions/server/server-cache.d.ts b/types/hapi/definitions/server/server-cache.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-cache.d.ts rename to types/hapi/definitions/server/server-cache.d.ts diff --git a/types/hapi/v17/definitions/server/server-events.d.ts b/types/hapi/definitions/server/server-events.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-events.d.ts rename to types/hapi/definitions/server/server-events.d.ts diff --git a/types/hapi/v17/definitions/server/server-ext.d.ts b/types/hapi/definitions/server/server-ext.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-ext.d.ts rename to types/hapi/definitions/server/server-ext.d.ts diff --git a/types/hapi/v17/definitions/server/server-info.d.ts b/types/hapi/definitions/server/server-info.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-info.d.ts rename to types/hapi/definitions/server/server-info.d.ts diff --git a/types/hapi/v17/definitions/server/server-inject.d.ts b/types/hapi/definitions/server/server-inject.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-inject.d.ts rename to types/hapi/definitions/server/server-inject.d.ts diff --git a/types/hapi/v17/definitions/server/server-method.d.ts b/types/hapi/definitions/server/server-method.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-method.d.ts rename to types/hapi/definitions/server/server-method.d.ts diff --git a/types/hapi/v17/definitions/server/server-options-cache.d.ts b/types/hapi/definitions/server/server-options-cache.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-options-cache.d.ts rename to types/hapi/definitions/server/server-options-cache.d.ts diff --git a/types/hapi/v17/definitions/server/server-options.d.ts b/types/hapi/definitions/server/server-options.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-options.d.ts rename to types/hapi/definitions/server/server-options.d.ts diff --git a/types/hapi/v17/definitions/server/server-realm.d.ts b/types/hapi/definitions/server/server-realm.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-realm.d.ts rename to types/hapi/definitions/server/server-realm.d.ts diff --git a/types/hapi/v17/definitions/server/server-register.d.ts b/types/hapi/definitions/server/server-register.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-register.d.ts rename to types/hapi/definitions/server/server-register.d.ts diff --git a/types/hapi/v17/definitions/server/server-route.d.ts b/types/hapi/definitions/server/server-route.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-route.d.ts rename to types/hapi/definitions/server/server-route.d.ts diff --git a/types/hapi/v17/definitions/server/server-state-options.d.ts b/types/hapi/definitions/server/server-state-options.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-state-options.d.ts rename to types/hapi/definitions/server/server-state-options.d.ts diff --git a/types/hapi/v17/definitions/server/server-state.d.ts b/types/hapi/definitions/server/server-state.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server-state.d.ts rename to types/hapi/definitions/server/server-state.d.ts diff --git a/types/hapi/v17/definitions/server/server.d.ts b/types/hapi/definitions/server/server.d.ts similarity index 100% rename from types/hapi/v17/definitions/server/server.d.ts rename to types/hapi/definitions/server/server.d.ts diff --git a/types/hapi/v17/definitions/util/json.d.ts b/types/hapi/definitions/util/json.d.ts similarity index 100% rename from types/hapi/v17/definitions/util/json.d.ts rename to types/hapi/definitions/util/json.d.ts diff --git a/types/hapi/v17/definitions/util/lifecycle.d.ts b/types/hapi/definitions/util/lifecycle.d.ts similarity index 100% rename from types/hapi/v17/definitions/util/lifecycle.d.ts rename to types/hapi/definitions/util/lifecycle.d.ts diff --git a/types/hapi/v17/definitions/util/util.d.ts b/types/hapi/definitions/util/util.d.ts similarity index 100% rename from types/hapi/v17/definitions/util/util.d.ts rename to types/hapi/definitions/util/util.d.ts diff --git a/types/hapi/v17/test/request/catch-all.ts b/types/hapi/test/request/catch-all.ts similarity index 100% rename from types/hapi/v17/test/request/catch-all.ts rename to types/hapi/test/request/catch-all.ts diff --git a/types/hapi/v17/test/request/parameters.ts b/types/hapi/test/request/parameters.ts similarity index 100% rename from types/hapi/v17/test/request/parameters.ts rename to types/hapi/test/request/parameters.ts diff --git a/types/hapi/test/request/query.ts b/types/hapi/test/request/query.ts index c6507c2da0..b5a950e2ad 100644 --- a/types/hapi/test/request/query.ts +++ b/types/hapi/test/request/query.ts @@ -1,14 +1,27 @@ // Added test in addition to docs, for request.query +import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; -import * as Hapi from 'hapi'; +const options: ServerOptions = { + port: 8000, +}; + +const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { + const query = request.query as GetThingQuery; + // http://localhost:8000/?name=test + return `You asked for ${query.name}` +}; + +const serverRoute: ServerRoute = { + path: '/', + method: 'GET', + handler: handler +}; interface GetThingQuery { name: string; } -const handler: Hapi.RouteHandler = function (request, reply) { - - const query = request.query as GetThingQuery; - - return reply(`You asked for ${query.name}`); -}; +const server = new Server(options); +server.route(serverRoute); +server.start(); +console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/response/continue.ts b/types/hapi/test/response/continue.ts similarity index 100% rename from types/hapi/v17/test/response/continue.ts rename to types/hapi/test/response/continue.ts diff --git a/types/hapi/v17/test/response/redirect.ts b/types/hapi/test/response/redirect.ts similarity index 100% rename from types/hapi/v17/test/response/redirect.ts rename to types/hapi/test/response/redirect.ts diff --git a/types/hapi/v17/test/response/response-events.ts b/types/hapi/test/response/response-events.ts similarity index 100% rename from types/hapi/v17/test/response/response-events.ts rename to types/hapi/test/response/response-events.ts diff --git a/types/hapi/v17/test/response/response.ts b/types/hapi/test/response/response.ts similarity index 100% rename from types/hapi/v17/test/response/response.ts rename to types/hapi/test/response/response.ts diff --git a/types/hapi/v17/test/route/adding-routes.ts b/types/hapi/test/route/adding-routes.ts similarity index 100% rename from types/hapi/v17/test/route/adding-routes.ts rename to types/hapi/test/route/adding-routes.ts diff --git a/types/hapi/test/route/handler.ts b/types/hapi/test/route/handler.ts index c66d17018e..e3bea54939 100644 --- a/types/hapi/test/route/handler.ts +++ b/types/hapi/test/route/handler.ts @@ -1,10 +1,9 @@ -'use strict'; +import {Lifecycle, Request, ResponseToolkit} from "hapi"; -import * as Hapi from 'hapi'; +const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { + return 'success'; +} -var handler: Hapi.RouteHandler = function(request, reply) { - reply('success'); -} -var strictHandler: Hapi.RouteHandler = function(request, reply) { - reply(123); +const strictHandler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { + return 123; } diff --git a/types/hapi/v17/test/route/route-options-pre.ts b/types/hapi/test/route/route-options-pre.ts similarity index 100% rename from types/hapi/v17/test/route/route-options-pre.ts rename to types/hapi/test/route/route-options-pre.ts diff --git a/types/hapi/v17/test/route/route-options.ts b/types/hapi/test/route/route-options.ts similarity index 100% rename from types/hapi/v17/test/route/route-options.ts rename to types/hapi/test/route/route-options.ts diff --git a/types/hapi/v17/test/server/server-app.ts b/types/hapi/test/server/server-app.ts similarity index 100% rename from types/hapi/v17/test/server/server-app.ts rename to types/hapi/test/server/server-app.ts diff --git a/types/hapi/v17/test/server/server-auth-api.ts b/types/hapi/test/server/server-auth-api.ts similarity index 100% rename from types/hapi/v17/test/server/server-auth-api.ts rename to types/hapi/test/server/server-auth-api.ts diff --git a/types/hapi/v17/test/server/server-auth-default.ts b/types/hapi/test/server/server-auth-default.ts similarity index 100% rename from types/hapi/v17/test/server/server-auth-default.ts rename to types/hapi/test/server/server-auth-default.ts diff --git a/types/hapi/v17/test/server/server-auth-test.ts b/types/hapi/test/server/server-auth-test.ts similarity index 100% rename from types/hapi/v17/test/server/server-auth-test.ts rename to types/hapi/test/server/server-auth-test.ts diff --git a/types/hapi/v17/test/server/server-bind.ts b/types/hapi/test/server/server-bind.ts similarity index 100% rename from types/hapi/v17/test/server/server-bind.ts rename to types/hapi/test/server/server-bind.ts diff --git a/types/hapi/v17/test/server/server-cache-provision.ts b/types/hapi/test/server/server-cache-provision.ts similarity index 100% rename from types/hapi/v17/test/server/server-cache-provision.ts rename to types/hapi/test/server/server-cache-provision.ts diff --git a/types/hapi/v17/test/server/server-cache.ts b/types/hapi/test/server/server-cache.ts similarity index 100% rename from types/hapi/v17/test/server/server-cache.ts rename to types/hapi/test/server/server-cache.ts diff --git a/types/hapi/v17/test/server/server-decoder.ts b/types/hapi/test/server/server-decoder.ts similarity index 100% rename from types/hapi/v17/test/server/server-decoder.ts rename to types/hapi/test/server/server-decoder.ts diff --git a/types/hapi/v17/test/server/server-decorations.ts b/types/hapi/test/server/server-decorations.ts similarity index 100% rename from types/hapi/v17/test/server/server-decorations.ts rename to types/hapi/test/server/server-decorations.ts diff --git a/types/hapi/v17/test/server/server-encoder.ts b/types/hapi/test/server/server-encoder.ts similarity index 100% rename from types/hapi/v17/test/server/server-encoder.ts rename to types/hapi/test/server/server-encoder.ts diff --git a/types/hapi/v17/test/server/server-events-once.ts b/types/hapi/test/server/server-events-once.ts similarity index 100% rename from types/hapi/v17/test/server/server-events-once.ts rename to types/hapi/test/server/server-events-once.ts diff --git a/types/hapi/v17/test/server/server-events.ts b/types/hapi/test/server/server-events.ts similarity index 100% rename from types/hapi/v17/test/server/server-events.ts rename to types/hapi/test/server/server-events.ts diff --git a/types/hapi/v17/test/server/server-expose.ts b/types/hapi/test/server/server-expose.ts similarity index 100% rename from types/hapi/v17/test/server/server-expose.ts rename to types/hapi/test/server/server-expose.ts diff --git a/types/hapi/v17/test/server/server-info.ts b/types/hapi/test/server/server-info.ts similarity index 100% rename from types/hapi/v17/test/server/server-info.ts rename to types/hapi/test/server/server-info.ts diff --git a/types/hapi/v17/test/server/server-inject.ts b/types/hapi/test/server/server-inject.ts similarity index 100% rename from types/hapi/v17/test/server/server-inject.ts rename to types/hapi/test/server/server-inject.ts diff --git a/types/hapi/v17/test/server/server-listener.ts b/types/hapi/test/server/server-listener.ts similarity index 100% rename from types/hapi/v17/test/server/server-listener.ts rename to types/hapi/test/server/server-listener.ts diff --git a/types/hapi/v17/test/server/server-load.ts b/types/hapi/test/server/server-load.ts similarity index 100% rename from types/hapi/v17/test/server/server-load.ts rename to types/hapi/test/server/server-load.ts diff --git a/types/hapi/v17/test/server/server-lookup.ts b/types/hapi/test/server/server-lookup.ts similarity index 100% rename from types/hapi/v17/test/server/server-lookup.ts rename to types/hapi/test/server/server-lookup.ts diff --git a/types/hapi/v17/test/server/server-match.ts b/types/hapi/test/server/server-match.ts similarity index 100% rename from types/hapi/v17/test/server/server-match.ts rename to types/hapi/test/server/server-match.ts diff --git a/types/hapi/v17/test/server/server-method.ts b/types/hapi/test/server/server-method.ts similarity index 100% rename from types/hapi/v17/test/server/server-method.ts rename to types/hapi/test/server/server-method.ts diff --git a/types/hapi/v17/test/server/server-methods.ts b/types/hapi/test/server/server-methods.ts similarity index 100% rename from types/hapi/v17/test/server/server-methods.ts rename to types/hapi/test/server/server-methods.ts diff --git a/types/hapi/v17/test/server/server-mime.ts b/types/hapi/test/server/server-mime.ts similarity index 100% rename from types/hapi/v17/test/server/server-mime.ts rename to types/hapi/test/server/server-mime.ts diff --git a/types/hapi/v17/test/server/server-options.ts b/types/hapi/test/server/server-options.ts similarity index 100% rename from types/hapi/v17/test/server/server-options.ts rename to types/hapi/test/server/server-options.ts diff --git a/types/hapi/v17/test/server/server-path.ts b/types/hapi/test/server/server-path.ts similarity index 100% rename from types/hapi/v17/test/server/server-path.ts rename to types/hapi/test/server/server-path.ts diff --git a/types/hapi/v17/test/server/server-plugins.ts b/types/hapi/test/server/server-plugins.ts similarity index 100% rename from types/hapi/v17/test/server/server-plugins.ts rename to types/hapi/test/server/server-plugins.ts diff --git a/types/hapi/v17/test/server/server-settings.ts b/types/hapi/test/server/server-settings.ts similarity index 100% rename from types/hapi/v17/test/server/server-settings.ts rename to types/hapi/test/server/server-settings.ts diff --git a/types/hapi/v17/test/server/server-start.ts b/types/hapi/test/server/server-start.ts similarity index 100% rename from types/hapi/v17/test/server/server-start.ts rename to types/hapi/test/server/server-start.ts diff --git a/types/hapi/v17/test/server/server-state.ts b/types/hapi/test/server/server-state.ts similarity index 100% rename from types/hapi/v17/test/server/server-state.ts rename to types/hapi/test/server/server-state.ts diff --git a/types/hapi/v17/test/server/server-stop.ts b/types/hapi/test/server/server-stop.ts similarity index 100% rename from types/hapi/v17/test/server/server-stop.ts rename to types/hapi/test/server/server-stop.ts diff --git a/types/hapi/v17/test/server/server-table.ts b/types/hapi/test/server/server-table.ts similarity index 100% rename from types/hapi/v17/test/server/server-table.ts rename to types/hapi/test/server/server-table.ts diff --git a/types/hapi/v17/test/server/server-version.ts b/types/hapi/test/server/server-version.ts similarity index 100% rename from types/hapi/v17/test/server/server-version.ts rename to types/hapi/test/server/server-version.ts diff --git a/types/hapi/v17/index.d.ts b/types/hapi/v17/index.d.ts deleted file mode 100644 index 5b941c2b2c..0000000000 --- a/types/hapi/v17/index.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -// Type definitions for hapi 17.0 -// Project: https://github.com/hapijs/hapi -// Definitions by: Marc Bornträger -// Rafael Souza Fijalkowski -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -// Note/Disclaimer: None. - -/// - -/** PLUGIN */ -export * from './definitions/plugin/plugin' -export * from './definitions/plugin/plugin-registered' - -/** REQUEST */ -export * from './definitions/request/request' -export * from './definitions/request/request-auth' -export * from './definitions/request/request-events' -export * from './definitions/request/request-info' -export * from './definitions/request/request-route' - -/** RESPONSE */ -export * from './definitions/response/response-events' -export * from './definitions/response/response-object' -export * from './definitions/response/response-settings' -export * from './definitions/response/response-toolkit' - -/** ROUTE */ -export * from './definitions/route/route-options' -export * from './definitions/route/route-options-access' -export * from './definitions/route/route-options-access-scope' -export * from './definitions/route/route-options-cache' -export * from './definitions/route/route-options-cors' -export * from './definitions/route/route-options-payload' -export * from './definitions/route/route-options-pre' -export * from './definitions/route/route-options-response' -export * from './definitions/route/route-options-secure' -export * from './definitions/route/route-options-validate' - -/** SERVER */ -export * from './definitions/server/server' -export * from './definitions/server/server-auth' -export * from './definitions/server/server-auth-scheme' -export * from './definitions/server/server-cache' -export * from './definitions/server/server-events' -export * from './definitions/server/server-ext' -export * from './definitions/server/server-info' -export * from './definitions/server/server-inject' -export * from './definitions/server/server-method' -export * from './definitions/server/server-options' -export * from './definitions/server/server-options-cache' -export * from './definitions/server/server-realm' -export * from './definitions/server/server-register' -export * from './definitions/server/server-route' -export * from './definitions/server/server-state' -export * from './definitions/server/server-state-options' - -/** UTIL */ -export * from './definitions/util/json' -export * from './definitions/util/lifecycle' -export * from './definitions/util/util' diff --git a/types/hapi/v17/test/request/event-types.ts b/types/hapi/v17/test/request/event-types.ts deleted file mode 100644 index 894e4dcf39..0000000000 --- a/types/hapi/v17/test/request/event-types.ts +++ /dev/null @@ -1,76 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents -// https://github.com/hapijs/hapi/blob/master/API.md#-requestevents -import { - Lifecycle, - Request, - ResponseToolkit, - RouteOptions, - Server, - ServerOptions, - ServerRoute -} from "hapi"; -import * as Crypto from 'crypto'; - -const options: ServerOptions = { - port: 8000, -}; - -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - } -}; - -const onRequest: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { - - /* - * Server events - */ - request.server.events.on('request', (request: Request, event: any, tags: any) => { - console.log(request.paramsArray); - console.log(event); - console.log(tags); - }); - - request.server.events.on('response', (request: Request) => { - console.log('Response sent for request: ' + request.path); - }); - - request.server.events.on('start', (route: RouteOptions) => { - console.log('Server started'); - }); - - request.server.events.once('stop', (route: RouteOptions) => { - console.log('Server stoped'); - }); - - /* - * Request events - */ - const hash = Crypto.createHash('sha1'); - - request.events.on("peek", (chunk: any) => { - hash.update(chunk); - }); - - request.events.once("finish", () => { - console.log(hash.digest('hex')); - }); - - request.events.once("disconnect", () => { - console.error('request aborted'); - }); - - return h.continue; - -}; - -const server = new Server(options); -server.route(serverRoute); -server.ext('onRequest', onRequest); - -server.start(); -console.log('Server started at: ' + server.info.uri); - diff --git a/types/hapi/v17/test/request/get-log.ts b/types/hapi/v17/test/request/get-log.ts deleted file mode 100644 index 007d396fe5..0000000000 --- a/types/hapi/v17/test/request/get-log.ts +++ /dev/null @@ -1,29 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data -import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; - -const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { - request.log(['test', 'error'], 'Test event'); - return 'path: ' + request.path; -}; - -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: handler -}; - -const server = new Server(options); -server.route(serverRoute); -server.start(); -console.log('Server started at: ' + server.info.uri); - -server.events.on('request', (request: Request, event: any, tags: any) => { - console.log(tags); - if (tags.error) { - console.log(event); - } -}); diff --git a/types/hapi/v17/test/request/query.ts b/types/hapi/v17/test/request/query.ts deleted file mode 100644 index b5a950e2ad..0000000000 --- a/types/hapi/v17/test/request/query.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Added test in addition to docs, for request.query -import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; - -const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { - const query = request.query as GetThingQuery; - // http://localhost:8000/?name=test - return `You asked for ${query.name}` -}; - -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: handler -}; - -interface GetThingQuery { - name: string; -} - -const server = new Server(options); -server.route(serverRoute); -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/response/error.ts b/types/hapi/v17/test/response/error.ts deleted file mode 100644 index 6cc92acbdb..0000000000 --- a/types/hapi/v17/test/response/error.ts +++ /dev/null @@ -1,31 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#errors -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; -import * as Boom from "boom"; - -const options: ServerOptions = { - port: 8000, -}; - -const serverRoutes: ServerRoute[] = [ - { - path: '/badRequest', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - throw Boom.badRequest('Unsupported parameter'); - } - }, - { - path: '/internal', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - throw new Error('unexpect error'); - } - }, -]; - - -const server = new Server(options); -server.route(serverRoutes); - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/route/config.ts b/types/hapi/v17/test/route/config.ts deleted file mode 100644 index 1f36cd51b3..0000000000 --- a/types/hapi/v17/test/route/config.ts +++ /dev/null @@ -1,52 +0,0 @@ -import {Request, ResponseToolkit, RouteOptions, Server, ServerOptions, ServerRoute} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; - -// different methods -var routeConfig: ServerRoute = { - path: '/signin', - method: 'PUT', - vhost: 'site.coms', -}; -var routeConfig: ServerRoute = { - path: '/signin', - method: '*' -}; -var routeConfig: ServerRoute = { - path: '/signin', - method: ['OPTIONS', '*'] -}; - -// different handlers -var routeConfig: ServerRoute = { - path: '/signin', - method: 'PUT', - handler: (request: Request, h: ResponseToolkit) => { - return 'ok'; - } -}; -var routeConfig: ServerRoute = { - path: '/signin', - method: 'PUT', - handler: (request: Request, h: ResponseToolkit) => { - return 'ok'; - } -}; - -const server = new Server(options); -server.route(routeConfig); - -// Handler in config -const user: RouteOptions = { - cache: { expiresIn: 5000 }, - handler: (request: Request, h: ResponseToolkit) => { - return { name: 'John' }; - } -}; - -server.route({method: 'GET', path: '/user', options: user }); - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v17/test/route/handler.ts b/types/hapi/v17/test/route/handler.ts deleted file mode 100644 index e3bea54939..0000000000 --- a/types/hapi/v17/test/route/handler.ts +++ /dev/null @@ -1,9 +0,0 @@ -import {Lifecycle, Request, ResponseToolkit} from "hapi"; - -const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { - return 'success'; -} - -const strictHandler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { - return 123; -} diff --git a/types/hapi/v17/tsconfig.json b/types/hapi/v17/tsconfig.json deleted file mode 100644 index 0134ca5ae1..0000000000 --- a/types/hapi/v17/tsconfig.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": false, - "baseUrl": "../../", - "typeRoots": [ - "../../" - ], - "types": [], - "paths": { - "hapi": [ - "hapi/v17" - ] - }, - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "test/request/catch-all.ts", - "test/request/event-types.ts", - "test/request/get-log.ts", - "test/request/parameters.ts", - "test/request/query.ts", - "test/response/continue.ts", - "test/response/error.ts", - "test/response/redirect.ts", - "test/response/response.ts", - "test/response/response-events.ts", - "test/route/adding-routes.ts", - "test/route/config.ts", - "test/route/handler.ts", - "test/route/route-options.ts", - "test/route/route-options-pre.ts", - "test/server/server-app.ts", - "test/server/server-auth-api.ts", - "test/server/server-auth-default.ts", - "test/server/server-auth-test.ts", - "test/server/server-bind.ts", - "test/server/server-cache.ts", - "test/server/server-cache-provision.ts", - "test/server/server-decoder.ts", - "test/server/server-decorations.ts", - "test/server/server-encoder.ts", - "test/server/server-events.ts", - "test/server/server-events-once.ts", - "test/server/server-expose.ts", - "test/server/server-info.ts", - "test/server/server-inject.ts", - "test/server/server-listener.ts", - "test/server/server-load.ts", - "test/server/server-lookup.ts", - "test/server/server-match.ts", - "test/server/server-method.ts", - "test/server/server-methods.ts", - "test/server/server-mime.ts", - "test/server/server-options.ts", - "test/server/server-path.ts", - "test/server/server-plugins.ts", - "test/server/server-settings.ts", - "test/server/server-start.ts", - "test/server/server-state.ts", - "test/server/server-stop.ts", - "test/server/server-table.ts", - "test/server/server-version.ts" - ] -} From 6e8f01c669e990838bbc066beb162f797075f880 Mon Sep 17 00:00:00 2001 From: Mick Charuwichitratana Date: Thu, 14 Dec 2017 11:40:54 +0700 Subject: [PATCH 144/298] Add support for append function --- types/express-serve-static-core/index.d.ts | 20 +++++++++++++++++--- types/express/express-tests.ts | 7 +++++++ types/express/index.d.ts | 4 ++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/types/express-serve-static-core/index.d.ts b/types/express-serve-static-core/index.d.ts index 2f8d862b14..83e26a23e4 100644 --- a/types/express-serve-static-core/index.d.ts +++ b/types/express-serve-static-core/index.d.ts @@ -1,8 +1,11 @@ -// Type definitions for Express 4.x +// Type definitions for Express 4.11 // Project: http://expressjs.com -// Definitions by: Boris Yankov , Michał Lytek , Kacper Polak +// Definitions by: Boris Yankov +// Michał Lytek +// Kacper Polak +// Satana Charuwichitratana // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.4 // This extracts the core definitions from express to prevent a circular dependency between express and serve-static /// @@ -807,6 +810,17 @@ export interface Response extends http.ServerResponse, Express.Response { vary(field: string): Response; app: Application; + + /** + * Appends the specified value to the HTTP response header field. + * If the header is not already set, it creates the header with the specified value. + * The value parameter can be a string or an array. + * + * Note: calling res.set() after res.append() will reset the previously-set header value. + * + * @since 4.11.0 + */ + append(field: string, value?: string[]|string): Response; } export interface Handler extends RequestHandler { } diff --git a/types/express/express-tests.ts b/types/express/express-tests.ts index 0c1081b49b..1c9220a8b5 100644 --- a/types/express/express-tests.ts +++ b/types/express/express-tests.ts @@ -119,6 +119,13 @@ namespace express_tests { router(req, res, next); }); + // Test append function + app.use((req, res, next) => { + res.append('Link', ['', '']); + res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly'); + res.append('Warning', '199 Miscellaneous warning'); + }); + app.use(router); app.listen(3000); diff --git a/types/express/index.d.ts b/types/express/index.d.ts index 59f60e92df..2ac9fb4bd3 100644 --- a/types/express/index.d.ts +++ b/types/express/index.d.ts @@ -1,8 +1,8 @@ -// Type definitions for Express 4.x +// Type definitions for Express 4.11 // Project: http://expressjs.com // Definitions by: Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.4 /* =================== USAGE =================== From 2cad227300f19c2f333a67c5ed6a10cf9d22fc51 Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Wed, 13 Dec 2017 20:35:40 -0800 Subject: [PATCH 145/298] fix lint --- types/text-encoding-utf-8/index.d.ts | 6 +---- .../text-encoding-utf-8-tests.ts | 24 +++++++++---------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/types/text-encoding-utf-8/index.d.ts b/types/text-encoding-utf-8/index.d.ts index 73aed16d6f..30f3728250 100644 --- a/types/text-encoding-utf-8/index.d.ts +++ b/types/text-encoding-utf-8/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for text-encoding-utf-8 +// Type definitions for text-encoding-utf-8 1.0 // Project: https://github.com/arv/text-encoding-utf-8 // Definitions by: Paul Taylor // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -54,7 +54,3 @@ declare var TextDecoder: TextEncoding.TextDecoderStatic; declare var TextEncoder: TextEncoding.TextEncoderStatic; declare var TextEncoding: TextEncoding.TextEncodingStatic; - -declare module "text-encoding-utf-8" { - export = TextEncoding; -} diff --git a/types/text-encoding-utf-8/text-encoding-utf-8-tests.ts b/types/text-encoding-utf-8/text-encoding-utf-8-tests.ts index afa837c65d..7ebfb04055 100644 --- a/types/text-encoding-utf-8/text-encoding-utf-8-tests.ts +++ b/types/text-encoding-utf-8/text-encoding-utf-8-tests.ts @@ -1,8 +1,6 @@ - - function test_encoder() { - var text = "plain text"; - var uint8array: Uint8Array; + const text = "plain text"; + let uint8array: Uint8Array; // constructor uint8array = new TextEncoder().encode(text); @@ -12,9 +10,9 @@ function test_encoder() { uint8array = TextEncoder('utf-8').encode(text); // attributes - var encoder = new TextEncoder(); + const encoder = new TextEncoder(); encoder.encoding = 'utf-8'; - var encoding: string = encoder.encoding; + const encoding: string = encoder.encoding; // methods encoder.encode(); @@ -22,9 +20,9 @@ function test_encoder() { } function test_decoder() { - var text = "plain text"; - var uint8array: Uint8Array = TextEncoder().encode(text); - var arrayBuffer: ArrayBuffer = uint8array.buffer + let text = "plain text"; + const uint8array: Uint8Array = TextEncoder().encode(text); + const arrayBuffer: ArrayBuffer = uint8array.buffer; // constructor text = new TextDecoder().decode(uint8array); @@ -34,16 +32,16 @@ function test_decoder() { text = TextDecoder('utf-8').decode(uint8array); // attributes - var decoder = new TextDecoder(); + const decoder = new TextDecoder(); decoder.encoding = 'utf-8'; - var encoding: string = decoder.encoding; + const encoding: string = decoder.encoding; decoder.fatal = true; - var fatal: boolean = decoder.fatal; + const fatal: boolean = decoder.fatal; decoder.ignoreBOM = true; - var ignoreBOM: boolean = decoder.ignoreBOM; + const ignoreBOM: boolean = decoder.ignoreBOM; // methods decoder.decode(); From 65521da5111aa78198e76a2f190816e5ca9c4023 Mon Sep 17 00:00:00 2001 From: Mick Charuwichitratana Date: Thu, 14 Dec 2017 12:04:07 +0700 Subject: [PATCH 146/298] Change TypeScript version back to 2.2 as it causes error in other package --- types/express-serve-static-core/index.d.ts | 2 +- types/express/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/types/express-serve-static-core/index.d.ts b/types/express-serve-static-core/index.d.ts index 83e26a23e4..10b379b565 100644 --- a/types/express-serve-static-core/index.d.ts +++ b/types/express-serve-static-core/index.d.ts @@ -5,7 +5,7 @@ // Kacper Polak // Satana Charuwichitratana // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 +// TypeScript Version: 2.2 // This extracts the core definitions from express to prevent a circular dependency between express and serve-static /// diff --git a/types/express/index.d.ts b/types/express/index.d.ts index 2ac9fb4bd3..18231dcfbc 100644 --- a/types/express/index.d.ts +++ b/types/express/index.d.ts @@ -2,7 +2,7 @@ // Project: http://expressjs.com // Definitions by: Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 +// TypeScript Version: 2.2 /* =================== USAGE =================== From af7d90c67226d5c495a196ac1ea13483396a4f5d Mon Sep 17 00:00:00 2001 From: Mick Charuwichitratana Date: Thu, 14 Dec 2017 12:16:48 +0700 Subject: [PATCH 147/298] Add message for deprecated functions since 4.11 --- types/express-serve-static-core/index.d.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/types/express-serve-static-core/index.d.ts b/types/express-serve-static-core/index.d.ts index 10b379b565..edc7641d29 100644 --- a/types/express-serve-static-core/index.d.ts +++ b/types/express-serve-static-core/index.d.ts @@ -76,8 +76,12 @@ export interface IRouter extends RequestHandler { * }); */ param(name: string, handler: RequestParamHandler): this; - // Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param() API - // deprecated since express 4.11.0 + + /** + * Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param() + * + * @deprecated since version 4.11 + */ param(callback: (name: string, matcher: RegExp) => RequestParamHandler): this; /** @@ -300,7 +304,7 @@ export interface Request extends http.IncomingMessage, Express.Request { accepted: MediaType[]; /** - * @deprecated Use either req.params, req.body or req.query, as applicable. + * @deprecated since 4.11 Use either req.params, req.body or req.query, as applicable. * * Return the value of param `name` when present or `defaultValue`. * @@ -896,7 +900,12 @@ export interface Application extends IRouter, Express.Application { get: ((name: string) => any) & IRouterMatcher; param(name: string | string[], handler: RequestParamHandler): this; - // Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param() API + + /** + * Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param() + * + * @deprecated since version 4.11 + */ param(callback: (name: string, matcher: RegExp) => RequestParamHandler): this; /** From 959f3d7aa3c3229a2cf9b1790840eaaeb3498590 Mon Sep 17 00:00:00 2001 From: Luka Maljic Date: Thu, 14 Dec 2017 10:08:58 +0100 Subject: [PATCH 148/298] Added types for webpack-cleanup-plugin --- types/webpack-cleanup-plugin/index.d.ts | 31 +++++++++++++++++++ types/webpack-cleanup-plugin/tsconfig.json | 23 ++++++++++++++ types/webpack-cleanup-plugin/tslint.json | 1 + .../webpack-cleanup-plugin-tests.ts | 7 +++++ 4 files changed, 62 insertions(+) create mode 100644 types/webpack-cleanup-plugin/index.d.ts create mode 100644 types/webpack-cleanup-plugin/tsconfig.json create mode 100644 types/webpack-cleanup-plugin/tslint.json create mode 100644 types/webpack-cleanup-plugin/webpack-cleanup-plugin-tests.ts diff --git a/types/webpack-cleanup-plugin/index.d.ts b/types/webpack-cleanup-plugin/index.d.ts new file mode 100644 index 0000000000..f5fa620413 --- /dev/null +++ b/types/webpack-cleanup-plugin/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for webpack-cleanup-plugin 0.5 +// Project: https://github.com/gpbl/webpack-cleanup-plugin#readme +// Definitions by: Luka Maljic +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import webpack = require('webpack'); + +export = WebpackCleanupPlugin; + +declare class WebpackCleanupPlugin extends webpack.Plugin { + constructor(options?: WebpackCleanupPlugin.Options); +} + +declare namespace WebpackCleanupPlugin { + interface Options { + /** + * Keep some files in the output path. It accepts globbing as in [minimatch](https://github.com/isaacs/minimatch). + */ + exclude?: string[]; + + /** + * Print the list of the files that will be deleted without actually deleting them. + */ + preview?: boolean; + + /** + * Mute the console output. + */ + quiet?: boolean; + } +} diff --git a/types/webpack-cleanup-plugin/tsconfig.json b/types/webpack-cleanup-plugin/tsconfig.json new file mode 100644 index 0000000000..f2712d3d73 --- /dev/null +++ b/types/webpack-cleanup-plugin/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "webpack-cleanup-plugin-tests.ts" + ] +} diff --git a/types/webpack-cleanup-plugin/tslint.json b/types/webpack-cleanup-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/webpack-cleanup-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/webpack-cleanup-plugin/webpack-cleanup-plugin-tests.ts b/types/webpack-cleanup-plugin/webpack-cleanup-plugin-tests.ts new file mode 100644 index 0000000000..dcd5f75c02 --- /dev/null +++ b/types/webpack-cleanup-plugin/webpack-cleanup-plugin-tests.ts @@ -0,0 +1,7 @@ +import WebpackCleanupPlugin = require('webpack-cleanup-plugin'); + +new WebpackCleanupPlugin({ + exclude: ["stats.json", "important.js", "folder/**/*"], + preview: true, + quiet: true +}); From 0e06269e028d92316c3380eb9dfd2ab72bed25ba Mon Sep 17 00:00:00 2001 From: Technion Date: Thu, 14 Dec 2017 10:43:13 +0000 Subject: [PATCH 149/298] Move #19662 fix to a fake interface as per PR discussion. --- types/jest/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index dda9bded66..0c595a5b82 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -1046,11 +1046,12 @@ declare namespace jest { path: Path; } + interface Set {} // To allow non-ES6 users the Set below interface Reporter { onTestResult?(test: Test, testResult: TestResult, aggregatedResult: AggregatedResult): void; onRunStart?(results: AggregatedResult, options: ReporterOnStartOptions): void; onTestStart?(test: Test): void; - onRunComplete?(contexts: [Context], results: AggregatedResult): Maybe>; + onRunComplete?(contexts: Set, results: AggregatedResult): Maybe>; getLastError?(): Maybe; } From efd09c3dba555d61cbfb846f64ca2570d8a1b20b Mon Sep 17 00:00:00 2001 From: Dmitrii Sorin Date: Thu, 14 Dec 2017 22:18:00 +1100 Subject: [PATCH 150/298] Add missing constructor options --- types/raven/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/raven/index.d.ts b/types/raven/index.d.ts index 610122ab66..e2d5e18198 100644 --- a/types/raven/index.d.ts +++ b/types/raven/index.d.ts @@ -60,6 +60,9 @@ export interface ConstructorOptions { tags?: { [key: string]: string }; extra?: { [key: string]: any }; dataCallback?: DataCallback; + maxReqQueueCount?: number; + sampleRate?: number; + sendTimeout?: number; shouldSendCallback?: ShouldSendCallback; transport?(): void; captureUnhandledRejections?: boolean; From e0ecca30c11feb61586fcb91f6414e5e65c77a99 Mon Sep 17 00:00:00 2001 From: Andrei Volchenko Date: Thu, 14 Dec 2017 14:28:43 +0300 Subject: [PATCH 151/298] add types for styled-jsx --- types/styled-jsx/index.d.ts | 13 +++++++++++++ types/styled-jsx/styled-jsx-tests.tsx | 15 +++++++++++++++ types/styled-jsx/tsconfig.json | 24 ++++++++++++++++++++++++ types/styled-jsx/tslint.json | 1 + 4 files changed, 53 insertions(+) create mode 100644 types/styled-jsx/index.d.ts create mode 100644 types/styled-jsx/styled-jsx-tests.tsx create mode 100644 types/styled-jsx/tsconfig.json create mode 100644 types/styled-jsx/tslint.json diff --git a/types/styled-jsx/index.d.ts b/types/styled-jsx/index.d.ts new file mode 100644 index 0000000000..9e3ac68dff --- /dev/null +++ b/types/styled-jsx/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for styled-jsx 2.2.1 +// Project: https://github.com/zeit/styled-jsx +// Definitions by: R1ZZU +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as React from 'react'; + +declare module 'react' { + interface StyleHTMLAttributes extends React.HTMLAttributes { + jsx?: boolean; + global?: boolean; + } +} diff --git a/types/styled-jsx/styled-jsx-tests.tsx b/types/styled-jsx/styled-jsx-tests.tsx new file mode 100644 index 0000000000..65081d9bbd --- /dev/null +++ b/types/styled-jsx/styled-jsx-tests.tsx @@ -0,0 +1,15 @@ +const styled = ( +

+ +
+); + +const styledGlobal = ( +
+ +
+); diff --git a/types/styled-jsx/tsconfig.json b/types/styled-jsx/tsconfig.json new file mode 100644 index 0000000000..494ed25a0a --- /dev/null +++ b/types/styled-jsx/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "styled-jsx-tests.tsx" + ] +} diff --git a/types/styled-jsx/tslint.json b/types/styled-jsx/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/styled-jsx/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From ca2179bf66a419d1e552a8e76768bf4750b371d8 Mon Sep 17 00:00:00 2001 From: Andrei Volchenko Date: Thu, 14 Dec 2017 14:36:08 +0300 Subject: [PATCH 152/298] specify ts version --- types/styled-jsx/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/styled-jsx/index.d.ts b/types/styled-jsx/index.d.ts index 9e3ac68dff..5ea6365d48 100644 --- a/types/styled-jsx/index.d.ts +++ b/types/styled-jsx/index.d.ts @@ -2,10 +2,11 @@ // Project: https://github.com/zeit/styled-jsx // Definitions by: R1ZZU // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -import * as React from 'react'; +import * as React from "react"; -declare module 'react' { +declare module "react" { interface StyleHTMLAttributes extends React.HTMLAttributes { jsx?: boolean; global?: boolean; From 8aa0c79cc6990384935c2bc367ca94e0ce432acb Mon Sep 17 00:00:00 2001 From: Andrei Volchenko Date: Thu, 14 Dec 2017 14:42:46 +0300 Subject: [PATCH 153/298] disable dt-header rule --- types/styled-jsx/tslint.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/types/styled-jsx/tslint.json b/types/styled-jsx/tslint.json index 3db14f85ea..65c83fb1e3 100644 --- a/types/styled-jsx/tslint.json +++ b/types/styled-jsx/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "dt-header": false + } +} From d0d28a0cd178391d21b2348475184efd9aa40380 Mon Sep 17 00:00:00 2001 From: Andrei Volchenko Date: Thu, 14 Dec 2017 14:51:52 +0300 Subject: [PATCH 154/298] drop no-unnecessary-qualifier rule --- types/styled-jsx/index.d.ts | 2 +- types/styled-jsx/tslint.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/styled-jsx/index.d.ts b/types/styled-jsx/index.d.ts index 5ea6365d48..61c2cffa23 100644 --- a/types/styled-jsx/index.d.ts +++ b/types/styled-jsx/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import * as React from "react"; +import "react"; declare module "react" { interface StyleHTMLAttributes extends React.HTMLAttributes { diff --git a/types/styled-jsx/tslint.json b/types/styled-jsx/tslint.json index 65c83fb1e3..1d415aae00 100644 --- a/types/styled-jsx/tslint.json +++ b/types/styled-jsx/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "dt-header": false + "dt-header": false, + "no-unnecessary-qualifier": false } } From 78c2b845a64d1d655677b04fb00d37b9986942f2 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 14 Dec 2017 09:15:57 +0100 Subject: [PATCH 155/298] Backup v4 --- types/react-i18next/v4/index.d.ts | 37 ++++++++ .../react-i18next/v4/src/I18nextProvider.d.ts | 12 +++ types/react-i18next/v4/src/interpolate.d.ts | 23 +++++ .../react-i18next/v4/src/loadNamespaces.d.ts | 9 ++ types/react-i18next/v4/src/trans.d.ts | 8 ++ types/react-i18next/v4/src/translate.d.ts | 15 +++ .../v4/test/react-i18next-tests.tsx | 92 +++++++++++++++++++ types/react-i18next/v4/tsconfig.json | 33 +++++++ types/react-i18next/v4/tslint.json | 1 + 9 files changed, 230 insertions(+) create mode 100644 types/react-i18next/v4/index.d.ts create mode 100644 types/react-i18next/v4/src/I18nextProvider.d.ts create mode 100644 types/react-i18next/v4/src/interpolate.d.ts create mode 100644 types/react-i18next/v4/src/loadNamespaces.d.ts create mode 100644 types/react-i18next/v4/src/trans.d.ts create mode 100644 types/react-i18next/v4/src/translate.d.ts create mode 100644 types/react-i18next/v4/test/react-i18next-tests.tsx create mode 100644 types/react-i18next/v4/tsconfig.json create mode 100644 types/react-i18next/v4/tslint.json diff --git a/types/react-i18next/v4/index.d.ts b/types/react-i18next/v4/index.d.ts new file mode 100644 index 0000000000..d7bb05a30f --- /dev/null +++ b/types/react-i18next/v4/index.d.ts @@ -0,0 +1,37 @@ +// Type definitions for react-i18next 4.6 +// Project: https://github.com/i18next/react-i18next +// Definitions by: Giedrius Grabauskas +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { TranslationFunction } from "i18next"; + +import I18nextProvider from "./src/I18nextProvider"; +import Interpolate from "./src/interpolate"; +import loadNamespaces from "./src/loadNamespaces"; +import Trans from "./src/trans"; +import translate from "./src/translate"; + +export { + I18nextProvider, + Interpolate, + loadNamespaces, + Trans, + translate, + // Exports for TypeScript only + TranslationFunction +}; + +/** + * Extend your component's Prop interface with this one to get access to `this.props.t` + * + * Please note that if you use the `translateFuncName` option, you should create + * your own interface just like this one, but with your name of the translation function. + * + * interface MyComponentProps extends ReactI18next.InjectedTranslateProps {} + */ +export interface InjectedTranslateProps { + t?: TranslationFunction; +} + +export as namespace reactI18Next; diff --git a/types/react-i18next/v4/src/I18nextProvider.d.ts b/types/react-i18next/v4/src/I18nextProvider.d.ts new file mode 100644 index 0000000000..2ecb87f4a1 --- /dev/null +++ b/types/react-i18next/v4/src/I18nextProvider.d.ts @@ -0,0 +1,12 @@ +import * as React from "react"; +import { i18n } from "i18next"; + +// tslint:disable-next-line:interface-name +export interface I18nextProviderProps { + i18n: i18n; + children: React.ReactElement; + initialI18nStore?: any; + initialLanguage?: string; +} + +export default class I18nextProvider extends React.Component { } diff --git a/types/react-i18next/v4/src/interpolate.d.ts b/types/react-i18next/v4/src/interpolate.d.ts new file mode 100644 index 0000000000..e6f07893ed --- /dev/null +++ b/types/react-i18next/v4/src/interpolate.d.ts @@ -0,0 +1,23 @@ +import * as React from "react"; +import { InterpolationOptions } from "i18next"; + +export type InterpolateValue = string | JSX.Element; + +export interface InterpolatePropsBase { + parent?: string; + regexp?: RegExp; + useDangerouslySetInnerHTML?: boolean; + dangerouslySetInnerHTMLPartElement?: string; + options?: InterpolationOptions; + i18nKey?: string; + className?: string; + style?: React.CSSProperties; +} + +export interface OtherInterpolateProps { + [regexKey: string]: InterpolateValue | RegExp | InterpolationOptions | boolean | undefined; +} + +export type InterpolateProps = InterpolatePropsBase & OtherInterpolateProps; + +export default class Interpolate extends React.Component { } diff --git a/types/react-i18next/v4/src/loadNamespaces.d.ts b/types/react-i18next/v4/src/loadNamespaces.d.ts new file mode 100644 index 0000000000..d0e0b372f5 --- /dev/null +++ b/types/react-i18next/v4/src/loadNamespaces.d.ts @@ -0,0 +1,9 @@ +import * as React from "react"; +import { i18n } from "i18next"; + +export interface LoadNamespacesArguments { + components: Array | React.StatelessComponent>; + i18n: i18n; +} + +export default function loadNamespaces(args: LoadNamespacesArguments): Promise; diff --git a/types/react-i18next/v4/src/trans.d.ts b/types/react-i18next/v4/src/trans.d.ts new file mode 100644 index 0000000000..384e1605f9 --- /dev/null +++ b/types/react-i18next/v4/src/trans.d.ts @@ -0,0 +1,8 @@ +import * as React from "react"; + +export interface TransProps { + i18nKey?: string; + [name: string]: any; +} + +export default class Trans extends React.Component { } diff --git a/types/react-i18next/v4/src/translate.d.ts b/types/react-i18next/v4/src/translate.d.ts new file mode 100644 index 0000000000..d41b4dc00a --- /dev/null +++ b/types/react-i18next/v4/src/translate.d.ts @@ -0,0 +1,15 @@ +import * as React from "react"; +import { i18n } from "i18next"; + +export interface TranslateOptions { + withRef?: boolean; + bindI18n?: string; + bindStore?: string; + translateFuncName?: string; + wait?: boolean; + nsMode?: string; + i18n?: i18n; +} + +// tslint:disable-next-line:ban-types +export default function translate(namespaces?: TKey[] | TKey, options?: TranslateOptions): (WrappedComponent: C) => C; diff --git a/types/react-i18next/v4/test/react-i18next-tests.tsx b/types/react-i18next/v4/test/react-i18next-tests.tsx new file mode 100644 index 0000000000..6105ccf921 --- /dev/null +++ b/types/react-i18next/v4/test/react-i18next-tests.tsx @@ -0,0 +1,92 @@ +import * as React from 'react'; +import * as i18n from 'i18next'; +import { translate, I18nextProvider, Interpolate, InjectedTranslateProps, TranslationFunction, loadNamespaces, Trans } from 'react-i18next'; + +interface InnerAnotherComponentProps { + _?: TranslationFunction; +} + +class InnerAnotherComponent extends React.Component { + render() { + const _ = this.props._!; + return

{_('content.text', { /* options t options */ })}

; + } +} + +const AnotherComponent = translate('view', { wait: true, translateFuncName: '_' })(InnerAnotherComponent); + +class InnerYetAnotherComponent extends React.Component { + render() { + const t = this.props.t!; + return

{t('usingDefaultNS', { /* options t options */ })}

; + } +} + +const YetAnotherComponent = translate()(InnerYetAnotherComponent); + +@translate(['view', 'nav'], { wait: true }) +class TranslatableView extends React.Component { + render() { + const t = this.props.t!; + const interpolateComponent = "a interpolated component"; + + return ( +
+

{t('common:appName')}

+ + + + + {t('nav:link1')} +
+ ); + } +} + +class App extends React.Component { + render() { + return ( +
+
+ +
+
+ ); + } +} + + + +; + +loadNamespaces({ components: [App], i18n }).then(() => { }).catch(error => { }); + +; +; + + +; + +type Key = "view" | "nav"; + +@translate(['view', 'nav']) +class GenericsTest extends React.Component { + render() { return null; } +} + +@translate('view') +class GenericsTest2 extends React.Component { + render() { return null; } +} diff --git a/types/react-i18next/v4/tsconfig.json b/types/react-i18next/v4/tsconfig.json new file mode 100644 index 0000000000..a0f7445e79 --- /dev/null +++ b/types/react-i18next/v4/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "react-i18next": [ "react-i18next/v4" ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "experimentalDecorators": true + }, + "files": [ + "index.d.ts", + "test/react-i18next-tests.tsx", + "src/I18nextProvider.d.ts", + "src/interpolate.d.ts", + "src/loadNamespaces.d.ts", + "src/trans.d.ts", + "src/translate.d.ts" + ] +} diff --git a/types/react-i18next/v4/tslint.json b/types/react-i18next/v4/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-i18next/v4/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From c46598893cdd00eeb70d797ff2f2556e772898cc Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 30 Nov 2017 21:15:13 +0100 Subject: [PATCH 156/298] React-i18next Generic translate Fixes #16395 --- types/react-i18next/index.d.ts | 18 ++---- types/react-i18next/src/context.d.ts | 14 +++++ types/react-i18next/src/props.d.ts | 24 +++++++ types/react-i18next/src/translate.d.ts | 61 ++++++++++++++++-- .../test/react-i18next-tests.tsx | 63 ++++++++++++++++--- 5 files changed, 151 insertions(+), 29 deletions(-) create mode 100644 types/react-i18next/src/context.d.ts create mode 100644 types/react-i18next/src/props.d.ts diff --git a/types/react-i18next/index.d.ts b/types/react-i18next/index.d.ts index d7bb05a30f..9e731fe5e6 100644 --- a/types/react-i18next/index.d.ts +++ b/types/react-i18next/index.d.ts @@ -1,10 +1,10 @@ -// Type definitions for react-i18next 4.6 +// Type definitions for react-i18next 7.0 // Project: https://github.com/i18next/react-i18next // Definitions by: Giedrius Grabauskas // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 -import { TranslationFunction } from "i18next"; +import { i18n as I18n, TranslationFunction } from "i18next"; import I18nextProvider from "./src/I18nextProvider"; import Interpolate from "./src/interpolate"; @@ -22,16 +22,6 @@ export { TranslationFunction }; -/** - * Extend your component's Prop interface with this one to get access to `this.props.t` - * - * Please note that if you use the `translateFuncName` option, you should create - * your own interface just like this one, but with your name of the translation function. - * - * interface MyComponentProps extends ReactI18next.InjectedTranslateProps {} - */ -export interface InjectedTranslateProps { - t?: TranslationFunction; -} +export { InjectedI18nProps, InjectedTranslateProps } from "./src/props"; export as namespace reactI18Next; diff --git a/types/react-i18next/src/context.d.ts b/types/react-i18next/src/context.d.ts new file mode 100644 index 0000000000..8e11a4d7a3 --- /dev/null +++ b/types/react-i18next/src/context.d.ts @@ -0,0 +1,14 @@ +import { i18n } from "i18next"; + +export interface ReactI18NextOptions { + wait?: boolean; + withRef?: boolean; + bindI18n?: string; + bindStore?: string; + translateFuncName?: string; + nsMode?: string; +} + +export function setDefaults(options: ReactI18NextOptions): void; + +export function setI18n(instance: i18n): void; diff --git a/types/react-i18next/src/props.d.ts b/types/react-i18next/src/props.d.ts new file mode 100644 index 0000000000..62a201049a --- /dev/null +++ b/types/react-i18next/src/props.d.ts @@ -0,0 +1,24 @@ +import {i18n as I18n, TranslationFunction} from "i18next"; + +/** + * Extend your component's Prop interface with this one to get access to `this.props.t` + * + * Please note that if you use the `translateFuncName` option, you should create + * your own interface just like this one, but with your name of the translation function. + * + * interface MyComponentProps extends ReactI18next.InjectedTranslateProps {} + * + * Then specify the name of the translate function as generic argument + * + * const translated = translate("view", { translateFuncName: "_" })(YourComponent); + */ +export interface InjectedTranslateProps { + t: TranslationFunction; +} + +/** + * Extend your component's Prop interface with this one to get access to `this.props.i18n` + */ +export interface InjectedI18nProps { + i18n: I18n +} diff --git a/types/react-i18next/src/translate.d.ts b/types/react-i18next/src/translate.d.ts index d41b4dc00a..0711d3895d 100644 --- a/types/react-i18next/src/translate.d.ts +++ b/types/react-i18next/src/translate.d.ts @@ -1,15 +1,64 @@ import * as React from "react"; -import { i18n } from "i18next"; +import { i18n as I18n, TranslationFunction } from "i18next"; +import { InjectedTranslateProps, InjectedI18nProps } from "./props"; +import { setDefaults, setI18n } from "./context"; -export interface TranslateOptions { +export interface TranslateOptions { withRef?: boolean; bindI18n?: string; bindStore?: string; - translateFuncName?: string; + translateFuncName?: TTranslateFuncName; wait?: boolean; nsMode?: string; - i18n?: i18n; + i18n?: I18n; } -// tslint:disable-next-line:ban-types -export default function translate(namespaces?: TKey[] | TKey, options?: TranslateOptions): (WrappedComponent: C) => C; +export interface TranslateHocProps { + i18n?: I18n; + initialI18nStore?: object; + initialLanguage?: string; +} + +// Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766 +type Diff = ({[P in T]: P } & {[P in U]: never } & { [x: string]: never })[T]; +type Omit = Pick>; + +type InjectedProps = InjectedI18nProps & InjectedTranslateProps; + +export interface WrapperComponentClass

extends React.ComponentClass

{ + new (props: P, context?: any): React.Component

& { getWrappedInstance(): React.Component }; +} + +// Injects props and removes them from the prop requirements. +// Adds the new properties t (or whatever the translation function is called) and i18n if needed. +export type InferableComponentEnhancerWithProps = +

(component: React.ComponentClass

| React.StatelessComponent

) => + React.ComponentClass & TranslateHocProps>; + +export type InferableComponentEnhancerWithPropsAndRef = +

(component: React.ComponentClass

| React.StatelessComponent

) => + WrapperComponentClass, P>; + +export interface Translate { + + (namespaces?: TNamespace | TNamespace[], options?: Omit & { withRef?: false }): + InferableComponentEnhancerWithProps<"t">; + + + (namespaces?: TNamespace | TNamespace[], options?: Omit & { withRef: true }): + InferableComponentEnhancerWithPropsAndRef<"t">; + + + (namespaces?: TNamespace | TNamespace[], options?: TranslateOptions & { withRef?: false }): + InferableComponentEnhancerWithProps; + + + (namespaces?: TNamespace | TNamespace[], options?: TranslateOptions & { withRef: true }): + InferableComponentEnhancerWithPropsAndRef; + + setDefaults: typeof setDefaults; + setI18n: typeof setI18n; +} + +declare const translate: Translate; +export default translate; diff --git a/types/react-i18next/test/react-i18next-tests.tsx b/types/react-i18next/test/react-i18next-tests.tsx index 6105ccf921..5ddb17c10c 100644 --- a/types/react-i18next/test/react-i18next-tests.tsx +++ b/types/react-i18next/test/react-i18next-tests.tsx @@ -1,33 +1,54 @@ import * as React from 'react'; import * as i18n from 'i18next'; import { translate, I18nextProvider, Interpolate, InjectedTranslateProps, TranslationFunction, loadNamespaces, Trans } from 'react-i18next'; +import { InjectedI18nProps } from 'react-i18next/src/props'; interface InnerAnotherComponentProps { - _?: TranslationFunction; + _: TranslationFunction; } class InnerAnotherComponent extends React.Component { render() { - const _ = this.props._!; + const _ = this.props._; return

{_('content.text', { /* options t options */ })}

; } } -const AnotherComponent = translate('view', { wait: true, translateFuncName: '_' })(InnerAnotherComponent); +const AnotherComponent = translate('view', { wait: true, translateFuncName: '_' })(InnerAnotherComponent); +const instanceWithoutRef = new AnotherComponent({}); +instanceWithoutRef.componentWillReceiveProps!({ + i18n, + initialI18nStore: { context: { text: "a message" } }, + initialLanguage: "en" +}, {}); + +translate.setDefaults({ wait: false }); +translate.setI18n(i18n); + +const AnotherComponentWithRef = translate("view" as Key, { translateFuncName: "_", withRef: true })(InnerAnotherComponent); +const instanceWithRef = new AnotherComponentWithRef({}); +const ref = instanceWithRef.getWrappedInstance(); +instanceWithRef.componentWillReceiveProps!({ + i18n, + initialI18nStore: { context: { text: "a message" } }, + initialLanguage: "en" +}, {}); class InnerYetAnotherComponent extends React.Component { render() { - const t = this.props.t!; + const t = this.props.t; return

{t('usingDefaultNS', { /* options t options */ })}

; } } const YetAnotherComponent = translate()(InnerYetAnotherComponent); -@translate(['view', 'nav'], { wait: true }) +const YetAnotherComponentWithRef = translate(undefined, { withRef: true })(InnerYetAnotherComponent); +new YetAnotherComponentWithRef({}).getWrappedInstance(); + class TranslatableView extends React.Component { render() { - const t = this.props.t!; + const t = this.props.t; const interpolateComponent = "a interpolated component"; return ( @@ -55,12 +76,14 @@ class TranslatableView extends React.Component { } } +const TranslatedView = translate(["view", "nav"] as Key[], { wait: true })(TranslatableView); + class App extends React.Component { render() { return (
- +
); @@ -81,12 +104,34 @@ loadNamespaces({ components: [App], i18n }).then(() => { }).catch(error => { }); type Key = "view" | "nav"; -@translate(['view', 'nav']) class GenericsTest extends React.Component { render() { return null; } } -@translate('view') +const TranslatedGenericsTest = translate(["view", "nav"] as Key[])(GenericsTest); +; + class GenericsTest2 extends React.Component { render() { return null; } } + +const TranslatedGenericsTest2 = translate("view" as Key)(GenericsTest2); +; + +class ComponentWithInjectedI18n extends React.Component { + render() { return null; } +} + +const TranslatedComponentWithInjectedI18n = translate()(ComponentWithInjectedI18n); +; + +function StatlessComponent(props: InjectedTranslateProps) { + return

{props.t("hy")}

; +} + +const TranslatedStatlessComponent = translate()(StatlessComponent); +; + +interface CustomTranslateFunctionProps { + _: TranslationFunction; +} From 0357d79df8c94a16368bf627beaf488cbc877797 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 14 Dec 2017 12:30:33 +0100 Subject: [PATCH 157/298] Enable Strict Function Types --- types/react-i18next/tsconfig.json | 1 + types/react-i18next/v4/tsconfig.json | 1 + 2 files changed, 2 insertions(+) diff --git a/types/react-i18next/tsconfig.json b/types/react-i18next/tsconfig.json index cbb9a8b45f..c38c15b504 100644 --- a/types/react-i18next/tsconfig.json +++ b/types/react-i18next/tsconfig.json @@ -16,6 +16,7 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true, "jsx": "react", "experimentalDecorators": true }, diff --git a/types/react-i18next/v4/tsconfig.json b/types/react-i18next/v4/tsconfig.json index a0f7445e79..bd85233525 100644 --- a/types/react-i18next/v4/tsconfig.json +++ b/types/react-i18next/v4/tsconfig.json @@ -18,6 +18,7 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, + "strictFunctionTypes": true, "jsx": "react", "experimentalDecorators": true }, From 9d8c0fb8b4b04b26f4a366c1cc77f297e2ec7c7d Mon Sep 17 00:00:00 2001 From: blink7 Date: Thu, 14 Dec 2017 17:39:33 +0300 Subject: [PATCH 158/298] Update index.d.ts Add handling for AutocompletePrediction's reference and structured formatting. --- types/googlemaps/index.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types/googlemaps/index.d.ts b/types/googlemaps/index.d.ts index 5e977257b8..60396493f1 100644 --- a/types/googlemaps/index.d.ts +++ b/types/googlemaps/index.d.ts @@ -2471,9 +2471,17 @@ declare namespace google.maps { description: string; matched_substrings: PredictionSubstring[]; place_id: string; + reference: string; + structured_formatting: AutocompleteStructuredFormatting; terms: PredictionTerm[]; types: string[]; } + + export interface AutocompleteStructuredFormatting { + main_text: string; + main_text_matched_substrings: PredictionSubstring[]; + secondary_text: string; + } export interface OpeningHours { open_now: boolean; From cebee43d80e672d95bcbd8fed69eb7819fedb276 Mon Sep 17 00:00:00 2001 From: DovidM Date: Thu, 14 Dec 2017 10:12:11 -0500 Subject: [PATCH 159/298] Generated files --- types/word-list-json/index.d.ts | 39 ++++++++++++++++++++ types/word-list-json/tsconfig.json | 22 +++++++++++ types/word-list-json/tslint.json | 1 + types/word-list-json/word-list-json-tests.ts | 0 4 files changed, 62 insertions(+) create mode 100644 types/word-list-json/index.d.ts create mode 100644 types/word-list-json/tsconfig.json create mode 100644 types/word-list-json/tslint.json create mode 100644 types/word-list-json/word-list-json-tests.ts diff --git a/types/word-list-json/index.d.ts b/types/word-list-json/index.d.ts new file mode 100644 index 0000000000..0dec6547e2 --- /dev/null +++ b/types/word-list-json/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for word-list-json 0.2 +// Project: https://github.com/sindresorhus/word-list +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/*~ If this module is a UMD module that exposes a global variable 'myLib' when + *~ loaded outside a module loader environment, declare that global here. + *~ Otherwise, delete this declaration. + */ +export as namespace myLib; + +/*~ If this module has methods, declare them as functions like so. + */ +export function myMethod(a: string): string; +export function myOtherMethod(a: number): number; + +/*~ You can declare types that are available via importing the module */ +export interface someType { + name: string; + length: number; + extras?: string[]; +} + +/*~ You can declare properties of the module using const, let, or var */ +export const myField: number; + +/*~ If there are types, properties, or methods inside dotted names + *~ of the module, declare them inside a 'namespace'. + */ +export namespace subProp { + /*~ For example, given this definition, someone could write: + *~ import { subProp } from 'yourModule'; + *~ subProp.foo(); + *~ or + *~ import * as yourMod from 'yourModule'; + *~ yourMod.subProp.foo(); + */ + export function foo(): void; +} \ No newline at end of file diff --git a/types/word-list-json/tsconfig.json b/types/word-list-json/tsconfig.json new file mode 100644 index 0000000000..af12c82665 --- /dev/null +++ b/types/word-list-json/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "word-list-json-tests.ts" + ] +} diff --git a/types/word-list-json/tslint.json b/types/word-list-json/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/word-list-json/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/word-list-json/word-list-json-tests.ts b/types/word-list-json/word-list-json-tests.ts new file mode 100644 index 0000000000..e69de29bb2 From 4db14a2b1bc0df16534d2a05931ff1980aaf83f6 Mon Sep 17 00:00:00 2001 From: Lewis Diamond Date: Thu, 14 Dec 2017 10:17:08 -0500 Subject: [PATCH 160/298] Add missing type on react-datepicker v0.62.0 customInputRef was just introduced and is missing from current type definitions. --- types/react-datepicker/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/react-datepicker/index.d.ts b/types/react-datepicker/index.d.ts index 2a7ed3ceb6..e6cf11d121 100644 --- a/types/react-datepicker/index.d.ts +++ b/types/react-datepicker/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-datepicker 0.55 +// Type definitions for react-datepicker 0.62 // Project: https://github.com/Hacker0x01/react-datepicker // Definitions by: Rajab Shakirov , // Andrey Balokha , @@ -19,6 +19,7 @@ export interface ReactDatePickerProps { children?: any; className?: string; customInput?: React.ReactNode; + customInputRef?: string; dateFormat?: string | string[]; dateFormatCalendar?: string; dayClassName?(date: moment.Moment): string | null; From c49b8de9c2cb96512d858f78d129c51684c4ee79 Mon Sep 17 00:00:00 2001 From: Christian Rackerseder Date: Thu, 14 Dec 2017 16:35:54 +0100 Subject: [PATCH 161/298] Add typings for redux-storage-engine-localstorage Removed embedded typings from redux-storage and created separate typing --- .../index.d.ts | 12 ++++++++++ ...redux-storage-engine-localstorage-tests.ts | 20 ++++++++++++++++ .../tsconfig.json | 23 +++++++++++++++++++ .../tslint.json | 1 + types/redux-storage/index.d.ts | 12 ---------- 5 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 types/redux-storage-engine-localstorage/index.d.ts create mode 100644 types/redux-storage-engine-localstorage/redux-storage-engine-localstorage-tests.ts create mode 100644 types/redux-storage-engine-localstorage/tsconfig.json create mode 100644 types/redux-storage-engine-localstorage/tslint.json diff --git a/types/redux-storage-engine-localstorage/index.d.ts b/types/redux-storage-engine-localstorage/index.d.ts new file mode 100644 index 0000000000..51f6d266df --- /dev/null +++ b/types/redux-storage-engine-localstorage/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for redux-storage-engine-localstorage 1.1 +// Project: https://github.com/react-stack/redux-storage-engine-localstorage +// Definitions by: Christian Rackerseder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { StorageEngine } from "redux-storage"; + +export type Replacer = (key: string, value: any) => any; + +export type Reviver = Replacer; + +export default function createEngine(key: string, replacer?: Replacer, reviver?: Reviver): StorageEngine; diff --git a/types/redux-storage-engine-localstorage/redux-storage-engine-localstorage-tests.ts b/types/redux-storage-engine-localstorage/redux-storage-engine-localstorage-tests.ts new file mode 100644 index 0000000000..a141c4f2c4 --- /dev/null +++ b/types/redux-storage-engine-localstorage/redux-storage-engine-localstorage-tests.ts @@ -0,0 +1,20 @@ +import { createLoader } from "redux-storage"; +import createEngine from "redux-storage-engine-localstorage"; + +let engine = createEngine('test-key'); + +createLoader(engine); + +engine = createEngine('test-key', (key, value) => { + if (typeof value === 'string') { + return 'foo'; + } + return value; +}, (key, value) => { + if (key === 'foo') { + return 'bar'; + } + return value; +}); + +createLoader(engine); diff --git a/types/redux-storage-engine-localstorage/tsconfig.json b/types/redux-storage-engine-localstorage/tsconfig.json new file mode 100644 index 0000000000..671323d17f --- /dev/null +++ b/types/redux-storage-engine-localstorage/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "redux-storage-engine-localstorage-tests.ts" + ] +} diff --git a/types/redux-storage-engine-localstorage/tslint.json b/types/redux-storage-engine-localstorage/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/redux-storage-engine-localstorage/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/redux-storage/index.d.ts b/types/redux-storage/index.d.ts index f04ee2b522..28a9dfaa2f 100644 --- a/types/redux-storage/index.d.ts +++ b/types/redux-storage/index.d.ts @@ -89,18 +89,6 @@ declare module "redux-storage-decorator-filter" { export default function (engine: StorageEngine, whitelist?: FilterList, blacklist?: FilterList): StorageEngine; } -declare module "redux-storage-engine-localstorage" { - import { StorageEngine } from "redux-storage"; - - export interface LocalStorageEngine extends StorageEngine { } - - /** - * Create local storage - * @param key localstorage key - */ - export default function createEngine(key: string): LocalStorageEngine; -} - declare module "redux-storage-engine-reactnativeasyncstorage" { import { StorageEngine } from "redux-storage"; From 084b629ffdaeee8ef947db433aebb862a9011fbe Mon Sep 17 00:00:00 2001 From: Mister 4 Eyes Date: Thu, 14 Dec 2017 10:56:37 -0500 Subject: [PATCH 162/298] Adds express flash notification definitions. --- .../express-flash-notification-tests.ts | 57 +++++++++++++++++++ types/express-flash-notification/index.d.ts | 39 +++++++++++++ .../express-flash-notification/tsconfig.json | 23 ++++++++ types/express-flash-notification/tslint.json | 1 + 4 files changed, 120 insertions(+) create mode 100644 types/express-flash-notification/express-flash-notification-tests.ts create mode 100644 types/express-flash-notification/index.d.ts create mode 100644 types/express-flash-notification/tsconfig.json create mode 100644 types/express-flash-notification/tslint.json diff --git a/types/express-flash-notification/express-flash-notification-tests.ts b/types/express-flash-notification/express-flash-notification-tests.ts new file mode 100644 index 0000000000..d5f5f3151f --- /dev/null +++ b/types/express-flash-notification/express-flash-notification-tests.ts @@ -0,0 +1,57 @@ +import * as express from "express"; +import * as flash from "express-flash-notification"; + +const app = express(); + +// Simple initialization test +app.use(flash(app)); + +// Incomplete object test +app.use(flash(app, { + sessionName: "to-flash", + utilityName: "||", + localsName: "!to-flash" +})); + +// Empty object test +app.use(flash(app, {})); + +// Functions test +app.use(flash(app, { + beforeSingleRender: (item, callback) => { callback(null, item); }, + afterAllRender: (htmlFragments, callback) => { callback(null, htmlFragments.join("\n")); } +})); + +// Full object test +app.use(flash(app, { + sessionName: "flash", + utilityName: "flash", + localsName: "flash", + viewName: "flash", + beforeSingleRender: (item, callback) => { callback(null, item); }, + afterAllRender: (htmlFragments, callback) => { callback(null, htmlFragments.join("\n")); } + })); + +app.use((req: express.Request, res: express.Response, next: express.NextFunction) => { + req.flash("info"); + req.flash("info", "I am a pretty butterfly"); + req.flash("info", "I am a pretty butterfly", "/"); + req.flash("info", "I am a pretty butterfly", true); + req.flash({ + type: "error", + message: "Lets mix things up, shall we?" + }); + + req.flash({ + type: "info", + message: "if cats rules the world", + redirect: false + }); + + req.flash({ + type: "success", + message: "Odd", + redirect: true, + url: "/" + }); +}); diff --git a/types/express-flash-notification/index.d.ts b/types/express-flash-notification/index.d.ts new file mode 100644 index 0000000000..7c9fdff97e --- /dev/null +++ b/types/express-flash-notification/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for express-flash-notification 0.5 +// Project: https://github.com/carlosascari/express-flash-notification +// Definitions by: Mister4Eyes +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as express from "express"; + +interface efnOptions { + sessionName?: string; + utilityName?: string; + localsName?: string; + viewName?: string; + beforeSingleRender?: (item: any, callback: (err: any, item: any) => void) => void; + afterAllRender?: (htmlFragments: string[], callback: (err: any, html: string) => void) => void; +} + +declare function express_flash_notification(app: express.Application, options?: efnOptions, ...args: any[]): any; + +declare namespace express_flash_notification { + const prototype: {}; +} + +declare global { + namespace Express { + interface FlashOptions { + type?: string; + message?: string; + redirect?: boolean; + url?: string; + } + interface Request { + flash(type: string, message?: string, redirect?: string|boolean): void; + flash(object: FlashOptions): void; + } + } +} + +export = express_flash_notification; diff --git a/types/express-flash-notification/tsconfig.json b/types/express-flash-notification/tsconfig.json new file mode 100644 index 0000000000..842aacf264 --- /dev/null +++ b/types/express-flash-notification/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "express-flash-notification-tests.ts" + ] +} diff --git a/types/express-flash-notification/tslint.json b/types/express-flash-notification/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/express-flash-notification/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file From fe6e2272bb37d96b43aa0da9da90f0f930d5fa0b Mon Sep 17 00:00:00 2001 From: Santiago Doldan Date: Thu, 14 Dec 2017 12:35:19 -0300 Subject: [PATCH 163/298] Add missing Elements props to react-stripe-elements --- types/react-stripe-elements/index.d.ts | 5 +++-- .../react-stripe-elements-tests.tsx | 21 +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/types/react-stripe-elements/index.d.ts b/types/react-stripe-elements/index.d.ts index 4322dfab89..9566b6a77c 100644 --- a/types/react-stripe-elements/index.d.ts +++ b/types/react-stripe-elements/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for react-stripe-elements 1.0 // Project: https://github.com/stripe/react-stripe-elements#readme // Definitions by: dan-j +// Santiago Doldan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -37,7 +38,7 @@ export namespace ReactStripeElements { } interface InjectedStripeProps { - stripe: StripeProps; + stripe?: StripeProps; } interface ElementProps extends ElementsOptions { @@ -58,7 +59,7 @@ export namespace ReactStripeElements { export class StripeProvider extends React.Component { } -export class Elements extends React.Component { +export class Elements extends React.Component { } export function injectStripe

( diff --git a/types/react-stripe-elements/react-stripe-elements-tests.tsx b/types/react-stripe-elements/react-stripe-elements-tests.tsx index 24e719957a..e737914e31 100644 --- a/types/react-stripe-elements/react-stripe-elements-tests.tsx +++ b/types/react-stripe-elements/react-stripe-elements-tests.tsx @@ -14,6 +14,7 @@ import InjectedStripeProps = ReactStripeElements.InjectedStripeProps; import ElementChangeResponse = stripe.elements.ElementChangeResponse; import ElementsOptions = stripe.elements.ElementsOptions; +import ElementsCreateOptions = stripe.elements.ElementsCreateOptions; import PatchedTokenResponse = ReactStripeElements.PatchedTokenResponse; const cardElementProps: ElementsOptions = { @@ -46,6 +47,22 @@ const cardElementProps: ElementsOptions = { hideIcon: true, }; +const fontElementsProps: ElementsCreateOptions = { + fonts: [ + { + cssSrc: "https://fonts.googleapis.com/css?family=Dosis" + }, + { + family: "Dosis, sanz", + src: "url(https://somewebsite.com/path/to/font.woff)", + style: "normal", + weight: "bold", + unicodeRange: "U+26" + } + ], + locale: "es" +}; + const ElementsWithPropsTest: React.SFC = () => (

{ onSubmit = () => { - this.props.stripe.createToken({ + this.props.stripe!.createToken({ name: '', address_line1: '', address_line2: '', @@ -133,7 +150,7 @@ class TestHOCs extends React.Component { render() { return ( - + From c59873dd583b69048b1970e208bd1aafa0dc0cbc Mon Sep 17 00:00:00 2001 From: RonanDrouglazet Date: Thu, 14 Dec 2017 17:30:07 +0100 Subject: [PATCH 164/298] append is* to wdio Client definition --- types/webdriverio/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/webdriverio/index.d.ts b/types/webdriverio/index.d.ts index f1d37d0f88..398e74de1e 100644 --- a/types/webdriverio/index.d.ts +++ b/types/webdriverio/index.d.ts @@ -1882,6 +1882,10 @@ declare namespace WebdriverIO { switchTab(windowHandle?: string): Client> & RawResult; switchTab

(windowHandle?: string): Client

; + + isIOS: boolean; + isAndroid: boolean; + isMobile: boolean; } const VERSION: string; From 01813635d48f7f35545ca51acd00f41a1cf6363e Mon Sep 17 00:00:00 2001 From: RonanDrouglazet Date: Thu, 14 Dec 2017 18:09:09 +0100 Subject: [PATCH 165/298] move is* props to the mobile Client part --- types/webdriverio/index.d.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/types/webdriverio/index.d.ts b/types/webdriverio/index.d.ts index 398e74de1e..de9a7c8833 100644 --- a/types/webdriverio/index.d.ts +++ b/types/webdriverio/index.d.ts @@ -863,6 +863,9 @@ declare namespace WebdriverIO { touchMultiPerform(actions: any): Client; touchPerform(actions: any): Client; unlock(): Client; + isIOS: boolean; + isAndroid: boolean; + isMobile: boolean; } // Property @@ -1882,10 +1885,6 @@ declare namespace WebdriverIO { switchTab(windowHandle?: string): Client> & RawResult; switchTab

(windowHandle?: string): Client

; - - isIOS: boolean; - isAndroid: boolean; - isMobile: boolean; } const VERSION: string; From 569036c4a17f47fa1682da90545168ef6708ae77 Mon Sep 17 00:00:00 2001 From: Dasa Paddock Date: Thu, 14 Dec 2017 11:38:59 -0800 Subject: [PATCH 166/298] Update for ArcGIS API for JavaScript version 4.6 --- types/arcgis-js-api/index.d.ts | 38717 ++++++++++++++++++++++++++++++- 1 file changed, 37640 insertions(+), 1077 deletions(-) diff --git a/types/arcgis-js-api/index.d.ts b/types/arcgis-js-api/index.d.ts index 9202525e55..dadb02d265 100644 --- a/types/arcgis-js-api/index.d.ts +++ b/types/arcgis-js-api/index.d.ts @@ -1,37 +1,47 @@ -// Type definitions for ArcGIS API for JavaScript 4.5 +// Type definitions for ArcGIS API for JavaScript 4.6 // Project: http://js.arcgis.com // Definitions by: Esri // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 + interface HashMap { [index: string]: T; } +interface IPromiseLike { + then(onfulfilled?: ((value: T) => TResult1 | IPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | IPromiseLike) | undefined | null): IPromiseLike; +} + interface IPromise { - always(callback?: (valueOrError: T) => IPromise | U | void): IPromise; + always(callback?: ((valueOrError: T | any) => TResult1 | IPromiseLike) | undefined | null): IPromise; cancel?(reason?: U, strict?: boolean): U; + catch(onrejected?: ((reason: any) => TResult | IPromiseLike) | undefined | null): IPromise; isCanceled?(): boolean; isFulfilled(): boolean; isRejected(): boolean; isResolved(): boolean; - otherwise(errback?: (reason: any) => IPromise | U | void): IPromise; - then(callback?: (value: T) => IPromise | U | void, errback?: (reason: any) => IPromise | U | void, progback?: (update: any) => IPromise | U | void): IPromise; + otherwise(onrejected?: ((reason: any) => TResult | IPromiseLike) | undefined | null): IPromise; + then(onfulfilled?: ((value: T) => TResult1 | IPromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | IPromiseLike) | undefined | null): IPromise; } interface IHandle { remove(): void; } + + declare namespace JSX { interface IntrinsicElements { [elementName: string]: any; } - interface Element {} + interface Element { + } } declare namespace __esri { + export class Accessor { constructor(obj?: any); @@ -52,6 +62,15 @@ declare namespace __esri { protected _set(propertyName: string, value: T): this; } + export interface AnonymousAccessor extends Object { + get?(propertyName: string): T; + get?(propertyName: string): any; + set?(propertyName: string, value: T): this; + set?(props: HashMap): this; + watch?(path: string | string[], callback: WatchCallback, sync?: boolean): WatchHandle; + } + + export type ItemCallback = (item: T, index: number) => void; @@ -108,7 +127,7 @@ declare namespace __esri { slice(begin?: number, end?: number): Collection; some(callback: ItemCallback): boolean; sort(compareFunction?: ItemCompareCallback): void; - splice(start: number, deleteCount: number, items: T[] | Collection): T[]; + splice(start: number, deleteCount: number, ...items: T[]): T[]; toArray(): T[]; unshift(...items: T[]): number; @@ -204,6 +223,10 @@ declare namespace __esri { export type MapViewPointerDownEventHandler = (event: MapViewPointerDownEvent) => void; + export type MapViewPointerEnterEventHandler = (event: MapViewPointerEnterEvent) => void; + + export type MapViewPointerLeaveEventHandler = (event: MapViewPointerLeaveEvent) => void; + export type MapViewPointerMoveEventHandler = (event: MapViewPointerMoveEvent) => void; export type MapViewPointerUpEventHandler = (event: MapViewPointerUpEvent) => void; @@ -211,21 +234,79 @@ declare namespace __esri { export type MapViewResizeEventHandler = (event: MapViewResizeEvent) => void; interface Basemap extends Accessor, Loadable, JSONSupport { + /** + * A collection of tile layers that make up the basemap's features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#baseLayers) + */ baseLayers: Collection; + /** + * An identifier used to refer to the basemap when referencing it elsewhere. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#id) + */ id: string; - loaded: boolean; + /** + * Indicates whether the basemap instance has loaded. When `true`, all the properties of the object can be accessed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#loaded) + * + * @default false + */ + readonly loaded: boolean; + /** + * The portal item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#portalItem) + */ portalItem: PortalItem; + /** + * A collection of tiled reference layers for displaying labels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#referenceLayers) + */ referenceLayers: Collection; + /** + * The URL pointing to an image that represents the basemap. When using a custom basemap in the [BasemapToggle](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html) widget, the image specified here will display in the widget. When the user clicks the image, the map's basemap will update to the basemap associated with the image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#thumbnailUrl) + */ thumbnailUrl: string; + /** + * The title of the basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#title) + */ title: string; + /** + * Creates a deep clone of this object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#clone) + * + * + */ clone(): Basemap; } interface BasemapConstructor { + /** + * Basemap is used for creating custom basemaps. These basemaps may be created from tiled services you publish to your own server or from tiled services published by third parties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) + */ + new(properties?: BasemapProperties): Basemap; + /** + * Creates a new basemap instance from a [well known basemap ID](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap). See [Map.basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) for a list of possible values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#fromId) + * + * @param id The basemap ID. + * + */ fromId(id: string): Basemap; fromJSON(json: any): Basemap; @@ -234,25 +315,94 @@ declare namespace __esri { export const Basemap: BasemapConstructor; interface BasemapProperties extends LoadableProperties { + /** + * A collection of tile layers that make up the basemap's features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#baseLayers) + */ baseLayers?: CollectionProperties; + /** + * An identifier used to refer to the basemap when referencing it elsewhere. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#id) + */ id?: string; - loaded?: boolean; + /** + * The portal item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#portalItem) + */ portalItem?: PortalItemProperties; + /** + * A collection of tiled reference layers for displaying labels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#referenceLayers) + */ referenceLayers?: CollectionProperties; + /** + * The URL pointing to an image that represents the basemap. When using a custom basemap in the [BasemapToggle](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html) widget, the image specified here will display in the widget. When the user clicks the image, the map's basemap will update to the basemap associated with the image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#thumbnailUrl) + */ thumbnailUrl?: string; + /** + * The title of the basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#title) + */ title?: string; } interface Camera extends Accessor, JSONSupport { + /** + * The field of view of the camera in degrees. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#fov) + * + * @default 55 + */ fov: number; + /** + * The compass heading of the camera in degrees. Heading is zero when north is the top of the screen. It increases as the view rotates clockwise. The angles are always normalized between 0 and 360 degrees. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading) + * + * @default 0 + */ heading: number; + /** + * The position of the camera defined by a map point. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#position) + */ position: Point; + /** + * The tilt of the camera in degrees with respect to the surface as projected down from the camera position. Tilt is zero when looking straight down at the surface and 90 degrees when the camera is looking parallel to the surface. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#tilt) + * + * @default 0 + */ tilt: number; + /** + * Creates a deep clone of the camera object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#clone) + * + * + */ clone(): Camera; } interface CameraConstructor { + /** + * The camera defines the [position](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#position), [tilt](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#tilt), and [heading](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading) of the point from which the [SceneView's](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) visible extent is observed. It is not associated with device hardware. This class only applies to 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html) + */ + new(properties?: CameraProperties): Camera; fromJSON(json: any): Camera; @@ -261,83 +411,455 @@ declare namespace __esri { export const Camera: CameraConstructor; interface CameraProperties { + /** + * The field of view of the camera in degrees. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#fov) + * + * @default 55 + */ fov?: number; + /** + * The compass heading of the camera in degrees. Heading is zero when north is the top of the screen. It increases as the view rotates clockwise. The angles are always normalized between 0 and 360 degrees. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading) + * + * @default 0 + */ heading?: number; + /** + * The position of the camera defined by a map point. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#position) + */ position?: PointProperties; + /** + * The tilt of the camera in degrees with respect to the surface as projected down from the camera position. Tilt is zero when looking straight down at the surface and 90 degrees when the camera is looking parallel to the surface. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#tilt) + * + * @default 0 + */ tilt?: number; } interface Color { + /** + * The alpha value. This value can be any number between `0` and `1` and represents the opacity of the Color. `0` indicates the color is fully transparent and `1` indicates it is fully opaque. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#a) + */ a: number; + /** + * The blue value. This value can range between `0` and `255`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#b) + */ b: number; + /** + * The green value. This value can range between `0` and `255`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#g) + */ g: number; + /** + * The red value. This value can range between `0` and `255`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#r) + */ r: number; + /** + * Creates a deep clone of the Color instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#clone) + * + * + */ clone(): Color; + /** + * Takes a named string, hex string, array of rgb or rgba values, an object with r, g, b, and a properties, or another Color object and sets this color instance to the input value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#setColor) + * + * @param color The new color value. This parameter can be a string representing a named color or a hex value; an array of three or four numbers representing r, g, b, a values; or an object with r, g, b, a properties. + * + */ setColor(color: string | number[] | any): Color; + /** + * Returns a CSS color string in rgba form representing the Color instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#toCss) + * + * @param includeAlpha If `true`, the alpha value will be included in the result. + * + */ toCss(includeAlpha?: boolean): string; + /** + * Returns a CSS color string in hexadecimal form that represents the Color instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#toHex) + * + * + */ toHex(): string; + /** + * Returns a JSON object with all the values from a Color instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#toJSON) + * + * + */ toJSON(): any; + /** + * Returns a 3-component array of rgb values that represent the Color instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#toRgb) + * + * + */ toRgb(): number[]; + /** + * Returns a 4-component array of rgba values that represent the Color instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#toRgba) + * + * + */ toRgba(): number[]; } interface ColorConstructor { + /** + * Creates a new color object by passing either a hex, rgba, or named color value. This class inherits all attributes from **dojo/_base/Color** to provide functions for setting colors. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) + */ + + /** + * Creates a Color instance by blending two colors using a weight factor. Optionally accepts a Color object to update and return instead of creating a new object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#blendColors) + * + * @param start The start color. + * @param end The end color. + * @param weight The weight value is a number from 0 to 1, with 0.5 being a 50/50 blend. + * @param obj A previously allocated Color object to reuse for the result. + * + */ blendColors(start: Color, end: Color, weight: number, obj?: Color): Color; + new(color: string | number[] | any): Color; + /** + * Creates a Color instance using a 3 or 4 element array, mapping each element in sequence to the rgb(a) values of the color. Optionally accepts a Color object to update with the color value and return instead of creating a new object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#fromArray) + * + * @param a The input array. + * @param obj A previously allocated Color object to reuse for the result. + * + */ fromArray(a: number[], obj?: Color): Color; + /** + * Creates a Color instance from a hex string with a '#' prefix. Supports 12-bit #rgb shorthand. Optionally accepts a Color object to update with the parsed value and return instead of creating a new object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#fromHex) + * + * @param color The input color in a hex string. + * @param obj A previously allocated Color object to reuse for the result. + * + */ fromHex(color: string, obj?: Color): Color; + /** + * Creates a new Color instance, and initializes it with values from a JSON object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#fromJSON) + * + * @param json A JSON representation of the instance. + * + */ fromJSON(json: any): Color; + /** + * Creates a Color instance from a string of the form "rgb()" or "rgba()". Optionally accepts a Color object to update with the parsed value and return instead of creating a new object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#fromRgb) + * + * @param color The input color in a string of the form "rgb()" or "rgba()". + * @param obj A previously allocated Color object to reuse for the result. + * + */ fromRgb(color: string, obj?: Color): Color; + /** + * Creates a Color instance by parsing a generic string. Accepts hex, rgb, and rgba style color values. Optionally accepts a Color object to update with the parsed value and return instead of creating a new object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html#fromString) + * + * @param str The input value. + * @param obj A previously allocated Color object to reuse for the result. + * + */ fromString(str: string, obj?: Color): Color; } export const Color: ColorConstructor; + /** + * Configure global properties of the library. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html) + */ interface config { + /** + * The default [GeometryService](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html) used by widgets and other operations, such as on-the-fly projections. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#geometryServiceUrl) + * + * @default "https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer" + */ geometryServiceUrl: string; + /** + * The URL for the utility service used by [GeoRSSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html) to convert GeoRSS documents. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#geoRSSServiceUrl) + * + * @default "https://utility.arcgis.com/sharing/rss" + */ geoRSSServiceUrl: string; + /** + * The URL for the utility service used by [KMLLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html) to convert KML documents. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#kmlServiceUrl) + * + * @default "https://utility.arcgis.com/sharing/kml" + */ kmlServiceUrl: string; + /** + * The URL of the portal instance. If using an on-premise portal, this value should be set to the portal instance, for example: `https://www.example.com/arcgis` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl) + * + * @default "https://www.arcgis.com" + */ portalUrl: string; + /** + * An object with properties that control various aspects of communication between the library and web servers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + */ request: configRequest; + /** + * The AMD loader's configuration object, which is loaded with each worker. Modify the configuration to specify locations of packages to be loaded with [the workers framework](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-workers.html) or to define a feature detection. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#workers) + */ workers: configWorkers; } export const config: config; - export interface configRequest { + + export interface configRequest extends Object { + /** + * Indicates whether the library automatically detects if [CORS](http://enable-cors.org/) (Cross-Origin Resource Sharing) specification is supported by ArcGIS Servers used in your application. Upon successful detection, the server will be added to `corsEnabledServers` list. CORS detection will not be performed for a server if it is already listed in `corsEnabledServers`. The default is `true` if your application is running in a web browser, or `false` if your application is running on [Apache Cordova](https://cordova.apache.org/) platform. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + */ corsDetection?: boolean; + /** + * Number of seconds to wait for response from the ArcGIS Server during CORS detection. If the detection is not complete before this time expires, then it is assumed that the server does not support CORS. Applicable when `corsDetection` is true. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + * + * @default 15 + */ corsDetectionTimeout?: number; + /** + * A list of servers known to support CORS specification. Out of the box, this list includes many Esri hosted servers that are known to support CORS and is updated at every release as the list grows. The library is capable of automatically detecting CORS support for servers used in an application (see `corsDetection`), but if you are already aware that a server supports CORS, then it should be added to this list. Since the API includes some servers by default it's important to add items onto this array rather than overwriting it. The following servers are enabled by default: + * * `basemaps.arcgis.com` (added in 4.3) + * * `demographics1.arcgis.com` (added in 4.4) + * * `demographics2.arcgis.com` (added in 4.4) + * * `demographics3.arcgis.com` (added in 4.4) + * * `demographics4.arcgis.com` (added in 4.4) + * * `demographics5.arcgis.com` (added in 4.4) + * * `demographics6.arcgis.com` (added in 4.4) + * * `elevation3d.arcgis.com` + * * `geocode.arcgis.com` + * * `geoenrich.arcgis.com` + * * `js.arcgis.com` + * * `server.arcgisonline.com` + * * `services.arcgis.com` + * * `services.arcgisonline.com` + * * `services1.arcgis.com` + * * `services2.arcgis.com` + * * `services3.arcgis.com` + * * `services4.arcgis.com` + * * `services5.arcgis.com` + * * `services6.arcgis.com` + * * `services7.arcgis.com` + * * `services8.arcgis.com` + * * `services9.arcgis.com` + * * `static.arcgis.com` + * * `tiles.arcgis.com` + * * `tiles1.arcgis.com` + * * `tiles2.arcgis.com` + * * `tiles3.arcgis.com` + * * `tiles4.arcgis.com` + * * `utility.arcgis.com` (added in 4.4) + * * `utility.arcgisonline.com` + * * `www.arcgis.com` + * + * + * Example: + * ```js + * // Add a known server to the list. + * require(["esri/config"], function(esriConfig) { + * esriConfig.request.corsEnabledServers.push(".:"); + * }); + * ``` + * + * You can also pass objects to this property with the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + */ corsEnabledServers?: (string | configRequestCorsEnabledServers)[]; + /** + * Indicates whether the proxy specified in `proxyUrl` is used for all AJAX requests made using [request](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html) and images added using `` element. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + * + * @default false + */ forceProxy?: boolean; + /** + * List of domain suffixes known to support https. This will automatically upgrade requests made to such domains to use https instead of http when the application is not running on http. Note that port numbers should not be included in the domain suffix to be matched. If no `httpsDomains` list exists , the API redirects all calls using https. If the list exists and a domain of a required http resource is not listed, the API sends the URL as it is specified within the code. Likewise, if the list exists and the domain of a required http resource is listed in it, the API sends an https request to that resource. The list includes the following domain suffixes by default: + * * `arcgis.com` + * * `arcgisonline.com` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + */ httpsDomains?: string[]; + /** + * Maximum number of characters allowed in the URL for HTTP GET requests made by [request](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html). If this limit is exceeded, HTTP POST method will be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + * + * @default 2000 + */ maxUrlLength?: number; + /** + * Resource proxy for your application. It is used by the library when communicating with a web server hosted on a domain that is different from the domain where your application is hosted. The library may or may not use the proxy depending on the type of request made, whether the server support CORS, whether the application is being run on older versions of browsers etc. To keep it simple, it is recommended that you always configure a resource proxy for your application. You can download the resource proxy from this [GitHub repo](https://github.com/Esri/resource-proxy). + * ```js + * require(["esri/config"], function(esriConfig) { + * esriConfig.request.proxyUrl = "/resource-proxy/Java/proxy.jsp"; + * }); + * ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + */ proxyUrl?: string; + /** + * Number of milliseconds [request](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html) will wait for response from a server. If a server fails to respond before this time expires, then the request is considered to have encountered an error. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + * + * @default 60000 + */ timeout?: number; + /** + * Indicates whether the library will use [CORS](http://enable-cors.org/)-enabled requests when communicating with a web server hosted on a domain that is different from the domain where the application is hosted. If `true`, AJAX requests are directly made to servers that support CORS. If `with-credentials` is specified, then AJAX requests will use credentials stored in a client's cookies. If `false`, direct requests are not made. A proxy will be used if available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + * + * @default with-credentials + */ useCors?: string | boolean; + /** + * **Since:** 4.5 Indicates whether `esri/request` will request a credential from `IdentityManager`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + * + * @default true + */ useIdentity?: boolean; + /** + * A proxy rule defines a proxy for a set of resources with an identical URL prefix. When using [esriRequest](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html), if a target URL matches a rule, then the request will be sent to the specified proxy. Rather than populating this array directly, use the urlUtils.addProxyRule() method. Rule objects have the following properties: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + */ proxyRules?: configRequestProxyRules[]; } - export interface configRequestCorsEnabledServers { + + export interface configRequestCorsEnabledServers extends Object { + /** + * The host name of the server to add to the list of CORS-enabled servers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + */ host?: string; + /** + * Indicates whether requests made to the associated server should include credentials such as cookies and authorization headers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + * + * @default false + */ withCredentials?: boolean; } - export interface configRequestProxyRules { + + export interface configRequestProxyRules extends Object { + /** + * The URL of the proxy. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + */ proxyUrl?: string; + /** + * URL prefix for resources that need to be accessed through a specific proxy. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) + */ urlPrefix?: string; } - export interface configWorkers { + + export interface configWorkers extends Object { + /** + * The configuration parameters for [the workers framework](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-workers.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#workers) + */ loaderConfig?: configWorkersLoaderConfig; } - export interface configWorkersLoaderConfig { + + export interface configWorkersLoaderConfig extends Object { + /** + * Determines if the specified feature capabilities are supported. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#workers) + */ has?: any; + /** + * Map of module id fragments to file paths. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#workers) + */ paths?: any; + /** + * Map paths in module identifiers to different paths. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#workers) + */ map?: any; + /** + * An array of objects which provide the package name and its location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#workers) + */ packages?: any[]; } @@ -345,28 +867,137 @@ declare namespace __esri { export type WatchCallback = (newValue: any, oldValue: any, propertyName: string, target: Accessor) => void; - export interface WatchHandle { + /** + * Represents a watch created when an object invokes [watch()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html#watch). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html#WatchHandle) + */ + export interface WatchHandle extends Object { + /** + * Removes the watch handle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html#WatchHandle) + * + * + */ remove(): void; } + interface decorators { + /** + * A property decorator that creates a two-way binding between the property it decorates and an inner property of one of its members. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#aliasOf) + * + * @param propertyName The aliased property name. + * + */ aliasOf(propertyName: string): Function; + /** + * This method decorator is used to define the method that will cast a property from a class. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#cast) + * + * @param propertyName The property name the function will cast. + * + */ cast(propertyName: string): Function; + /** + * This parameter decorator is used to define the function or class for a parameter of a method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#cast) + * + * @param classFunction The function or class to cast the parameter + * + */ cast(classFunction: Function): Function; + /** + * A function that can be used as a class. It extends [expression](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-1-6.html#extending-expressions) and is used in conjunction with the `@subclass` decorator to create a class compatible to [dojo.declare](https://dojotoolkit.org/reference-guide/1.10/dojo/declare.html). Please refer to the `subclass` documentation for further information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#declared) + * + * @param baseClass The class to extend. + * @param mixinClasses The mixin classes used to extend the base class. + * + */ declared(baseClass: T, ...mixinClasses: any[]): T; + /** + * This convenience decorator is used to define an [Accessor](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html) property. Any property defined with this decorator can now be `get` and `set`. In addition, you can [watch for any property changes](https://developers.arcgis.com/javascript/latest/guide/working-with-props/index.html). Many times this decorator is used in conjunction with the [@renderable](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-widget.html) decorator. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#property) + * + * @param propertyMetadata An object describing the property. + * @param propertyMetadata.dependsOn Property names of dependencies. + * @param propertyMetadata.type The constructor used to [autocast](https://developers.arcgis.com/javascript/latest/guide/autocasting/index.html) the property. + * @param propertyMetadata.cast The function to use to [autocast](https://developers.arcgis.com/javascript/latest/guide/autocasting/index.html) the property. Alternative to define the `type`. The function is called with the value set by the user and should return the cast value. + * @param propertyMetadata.readOnly Indicates whether the property is read-only. + * @param propertyMetadata.constructOnly Indicates whether the property can be set during construction but is otherwise read-only. + * @param propertyMetadata.aliasOf The property decorator that creates a two-way binding between the property it decorates and an inner property of one of its members. + * @param propertyMetadata.value The default value for the property. + * + */ property(propertyMetadata?: decoratorsPropertyPropertyMetadata): Function; + /** + * A class decorator that must be used together with the `declared` function to create a class compatible to [dojo.declare](https://dojotoolkit.org/reference-guide/1.10/dojo/declare.html). It supports both single and multiple inheritance and can be considered the underlying functionality needed when creating 4.x classes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#subclass) + * + * @param declaredClass The subclass name. + * + */ subclass(declaredClass?: string): Function; } export const decorators: decorators; - export interface decoratorsPropertyPropertyMetadata { + + export interface decoratorsPropertyPropertyMetadata extends Object { + /** + * Property names of dependencies. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#property) + */ dependsOn?: string[]; + /** + * The constructor used to [autocast](https://developers.arcgis.com/javascript/latest/guide/autocasting/index.html) the property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#property) + */ type?: Function; + /** + * The function to use to [autocast](https://developers.arcgis.com/javascript/latest/guide/autocasting/index.html) the property. Alternative to define the `type`. The function is called with the value set by the user and should return the cast value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#property) + */ cast?: Function; + /** + * Indicates whether the property is read-only. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#property) + * + * @default false + */ readOnly?: boolean; + /** + * Indicates whether the property can be set during construction but is otherwise read-only. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#property) + * + * @default false + */ constructOnly?: boolean; + /** + * The property decorator that creates a two-way binding between the property it decorates and an inner property of one of its members. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#property) + */ aliasOf?: string; + /** + * The default value for the property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html#property) + */ value?: any; } @@ -382,182 +1013,812 @@ declare namespace __esri { + interface Error { + /** + * The details object provides additional details specific to the error, giving more information about why the error was raised. For example, the details object for esriRequest includes additional information to help the developer diagnose issues with a problematic request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Error.html#details) + */ details: any; + /** + * A message describing the details of the error. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Error.html#message) + */ message: string; + /** + * A unique error name. This can be used to map to a localized error message to present to the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Error.html#name) + */ name: string; } export const Error: Error; export class Evented { + /** + * Emits an event on the instance. This method should only be used when creating subclasses of this class. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Evented.html#emit) + * + * @param type The name of the event. + * @param event The event payload. + * + */ protected emit(type: string, event: any): void; + /** + * Indicates whether there is an event listener on the instance that matches the provided event name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Evented.html#hasEventListener) + * + * @param type The name of the event. + * + */ hasEventListener(type: string): boolean; + /** + * Registers an event handler on the instance. Call this method to hook an event with a listener. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Evented.html#on) + * + * @param type The name of event to listen for. + * @param listener The function to call when the event is fired. + * + */ on(type: string, listener: EventHandler): IHandle; } export type EventHandler = (event: any) => void; interface JSONSupport { + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-JSONSupport.html#toJSON) + * + * + */ toJSON(): any; } interface JSONSupportConstructor { + + new(): JSONSupport; + /** + * Creates a new instance of [this class]() and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input `json` parameter often comes from a response to a query operation in the REST API or a [toJSON()](http://pro.arcgis.com/en/pro-app/tool-reference/conversion/features-to-json.htm) method from another ArcGIS product. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for details and examples of when and how to use this function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-JSONSupport.html#fromJSON) + * + * @param json A JSON representation of the instance in the ArcGIS format. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Classification_objects/02r30000019z000000/) for examples of the structure of various input JSON objects. + * + */ fromJSON(json: any): any; } export const JSONSupport: JSONSupportConstructor; + interface lang { + /** + * Use this method to deeply clone objects with properties that are computed or have their own `clone()` method. For example, if you are creating an object that stores an initial extent and a spatial reference for your application, you can use `esriLang.clone(initialProps)` to clone this object so that the `extent` and `spatialReference` are properly cloned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-lang.html#clone) + * + * @param elem The object to be cloned. + * + */ clone(elem: any): any; } export const lang: lang; interface Loadable { - loadError: Error; - loadStatus: string; - loadWarnings: any[]; + /** + * The Error object returned if an error occurred while loading. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#loadError) + * + * @default null + */ + readonly loadError: Error; + /** + * Represents the status of a [load](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#load) operation. + * + * Value | Description + * ------|------------ + * not-loaded | The object's resources have not loaded. + * loading | The object's resources are currently loading. + * loaded | The object's resources have loaded without errors. + * failed | The object's resources failed to load. See [loadError](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#loadError) for more details. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#loadStatus) + * + * @default not-loaded + */ + readonly loadStatus: string; + /** + * A list of warnings which occurred while loading. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#loadWarnings) + */ + readonly loadWarnings: any[]; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `always()` may be used to execute a function if the promise is rejected or resolved. The input function will always execute no matter the response. For more information about promises, see the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#always) + * + * @param callbackOrErrback The function to execute when the promise is rejected or resolved. + * + */ always(callbackOrErrback?: Function): IPromise; + /** + * Cancels a [load()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#load) operation if it is already in progress. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#cancelLoad) + * + * + */ cancelLoad(): void; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `isFulfilled()` may be used to verify if the promise is fulfilled (either resolved or rejected). If it is fulfilled, `true` will be returned. See the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page for more information about promises. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#isFulfilled) + * + * + */ isFulfilled(): boolean; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `isRejected()` may be used to verify if the promise is rejected. If it is rejected, `true` will be returned. See the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page for more information about promises. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#isRejected) + * + * + */ isRejected(): boolean; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `isResolved()` may be used to verify if the promise is resolved. If it is resolved, `true` will be returned. See the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page for more information about promises. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#isResolved) + * + * + */ isResolved(): boolean; + /** + * Loads the resources referenced by this class. This method automatically executes for a [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) and all of the resources it references in [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) if the view is constructed with a map instance. This method must be called by the developer when accessing a resource that will not be loaded in a [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#load) + * + * + */ load(): IPromise; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Use `otherwise()` to call a function once the promise is rejected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#otherwise) + * + * @param errback The function to execute when the promise fails. + * + */ otherwise(errback?: Function): IPromise; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `then()` may be leveraged once an instance of the class is created. This method takes two input parameters: a `callback` function and an `errback` function. The `callback` executes when the promise resolves (when the instance of the class loads). The `errback` executes if the promise fails. See the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page for additional details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#then) + * + * @param callback The function to call when the promise resolves. + * @param errback The function to execute when the promise fails. + * @param progback The function to invoke when the promise emits a progress update. + * + */ then(callback?: Function, errback?: Function, progback?: Function): IPromise; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `when()` may be leveraged once an instance of the class is created. This method takes two input parameters: a `callback` function and an `errback` function. The `callback` executes when the promise resolves (when the instance of the class loads). The `errback` executes if the promise fails. See the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page for additional details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Loadable.html#when) + * + * @param callback The function to call when the promise resolves. + * @param errback The function to execute when the promise fails. + * @param progback The function to invoke when the promise emits a progress update. + * + */ + when(callback?: Function, errback?: Function, progback?: Function): IPromise; } interface LoadableConstructor { + + new(): Loadable; } export const Loadable: LoadableConstructor; interface LoadableProperties { - loadError?: Error; - loadStatus?: string; - loadWarnings?: any[]; + } interface corePromise { + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `always()` may be used to execute a function if the promise is rejected or resolved. The input function will always execute no matter the response. For more information about promises, see the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Promise.html#always) + * + * @param callbackOrErrback The function to execute when the promise is rejected or resolved. + * + */ always(callbackOrErrback?: Function): IPromise; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `isFulfilled()` may be used to verify if the promise is fulfilled (either resolved or rejected). If it is fulfilled, `true` will be returned. See the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page for more information about promises. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Promise.html#isFulfilled) + * + * + */ isFulfilled(): boolean; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `isRejected()` may be used to verify if the promise is rejected. If it is rejected, `true` will be returned. See the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page for more information about promises. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Promise.html#isRejected) + * + * + */ isRejected(): boolean; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `isResolved()` may be used to verify if the promise is resolved. If it is resolved, `true` will be returned. See the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page for more information about promises. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Promise.html#isResolved) + * + * + */ isResolved(): boolean; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Use `otherwise()` to call a function once the promise is rejected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Promise.html#otherwise) + * + * @param errback The function to execute when the promise fails. + * + */ otherwise(errback?: Function): IPromise; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `then()` may be leveraged once an instance of the class is created. This method takes two input parameters: a `callback` function and an `errback` function. The `callback` executes when the promise resolves (when the instance of the class loads). The `errback` executes if the promise fails. See the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page for additional details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Promise.html#then) + * + * @param callback The function to call when the promise resolves. + * @param errback The function to execute when the promise fails. + * @param progback The function to invoke when the promise emits a progress update. + * + */ then(callback?: Function, errback?: Function, progback?: Function): IPromise; + /** + * An instance of this class is a [Promise](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html). Therefore `when()` may be leveraged once an instance of the class is created. This method takes two input parameters: a `callback` function and an `errback` function. The `callback` executes when the promise resolves (when the instance of the class loads). The `errback` executes if the promise fails. See the [Working with Promises](https://developers.arcgis.com/javascript/latest/guide/working-with-promises/index.html) guide page for additional details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Promise.html#when) + * + * @param callback The function to call when the promise resolves. + * @param errback The function to execute when the promise fails. + * @param progback The function to invoke when the promise emits a progress update. + * + */ + when(callback?: Function, errback?: Function, progback?: Function): IPromise; } interface corePromiseConstructor { + + new(): corePromise; } export const corePromise: corePromiseConstructor; + interface promiseUtils { + /** + * Convenience utility method to wait for a number of promises to either resolve or reject. The resulting promise resolves to an array of result objects containing the promise and either a value if the promise resolved, or an error if the promise rejected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-promiseUtils.html#eachAlways) + * + * @param promises Array of promises, or object where each property is a promise. + * + */ eachAlways(promises: IPromise[] | any): IPromise | any; + /** + * A convenience utility method for filtering an array of values using an asynchronous predicate function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-promiseUtils.html#filter) + * + * @param input The array of input values to filter. + * @param predicate A predicate function returning a promise. Only array entries for which the returned promise contains `true` are kept. + * + */ filter(input: T[], predicate: FilterPredicateCallback): IPromise; + /** + * Convenience utility method to create a promise that has been rejected with a provided error value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-promiseUtils.html#reject) + * + * @param error The error to reject the resulting promise with. + * + */ reject(error?: any): IPromise; + /** + * Convenience utility method to create a promise that will be resolved with a provided value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-promiseUtils.html#resolve) + * + * @param value The value to resolve the resulting promise with. + * + */ resolve(value?: T): IPromise; } export const promiseUtils: promiseUtils; - export interface EachAlwaysResult { + /** + * The result object for a promise passed to [promiseUtils.eachAlways](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-promiseUtils.html#eachAlways). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-promiseUtils.html#EachAlwaysResult) + */ + export interface EachAlwaysResult extends Object { + /** + * The promise that has been fulfilled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-promiseUtils.html#EachAlwaysResult) + */ promise: IPromise; - value: any; - error: any; + /** + * The value with which the promise resolved. Defined only if the promise resolved. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-promiseUtils.html#EachAlwaysResult) + */ + value?: any; + /** + * The error with which the promise rejected. Defined only if the promise rejected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-promiseUtils.html#EachAlwaysResult) + */ + error?: any; } export type FilterPredicateCallback = (value: any, index: number) => IPromise; + interface requireUtils { + /** + * Dynamically requires one or more modules and returns a promise that resolves when all the specified modules have loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-requireUtils.html#when) + * + * @param moduleRequire The `require` function used to load the modules. This is the AMD alias (e.g. the `moduleRequire` reference in the snippets below) used to reference the `require` module. + * @param moduleNames The names of the modules to load. + * + */ when(moduleRequire: any, moduleNames: string[] | string): IPromise; } export const requireUtils: requireUtils; + interface urlUtils { + /** + * Adds the given proxy rule to the proxy rules list: `esriConfig.request.proxyRules`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-urlUtils.html#addProxyRule) + * + * @param rule An object specifying a URL that should use the proxy. See the object specification table below for the required properties of this object. + * @param rule.proxyUrl The URL of the proxy. + * @param rule.urlPrefix The URL prefix of the resources that should be accessed through the given proxy. + * + */ addProxyRule(rule: urlUtilsAddProxyRuleRule): number; + /** + * Returns the proxy rule that matches the given URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-urlUtils.html#getProxyRule) + * + * @param url The URL of the resources accessed via proxy. + * + */ getProxyRule(url: string): any; + /** + * Converts the URL arguments to an object representation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-urlUtils.html#urlToObject) + * + * @param url The input URL. + * + */ urlToObject(url: string): any; } export const urlUtils: urlUtils; - export interface urlUtilsAddProxyRuleRule { + + export interface urlUtilsAddProxyRuleRule extends Object { + /** + * The URL of the proxy. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-urlUtils.html#addProxyRule) + */ proxyUrl: string; + /** + * The URL prefix of the resources that should be accessed through the given proxy. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-urlUtils.html#addProxyRule) + */ urlPrefix: string; } + interface watchUtils { + /** + * Watches a property for changes and calls the callback with the initial value of the property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#init) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call with the initial value of the property when the property changes. + * + */ init(obj: Accessor, propertyName: string | string[], callback: WatchCallback): WatchHandle; - on(obj: Accessor, propertyName: string, eventName: string, eventHandler: Function, attachedHandler?: EventAttachedCallback, detachedHandler?: EventAttachedCallback): WatchHandle; - once(obj: Accessor, propertyName: string, callback?: WatchCallback): PromisedWatchHandle; - pausable(obj: Accessor, propertyName: string, callback?: WatchCallback): PausableWatchHandle; + /** + * Watches a property for changes and automatically attaches and detaches an event handler for a given event to the property value as needed. The attachedHandler and detachedHandler are optional and if provided will be called whenever the event handler is attached and detached respectively. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#on) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param eventName The name of the event to attach the event handler for. + * @param eventHandler The event handler callback function. + * @param attachedHandler Callback called each time the event handler is attached. + * @param detachedHandler Callback called each time the event handler is detached. + * + */ + on(obj: Accessor, propertyName: string | string[], eventName: string, eventHandler: Function, attachedHandler?: EventAttachedCallback, detachedHandler?: EventAttachedCallback): WatchHandle; + /** + * Watches a property for changes once. The returned watch handle is removed after the first time the callback has been invoked. The returned handle additionally implements the Promise interface and can be used to create a promise chain to asynchronously handle a property value becoming truthy. The promise result is an object containing a `value`, `oldValue`, `propertyName` and `target`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#once) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + once(obj: Accessor, propertyName: string | string[], callback?: WatchCallback): PromisedWatchHandle; + /** + * Watches a property for changes. The returned handle can be paused (and resumed) to temporarily prevent the callback from being called on property changes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#pausable) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + pausable(obj: Accessor, propertyName: string | string[], callback?: WatchCallback): PausableWatchHandle; + /** + * Watches a property for changes. This is an alias for [Accessor.watch()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html#watch), provided for completeness. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#watch) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ watch(obj: Accessor, propertyName: string | string[], callback: WatchCallback): WatchHandle; - when(obj: Accessor, propertyName: string, callback: WatchCallback): WatchHandle; - whenDefined(obj: Accessor, propertyName: string, callback: WatchCallback): WatchHandle; - whenDefinedOnce(obj: Accessor, propertyName: string, callback?: WatchCallback): PromisedWatchHandle; - whenFalse(obj: Accessor, propertyName: string, callback: WatchCallback): WatchHandle; - whenFalseOnce(obj: Accessor, propertyName: string, callback?: WatchCallback): PromisedWatchHandle; - whenNot(obj: Accessor, propertyName: string, callback: WatchCallback): WatchHandle; - whenNotOnce(obj: Accessor, propertyName: string, callback?: WatchCallback): PromisedWatchHandle; - whenOnce(obj: Accessor, propertyName: string, callback?: WatchCallback): PromisedWatchHandle; - whenTrue(obj: Accessor, propertyName: string, callback: WatchCallback): WatchHandle; - whenTrueOnce(obj: Accessor, propertyName: string, callback?: WatchCallback): PromisedWatchHandle; - whenUndefined(obj: Accessor, propertyName: string, callback: WatchCallback): WatchHandle; - whenUndefinedOnce(obj: Accessor, propertyName: string, callback?: WatchCallback): PromisedWatchHandle; + /** + * Watches a property for becoming truthy. As with module:esri/core/watchUtils#init, the callback is called initially if the property is initially truthy. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#when) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + when(obj: Accessor, propertyName: string | string[], callback: WatchCallback): WatchHandle; + /** + * Watches a property for becoming `defined`. As with init(), the callback is called if the property is initially defined. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#whenDefined) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + whenDefined(obj: Accessor, propertyName: string | string[], callback: WatchCallback): WatchHandle; + /** + * Watches a property for becoming `defined` once. As with init(), the callback is called if the property is initially `defined`. The returned watch handle is removed after the first time the callback has been invoked. The returned handle additionally implements the Promise interface and can be used to create a promise chain to asynchronously handle a property value becoming defined. The promise result is an object containing a `value`, `oldValue`, `propertyName` and `target`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#whenDefinedOnce) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + whenDefinedOnce(obj: Accessor, propertyName: string | string[], callback?: WatchCallback): PromisedWatchHandle; + /** + * Watches a property for becoming `false`. As with init(), the callback is called if the property is initially `false`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#whenFalse) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + whenFalse(obj: Accessor, propertyName: string | string[], callback: WatchCallback): WatchHandle; + /** + * Watches a property for becoming `false` once. As with init(), the callback is called if the property is initially `false`. The returned watch handle is removed after the first time the callback has been invoked. The returned handle additionally implements the Promise interface and can be used to create a promise chain to asynchronously handle a property value becoming false. The promise result is an object containing a `value`, `oldValue`, `propertyName` and `target`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#whenFalseOnce) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + whenFalseOnce(obj: Accessor, propertyName: string | string[], callback?: WatchCallback): PromisedWatchHandle; + /** + * Watches a property for becoming falsy. As with module:esri/core/watchUtils#init, the callback is called initially if the property is initially falsy. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#whenNot) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + whenNot(obj: Accessor, propertyName: string | string[], callback: WatchCallback): WatchHandle; + /** + * Watches a property for becoming falsy once. As with init(), the callback is called if the property is initially falsy. The returned watch handle is removed after the first time the callback has been invoked. The returned handle additionally implements the Promise interface and can be used to create a promise chain to asynchronously handle a property value becoming falsy. The promise result is an object containing a `value`, `oldValue`, `propertyName` and `target`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#whenNotOnce) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + whenNotOnce(obj: Accessor, propertyName: string | string[], callback?: WatchCallback): PromisedWatchHandle; + /** + * Watches a property for becoming truthy once. As with init(), the callback is called if the property is initially truthy. The returned watch handle is removed after the first time the callback has been invoked. The returned handle additionally implements the Promise interface and can be used to create a promise chain to asynchronously handle a property value becoming truthy. The promise result is an object containing a `value`, `oldValue`, `propertyName` and `target`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#whenOnce) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + whenOnce(obj: Accessor, propertyName: string | string[], callback?: WatchCallback): PromisedWatchHandle; + /** + * Watches a property for becoming `true`. As with init(), the callback is called if the property is initially `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#whenTrue) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + whenTrue(obj: Accessor, propertyName: string | string[], callback: WatchCallback): WatchHandle; + /** + * Watches a property for becoming `true` once. As with init(), the callback is called if the property is initially `true`. The returned watch handle is removed after the first time the callback has been invoked. The returned handle additionally implements the Promise interface and can be used to create a promise chain to asynchronously handle a property value becoming true. The promise result is an object containing a `value`, `oldValue`, `propertyName` and `target`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#whenTrueOnce) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + whenTrueOnce(obj: Accessor, propertyName: string | string[], callback?: WatchCallback): PromisedWatchHandle; + /** + * Watches a property for becoming `undefined`. As with init(), the callback is called if the property is initially `undefined`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#whenUndefined) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + whenUndefined(obj: Accessor, propertyName: string | string[], callback: WatchCallback): WatchHandle; + /** + * Watches a property for becoming `undefined` once. As with init(), the callback is called if the property is initially `undefined`. The returned watch handle is removed after the first time the callback has been invoked. The returned handle additionally implements the Promise interface and can be used to create a promise chain to asynchronously handle a property value becoming undefined. The promise result is an object containing a `value`, `oldValue`, `propertyName` and `target`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#whenUndefinedOnce) + * + * @param obj The object containing the property to watch. + * @param propertyName The name of the property to watch. + * @param callback The function to call when the property changes. + * + */ + whenUndefinedOnce(obj: Accessor, propertyName: string | string[], callback?: WatchCallback): PromisedWatchHandle; } export const watchUtils: watchUtils; export type EventAttachedCallback = (target: any, propName: string, obj: Accessor, eventName: string) => void; - export interface PausableWatchHandle { + /** + * Represents a watch created when an object invokes [watch()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html#watch). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#PausableWatchHandle) + */ + export interface PausableWatchHandle extends Object { + /** + * Removes the watch handle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#PausableWatchHandle) + * + * + */ remove(): void; + /** + * Pauses the handle preventing changes to invoke the associated callback. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#PausableWatchHandle) + * + * + */ pause(): void; + /** + * Resumes a paused the handle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-watchUtils.html#PausableWatchHandle) + * + * + */ resume(): void; } export interface PromisedWatchHandle extends IPromise { + remove(): void; } + /** + * This module is a utility framework that simplifies the use of [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) in the ArcGIS API for JavaScript. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-workers.html) + */ interface workers { + /** + * Opens a connection to workers and loads a script with the workers framework. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-workers.html#open) + * + * @param client The instance of the client which will be using the [Connection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-workers-Connection.html). + * @param modulePath A fully qualified URL to a script to execute with the workers framework. + * + */ open(client: any, modulePath: string): IPromise; } export const workers: workers; interface Connection { + /** + * A convenient method that broadcasts a message to all workers. Use this method if it is mandatory that all workers need to have a piece of information which is critical for them to process additional requests. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-workers-Connection.html#broadcast) + * + * @param methodName The name of the method to invoke on all workers. + * @param data The object which contains all required parameters to be passed to the method. The data passed between the main thread and the workers framework are copied, not shared. Objects are serialized and de-serialized on both ends. + * @param buffers An array of [transferable](https://developer.mozilla.org/en-US/docs/Web/API/Transferable) buffers. Each buffer in the array should have a corresponding entry in the data object. Transferable objects are transferred from one context to another with a zero-copy operation, which results in a big performance improvement when sending large data sets. + * + */ broadcast(methodName: string, data?: any, buffers?: ArrayBuffer[]): IPromise; + /** + * Closes the existing connection instance to workers. Notify all workers to destroy the connection instance and unload the connection module. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-workers-Connection.html#close) + * + * + */ close(): void; + /** + * Invokes a method on the script loaded with the workers framework. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-workers-Connection.html#invoke) + * + * @param methodName The name of the method to be invoked in the script. + * @param data The object which contains all required parameters to be passed to the method. The data passed between the main thread and the workers framework are copied, not shared. Objects are serialized and de-serialized on both ends. + * @param buffers An array of [transferable](https://developer.mozilla.org/en-US/docs/Web/API/Transferable) buffers. Each buffer in the array should have a corresponding entry in the data object. Transferable objects are transferred from one context to another with a zero-copy operation, which results in a big performance improvement when sending large data sets. + * + */ invoke(methodName: string, data?: any, buffers?: ArrayBuffer[]): IPromise; } interface ConnectionConstructor { + /** + * The Connection class is used to access code loaded into a separate thread via the [workers framework](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-workers.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-workers-Connection.html) + */ + + new(client: any, id: number): Connection; } export const Connection: ConnectionConstructor; + /** + * A convenience module for importing [Geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) classes when developing with [TypeScript](https://developers.arcgis.com/javascript/latest/guide/typescript-setup/index.html). For example, rather than importing geometries one at a time like this: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry.html) + */ + interface geometry { + } + + export const geometry: geometry; + interface Circle extends Polygon { - center: Point | number[]; + /** + * The center point of the circle. The center must be specified either as a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) or an array of longitude/latitude coordinates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html#center) + */ + center: Point; + /** + * Applicable when the spatial reference of the center point is either set to Web Mercator (wkid: 3857) or geographic/geodesic (wkid: 4326). When either of those spatial references is used, set geodesic to `true` to minimize distortion. Other coordinate systems will not create geodesic circles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html#geodesic) + * + * @default false + */ geodesic: boolean; + /** + * This value defines the number of points along the curve of the circle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html#numberOfPoints) + * + * @default 60 + */ numberOfPoints: number; + /** + * The radius of the circle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html#radius) + * + * @default 1000 + */ radius: number; + /** + * Unit of the radius. **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html#radiusUnit) + * + * @default meters + */ radiusUnit: string; + /** + * Creates a deep clone of Circle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html#clone) + * + * + */ clone(): Circle; } interface CircleConstructor { + + new(properties?: CircleProperties): Circle; fromJSON(json: any): Circle; @@ -566,39 +1827,233 @@ declare namespace __esri { export const Circle: CircleConstructor; interface CircleProperties extends PolygonProperties { - center?: PointProperties | number[]; + /** + * The center point of the circle. The center must be specified either as a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) or an array of longitude/latitude coordinates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html#center) + */ + center?: PointProperties; + /** + * Applicable when the spatial reference of the center point is either set to Web Mercator (wkid: 3857) or geographic/geodesic (wkid: 4326). When either of those spatial references is used, set geodesic to `true` to minimize distortion. Other coordinate systems will not create geodesic circles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html#geodesic) + * + * @default false + */ geodesic?: boolean; + /** + * This value defines the number of points along the curve of the circle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html#numberOfPoints) + * + * @default 60 + */ numberOfPoints?: number; + /** + * The radius of the circle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html#radius) + * + * @default 1000 + */ radius?: number; + /** + * Unit of the radius. **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Circle.html#radiusUnit) + * + * @default meters + */ radiusUnit?: string; } interface Extent extends Geometry { - center: Point; - height: number; + /** + * The center point of the extent in map units. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#center) + */ + readonly center: Point; + /** + * The height of the extent in map units (the distance between [ymin](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#ymin) and [ymax](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#ymax)). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#height) + */ + readonly height: number; + /** + * The maximum possible `m` value in an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#mmax) + * + * @default undefined + */ mmax: number; + /** + * The minimum possible `m` value of an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#mmin) + * + * @default undefined + */ mmin: number; - width: number; + /** + * For Extent, the type is always `extent`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#type) + */ + readonly type: "extent"; + /** + * The width of the extent in map units (the distance between [xmin](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#xmin) and [xmax](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#xmax)). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#width) + */ + readonly width: number; + /** + * The bottom-right X-coordinate of an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#xmax) + * + * @default 0 + */ xmax: number; + /** + * The top-left X-coordinate of an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#xmin) + * + * @default 0 + */ xmin: number; + /** + * The top-right Y-coordinate of an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#ymax) + * + * @default 0 + */ ymax: number; + /** + * The bottom-left Y-coordinate of an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#ymin) + * + * @default 0 + */ ymin: number; + /** + * The maximum possible `z`, or elevation, value in an extent envelope. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#zmax) + * + * @default undefined + */ zmax: number; + /** + * The minimum possible `z`, or elevation, value of an extent envelope. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#zmin) + * + * @default undefined + */ zmin: number; + /** + * Centers the extent to the specified [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html). This method modifies the extent geometry in-place. You should [clone](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone) the extent object before calling this method where appropriate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#centerAt) + * + * @param point The point to center the extent. + * + */ centerAt(point: Point): Extent; + /** + * Creates a deep clone of Extent object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone) + * + * + */ clone(): Extent; + /** + * Checks if the input geometry is contained within the extent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#contains) + * + * @param geometry Input geometry to test if it is contained within the extent. + * + */ contains(geometry: Point | Extent): boolean; + /** + * Indicates if the input extent is equal to the testing extent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#equals) + * + * @param extent Input extent. + * + */ equals(extent: Extent): boolean; + /** + * Expands the extent by the given factor. For example, a value of 1.5 will expand the extent to be 50 percent larger than the original extent. This method modifies the extent geometry in-place. You should [clone](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone) the extent object before calling this method where appropriate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#expand) + * + * @param factor The multiplier value. + * + */ expand(factor: number): Extent; + /** + * Shrinks the original extent to the intersection with the input extent. This method modifies the extent geometry in-place. You should [clone](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone) the extent object before calling this method where appropriate. If the original extent and the input extent have no intersection, the extent is not modified and null is returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#intersection) + * + * @param extent The input extent to intersect. + * + */ intersection(extent: Extent): Extent; + /** + * Tests to validate if the input geometry intersects the extent and returns a Boolean value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#intersects) + * + * @param geometry The geometry used to test the intersection. It can be a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html), [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html), [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html), [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) or [Multipoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html). + * + */ intersects(geometry: Geometry): boolean; + /** + * Returns an array with either one Extent that's been shifted to within +/- 180 or two Extents if the original extent intersects the International Dateline. This method modifies the extent geometry in-place. You should [clone](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone) the extent object before calling this method where appropriate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#normalize) + * + * + */ normalize(): Extent[]; + /** + * Modifies the extent geometry in-place with X and Y offsets in map units. You should [clone](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone) the extent object before calling this method where appropriate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#offset) + * + * @param dx The offset distance in map units for the X-coordinate. + * @param dy The offset distance in map units for the Y-coordinate. + * @param dz The offset distance in map units for the Z-coordinate. + * + */ offset(dx: number, dy: number, dz: number): Extent; + /** + * Expands the original extent to include the extent of the input Extent. This method modifies the extent geometry in-place. You should [clone](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone) the extent object before calling this method where appropriate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#union) + * + * @param extent The input extent to union. + * + */ union(extent: Extent): Extent; } interface ExtentConstructor { + + new(properties?: ExtentProperties): Extent; fromJSON(json: any): Extent; @@ -607,31 +2062,128 @@ declare namespace __esri { export const Extent: ExtentConstructor; interface ExtentProperties extends GeometryProperties { - center?: PointProperties; - height?: number; + /** + * The maximum possible `m` value in an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#mmax) + * + * @default undefined + */ mmax?: number; + /** + * The minimum possible `m` value of an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#mmin) + * + * @default undefined + */ mmin?: number; - width?: number; + /** + * The bottom-right X-coordinate of an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#xmax) + * + * @default 0 + */ xmax?: number; + /** + * The top-left X-coordinate of an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#xmin) + * + * @default 0 + */ xmin?: number; + /** + * The top-right Y-coordinate of an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#ymax) + * + * @default 0 + */ ymax?: number; + /** + * The bottom-left Y-coordinate of an extent envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#ymin) + * + * @default 0 + */ ymin?: number; + /** + * The maximum possible `z`, or elevation, value in an extent envelope. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#zmax) + * + * @default undefined + */ zmax?: number; + /** + * The minimum possible `z`, or elevation, value of an extent envelope. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#zmin) + * + * @default undefined + */ zmin?: number; } interface Geometry extends Accessor, JSONSupport { - cache: any; - extent: Extent; + /** + * The cache is used to store values computed from geometries that need to cleared or recomputed upon mutation. An example is the extent of a polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#cache) + */ + readonly cache: any; + /** + * The extent of the geometry. For points, the extent is null. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#extent) + */ + readonly extent: Extent; + /** + * Indicates if the geometry has M values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#hasM) + */ hasM: boolean; + /** + * Indicates if the geometry has Z (elevation) values. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#hasZ) + */ hasZ: boolean; + /** + * The spatial reference of the geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#spatialReference) + * + * @default WGS84 (wkid: 4326) + */ spatialReference: SpatialReference; - type: string; + /** + * The geometry type. **Possible Values:** point | multipoint | polyline | polygon | extent + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#type) + */ + readonly type: string; + /** + * Creates a deep clone of the geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#clone) + * + * + */ clone(): Geometry; } interface GeometryConstructor { + + new(properties?: GeometryProperties): Geometry; fromJSON(json: any): Geometry; @@ -640,111 +2192,861 @@ declare namespace __esri { export const Geometry: GeometryConstructor; interface GeometryProperties { - cache?: any; - extent?: ExtentProperties; + /** + * Indicates if the geometry has M values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#hasM) + */ hasM?: boolean; + /** + * Indicates if the geometry has Z (elevation) values. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#hasZ) + */ hasZ?: boolean; + /** + * The spatial reference of the geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#spatialReference) + * + * @default WGS84 (wkid: 4326) + */ spatialReference?: SpatialReferenceProperties; - type?: string; } + interface geometryEngine { + /** + * Creates planar (or Euclidean) buffer polygons at a specified distance around the input geometries. The GeometryEngine has two methods for buffering geometries client-side: buffer and [geodesicBuffer](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#geodesicBuffer). Use caution when deciding which method to use. As a general rule, use [geodesicBuffer](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#geodesicBuffer) if the input geometries have a spatial reference of either WGS84 (wkid: 4326) or [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator). Only use buffer (this method) when attempting to buffer geometries with a [projected coordinate system](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/) other than Web Mercator. If you need to buffer geometries with a [geographic coordinate system](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) other than WGS84 (wkid: 4326), use [GeometryService.buffer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#buffer). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#buffer) + * + * @param geometry The buffer input geometry. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. + * @param distance The specified distance(s) for buffering. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. When using an array of geometries as input, the length of the geometry array does not have to equal the length of the `distance` array. For example, if you pass an array of four geometries: `[g1, g2, g3, g4]` and an array with one distance: `[d1]`, all four geometries will be buffered by the single distance value. If instead you use an array of three distances: `[d1, d2, d3]`, `g1` will be buffered by `d1`, `g2` by `d2`, and `g3` and `g4` will both be buffered by `d3`. The value of the geometry array will be matched one to one with those in the distance array until the final value of the distance array is reached, in which case that value will be applied to the remaining geometries. + * @param unit Measurement unit of the distance(s). Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * @param unionResults Determines whether the output geometries should be unioned into a single polygon. + * + */ buffer(geometry: Geometry | Geometry[], distance: number | number[], unit: string | number, unionResults?: boolean): Polygon | Polygon[]; + /** + * Calculates the clipped geometry from a target geometry by an envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#clip) + * + * @param geometry The geometry to be clipped. + * @param envelope The envelope used to clip. + * + */ clip(geometry: Geometry, envelope: Extent): Geometry; + /** + * Indicates if one geometry contains another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#contains) + * + * @param containerGeometry The geometry that is tested for the "contains" relationship to the other geometry. Think of this geometry as the potential "container" of the `insideGeometry`. + * @param insideGeometry The geometry that is tested for the "within" relationship to the `containerGeometry`. + * + */ contains(containerGeometry: Geometry, insideGeometry: Geometry): boolean; + /** + * Calculates the convex hull of the input geometry. A convex hull is the smallest convex polygon that encloses a group of Objects, such as points. The input geometry can be a point, multipoint, polyline or polygon. The hull is typically a polygon but can also be a polyline or point in degenerate cases. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#convexHull) + * + * @param geometry The input geometry. + * @param merge Dictates whether to merge output geometries. + * + */ convexHull(geometry: Geometry, merge?: boolean): Geometry | Geometry[]; + /** + * Indicates if one geometry crosses another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#crosses) + * + * @param geometry1 The geometry to cross. + * @param geometry2 The geometry being crossed. + * + */ crosses(geometry1: Geometry, geometry2: Geometry): boolean; + /** + * Split the input Polyline or Polygon where it crosses a cutting Polyline. For Polylines, all left cuts are grouped together in the first Geometry. Right cuts and coincident cuts are grouped in the second Geometry and each undefined cut, along with any uncut parts, are output as separate Polylines. For Polygons, all left cuts are grouped in the first Polygon, all right cuts are grouped in the second Polygon, and each undefined cut, along with any left-over parts after cutting, are output as a separate Polygon. If no cuts are returned then the array will be empty. An undefined cut will only be produced if a left cut or right cut was produced and there was a part left over after cutting, or a cut is bounded to the left and right of the cutter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#cut) + * + * @param geometry The geometry to be cut. + * @param cutter The polyline to cut the geometry. + * + */ cut(geometry: Geometry, cutter: Polyline): Geometry[]; + /** + * Densify geometries by plotting points between existing vertices. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#densify) + * + * @param geometry The geometry to be densified. + * @param maxSegmentLength The maximum segment length allowed. Must be a positive value. + * @param maxSegmentLengthUnit Measurement unit for maxSegmentLength. Defaults to the units of the input geometry. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ densify(geometry: Geometry, maxSegmentLength: number, maxSegmentLengthUnit: string | number): Geometry; + /** + * Creates the difference of two geometries. The resultant geometry is the portion of `inputGeometry` not in the `subtractor`. The dimension of the `subtractor` has to be equal to or greater than that of the `inputGeometry`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#difference) + * + * @param inputGeometry The input geometry to subtract from. + * @param subtractor The geometry being subtracted from inputGeometry. + * + */ difference(inputGeometry: Geometry | Geometry[], subtractor: Geometry): Geometry | Geometry[]; + /** + * Indicates if one geometry is disjoint (doesn't intersect in any way) with another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#disjoint) + * + * @param geometry1 The base geometry that is tested for the "disjoint" relationship to the other geometry. + * @param geometry2 The comparison geometry that is tested for the "disjoint" relationship to the other geometry. + * + */ disjoint(geometry1: Geometry, geometry2: Geometry): boolean; + /** + * Calculates the shortest planar distance between two geometries. Distance is reported in the linear units specified by `distanceUnit` or, if `distanceUnit` is null, the units of the spatialReference of input geometry. + * > To calculate the geodesic distance between two points, first construct a [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) using the two points of interest as the beginning and ending points of a single path. Then use the polyline as input for the [geodesicLength()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#geodesicLength) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#distance) + * + * @param geometry1 First input geometry. + * @param geometry2 Second input geometry. + * @param distanceUnit Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ distance(geometry1: Geometry, geometry2: Geometry, distanceUnit: string | number): number; + /** + * Indicates if two geometries are equal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#equals) + * + * @param geometry1 First input geometry. + * @param geometry2 Second input geometry. + * + */ equals(geometry1: Geometry, geometry2: Geometry): boolean; + /** + * Returns an Object containing additional information about the input spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#extendedSpatialReferenceInfo) + * + * @param spatialReference The input spatial reference. + * + */ extendedSpatialReferenceInfo(spatialReference: SpatialReference): any; + /** + * Flips a geometry on the horizontal axis. Can optionally be flipped around a point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#flipHorizontal) + * + * @param geometry The input geometry to be flipped. + * @param flipOrigin Point to flip the geometry around. Defaults to the centroid of the geometry. + * + */ flipHorizontal(geometry: Geometry, flipOrigin?: Point): Geometry; + /** + * Flips a geometry on the vertical axis. Can optionally be flipped around a point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#flipVertical) + * + * @param geometry The input geometry to be flipped. + * @param flipOrigin Point to flip the geometry around. Defaults to the centroid of the geometry. + * + */ flipVertical(geometry: Geometry, flipOrigin?: Point): Geometry; + /** + * Performs the generalize operation on the geometries in the cursor. Point and Multipoint geometries are left unchanged. Envelope is converted to a Polygon and then generalized. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#generalize) + * + * @param geometry The input geometry to be generalized. + * @param maxDeviation The maximum allowed deviation from the generalized geometry to the original geometry. + * @param removeDegenerateParts When `true` the degenerate parts of the geometry will be removed from the output (may be undesired for drawing). + * @param maxDeviationUnit Measurement unit for maxDeviation. Defaults to the units of the input geometry. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ generalize(geometry: Geometry, maxDeviation: number, removeDegenerateParts?: boolean, maxDeviationUnit?: string | number): Geometry; + /** + * Calculates the area of the input geometry. As opposed to [planarArea()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#planarArea), geodesicArea takes into account the curvature of the earth when performing this calculation. Therefore, when using input geometries with a spatial reference of either WGS84 (wkid: 4326) or [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator), it is best practice to calculate areas using geodesicArea(). If the input geometries have a projected coordinate system other than Web Mercator, use [planarArea()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#planarArea) instead. This method only works with WGS84 (wkid: 4326) and [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator) spatial references. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#geodesicArea) + * + * @param geometry The input polygon. + * @param unit Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for area units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.AreaUnit.Code.ACRE). **Possible Values:** acres | ares | hectares | square-feet | square-meters | square-yards | square-kilometers | square-miles + * + */ geodesicArea(geometry: Polygon, unit: string | number): number; + /** + * Creates geodesic buffer polygons at a specified distance around the input geometries. When calculating distances, this method takes the curvature of the earth into account, which provides highly accurate results when dealing with very large geometries and/or geometries that spatially vary on a global scale where one projected coordinate system could not accurately plot coordinates and measure distances for all the geometries. This method only works with WGS84 (wkid: 4326) and [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator) spatial references. In general, if your input geometries are assigned one of those two spatial references, you should always use geodesicBuffer() to obtain the most accurate results for those geometries. If needing to buffer points assigned a [projected coordinate system other than Web Mercator](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/), use [buffer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#buffer) instead. If the input geometries have a [geographic coordinate system](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) other than WGS84 (wkid: 4326), use [GeometryService.buffer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#buffer). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#geodesicBuffer) + * + * @param geometry The buffer input geometry. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. + * @param distance The specified distance(s) for buffering. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. When using an array of geometries as input, the length of the geometry array does not have to equal the length of the `distance` array. For example, if you pass an array of four geometries: `[g1, g2, g3, g4]` and an array with one distance: `[d1]`, all four geometries will be buffered by the single distance value. If instead you use an array of three distances: `[d1, d2, d3]`, `g1` will be buffered by `d1`, `g2` by `d2`, and `g3` and `g4` will both be buffered by `d3`. The value of the geometry array will be matched one to one with those in the distance array until the final value of the distance array is reached, in which case that value will be applied to the remaining geometries. + * @param unit Measurement unit of the distance(s). Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * @param unionResults Determines whether the output geometries should be unioned into a single polygon. + * + */ geodesicBuffer(geometry: Geometry | Geometry[], distance: number | number[], unit: string | number, unionResults?: boolean): Polygon | Polygon[]; + /** + * Returns a geodesically densified version of the input geometry. Use this function to draw the line(s) of the geometry along great circles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#geodesicDensify) + * + * @param geometry A polyline or polygon to densify. + * @param maxSegmentLength The maximum segment length allowed. This must be a positive value. + * @param maxSegmentLengthUnit Measurement unit for `maxSegmentLength`. If a unit is not specified, the units are considered to be the same as the units of the `geometry`. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ geodesicDensify(geometry: Polyline | Polygon, maxSegmentLength: number, maxSegmentLengthUnit: string | number): Geometry; + /** + * Calculates the length of the input geometry. As opposed to [planarLength()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#planarLength), geodesicLength() takes into account the curvature of the earth when performing this calculation. Therefore, when using input geometries with a spatial reference of either WGS84 (wkid: 4326) or [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator), it is best practice to calculate lengths using geodesicLength(). If the input geometries have a projected coordinate system other than Web Mercator, use [planarLength()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#planarLength) instead. This method only works with WGS84 (wkid: 4326) and [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator) spatial references. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#geodesicLength) + * + * @param geometry The input geometry. + * @param unit Measurement unit of the return value. Defaults to the units of the input geometry. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ geodesicLength(geometry: Geometry, unit: string | number): number; + /** + * Creates a new geometry through intersection between two geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#intersect) + * + * @param geometry The input geometry(ies). + * @param intersector The geometry being intersected. + * + */ intersect(geometry: Geometry | Geometry[], intersector: Geometry): Geometry | Geometry[]; + /** + * Indicates if one geometry intersects another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#intersects) + * + * @param geometry1 The geometry that is tested for the intersects relationship to the other geometry. + * @param geometry2 The geometry being intersected. + * + */ intersects(geometry1: Geometry, geometry2: Geometry): boolean; + /** + * Indicates if the given geometry is topologically simple. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#isSimple) + * + * @param geometry The input geometry. + * + */ isSimple(geometry: Geometry): boolean; + /** + * Finds the coordinate of the geometry that is closest to the specified point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#nearestCoordinate) + * + * @param geometry The geometry to consider. + * @param inputPoint The point used to search the nearest coordinate in the geometry. + * + */ nearestCoordinate(geometry: Geometry, inputPoint: Point): NearestPointResult; + /** + * Finds the vertex on the geometry nearest to the specified point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#nearestVertex) + * + * @param geometry The geometry to consider. + * @param inputPoint The point used to search the nearest vertex in the geometry. + * + */ nearestVertex(geometry: Geometry, inputPoint: Point): NearestPointResult; + /** + * Finds all vertices in the given distance from the specified point, sorted from the closest to the furthest and returns them as an array of Objects. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#nearestVertices) + * + * @param geometry The geometry to consider. + * @param inputPoint The point from which to measure. + * @param searchRadius The distance to search from the inputPoint in the units of the view's spatial reference. + * @param maxVertexCountToReturn The maximum number of vertices to return. + * + */ nearestVertices(geometry: Geometry, inputPoint: Point, searchRadius: number, maxVertexCountToReturn: number): NearestPointResult[]; + /** + * The offset operation creates a geometry that is a constant planar distance from an input polyline or polygon. It is similar to buffering, but produces a one-sided result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#offset) + * + * @param geometry The geometries to offset. + * @param offsetDistance The planar distance to offset from the input geometry. If offsetDistance > 0, then the offset geometry is constructed to the right of the oriented input geometry, if offsetDistance = 0, then there is no change in the geometries, otherwise it is constructed to the left. For a simple polygon, the orientation of outer rings is clockwise and for inner rings it is counter clockwise. So the "right side" of a simple polygon is always its inside. + * @param offsetUnit Measurement unit of the offset distance. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * @param joinType The join type. **Possible values:** round | bevel | miter | square + * @param bevelRatio Applicable when `joinType = 'miter'`; bevelRatio is multiplied by the offset distance and the result determines how far a mitered offset intersection can be located before it is beveled. + * @param flattenError Applicable when `joinType = 'round'`; flattenError determines the maximum distance of the resulting segments compared to the true circular arc. The algorithm never produces more than around 180 vertices for each round join. + * + */ offset(geometry: Geometry | Geometry[], offsetDistance: number, offsetUnit: string | number, joinType: string, bevelRatio?: number, flattenError?: number): Geometry | Geometry[]; + /** + * Indicates if one geometry overlaps another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#overlaps) + * + * @param geometry1 The base geometry that is tested for the "overlaps" relationship with the other geometry. + * @param geometry2 The comparison geometry that is tested for the "overlaps" relationship with the other geometry. + * + */ overlaps(geometry1: Geometry, geometry2: Geometry): boolean; + /** + * Calculates the area of the input geometry. As opposed to [geodesicArea()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#geodesicArea), planarArea() performs this calculation using projected coordinates and does not take into account the earth's curvature. When using input geometries with a spatial reference of either WGS84 (wkid: 4326) or [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator), it is best practice to calculate areas using [geodesicArea()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#geodesicArea). If the input geometries have a projected coordinate system other than Web Mercator, use planarArea() instead. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#planarArea) + * + * @param geometry The input polygon. + * @param unit Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for area units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.AreaUnit.Code.ACRE). **Possible Values:** acres | ares | hectares | square-feet | square-meters | square-yards | square-kilometers | square-miles + * + */ planarArea(geometry: Polygon, unit: string | number): number; + /** + * Calculates the length of the input geometry. As opposed to [geodesicLength()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#geodesicLength), planarLength() uses projected coordinates and does not take into account the curvature of the earth when performing this calculation. When using input geometries with a spatial reference of either WGS84 (wkid: 4326) or [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator), it is best practice to calculate lengths using [geodesicLength()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#geodesicLength). If the input geometries have a projected coordinate system other than Web Mercator, use planarLength() instead. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#planarLength) + * + * @param geometry The input geometry. + * @param unit Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ planarLength(geometry: Geometry, unit: string | number): number; + /** + * Indicates if the given DE-9IM relation holds for the two geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#relate) + * + * @param geometry1 The first geometry for the relation. + * @param geometry2 The second geometry for the relation. + * @param relation The Dimensionally Extended 9 Intersection Model (DE-9IM) matrix relation (encoded as a string) to test against the relationship of the two geometries. This string contains the test result of each intersection represented in the DE-9IM matrix. Each result is one character of the string and may be represented as either a number (maximum dimension returned: `0`,`1`,`2`), a Boolean value (`T` or `F`), or a mask character (for ignoring results: '\*'). Example: Each of the following DE-9IM string codes are valid for testing whether a polygon geometry completely contains a line geometry: `TTTFFTFFT` (Boolean), 'T*\*\*\*\*\*FF\*' (ignore irrelevant intersections), or '102FF\*FF\*' (dimension form). Each returns the same result. See [this article](https://en.wikipedia.org/wiki/DE-9IM) and [this ArcGIS help page](https://desktop.arcgis.com/en/arcmap/latest/manage-data/using-sql-with-gdbs/relational-functions-for-st-geometry.htm) for more information about the DE-9IM model and how string codes are constructed. + * + */ relate(geometry1: Geometry, geometry2: Geometry, relation: string): boolean; + /** + * Rotates a geometry counterclockwise by the specified number of degrees. Rotation is around the centroid, or a given rotation point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#rotate) + * + * @param geometry The geometry to rotate. + * @param angle The rotation angle in degrees. + * @param rotationOrigin Point to rotate the geometry around. Defaults to the centroid of the geometry. + * + */ rotate(geometry: Geometry, angle: number, rotationOrigin?: Point): Geometry; + /** + * Performs the simplify operation on the geometry which alters the given geometries to make their definitions topologically legal with respect to their geometry type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#simplify) + * + * @param geometry The geometry to be simplified. + * + */ simplify(geometry: Geometry): Geometry; + /** + * Creates the symmetric difference of two geometries. The symmetric difference includes the parts that are in either of the sets, but not in both. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#symmetricDifference) + * + * @param leftGeometry One of the Geometry instances in the XOR operation. + * @param rightGeometry One of the Geometry instances in the XOR operation. + * + */ symmetricDifference(leftGeometry: Geometry | Geometry[], rightGeometry: Geometry): Geometry | Geometry[]; + /** + * Indicates if one geometry touches another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#touches) + * + * @param geometry1 The geometry to test the "touches" relationship with the other geometry. + * @param geometry2 The geometry to be touched. + * + */ touches(geometry1: Geometry, geometry2: Geometry): boolean; + /** + * All inputs must be of the same type of geometries and share one spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#union) + * + * @param geometries An array of Geometries to union. + * + */ union(geometries: Geometry[]): Geometry; + /** + * Indicates if one geometry is within another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#within) + * + * @param innerGeometry The base geometry that is tested for the "within" relationship to the other geometry. + * @param outerGeometry The comparison geometry that is tested for the "contains" relationship to the other geometry. + * + */ within(innerGeometry: Geometry, outerGeometry: Geometry): boolean; } export const geometryEngine: geometryEngine; - export interface NearestPointResult { + /** + * Object returned from the [nearestCoordinate()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#nearestCoordinate), [nearestVertex()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#nearestVertex), and [nearestVertices()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#nearestVertices) methods. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#NearestPointResult) + */ + export interface NearestPointResult extends Object { + /** + * A vertex within the specified distance of the search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#NearestPointResult) + */ coordinate: Point; + /** + * The distance from the `inputPoint` in the units of the view's spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#NearestPointResult) + */ distance: number; + /** + * Indicates if the vertex is on the right side of the `geometry`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#NearestPointResult) + */ isRightSide: boolean; + /** + * The index of the vertex within the geometry's rings or paths. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#NearestPointResult) + */ vertexIndex: number; + /** + * Indicates if it is an empty geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#NearestPointResult) + */ isEmpty: boolean; } + interface geometryEngineAsync { + /** + * Creates planar (or Euclidean) buffer polygons at a specified distance around the input geometries. The GeometryEngine has two methods for buffering geometries client-side: buffer and [geodesicBuffer](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicBuffer). Use caution when deciding which method to use. As a general rule, use [geodesicBuffer](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicBuffer) if the input geometries have a spatial reference of either WGS84 (wkid: 4326) or [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator). Only use buffer (this method) when attempting to buffer geometries with a [projected coordinate system](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/) other than Web Mercator. If you need to buffer geometries with a [geographic coordinate system](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) other than WGS84 (wkid: 4326), use [GeometryService.buffer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#buffer). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#buffer) + * + * @param geometry The buffer input geometry. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. + * @param distance The specified distance(s) for buffering. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. When using an array of geometries as input, the length of the geometry array does not have to equal the length of the `distance` array. For example, if you pass an array of four geometries: `[g1, g2, g3, g4]` and an array with one distance: `[d1]`, all four geometries will be buffered by the single distance value. If instead you use an array of three distances: `[d1, d2, d3]`, `g1` will be buffered by `d1`, `g2` by `d2`, and `g3` and `g4` will both be buffered by `d3`. The value of the geometry array will be matched one to one with those in the distance array until the final value of the distance array is reached, in which case that value will be applied to the remaining geometries. + * @param unit Measurement unit of the distance(s). Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * @param unionResults Determines whether the output geometries should be unioned into a single polygon. + * + */ buffer(geometry: Geometry | Geometry[], distance: number | number[], unit: string | number, unionResults?: boolean): IPromise; + /** + * Calculates the clipped geometry from a target geometry by an envelope. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#clip) + * + * @param geometry The geometry to be clipped. + * @param envelope The envelope used to clip. + * + */ clip(geometry: Geometry, envelope: Extent): IPromise; + /** + * Indicates if one geometry contains another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#contains) + * + * @param containerGeometry The geometry that is tested for the "contains" relationship to the other geometry. Think of this geometry as the potential "container" of the `insideGeometry`. + * @param insideGeometry The geometry that is tested for the "within" relationship to the `containerGeometry`. + * + */ contains(containerGeometry: Geometry, insideGeometry: Geometry): IPromise; + /** + * Calculates the convex hull of the input geometry. A convex hull is the smallest convex polygon that encloses a group of Objects, such as points. The input geometry can be a point, multipoint, polyline or polygon. The hull is typically a polygon but can also be a polyline or point in degenerate cases. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#convexHull) + * + * @param geometry The input geometry. + * @param merge Dictates whether to merge output geometries. + * + */ convexHull(geometry: Geometry, merge?: boolean): IPromise; + /** + * Indicates if one geometry crosses another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#crosses) + * + * @param geometry1 The geometry to cross. + * @param geometry2 The geometry being crossed. + * + */ crosses(geometry1: Geometry, geometry2: Geometry): IPromise; + /** + * Split the input Polyline or Polygon where it crosses a cutting Polyline. For Polylines, all left cuts are grouped together in the first Geometry. Right cuts and coincident cuts are grouped in the second Geometry and each undefined cut, along with any uncut parts, are output as separate Polylines. For Polygons, all left cuts are grouped in the first Polygon, all right cuts are grouped in the second Polygon, and each undefined cut, along with any left-over parts after cutting, are output as a separate Polygon. If no cuts are returned then the array will be empty. An undefined cut will only be produced if a left cut or right cut was produced and there was a part left over after cutting, or a cut is bounded to the left and right of the cutter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#cut) + * + * @param geometry The geometry to be cut. + * @param cutter The polyline to cut the geometry. + * + */ cut(geometry: Geometry, cutter: Polyline): IPromise; + /** + * Densify geometries by plotting points between existing vertices. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#densify) + * + * @param geometry The geometry to be densified. + * @param maxSegmentLength The maximum segment length allowed. Must be a positive value. + * @param maxSegmentLengthUnit Measurement unit for maxSegmentLength. Defaults to the units of the input geometry. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ densify(geometry: Geometry, maxSegmentLength: number, maxSegmentLengthUnit: string | number): IPromise; + /** + * Creates the difference of two geometries. The resultant geometry is the portion of inputGeometry not in the subtractor. The dimension of the subtractor has to be equal to or greater than that of the inputGeometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#difference) + * + * @param inputGeometry The input geometry to subtract from. + * @param subtractor The geometry being subtracted from inputGeometry. + * + */ difference(inputGeometry: Geometry | Geometry[], subtractor: Geometry): IPromise; + /** + * Indicates if one geometry is disjoint (doesn't intersect in any way) with another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#disjoint) + * + * @param geometry1 The base geometry that is tested for the "disjoint" relationship to the other geometry. + * @param geometry2 The comparison geometry that is tested for the "disjoint" relationship to the other geometry. + * + */ disjoint(geometry1: Geometry, geometry2: Geometry): IPromise; + /** + * Calculates the shortest planar distance between two geometries. Distance is reported in the linear units specified by `distanceUnit` or, if `distanceUnit` is null, the units of the spatialReference of input geometry. + * > To calculate the geodesic distance between two points, first construct a [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) using the two points of interest as the beginning and ending points of a single path. Then use the polyline as input for the [geodesicLength()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicLength) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#distance) + * + * @param geometry1 First input geometry. + * @param geometry2 Second input geometry. + * @param distanceUnit Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ distance(geometry1: Geometry, geometry2: Geometry, distanceUnit: string | number): IPromise; + /** + * Indicates if two geometries are equal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#equals) + * + * @param geometry1 First input geometry. + * @param geometry2 Second input geometry. + * + */ equals(geometry1: Geometry, geometry2: Geometry): IPromise; + /** + * Returns an Object containing additional information about the input spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#extendedSpatialReferenceInfo) + * + * @param spatialReference The input spatial reference. + * + */ extendedSpatialReferenceInfo(spatialReference: SpatialReference): IPromise; + /** + * Flips a geometry on the horizontal axis. Can optionally be flipped around a point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#flipHorizontal) + * + * @param geometry The input geometry to be flipped. + * @param flipOrigin Point to flip the geometry around. Defaults to the centroid of the geometry. + * + */ flipHorizontal(geometry: Geometry, flipOrigin?: Point): IPromise; + /** + * Flips a geometry on the vertical axis. Can optionally be flipped around a point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#flipVertical) + * + * @param geometry The input geometry to be flipped. + * @param flipOrigin Point to flip the geometry around. Defaults to the centroid of the geometry. + * + */ flipVertical(geometry: Geometry, flipOrigin?: Point): IPromise; + /** + * Performs the generalize operation on the geometries in the cursor. Point and Multipoint geometries are left unchanged. Envelope is converted to a Polygon and then generalized. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#generalize) + * + * @param geometry The input geometry to be generalized. + * @param maxDeviation The maximum allowed deviation from the generalized geometry to the original geometry. + * @param removeDegenerateParts When `true` the degenerate parts of the geometry will be removed from the output (may be undesired for drawing). + * @param maxDeviationUnit Measurement unit for maxDeviation. Defaults to the units of the input geometry. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ generalize(geometry: Geometry, maxDeviation: number, removeDegenerateParts?: boolean, maxDeviationUnit?: string | number): IPromise; + /** + * Calculates the area of the input geometry. As opposed to [planarArea()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#planarArea), geodesicArea takes into account the curvature of the earth when performing this calculation. Therefore, when using input geometries with a spatial reference of either WGS84 (wkid: 4326) or [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator), it is best practice to calculate areas using geodesicArea(). If the input geometries have a projected coordinate system other than Web Mercator, use [planarArea()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#planarArea) instead. This method only works with WGS84 (wkid: 4326) and [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator) spatial references. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicArea) + * + * @param geometry The input polygon. + * @param unit Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for area units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.AreaUnit.Code.ACRE). **Possible Values:** acres | ares | hectares | square-feet | square-meters | square-yards | square-kilometers | square-miles + * + */ geodesicArea(geometry: Polygon, unit: string | number): IPromise; + /** + * Creates geodesic buffer polygons at a specified distance around the input geometries. When calculating distances, this method takes the curvature of the earth into account, which provides highly accurate results when dealing with very large geometries and/or geometries that spatially vary on a global scale where one projected coordinate system could not accurately plot coordinates and measure distances for all the geometries. This method only works with WGS84 (wkid: 4326) and [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator) spatial references. In general, if your input geometries are assigned one of those two spatial references, you should always use geodesicBuffer() to obtain the most accurate results for those geometries. If needing to buffer points assigned a [projected coordinate system other than Web Mercator](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/), use [buffer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#buffer) instead. If the input geometries have a [geographic coordinate system](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) other than WGS84 (wkid: 4326), use [GeometryService.buffer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#buffer). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicBuffer) + * + * @param geometry The buffer input geometry. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. + * @param distance The specified distance(s) for buffering. The `geometry` and `distance` parameters must be specified as either both arrays or both non-arrays. Never specify one as an array and the other a non-array. When using an array of geometries as input, the length of the geometry array does not have to equal the length of the `distance` array. For example, if you pass an array of four geometries: `[g1, g2, g3, g4]` and an array with one distance: `[d1]`, all four geometries will be buffered by the single distance value. If instead you use an array of three distances: `[d1, d2, d3]`, `g1` will be buffered by `d1`, `g2` by `d2`, and `g3` and `g4` will both be buffered by `d3`. The value of the geometry array will be matched one to one with those in the distance array until the final value of the distance array is reached, in which case that value will be applied to the remaining geometries. + * @param unit Measurement unit of the distance(s). Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * @param unionResults Determines whether the output geometries should be unioned into a single polygon. + * + */ geodesicBuffer(geometry: Geometry | Geometry[], distance: number | number[], unit: string | number, unionResults?: boolean): IPromise; + /** + * Returns a geodesically densified version of the input geometry. Use this function to draw the line(s) of the geometry along great circles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicDensify) + * + * @param geometry A polyline or polygon to densify. + * @param maxSegmentLength The maximum segment length allowed. This must be a positive value. + * @param maxSegmentLengthUnit Measurement unit for `maxSegmentLength`. If a unit is not specified, the units are considered to be the same as the units of the `geometry`. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ geodesicDensify(geometry: Polyline | Polygon, maxSegmentLength: number, maxSegmentLengthUnit: string | number): IPromise; + /** + * Calculates the length of the input geometry. As opposed to [planarLength()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#planarLength), geodesicLength() takes into account the curvature of the earth when performing this calculation. Therefore, when using input geometries with a spatial reference of either WGS84 (wkid: 4326) or [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator), it is best practice to calculate lengths using geodesicLength(). If the input geometries have a projected coordinate system other than Web Mercator, use [planarLength()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#planarLength) instead. This method only works with WGS84 (wkid: 4326) and [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator) spatial references. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicLength) + * + * @param geometry The input geometry. + * @param unit Measurement unit of the return value. Defaults to the units of the input geometry. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ geodesicLength(geometry: Geometry, unit: string | number): IPromise; + /** + * Creates a new geometry through intersection between two geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#intersect) + * + * @param geometry The input geometry(ies). + * @param intersector The geometry being intersected. + * + */ intersect(geometry: Geometry | Geometry[], intersector: Geometry): IPromise; + /** + * Indicates if one geometry intersects another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#intersects) + * + * @param geometry1 The geometry that is tested for the intersects relationship to the other geometry. + * @param geometry2 The geometry being intersected. + * + */ intersects(geometry1: Geometry, geometry2: Geometry): IPromise; + /** + * Indicates if the given geometry is topologically simple. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#isSimple) + * + * @param geometry The input geometry. + * + */ isSimple(geometry: Geometry): IPromise; + /** + * Finds the coordinate of the geometry that is closest to the specified point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#nearestCoordinate) + * + * @param geometry The geometry to consider. + * @param inputPoint The point used to search the nearest coordinate in the geometry. + * + */ nearestCoordinate(geometry: Geometry, inputPoint: Point): IPromise; + /** + * Finds vertex on the geometry nearest to the specified point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#nearestVertex) + * + * @param geometry The geometry to consider. + * @param inputPoint The point used to search the nearest vertex in the geometry. + * + */ nearestVertex(geometry: Geometry, inputPoint: Point): IPromise; + /** + * Finds all vertices in the given distance from the specified point, sorted from the closest to the furthest and returns them as an array of Objects. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#nearestVertices) + * + * @param geometry The geometry to consider. + * @param inputPoint The point from which to measure. + * @param searchRadius The distance to search from the inputPoint in the units of the view's spatial reference. + * @param maxVertexCountToReturn The maximum number of vertices to return. + * + */ nearestVertices(geometry: Geometry, inputPoint: Point, searchRadius: number, maxVertexCountToReturn: number): IPromise; + /** + * The offset operation creates a geometry that is a constant planar distance from an input polyline or polygon. It is similar to buffering, but produces a one-sided result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#offset) + * + * @param geometry The geometries to offset. + * @param offsetDistance The planar distance to offset from the input geometry. If offsetDistance > 0, then the offset geometry is constructed to the right of the oriented input geometry, if offsetDistance = 0, then there is no change in the geometries, otherwise it is constructed to the left. For a simple polygon, the orientation of outer rings is clockwise and for inner rings it is counter clockwise. So the "right side" of a simple polygon is always its inside. + * @param offsetUnit Measurement unit of the offset distance. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * @param joinType The join type. **Possible values:** round | bevel | miter | square + * @param bevelRatio Applicable when `joinType = 'miter'`; bevelRatio is multiplied by the offset distance and the result determines how far a mitered offset intersection can be located before it is beveled. + * @param flattenError Applicable when `joinType = 'round'`; flattenError determines the maximum distance of the resulting segments compared to the true circular arc. The algorithm never produces more than around 180 vertices for each round join. + * + */ offset(geometry: Geometry | Geometry[], offsetDistance: number, offsetUnit: string | number, joinType: string, bevelRatio?: number, flattenError?: number): IPromise; + /** + * Indicates if one geometry overlaps another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#overlaps) + * + * @param geometry1 The base geometry that is tested for the "overlaps" relationship with the other geometry. + * @param geometry2 The comparison geometry that is tested for the "overlaps" relationship with the other geometry. + * + */ overlaps(geometry1: Geometry, geometry2: Geometry): IPromise; + /** + * Calculates the area of the input geometry. As opposed to [geodesicArea()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicArea), planarArea() performs this calculation using projected coordinates and does not take into account the earth's curvature. When using input geometries with a spatial reference of either WGS84 (wkid: 4326) or [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator), it is best practice to calculate areas using [geodesicArea()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicArea). If the input geometries have a projected coordinate system other than Web Mercator, use planarArea() instead. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#planarArea) + * + * @param geometry The input polygon. + * @param unit Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for area units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.AreaUnit.Code.ACRE). **Possible Values:** acres | ares | hectares | square-feet | square-meters | square-yards | square-kilometers | square-miles + * + */ planarArea(geometry: Polygon, unit: string | number): IPromise; + /** + * Calculates the length of the input geometry. As opposed to [geodesicLength()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicLength), planarLength() uses projected coordinates and does not take into account the curvature of the earth when performing this calculation. When using input geometries with a spatial reference of either WGS84 (wkid: 4326) or [Web Mercator](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator), it is best practice to calculate lengths using [geodesicLength()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#geodesicLength). If the input geometries have a projected coordinate system other than Web Mercator, use planarLength() instead. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#planarLength) + * + * @param geometry The input geometry. + * @param unit Measurement unit of the return value. Defaults to the units of the input geometries. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** meters | feet | kilometers | miles | nautical-miles | yards + * + */ planarLength(geometry: Geometry, unit: string | number): IPromise; + /** + * Indicates if the given DE-9IM relation holds for the two geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#relate) + * + * @param geometry1 The first geometry for the relation. + * @param geometry2 The second geometry for the relation. + * @param relation The Dimensionally Extended 9 Intersection Model (DE-9IM) matrix relation (encoded as a string) to test against the relationship of the two geometries. This string contains the test result of each intersection represented in the DE-9IM matrix. Each result is one character of the string and may be represented as either a number (maximum dimension returned: `0`,`1`,`2`), a Boolean value (`T` or `F`), or a mask character (for ignoring results: '\*'). Example: Each of the following DE-9IM string codes are valid for testing whether a polygon geometry completely contains a line geometry: `TTTFFTFFT` (Boolean), 'T\*\*\*\*\*FF\*' (ignore irrelevant intersections), or '102FF\*FF\*' (dimension form). Each returns the same result. See [this article](https://en.wikipedia.org/wiki/DE-9IM) and [this ArcGIS help page](https://desktop.arcgis.com/en/arcmap/latest/manage-data/using-sql-with-gdbs/relational-functions-for-st-geometry.htm) for more information about the DE-9IM model and how string codes are constructed. + * + */ relate(geometry1: Geometry, geometry2: Geometry, relation: string): IPromise; + /** + * Rotates a geometry counterclockwise by the specified number of degrees. Rotation is around the centroid, or a given rotation point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#rotate) + * + * @param geometry The geometry to rotate. + * @param angle The rotation angle in degrees. + * @param rotationOrigin Point to rotate the geometry around. Defaults to the centroid of the geometry. + * + */ rotate(geometry: Geometry, angle: number, rotationOrigin?: Point): IPromise; + /** + * Performs the simplify operation on the geometry which alters the given geometries to make their definitions topologically legal with respect to their geometry type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#simplify) + * + * @param geometry The geometry to be simplified. + * + */ simplify(geometry: Geometry): IPromise; + /** + * Creates the symmetric difference of two geometries. The symmetric difference includes the parts that are in either of the sets, but not in both. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#symmetricDifference) + * + * @param leftGeometry One of the Geometry instances in the XOR operation. + * @param rightGeometry One of the Geometry instances in the XOR operation. + * + */ symmetricDifference(leftGeometry: Geometry | Geometry[], rightGeometry: Geometry): IPromise; + /** + * Indicates if one geometry touches another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#touches) + * + * @param geometry1 The geometry to test the "touches" relationship with the other geometry. + * @param geometry2 The geometry to be touched. + * + */ touches(geometry1: Geometry, geometry2: Geometry): IPromise; + /** + * All inputs must be of the same type of geometries and share one spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#union) + * + * @param geometries An array of Geometries to union. + * + */ union(geometries: Geometry[]): IPromise; + /** + * Indicates if one geometry is within another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngineAsync.html#within) + * + * @param innerGeometry The base geometry that is tested for the "within" relationship to the other geometry. + * @param outerGeometry The comparison geometry that is tested for the "contains" relationship to the other geometry. + * + */ within(innerGeometry: Geometry, outerGeometry: Geometry): IPromise; } export const geometryEngineAsync: geometryEngineAsync; interface HeightModelInfo extends Accessor, JSONSupport { - heightModel: string; - heightUnit: string; - vertCRS: string; + /** + * The surface type or height model of the vertical coordinate system (VCS). A [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) will only render layers containing data that is compatible with the HeightModelInfo of the scene. + * + * Value | Description + * ------|------------ + * gravity-related-height | A gravity-related VCS may set its zero point through a local mean sea level or a benchmark, and is compatible with other gravity-related VCS for the purposes of rendering. + * ellipsoidal | An ellipsoidal VCS defines heights that are referenced to an ellipsoid of a geographic coordinate system. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-HeightModelInfo.html#heightModel) + * + * @default "gravity-related-height" + */ + readonly heightModel: string; + /** + * The unit of the vertical coordinate system. A [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) will use this property to check that the vertical data of layers that define a HeightModelInfo is compatible with the view. **Possible Values:** meters | feet | us-feet | clarke-feet | clarke-yards | clarke-links | sears-yards | sears-feet | sears-chains | benoit-1895-b-chains | indian-yards | indian-1937-yards | gold-coast-feet | sears-1922-truncated-chains | 50-kilometers | 150-kilometers + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-HeightModelInfo.html#heightUnit) + * + * @default "meters" + */ + readonly heightUnit: string; + /** + * The datum realization of the vertical coordinate system. A [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) will only render layers that define a HeightModelInfo with an identical `vertCRS` to that of the scene, when using an `ellipsoidal` height model. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-HeightModelInfo.html#vertCRS) + */ + readonly vertCRS: string; } interface HeightModelInfoConstructor { + + new(properties?: HeightModelInfoProperties): HeightModelInfo; fromJSON(json: any): HeightModelInfo; @@ -753,22 +3055,100 @@ declare namespace __esri { export const HeightModelInfo: HeightModelInfoConstructor; interface HeightModelInfoProperties { + /** + * The surface type or height model of the vertical coordinate system (VCS). A [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) will only render layers containing data that is compatible with the HeightModelInfo of the scene. + * + * Value | Description + * ------|------------ + * gravity-related-height | A gravity-related VCS may set its zero point through a local mean sea level or a benchmark, and is compatible with other gravity-related VCS for the purposes of rendering. + * ellipsoidal | An ellipsoidal VCS defines heights that are referenced to an ellipsoid of a geographic coordinate system. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-HeightModelInfo.html#heightModel) + * + * @default "gravity-related-height" + */ heightModel?: string; + /** + * The unit of the vertical coordinate system. A [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) will use this property to check that the vertical data of layers that define a HeightModelInfo is compatible with the view. **Possible Values:** meters | feet | us-feet | clarke-feet | clarke-yards | clarke-links | sears-yards | sears-feet | sears-chains | benoit-1895-b-chains | indian-yards | indian-1937-yards | gold-coast-feet | sears-1922-truncated-chains | 50-kilometers | 150-kilometers + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-HeightModelInfo.html#heightUnit) + * + * @default "meters" + */ heightUnit?: string; + /** + * The datum realization of the vertical coordinate system. A [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) will only render layers that define a HeightModelInfo with an identical `vertCRS` to that of the scene, when using an `ellipsoidal` height model. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-HeightModelInfo.html#vertCRS) + */ vertCRS?: string; } interface Multipoint extends Geometry { + /** + * An array of points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html#points) + */ points: number[][]; + /** + * For Multipoint, the type is always `multipoint`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html#type) + */ + readonly type: "multipoint"; + /** + * Adds a point to the Multipoint. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html#addPoint) + * + * @param point The point to add to the multipoint. The point can either be a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) or an array of numbers representing XY coordinates. + * + */ addPoint(point: Point | number[]): Multipoint; + /** + * Creates a deep clone of Multipoint object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html#clone) + * + * + */ clone(): Multipoint; + /** + * Returns the point at the specified index. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html#getPoint) + * + * @param index The index of the point in the [points](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html#points) property. + * + */ getPoint(index: number): Point; + /** + * Removes a point from the Multipoint. The index specifies which point to remove. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html#removePoint) + * + * @param index The index of the point to remove. + * + */ removePoint(index: number): Point; + /** + * Updates the point at the specified index. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html#setPoint) + * + * @param index The index of the point in the [points](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html#points) property. + * @param point Point geometry that specifies the new location. + * + */ setPoint(index: number, point: Point): Multipoint; } interface MultipointConstructor { + + new(properties?: MultipointProperties): Multipoint; fromJSON(json: any): Multipoint; @@ -777,25 +3157,119 @@ declare namespace __esri { export const Multipoint: MultipointConstructor; interface MultipointProperties extends GeometryProperties { + /** + * An array of points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html#points) + */ points?: number[][]; } interface Point extends Geometry { + /** + * The latitude of the point if the spatial reference is Web Mercator (wkid: 3857) or WGS84 (wkid: 4326). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#latitude) + */ latitude: number; + /** + * The longitude of the point if the spatial reference is Web Mercator (wkid: 3857) or WGS84 (wkid: 4326). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#longitude) + */ longitude: number; + /** + * The m-coordinate of the point in map units. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#m) + * + * @default undefined + */ m: number; + /** + * For Point, the type is always `point`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#type) + */ + readonly type: "point"; + /** + * The x-coordinate (easting) of the point in map units. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#x) + * + * @default 0 + */ x: number; + /** + * The y-coordinate (northing) of the point in map units. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#y) + * + * @default 0 + */ y: number; + /** + * The z-coordinate (or elevation) of the point in map units. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#z) + * + * @default undefined + */ z: number; + /** + * Creates a deep clone of Point object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#clone) + * + * + */ clone(): Point; + /** + * Copies all values from another Point instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#copy) + * + * @param other The point to copy from. + * + */ copy(other: Point): void; + /** + * Computes the Euclidean distance between this Point and a given Point. Points must have the same spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#distance) + * + * @param other The point to compute the distance to. + * + */ distance(other: Point): number; + /** + * Determines if the input point is equal to the point calling the function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#equals) + * + * @param point The input point to test. + * + */ equals(point: Point): boolean; + /** + * Modifies the point geometry in-place by shifting the X-coordinate to within +/- 180 span in map units. You should [clone](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#clone) the point object before calling this method where appropriate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#normalize) + * + * + */ normalize(): Point; } interface PointConstructor { + /** + * A location defined by X, Y, and Z coordinates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) + */ + new(properties?: PointProperties): Point; fromJSON(json: any): Point; @@ -804,34 +3278,193 @@ declare namespace __esri { export const Point: PointConstructor; interface PointProperties extends GeometryProperties { + /** + * The latitude of the point if the spatial reference is Web Mercator (wkid: 3857) or WGS84 (wkid: 4326). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#latitude) + */ latitude?: number; + /** + * The longitude of the point if the spatial reference is Web Mercator (wkid: 3857) or WGS84 (wkid: 4326). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#longitude) + */ longitude?: number; + /** + * The m-coordinate of the point in map units. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#m) + * + * @default undefined + */ m?: number; + /** + * The x-coordinate (easting) of the point in map units. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#x) + * + * @default 0 + */ x?: number; + /** + * The y-coordinate (northing) of the point in map units. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#y) + * + * @default 0 + */ y?: number; + /** + * The z-coordinate (or elevation) of the point in map units. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#z) + * + * @default undefined + */ z?: number; } interface Polygon extends Geometry { + /** + * The centroid of the polygon. For a polygon with multiple rings, it represents the centroid of the largest ring. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#centroid) + */ centroid: Point; + /** + * Checks to see if polygon rings cross each other and indicates if the polygon is self-intersecting, which means the ring of the polygon crosses itself. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#isSelfIntersecting) + */ isSelfIntersecting: boolean; + /** + * An array of rings. Each ring is a two-dimensional array of numbers representing the coordinates of each vertex in the ring in the spatial reference of the view. The first vertex of each ring should always be the same as the last vertex. Each vertex is an array of two, three, or four numbers. The table below shows the various structures of a vertex array. + * + * Case | Vertex array + * --- | --- + * [without z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasZ) and [without m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasM)| [x, y] + * [without z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasZ) and [with m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasM) | [x, y, m] + * [with z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasZ) and [without m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasM) | [x, y, z] + * [with z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasZ) and [with m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasM) | [x, y, z, m] + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#rings) + */ rings: number[][][]; + /** + * For Polygon, the type is always `polygon`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#type) + */ + readonly type: "polygon"; - addRing(ring: Point[] | number[][]): Polygon; + /** + * Adds a ring to the Polygon. The ring can be one of the following: an array of numbers or an array of points. When added the index of the ring is incremented by one. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#addRing) + * + * @param points A polygon ring. The first and last coordinates/points in the ring must be the same. This can either be defined as an array of Point geometries or an array of XY coordinates. + * + */ + addRing(points: Point[] | number[][]): Polygon; + /** + * Creates a deep clone of Polygon object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#clone) + * + * + */ clone(): Polygon; + /** + * Checks on the client if the input point is inside the polygon. A point on the polygon line is considered inside. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#contains) + * + * @param point The point to test whether it is contained within the testing polygon. + * + */ contains(point: Point): boolean; + /** + * Returns a point specified by a ring and point in the path. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#getPoint) + * + * @param ringIndex The index of the ring containing the desired point. + * @param pointIndex The index of the desired point within the ring. + * + */ getPoint(ringIndex: number, pointIndex: number): Point; - insertPoint(ringIndex: number, pointIndex: number, point: Point): Polygon; + /** + * Inserts a new point into the polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#insertPoint) + * + * @param ringIndex The index of the ring in which to insert the point. + * @param pointIndex The index of the point to insert within the ring. + * @param point The point to insert. + * + */ + insertPoint(ringIndex: number, pointIndex: number, point: Point | number[]): Polygon; + /** + * Checks if a Polygon ring is clockwise. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#isClockwise) + * + * @param ring A polygon ring. The first and last coordinates/points in the ring must be the same. This can either be defined as an array of Point geometries or an array of XY coordinates. + * + */ isClockwise(ring: Point[] | number[][]): boolean; + /** + * Removes a point from the polygon at the given `pointIndex` within the ring identified by `ringIndex`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#removePoint) + * + * @param ringIndex The index of the ring containing the point to remove. + * @param pointIndex The index of the point to remove within the ring. + * + */ removePoint(ringIndex: number, pointIndex: number): Point[]; + /** + * Removes a ring from the Polygon. The index specifies which ring to remove. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#removeRing) + * + * @param index The index of the ring to remove. + * + */ removeRing(index: number): Point[]; - setPoint(ringIndex: number, pointIndex: number, point: Point): Polygon; + /** + * Updates a point in the polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#setPoint) + * + * @param ringIndex The index of the ring containing the point to update. + * @param pointIndex The index of the point to update within the ring. + * @param point The new point geometry. + * + */ + setPoint(ringIndex: number, pointIndex: number, point: Point | number[]): Polygon; } interface PolygonConstructor { + /** + * A polygon contains an array of [rings](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#rings) and a [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#spatialReference). Each ring is represented as an array points. The first and last points of a ring must be the same. A polygon also has boolean-valued [hasM](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasM) and [hasZ](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasZ) fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) + */ + new(properties?: PolygonProperties): Polygon; + /** + * Converts the given Extent to a Polygon instance. This is useful for scenarios in which you would like to display an area of interest, which is typically defined by an Extent or bounding box, as a polygon with a fill symbol in the view. Some geoprocessing tools require input geometries to be of a Polygon type and not an Extent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#fromExtent) + * + * @param extent An extent object to convert to a polygon. + * + */ fromExtent(extent: Extent): Polygon; fromJSON(json: any): Polygon; @@ -840,24 +3473,129 @@ declare namespace __esri { export const Polygon: PolygonConstructor; interface PolygonProperties extends GeometryProperties { + /** + * The centroid of the polygon. For a polygon with multiple rings, it represents the centroid of the largest ring. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#centroid) + */ centroid?: PointProperties; + /** + * Checks to see if polygon rings cross each other and indicates if the polygon is self-intersecting, which means the ring of the polygon crosses itself. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#isSelfIntersecting) + */ isSelfIntersecting?: boolean; + /** + * An array of rings. Each ring is a two-dimensional array of numbers representing the coordinates of each vertex in the ring in the spatial reference of the view. The first vertex of each ring should always be the same as the last vertex. Each vertex is an array of two, three, or four numbers. The table below shows the various structures of a vertex array. + * + * Case | Vertex array + * --- | --- + * [without z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasZ) and [without m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasM)| [x, y] + * [without z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasZ) and [with m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasM) | [x, y, m] + * [with z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasZ) and [without m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasM) | [x, y, z] + * [with z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasZ) and [with m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#hasM) | [x, y, z, m] + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html#rings) + */ rings?: number[][][]; } interface Polyline extends Geometry { + /** + * An array of paths, or line segments, that make up the polyline. Each path is a two-dimensional array of numbers representing the coordinates of each vertex in the path in the spatial reference of the view. Each vertex is represented as an array of two, three, or four numbers. The table below shows the various structures of a vertex array. + * + * Case | Vertex array + * --- | --- + * [without z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasZ) and [without m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasM) | [x, y] + * [without z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasZ) and [with m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasM) | [x, y, m] + * [with z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasZ) and [without m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasM) | [x, y, z] + * [with z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasZ) and [with m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasM) | [x, y, z, m] + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#paths) + */ paths: number[][][]; + /** + * For Polyline, the type is always `polyline`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#type) + */ + readonly type: "polyline"; - addPath(points: number[][]): Polyline; + /** + * Adds a path, or line segment, to the polyline. When added, the index of the path is incremented by one. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#addPath) + * + * @param points A polyline path. This can either be defined as an array of Point geometries or an array of XY coordinates. + * + */ + addPath(points: Point[] | number[][]): Polyline; + /** + * Creates a deep clone of Polyline object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#clone) + * + * + */ clone(): Polyline; + /** + * Returns a point specified by a path and point in the path. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#getPoint) + * + * @param pathIndex The index of a path in the polyline. + * @param pointIndex The index of a point in a path. + * + */ getPoint(pathIndex: number, pointIndex: number): Point; - insertPoint(pathIndex: number, pointIndex: number, point: Point): Polyline; + /** + * Inserts a new point into a polyline. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#insertPoint) + * + * @param pathIndex The index of the path in which to insert a point. + * @param pointIndex The index of the inserted point in the path. + * @param point The point to insert. + * + */ + insertPoint(pathIndex: number, pointIndex: number, point: Point | number[]): Polyline; + /** + * Removes a path from the Polyline. The index specifies which path to remove. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#removePath) + * + * @param index The index of the path to remove from the polyline. + * + */ removePath(index: number): Point[]; + /** + * Removes a point from the polyline at the given `pointIndex` within the path identified by the given `pathIndex`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#removePoint) + * + * @param pathIndex The index of the path containing the point to be removed. + * @param pointIndex The index of the point to be removed within the path. + * + */ removePoint(pathIndex: number, pointIndex: number): Point; - setPoint(pathIndex: number, pointIndex: number, point: Point): Polyline; + /** + * Updates a point in a polyline. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#setPoint) + * + * @param pathIndex The index of the path that contains the point to be updated. + * @param pointIndex The index of the point to be updated in the path. + * @param point Point geometry to update in the path. + * + */ + setPoint(pathIndex: number, pointIndex: number, point: Point | number[]): Polyline; } interface PolylineConstructor { + + new(properties?: PolylineProperties): Polyline; fromJSON(json: any): Polyline; @@ -866,96 +3604,354 @@ declare namespace __esri { export const Polyline: PolylineConstructor; interface PolylineProperties extends GeometryProperties { + /** + * An array of paths, or line segments, that make up the polyline. Each path is a two-dimensional array of numbers representing the coordinates of each vertex in the path in the spatial reference of the view. Each vertex is represented as an array of two, three, or four numbers. The table below shows the various structures of a vertex array. + * + * Case | Vertex array + * --- | --- + * [without z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasZ) and [without m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasM) | [x, y] + * [without z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasZ) and [with m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasM) | [x, y, m] + * [with z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasZ) and [without m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasM) | [x, y, z] + * [with z](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasZ) and [with m](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#hasM) | [x, y, z, m] + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html#paths) + */ paths?: number[][][]; } interface ScreenPoint extends Accessor { + /** + * X-coordinate in pixels relative to the top-left corner of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-ScreenPoint.html#x) + * + * @default 0 + */ x: number; + /** + * Y-coordinate in pixels relative to the top-left corner of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-ScreenPoint.html#y) + * + * @default 0 + */ y: number; + + /** + * Creates a deep clone of ScreenPoint object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-ScreenPoint.html#clone) + * + * + */ + clone(): ScreenPoint; } interface ScreenPointConstructor { + + new(properties?: ScreenPointProperties): ScreenPoint; } export const ScreenPoint: ScreenPointConstructor; interface ScreenPointProperties { + /** + * X-coordinate in pixels relative to the top-left corner of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-ScreenPoint.html#x) + * + * @default 0 + */ x?: number; + /** + * Y-coordinate in pixels relative to the top-left corner of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-ScreenPoint.html#y) + * + * @default 0 + */ y?: number; } interface SpatialReference extends Accessor, JSONSupport { - isGeographic: boolean; - isWebMercator: boolean; - isWGS84: boolean; - isWrappable: boolean; - WebMercator: SpatialReference; - WGS84: SpatialReference; + /** + * Indicates if the spatial reference refers to a geographic coordinate system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isGeographic) + */ + readonly isGeographic: boolean; + /** + * Indicates if the [wkid](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#wkid) of the spatial reference object is one of the following values: `102113`, `102100`, `3857`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWebMercator) + */ + readonly isWebMercator: boolean; + /** + * Indicates if the [wkid](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#wkid) of the spatial reference object is `4326`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWGS84) + */ + readonly isWGS84: boolean; + /** + * Indicates if the spatial reference of the map supports wrapping around the International Date Line. Value is `true` if the spatial reference is Web Mercator or WGS84. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#isWrappable) + */ + readonly isWrappable: boolean; + /** + * The well-known ID of a spatial reference. See [Projected Coordinate Systems](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/) and [Geographic Coordinate Systems](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) for the list of supported spatial references. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#wkid) + */ wkid: number; + /** + * The well-known text that defines a spatial reference. Many browsers have a limit to the length of a GET request of approximately 2048 characters. When using well-known text to specify the spatial reference you can easily exceed this limit. In these cases, you will need to setup and use a proxy page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#wkt) + */ wkt: string; + /** + * Returns a deep clone of the spatial reference object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#clone) + * + * + */ clone(): SpatialReference; + /** + * Checks if the specified spatial reference object has the same [wkid](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#wkid) or [wkt](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#wkt) as this spatial reference object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#equals) + * + * @param spatialReference The spatial reference to compare to. + * + */ equals(spatialReference: SpatialReference): boolean; } interface SpatialReferenceConstructor { + + new(properties?: SpatialReferenceProperties): SpatialReference; + + /** + * A convenience spatial reference instance for Web Mercator. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#WebMercator) + */ + WebMercator: SpatialReference; + /** + * A convenience spatial reference instance for WGS84. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#WGS84) + */ + WGS84: SpatialReference; + fromJSON(json: any): SpatialReference; } export const SpatialReference: SpatialReferenceConstructor; interface SpatialReferenceProperties { - isGeographic?: boolean; - isWebMercator?: boolean; - isWGS84?: boolean; - isWrappable?: boolean; - WebMercator?: SpatialReferenceProperties; - WGS84?: SpatialReferenceProperties; + /** + * The well-known ID of a spatial reference. See [Projected Coordinate Systems](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/) and [Geographic Coordinate Systems](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) for the list of supported spatial references. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#wkid) + */ wkid?: number; + /** + * The well-known text that defines a spatial reference. Many browsers have a limit to the length of a GET request of approximately 2048 characters. When using well-known text to specify the spatial reference you can easily exceed this limit. In these cases, you will need to setup and use a proxy page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html#wkt) + */ wkt?: string; } + interface jsonUtils { + /** + * Creates a new instance of an appropriate [Geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input `json` parameter often comes from a response to a query operation in the REST API or a [toJSON()](http://pro.arcgis.com/en/pro-app/tool-reference/conversion/features-to-json.htm) method from another ArcGIS product. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for details and examples of when and how to use this function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-jsonUtils.html#fromJSON) + * + * @param json A JSON representation of the instance in the ArcGIS format. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geometry_objects/02r3000000n1000000/) for examples of the structure of various input JSON objects. + * + */ fromJSON(json: any): Geometry; + /** + * Returns the type for a given geometry in the JSON format used by the ArcGIS platform. This only applies to geometries that can be processed by the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-jsonUtils.html#getJsonType) + * + * @param geometry The input geometry object. + * + */ getJsonType(geometry: Geometry): string; } export const jsonUtils: jsonUtils; + interface normalizeUtils { + /** + * Normalizes geometries that intersect the central meridian or fall outside the world extent so they stay within the coordinate system of the view. Only supported for Web Mercator and WGS84 spatial references. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-normalizeUtils.html#normalizeCentralMeridian) + * + * @param geometries An array of geometries to normalize. + * @param geometryService A geometry service used to perform the normalization. If this value is `null` then the default geometry service in [esriConfig.geometryServiceUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#geometryServiceUrl) is used. + * + */ normalizeCentralMeridian(geometries: Geometry[], geometryService?: GeometryService): IPromise; } export const normalizeUtils: normalizeUtils; + interface webMercatorUtils { + /** + * Returns `true` if the `source` spatial reference can be projected to the `target` spatial reference with the [project()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-webMercatorUtils.html#project) function, or if the `source` and `target` are the same [SpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-webMercatorUtils.html#canProject) + * + * @param source The input [SpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html) or an object with `spatialReference` property such as [Geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) or [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html). + * @param target The target [SpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html) or an object with `spatialReference` property such as [Geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) or [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html). + * + */ canProject(source: SpatialReference | any, target: SpatialReference | any): boolean; + /** + * Converts a geometry from geographic units (wkid: 4326) to Web Mercator units (wkid: 3857). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-webMercatorUtils.html#geographicToWebMercator) + * + * @param geometry The input geometry to convert. + * + */ geographicToWebMercator(geometry: Geometry): Geometry; + /** + * Translates the given latitude and longitude (decimal degree) values to Web Mercator XY values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-webMercatorUtils.html#lngLatToXY) + * + * @param long The longitude value to convert. + * @param lat The latitude value to convert. + * + */ lngLatToXY(long: number, lat: number): number[]; + /** + * Projects the geometry clientside (if possible). You should test the input geometry in [canProject()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-webMercatorUtils.html#canProject) prior to using this function. If the result of [canProject()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-webMercatorUtils.html#canProject) is `true`, then proceed to project. If [canProject()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-webMercatorUtils.html#canProject) returns `false`, then `project()` won't return useful results. Use [GeometryService.project()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#project) instead. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-webMercatorUtils.html#project) + * + * @param geometry The input geometry. + * @param spatialReference The target [SpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html) or an object with `spatialReference` property such as [Geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) or [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html). + * + */ project(geometry: Geometry, spatialReference: SpatialReference | any): Geometry; + /** + * Converts a geometry from Web Mercator units (wkid: 3857) to geographic units (wkid: 4326). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-webMercatorUtils.html#webMercatorToGeographic) + * + * @param geometry The input geometry to convert. + * + */ webMercatorToGeographic(geometry: Geometry): Geometry; + /** + * Translates the given Web Mercator coordinates to Longitude and Latitude values (decimal degrees). By default the returned longitude is normalized so that it is within -180 and +180. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-webMercatorUtils.html#xyToLngLat) + * + * @param x The X coordinate value to convert. + * @param y The Y coordinate value to convert. + * + */ xyToLngLat(x: number, y: number): number[]; } export const webMercatorUtils: webMercatorUtils; interface Graphic extends Accessor, JSONSupport { + /** + * Name-value pairs of fields and field values associated with the graphic. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#attributes) + */ attributes: any; + /** + * The geometry that defines the graphic's location. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#geometry) + */ geometry: Geometry; - layer: FeatureLayer | GraphicsLayer; + /** + * If applicable, references the layer in which the graphic is stored. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#layer) + */ + layer: Layer; + /** + * The template for displaying content in a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when the graphic is selected. The [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) may be used to access a graphic's [attributes](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#attributes) and display their values in the view's default popup. See the documentation for [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) for details on how to display attribute values in the popup. As of version 4.5, if the `popupTemplate` is not defined on the `Graphic`, it will use the graphic [layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#layer) popupTemplate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#popupTemplate) + */ popupTemplate: PopupTemplate; + /** + * The [Symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol.html) for the graphic. Choosing a symbol for a graphic depends on the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) type (SceneView or MapView), and the [geometry type](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#type) of the graphic. If the symbol is not specified for a graphic in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), it displays using the symbol defined in the layer's [renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html). Each graphic may have its own symbol specified when the parent layer is a [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#symbol) + */ symbol: Symbol; + /** + * Indicates the visibility of the graphic. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#visible) + * + * @default true + */ visible: boolean; + /** + * Creates a deep clone of the graphic object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#clone) + * + * + */ clone(): Graphic; + /** + * Returns the value of the specified attribute. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#getAttribute) + * + * @param name The name of the attribute. + * + */ getAttribute(name: string): any; + /** + * Sets a new value to the specified attribute. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#setAttribute) + * + * @param name The name of the attribute to set. + * @param newValue The new value to set on the named attribute. + * + */ setAttribute(name: string, newValue: any): void; } interface GraphicConstructor { + /** + * A Graphic is a vector representation of real world geographic phenomena. It can contain [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#geometry), a [symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#symbol), and [attributes](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#attributes). A Graphic is displayed in the [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) + */ + new(properties?: GraphicProperties): Graphic; fromJSON(json: any): Graphic; @@ -964,23 +3960,92 @@ declare namespace __esri { export const Graphic: GraphicConstructor; interface GraphicProperties { + /** + * Name-value pairs of fields and field values associated with the graphic. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#attributes) + */ attributes?: any; + /** + * The geometry that defines the graphic's location. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#geometry) + */ geometry?: GeometryProperties; - layer?: FeatureLayerProperties | GraphicsLayerProperties; + /** + * If applicable, references the layer in which the graphic is stored. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#layer) + */ + layer?: LayerProperties; + /** + * The template for displaying content in a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when the graphic is selected. The [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) may be used to access a graphic's [attributes](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#attributes) and display their values in the view's default popup. See the documentation for [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) for details on how to display attribute values in the popup. As of version 4.5, if the `popupTemplate` is not defined on the `Graphic`, it will use the graphic [layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#layer) popupTemplate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#popupTemplate) + */ popupTemplate?: PopupTemplateProperties; + /** + * The [Symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol.html) for the graphic. Choosing a symbol for a graphic depends on the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) type (SceneView or MapView), and the [geometry type](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#type) of the graphic. If the symbol is not specified for a graphic in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), it displays using the symbol defined in the layer's [renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html). Each graphic may have its own symbol specified when the parent layer is a [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#symbol) + */ symbol?: SymbolProperties; + /** + * Indicates the visibility of the graphic. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#visible) + * + * @default true + */ visible?: boolean; } interface Ground extends Accessor, Loadable, JSONSupport { - layers: Collection; - loaded: boolean; + /** + * A collection of [ElevationLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html) that define the elevation or terrain that makes up the ground surface. When elevation layers are added to the ground, the topographical variations of the surface are rendered in 3D as they would appear in the real world. ![elev-default](https://developers.arcgis.com/javascript/latest/assets/img/apiref/ground/elev-default.png) When the layers collection is empty, the ground surface is flat. ![no-elev](https://developers.arcgis.com/javascript/latest/assets/img/apiref/ground/no-elev.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#layers) + */ + layers: Collection; + /** + * Indicates whether the instance has loaded. When `true`, the properties of the object can be accessed. A Ground is considered loaded when its [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#layers) are fully created, but not yet loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#loaded) + * + * @default false + */ + readonly loaded: boolean; + /** + * Creates a deep clone of this object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#clone) + * + * + */ clone(): Ground; + /** + * Queries the ground layer services for elevation values for the given geometry. The returned result contains a copy of the geometry with z-values sampled from elevation data from the first layer that has data available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#queryElevation) + * + * @param geometry The geometry to sample. + * @param options Additional query options. + * @param options.returnSampleInfo Indicates whether to return additional sample information for each sampled coordinate. + * @param options.noDataValue The value that appears in the resulting geometry when there is no data available. + * + */ queryElevation(geometry: Point | Multipoint | Polyline, options?: GroundQueryElevationOptions): IPromise; } interface GroundConstructor { + /** + * The Ground class contains properties that specify how the ground surface is displayed in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). It contains a [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#layers) property, which is a collection of [ElevationLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html) that defines the elevation or terrain of the map's surface. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html) + */ + new(properties?: GroundProperties): Ground; fromJSON(json: any): Ground; @@ -989,74 +4054,242 @@ declare namespace __esri { export const Ground: GroundConstructor; interface GroundProperties extends LoadableProperties { - layers?: CollectionProperties; - loaded?: boolean; + /** + * A collection of [ElevationLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html) that define the elevation or terrain that makes up the ground surface. When elevation layers are added to the ground, the topographical variations of the surface are rendered in 3D as they would appear in the real world. ![elev-default](https://developers.arcgis.com/javascript/latest/assets/img/apiref/ground/elev-default.png) When the layers collection is empty, the ground surface is flat. ![no-elev](https://developers.arcgis.com/javascript/latest/assets/img/apiref/ground/no-elev.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#layers) + */ + layers?: CollectionProperties; } - export interface ElevationQueryResult { + /** + * Object returned when [queryElevation()](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#queryElevation) promise resolves: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#ElevationQueryResult) + */ + export interface ElevationQueryResult extends Object { + /** + * The geometry with sampled z-values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#ElevationQueryResult) + */ geometry: Point | Multipoint | Polyline; - sampleInfo: ElevationQueryResultSampleInfo[]; + /** + * Contains additional information about how the geometry was sampled. This property is present depending on whether the user set `options.returnSampleInfo = true`, for each coordinate in the geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#ElevationQueryResult) + */ + sampleInfo?: ElevationQueryResultSampleInfo[]; + /** + * The value used when there is no data available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#ElevationQueryResult) + */ noDataValue: number; } - export interface GroundQueryElevationOptions { + + export interface GroundQueryElevationOptions extends Object { + /** + * Indicates whether to return additional sample information for each sampled coordinate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#queryElevation) + * + * @default false + */ returnSampleInfo?: boolean; + /** + * The value that appears in the resulting geometry when there is no data available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#queryElevation) + * + * @default 0 + */ noDataValue?: number; } - export interface ElevationQueryResultSampleInfo { + + export interface ElevationQueryResultSampleInfo extends Object { + /** + * The resolution at which the z-value was sampled. If no data was available for sampling for a given coordinate, the dem resolution value will be -1 for that coordinate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#ElevationQueryResult) + */ demResolution: number; + /** + * The elevation source from which the data for the corresponding coordinate was sampled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#ElevationQueryResult) + */ source: ElevationLayer; } interface Credential extends Accessor { + /** + * Token expiration time specified as number of milliseconds since 1 January 1970 00:00:00 UTC. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#expires) + */ expires: number; + /** + * Indicates whether this credential belongs to a user with admin privileges. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#isAdmin) + */ isAdmin: boolean; + /** + * The Identity Manager's [setOAuthRedirectionHandler](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#setOAuthRedirectionHandler) returns an object that contains a `state` property. This information is returned for this property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#oAuthState) + */ oAuthState: any; + /** + * The server url. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#server) + */ server: string; + /** + * Indicates whether the resources accessed using this credential should be fetched over HTTPS protocol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#ssl) + */ ssl: boolean; + /** + * Token generated by the token service using the specified userId and password. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#token) + */ token: string; + /** + * User associated with the Credential object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#userId) + */ userId: string; + /** + * Destroys the credential. When the credential is destroyed, you should remove any map layers that are using this credential. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#destroy) + * + * + */ destroy(): void; + /** + * Generates a new token and updates the Credential's [token](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#token) property with the newly acquired token. Tokens are typically kept valid using a timer that automatically triggers a refresh before the token expires. Use this method in cases where the timer has been delayed or stopped. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#refreshToken) + * + * + */ refreshToken(): void; } interface CredentialConstructor { + + new(properties?: CredentialProperties): Credential; } export const Credential: CredentialConstructor; interface CredentialProperties { + /** + * Token expiration time specified as number of milliseconds since 1 January 1970 00:00:00 UTC. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#expires) + */ expires?: number; + /** + * Indicates whether this credential belongs to a user with admin privileges. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#isAdmin) + */ isAdmin?: boolean; + /** + * The Identity Manager's [setOAuthRedirectionHandler](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#setOAuthRedirectionHandler) returns an object that contains a `state` property. This information is returned for this property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#oAuthState) + */ oAuthState?: any; + /** + * The server url. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#server) + */ server?: string; + /** + * Indicates whether the resources accessed using this credential should be fetched over HTTPS protocol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#ssl) + */ ssl?: boolean; + /** + * Token generated by the token service using the specified userId and password. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#token) + */ token?: string; + /** + * User associated with the Credential object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html#userId) + */ userId?: string; } interface IdentityManager extends IdentityManagerBase { + /** + * Dialog box widget used to challenge the user for their credentials when the application attempts to access a secure resource. This property is available after the dialog-create event has fired. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#dialog) + */ dialog: any; + /** + * When accessing secure resources via Oauth 2.0 from ArcGIS.com or one of its sub-domains the IdentityManager redirects the user to the ArcGIS.com or Portal for ArcGIS sign-in page. Once the user successfully logs in they are redirected back to the application. Use this method if the application needs to execute custom logic before the page is redirected. The IdentityManager calls the custom handler function with an object containing redirection properties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#setOAuthRedirectionHandler) + * + * @param handlerFunction When called, the callback passed to `setOAuthRedirectionHandler` receives an object containing the redirection properties. + * + */ setOAuthRedirectionHandler(handlerFunction: HandlerCallback): void; + /** + * Use this method in the popup callback page to pass the token and other values back to the IdentityManager. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#setOAuthResponseHash) + * + * @param hash The token information in addition to any other values needed to be passed back to the IdentityManager. + * + */ setOAuthResponseHash(hash: string): void; + on(name: "credential-create", eventHandler: IdentityManagerCredentialCreateEventHandler): IHandle; + on(name: "credential-create", modifiers: string[], eventHandler: IdentityManagerCredentialCreateEventHandler): IHandle; + on(name: "credentials-destroy", eventHandler: IdentityManagerCredentialsDestroyEventHandler): IHandle; + on(name: "credentials-destroy", modifiers: string[], eventHandler: IdentityManagerCredentialsDestroyEventHandler): IHandle; } interface IdentityManagerConstructor { + /** + * This object provides the framework and helper methods used in managing user credentials for the following resources: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html) + */ + new(): IdentityManager; } export const IdentityManager: IdentityManagerConstructor; export interface IdentityManagerCredentialCreateEvent { + credential: Credential; } @@ -1066,91 +4299,463 @@ declare namespace __esri { export type HandlerCallback = (authorizeParams: any, authorizeUrl: string, oAuthInfo: OAuthInfo, resourceUrl: string, serverInfo: ServerInfo) => void; interface IdentityManagerBase extends Evented { + /** + * The suggested lifetime of the token in minutes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#tokenValidity) + * + * @default 60 + */ tokenValidity: number; + /** + * Returns the [Credential](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html) if the user has already signed in to access the given resource. If the user has not signed in, then the promise will be rejected and its error callback will be called. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#checkSignInStatus) + * + * @param resUrl The resource URL. + * + */ checkSignInStatus(resUrl: string): IPromise; + /** + * Destroys all credentials. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#destroyCredentials) + * + * + */ destroyCredentials(): void; + /** + * Returns the [Credential](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html) for the resource identified by the specified url. Optionally, you can provide a userId to find credentials for a specific user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#findCredential) + * + * @param url The URL to a server. + * @param userId The userId for which you want to obtain credentials. + * + */ findCredential(url: string, userId?: string): Credential; + /** + * Returns the [OAuthInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html) configuration for the passed in Portal server URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#findOAuthInfo) + * + * @param url The URL to a Portal. + * + */ findOAuthInfo(url: string): OAuthInfo; + /** + * Returns information about the server that is hosting the specified URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#findServerInfo) + * + * @param url The URL to the server + * + */ findServerInfo(url: string): ServerInfo; + /** + * Returns an object containing a token and its expiration time. It is necessary to provide the [ServerInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-ServerInfo.html) object that contains a token service URL and a user info object containing username and password. This is a helper method typically called by sub-classes to generate tokens. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#generateToken) + * + * @param serverInfo A ServerInfo object that contains a token service URL. + * @param userInfo A user info object containing a user name and password. + * @param options See the table below for the structure of this object. + * @param options.serverUrl The server URL. + * @param options.token The server token. + * @param options.ssl Indicates if the server requires SSL. + * + */ generateToken(serverInfo: ServerInfo, userInfo: any, options?: IdentityManagerBaseGenerateTokenOptions): IPromise; + /** + * Returns a [Credential](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-Credential.html) object that can be used to access the secured resource identified by the input URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#getCredential) + * + * @param url The URL for the secure resource + * @param options See the table below for the structure of the **options** object. + * @param options.error Error object returned by the server from a previous attempt to fetch the given URL. + * @param options.oAuthPopupConfirmation If set to *false*, the user will not be shown a dialog before the OAuth popup window is opened. + * @param options.retry Determines if the method should make additional attempts to get the credentials after a failure. + * @param options.token Token used for a previous unsuccessful attempt to fetch the given URL. + * + */ getCredential(url: string, options?: IdentityManagerBaseGetCredentialOptions): IPromise; + /** + * Call this method during application initialization with the JSON previously obtained from the [toJSON()](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#toJSON) method used to re-hydrate the state of IdentityManager. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#initialize) + * + * @param json The JSON obtained from the [toJSON()](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#toJSON) method. + * + */ initialize(json: any): void; + /** + * Indicates if the IdentityManager is busy accepting user input. For example, it returns `true` if the user has invoked [signIn](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#signIn) and is waiting for a response. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#isBusy) + * + * + */ isBusy(): boolean; + /** + * Subclasses must implement this method if OAuth support is required. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#oAuthSignIn) + * + * @param resUrl The resource URL. + * @param serverInfo A ServerInfo object that contains the token service URL. + * @param oAuthInfo An OAuthInfo object that contains the authorization configuration. + * @param options See the table below for the structure of the **options** object. + * @param options.error Error object returned by the server from a previous attempt to fetch the given URL. + * @param options.oAuthPopupConfirmation Indicates whether the user will be shown a dialog before the OAuth popup window is opened. + * @param options.token Token used for previous unsuccessful attempts to fetch the given URL. + * + */ oAuthSignIn(resUrl: string, serverInfo: ServerInfo, oAuthInfo: OAuthInfo, options?: IdentityManagerBaseOAuthSignInOptions): IPromise; + /** + * Registers OAuth 2.0 configurations. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#registerOAuthInfos) + * + * @param oAuthInfos An array of OAuthInfo objects that defines the OAuth configurations. + * + */ registerOAuthInfos(oAuthInfos: OAuthInfo[]): void; + /** + * Register secure servers and the token endpoints. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#registerServers) + * + * @param serverInfos An array of ServerInfos objects that defines the secure service and token endpoint. The IdentityManager makes its best guess to determine the location of the secure server and token endpoint. Therefore, in most cases calling this method is not necessary. However, if the location of your server or token endpoint is not standard, use this method to register the location. + * + */ registerServers(serverInfos: ServerInfo[]): void; + /** + * Registers the given OAuth 2.0 access token or ArcGIS Server token with the IdentityManager. See [registerOAuthInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#registerOAuthInfos) for additional information. The `registerToken` method is an advanced workflow for pre-registering long-term tokens for when you don't want users to sign in. See also [resource-proxy](https://github.com/Esri/resource-proxy) for another workflow to achieve this result. Once a user logs in, the access token is registered with the IdentityManager. Subsequently, every AJAX request made by the application forwards this token when accessing web maps and other items stored in ArcGIS Online, or resources on your server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#registerToken) + * + * @param properties See the table below for the structure of the **properties** object. + * @param properties.expires Token expiration time specified as number of milliseconds since 1 January 1970 00:00:00 UTC. + * @param properties.server For ArcGIS Online or Portal, this is https://www.arcgis.com/sharing/rest or similar to https://www.example.com/portal/sharing/rest. For ArcGIS Server this is similar to https://www.example.com/arcgis/rest/services. + * @param properties.ssl Set this to `true` if the user has an ArcGIS Online organizational account and the organization is configured to allow access to resources only through SSL. + * @param properties.token The access token. + * @param properties.userId The id of the user who owns the access token. + * + */ registerToken(properties: IdentityManagerBaseRegisterTokenProperties): void; + /** + * When accessing secured resources, the IdentityManager may prompt for username and password and send them to the server using a secure connection. Due to potential browser limitations, it may not be possible to establish a secure connection with the server if the application is being run over HTTP protocol. In such cases, the Identity Manager will abort the request to fetch the secured resource. To resolve this issue, configure your web application server with HTTPS support and run the application over HTTPS. This is the recommended solution for production environments. However, for internal development environments that don't have HTTPS support, you can define a protocol error handler that allows the Identity Manager to continue with the process over HTTP protocol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#setProtocolErrorHandler) + * + * @param handlerFunction The function to call when the protocol is mismatched. + * @param handlerFunction.resourceUrl The secure resource URL. + * @param handlerFunction.serverInfo ServerInfo object describing the server where the secure resource is hosted. + * + */ setProtocolErrorHandler(handlerFunction: IdentityManagerBaseSetProtocolErrorHandlerHandlerFunction): void; + /** + * When accessing secure resources from ArcGIS.com or one of its subdomains, the IdentityManager redirects the user to the ArcGIS.com sign-in page. Once the user successfully logs in they are redirected back to the application. Use this method if the application needs to execute custom logic before the page is redirected by creating a custom redirection handler. The IdentityManager calls the custom handler function with an object containing the redirection properties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#setRedirectionHandler) + * + * @param handlerFunction The function passed to setRedirectionHandler receives an object containing redirection properties. These properties are listed in the table below. + * @param handlerFunction.resourceUrl The URL of the secure resource that triggers the redirection to the ArcGIS.com sign-in page. + * @param handlerFunction.returnUrlParamName The application URL where the sign-in page redirects after a successful login. To create the return URL, append the application's URL to signInPage as a parameter. The *returnUrlParamName* contains the name of the parameter. + * @param handlerFunction.serverInfo The ServerInfo object describing the server where the secure resource is hosted. + * @param handlerFunction.signInPage URL of the sign-in page where users will be redirected. + * + */ setRedirectionHandler(handlerFunction: IdentityManagerBaseSetRedirectionHandlerHandlerFunction): void; + /** + * Subclasses must implement this method to create and manage the user interface used to obtain a username and password from the end user. It should perform the following tasks: + * * challenge the user for a username and password, + * * generate a token and return it to the caller. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#signIn) + * + * @param url URL for the secured resource. + * @param serverInfo A ServerInfo object that contains the token service URL. + * @param options See the table below for the structure of the **options** object. + * @param options.error Error object returned by the server from a previous attempt to fetch the given URL. + * + */ signIn(url: string, serverInfo: ServerInfo, options?: IdentityManagerBaseSignInOptions): IPromise; + /** + * Return properties of this object in JSON format. It can be stored in a cookie or persisted in HTML5 LocalStorage and later used to: + * * Initialize the IdentityManager the next time a user opens your application. + * * Share the state of the IdentityManager between multiple web pages of your website. This way users will not be asked to sign in repeatedly when they launch your app multiple times or when navigating between multiple web pages in your website. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#toJSON) + * + * + */ toJSON(): any; } interface IdentityManagerBaseConstructor { + /** + * This class provides the framework and helper methods required to implement a solution for managing user credentials. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html) + */ + new(): IdentityManagerBase; } export const IdentityManagerBase: IdentityManagerBaseConstructor; - export interface IdentityManagerBaseGenerateTokenOptions { + + export interface IdentityManagerBaseGenerateTokenOptions extends Object { + /** + * The server URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#generateToken) + */ serverUrl: string; + /** + * The server token. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#generateToken) + */ token: string; + /** + * Indicates if the server requires SSL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#generateToken) + */ ssl: boolean; } - export interface IdentityManagerBaseGetCredentialOptions { + + export interface IdentityManagerBaseGetCredentialOptions extends Object { + /** + * Error object returned by the server from a previous attempt to fetch the given URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#getCredential) + */ error?: Error; + /** + * If set to *false*, the user will not be shown a dialog before the OAuth popup window is opened. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#getCredential) + * + * @default true + */ oAuthPopupConfirmation?: boolean; + /** + * Determines if the method should make additional attempts to get the credentials after a failure. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#getCredential) + */ retry?: boolean; + /** + * Token used for a previous unsuccessful attempt to fetch the given URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#getCredential) + */ token?: string; } - export interface IdentityManagerBaseOAuthSignInOptions { - error: Error; - oAuthPopupConfirmation: boolean; - token: string; + + export interface IdentityManagerBaseOAuthSignInOptions extends Object { + /** + * Error object returned by the server from a previous attempt to fetch the given URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#oAuthSignIn) + */ + error?: Error; + /** + * Indicates whether the user will be shown a dialog before the OAuth popup window is opened. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#oAuthSignIn) + * + * @default true + */ + oAuthPopupConfirmation?: boolean; + /** + * Token used for previous unsuccessful attempts to fetch the given URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#oAuthSignIn) + */ + token?: string; } - export interface IdentityManagerBaseRegisterTokenProperties { + + export interface IdentityManagerBaseRegisterTokenProperties extends Object { + /** + * Token expiration time specified as number of milliseconds since 1 January 1970 00:00:00 UTC. + * + * [Read more...](properties.html) + */ expires?: number; + /** + * For ArcGIS Online or Portal, this is https://www.arcgis.com/sharing/rest or similar to https://www.example.com/portal/sharing/rest. For ArcGIS Server this is similar to https://www.example.com/arcgis/rest/services. + * + * [Read more...](properties.html) + */ server: string; + /** + * Set this to `true` if the user has an ArcGIS Online organizational account and the organization is configured to allow access to resources only through SSL. + * + * [Read more...](properties.html) + */ ssl?: boolean; + /** + * The access token. + * + * [Read more...](properties.html) + */ token: string; + /** + * The id of the user who owns the access token. + * + * [Read more...](properties.html) + */ userId?: string; } - export interface IdentityManagerBaseSetProtocolErrorHandlerHandlerFunction { + + export interface IdentityManagerBaseSetProtocolErrorHandlerHandlerFunction extends Object { + /** + * The secure resource URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#setProtocolErrorHandler) + */ resourceUrl: string; + /** + * ServerInfo object describing the server where the secure resource is hosted. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#setProtocolErrorHandler) + */ serverInfo: ServerInfo; } - export interface IdentityManagerBaseSetRedirectionHandlerHandlerFunction { + + export interface IdentityManagerBaseSetRedirectionHandlerHandlerFunction extends Object { + /** + * The URL of the secure resource that triggers the redirection to the ArcGIS.com sign-in page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#setRedirectionHandler) + */ resourceUrl: string; + /** + * The application URL where the sign-in page redirects after a successful login. To create the return URL, append the application's URL to signInPage as a parameter. The *returnUrlParamName* contains the name of the parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#setRedirectionHandler) + */ returnUrlParamName: string; + /** + * The ServerInfo object describing the server where the secure resource is hosted. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#setRedirectionHandler) + */ serverInfo: ServerInfo; + /** + * URL of the sign-in page where users will be redirected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#setRedirectionHandler) + */ signInPage: string; } - export interface IdentityManagerBaseSignInOptions { + + export interface IdentityManagerBaseSignInOptions extends Object { + /** + * Error object returned by the server from a previous attempt to fetch the given URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManagerBase.html#signIn) + */ error: Error; } interface OAuthInfo extends Accessor, JSONSupport { + /** + * The registered application id. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#appId) + */ appId: string; + /** + * Applications with the same value will share the stored token on the same host. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#authNamespace) + * + * @default / (forward slash) + */ authNamespace: string; + /** + * The number of minutes that the token is valid. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#expiration) + * + * @default 20160 (two weeks) + */ expiration: number; + /** + * The locale for the OAuth sign in page. The default locale is based on your browser/OS and the organization locale. You can use the locale property to change this. The locale needs to follow the language dash country code syntax supported by ArcGIS.com. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#locale) + * + * @default Based on your browser/OS and the organization locale. + */ locale: string; + /** + * The minimum time in minutes before a saved token is due to expire that it should still be considered valid for use. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#minTimeUntilExpiration) + * + * @default 30 + */ minTimeUntilExpiration: number; + /** + * Set to `true` to show the OAuth sign in page in a popup window. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#popup) + * + * @default false + */ popup: boolean; + /** + * Applicable if working with the popup user-login workflow. This is a relative page URL that redirects the user back to the secured application after successful login. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#popupCallbackUrl) + * + * @default "oauth-callback.html" + */ popupCallbackUrl: string; + /** + * The window features passed to [window.open()](https://developer.mozilla.org/en-US/docs/Web/API/Window/open). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#popupWindowFeatures) + * + * @default height=490,width=800,resizable,scrollbars,status + */ popupWindowFeatures: string; + /** + * The ArcGIS for Portal URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#portalUrl) + * + * @default "https://www.arcgis.com" + */ portalUrl: string; + /** + * Creates a copy of the OAuthInfo object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#clone) + * + * + */ clone(): OAuthInfo; } interface OAuthInfoConstructor { + + new(properties?: OAuthInfoProperties): OAuthInfo; fromJSON(json: any): OAuthInfo; @@ -1159,26 +4764,114 @@ declare namespace __esri { export const OAuthInfo: OAuthInfoConstructor; interface OAuthInfoProperties { + /** + * The registered application id. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#appId) + */ appId?: string; + /** + * Applications with the same value will share the stored token on the same host. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#authNamespace) + * + * @default / (forward slash) + */ authNamespace?: string; + /** + * The number of minutes that the token is valid. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#expiration) + * + * @default 20160 (two weeks) + */ expiration?: number; + /** + * The locale for the OAuth sign in page. The default locale is based on your browser/OS and the organization locale. You can use the locale property to change this. The locale needs to follow the language dash country code syntax supported by ArcGIS.com. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#locale) + * + * @default Based on your browser/OS and the organization locale. + */ locale?: string; + /** + * The minimum time in minutes before a saved token is due to expire that it should still be considered valid for use. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#minTimeUntilExpiration) + * + * @default 30 + */ minTimeUntilExpiration?: number; + /** + * Set to `true` to show the OAuth sign in page in a popup window. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#popup) + * + * @default false + */ popup?: boolean; + /** + * Applicable if working with the popup user-login workflow. This is a relative page URL that redirects the user back to the secured application after successful login. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#popupCallbackUrl) + * + * @default "oauth-callback.html" + */ popupCallbackUrl?: string; + /** + * The window features passed to [window.open()](https://developer.mozilla.org/en-US/docs/Web/API/Window/open). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#popupWindowFeatures) + * + * @default height=490,width=800,resizable,scrollbars,status + */ popupWindowFeatures?: string; + /** + * The ArcGIS for Portal URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#portalUrl) + * + * @default "https://www.arcgis.com" + */ portalUrl?: string; } interface ServerInfo extends Accessor, JSONSupport { + /** + * The token service URL used to generate tokens for ArcGIS Server Admin resources. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-ServerInfo.html#adminTokenServiceUrl) + */ adminTokenServiceUrl: string; + /** + * Version of the ArcGIS Server deployed on this server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-ServerInfo.html#currentVersion) + */ currentVersion: number; + /** + * The server URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-ServerInfo.html#server) + */ server: string; + /** + * Validity of short-lived token in minutes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-ServerInfo.html#shortLivedTokenValidity) + */ shortLivedTokenValidity: number; + /** + * The token service URL used to generate tokens for the secured resources on the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-ServerInfo.html#tokenServiceUrl) + */ tokenServiceUrl: string; } interface ServerInfoConstructor { + + new(properties?: ServerInfoProperties): ServerInfo; fromJSON(json: any): ServerInfo; @@ -1187,262 +4880,961 @@ declare namespace __esri { export const ServerInfo: ServerInfoConstructor; interface ServerInfoProperties { + /** + * The token service URL used to generate tokens for ArcGIS Server Admin resources. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-ServerInfo.html#adminTokenServiceUrl) + */ adminTokenServiceUrl?: string; + /** + * Version of the ArcGIS Server deployed on this server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-ServerInfo.html#currentVersion) + */ currentVersion?: number; + /** + * The server URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-ServerInfo.html#server) + */ server?: string; + /** + * Validity of short-lived token in minutes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-ServerInfo.html#shortLivedTokenValidity) + */ shortLivedTokenValidity?: number; + /** + * The token service URL used to generate tokens for the secured resources on the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-ServerInfo.html#tokenServiceUrl) + */ tokenServiceUrl?: string; } + interface kernel { - version: string; + /** + * Current version of the ArcGIS API for JavaScript. + * ```js + * require([ + * "esri/kernel" + * ], function(esriNS) { + * console.log(esriNS.version); + * }); + * ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-kernel.html#version) + */ + readonly version: string; } export const kernel: kernel; - interface BaseDynamicLayer extends Layer, ScaleRangeLayer { + interface BaseDynamicLayer extends Layer, ScaleRangeLayer, RefreshableLayer { + /** + * Adds a promise to the layer's [loadable](https://developers.arcgis.com/javascript/latest/guide/loadable/index.html) chain. This is typically used in the [load()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseDynamicLayer.html#load) method to ensure that all [loadable](https://developers.arcgis.com/javascript/latest/guide/loadable/index.html) resources required for the layer to function are loaded prior to this layer resolving and becoming [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseDynamicLayer.html#loaded). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseDynamicLayer.html#addResolvingPromise) + * + * @param promiseToLoad A promise that must resolve for the layer to resolve and move from the `loading` [status](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseDynamicLayer.html#loadStatus) to being [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseDynamicLayer.html#loaded). + * + */ addResolvingPromise(promiseToLoad: IPromise): IPromise; + /** + * This method fetches the image for the specified extent and size. Override this method if the data returned from the server needs to be processed before it can be displayed. For example, if the server returns binary data, override this method to convert the binary data to an image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseDynamicLayer.html#fetchImage) + * + * @param extent The extent of the view. This value is provided by the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param width The width of the view in pixels. This value is provided by the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param height The height of the view in pixels. This value is provided by the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param options Optional settings for the image request. The options have the following properties. + * @param options.allowImageDataAccess Indicates if access to pixels of the image is allowed. This value must be set to `true` if the layer will be drawn in 3D and [WebGL textures](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL) are required to display the layer. Loading of WebGL textures is dependent on [cross-domain access](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL#Cross-domain_textures) controls. This option allows cross-domain access to create WebGL textures. + * + */ fetchImage(extent: Extent, width: number, height: number, options?: BaseDynamicLayerFetchImageOptions): IPromise; + /** + * This method returns a URL to an image for a given extent, width, and height. Override this method to construct the URL for the image based on user interaction. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseDynamicLayer.html#getImageUrl) + * + * @param extent Extent of the view. This value is populated by the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param width Width of the view in pixels. This value is populated by the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param height Height of the view in pixels. This value is populated by the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * + */ getImageUrl(extent: Extent, width: number, height: number): IPromise | string; + on(name: "layerview-create", eventHandler: BaseDynamicLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: BaseDynamicLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: BaseDynamicLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: BaseDynamicLayerLayerviewDestroyEventHandler): IHandle; } interface BaseDynamicLayerConstructor { + /** + * This class may be extended to create dynamic map layers. Dynamic layers display an image dynamically generated on the server based on a request, including the extent and size of the image. The exported image covers the entire view extent. Each interaction on the view (e.g. panning, zooming) will result in an export of a new image on the server. Each export is unique so it cannot be cached in the browser. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseDynamicLayer.html) + */ + new(properties?: BaseDynamicLayerProperties): BaseDynamicLayer; } export const BaseDynamicLayer: BaseDynamicLayerConstructor; - interface BaseDynamicLayerProperties extends LayerProperties, ScaleRangeLayerProperties { + interface BaseDynamicLayerProperties extends LayerProperties, ScaleRangeLayerProperties, RefreshableLayerProperties { } - export interface BaseDynamicLayerFetchImageOptions { + + export interface BaseDynamicLayerFetchImageOptions extends Object { + /** + * Indicates if access to pixels of the image is allowed. This value must be set to `true` if the layer will be drawn in 3D and [WebGL textures](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL) are required to display the layer. Loading of WebGL textures is dependent on [cross-domain access](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL#Cross-domain_textures) controls. This option allows cross-domain access to create WebGL textures. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseDynamicLayer.html#fetchImage) + */ allowImageDataAccess?: boolean; } export interface BaseDynamicLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface BaseDynamicLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface BaseElevationLayer extends Layer { + /** + * The spatial reference of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#spatialReference) + * + * @default {@link module:esri/geometry/SpatialReference#WebMercator SpatialReference.WebMercator} + */ spatialReference: SpatialReference; + /** + * The tiling scheme information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#tileInfo) + */ tileInfo: TileInfo; + /** + * Adds a promise to the layer's [loadable](https://developers.arcgis.com/javascript/latest/guide/loadable/index.html) chain. This is typically used in the [load()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#load) method to ensure that all [loadable](https://developers.arcgis.com/javascript/latest/guide/loadable/index.html) resources required for the layer to function are loaded prior to this layer resolving and becoming [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#loaded). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#addResolvingPromise) + * + * @param promiseToLoad A promise that must resolve for the layer to resolve and move from the `loading` [status](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#loadStatus) to being [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#loaded). + * + */ addResolvingPromise(promiseToLoad: IPromise): IPromise; + /** + * Fetches a tile at the given level, row, and column present in the view. This method must be overwritten to display custom elevation values in the [Map.ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#ground). Note that this method must return a promise that resolves to an object with the properties defined in [ElevationTileData](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#ElevationTileData). See the following samples for examples of how to overwrite this method: + * * [Sample - Custom ElevationLayer: Exaggerating elevation](https://developers.arcgis.com/javascript/latest/sample-code/layers-custom-elevation-exaggerated/index.html) + * * [Sample - Custom ElevationLayer: Thematic data as elevation](https://developers.arcgis.com/javascript/latest/sample-code/layers-custom-elevation-thematic/index.html) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#fetchTile) + * + * @param level The level of detail of the tile to fetch. + * @param row The row (y) position of the tile to fetch. + * @param column The column (x) position of the tile to fetch. + * @param options Optional settings for the tile request. + * @param options.noDataValue The value representing pixels in the tile that don't contain an elevation value. + * + */ fetchTile(level: number, row: number, column: number, options?: BaseElevationLayerFetchTileOptions): IPromise; + /** + * Returns the bounds of the tile as an array of four numbers that can be readily converted to an [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) object. See the table in the `returns` section below for more details about the values returned by this method. This function can be used inside [fetchTile()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#fetchTile) so you can get the bounds of the current tile, convert it to an extent object, and request the desired data for the given extent. See the [Custom ElevationLayer: Thematic data as elevation](https://developers.arcgis.com/javascript/latest/sample-code/layers-custom-elevation-thematic/index.html) sample for an example of how this method works. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#getTileBounds) + * + * @param level The level of detail (LOD) of the tile. + * @param row The tile's row (y) position in the dataset. + * @param column The tiles column (x) position in the dataset. + * @param out Array for storing the tile bounds or extent. + * + */ getTileBounds(level: number, row: number, column: number, out?: number[]): number[]; + on(name: "layerview-create", eventHandler: BaseElevationLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: BaseElevationLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: BaseElevationLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: BaseElevationLayerLayerviewDestroyEventHandler): IHandle; } interface BaseElevationLayerConstructor { + /** + * BaseElevationLayer is intended to be extended for creating custom elevation layers. You create a custom [ElevationLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html) by calling [createSubclass()](https://dojotoolkit.org/reference-guide/1.10/dojo/_base/declare.html#createsubclass) on the `BaseElevationLayer`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html) + */ + new(properties?: BaseElevationLayerProperties): BaseElevationLayer; } export const BaseElevationLayer: BaseElevationLayerConstructor; interface BaseElevationLayerProperties extends LayerProperties { + /** + * The spatial reference of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#spatialReference) + * + * @default {@link module:esri/geometry/SpatialReference#WebMercator SpatialReference.WebMercator} + */ spatialReference?: SpatialReferenceProperties; + /** + * The tiling scheme information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#tileInfo) + */ tileInfo?: TileInfoProperties; } - export interface BaseElevationLayerFetchTileOptions { + + export interface BaseElevationLayerFetchTileOptions extends Object { + /** + * The value representing pixels in the tile that don't contain an elevation value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#fetchTile) + */ noDataValue?: number; } - export interface ElevationTileData { + /** + * Describes elevation contained in the pixels that comprise an elevation tile. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#ElevationTileData) + */ + export interface ElevationTileData extends Object { + /** + * The elevation values of each pixel in the tile. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#ElevationTileData) + */ values: number[]; + /** + * The width of the tile in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#ElevationTileData) + */ width: number; + /** + * The height of the tile in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#ElevationTileData) + */ height: number; + /** + * The maximum allowed error of the Z-value for each value in meters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#ElevationTileData) + */ maxZError: number; + /** + * Indicating the pixel values where no elevation data is present. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseElevationLayer.html#ElevationTileData) + */ noDataValue: number; } export interface BaseElevationLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface BaseElevationLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } - interface BaseTileLayer extends Layer, ScaleRangeLayer { + interface BaseTileLayer extends Layer, ScaleRangeLayer, RefreshableLayer { + /** + * The spatial reference of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#spatialReference) + * + * @default {@link module:esri/geometry/SpatialReference#WebMercator SpatialReference.WebMercator} + */ spatialReference: SpatialReference; + /** + * The tiling scheme information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#tileInfo) + */ tileInfo: TileInfo; + /** + * Adds a promise to the layer's [loadable](https://developers.arcgis.com/javascript/latest/guide/loadable/index.html) chain. This is typically used in the [load()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#load) method to ensure that all [loadable](https://developers.arcgis.com/javascript/latest/guide/loadable/index.html) resources required for the layer to function are loaded prior to this layer resolving and becoming [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#loaded). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#addResolvingPromise) + * + * @param promiseToLoad A promise that must resolve for the layer to resolve and move from the `loading` [status](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#loadStatus) to being [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#loaded). + * + */ addResolvingPromise(promiseToLoad: IPromise): IPromise; + /** + * This method fetches a tile for the given level, row and column present in the view. Override this method if the data or image returned from the server needs to be processed before it can be displayed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#fetchTile) + * + * @param level Level of detail of the tile to fetch. This value is provided by [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param row The row (y) position of the tile fetch. This value is provided by [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param column The column (x) position of the tile to fetch. This value is provided by [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param options Optional settings for the tile request. The options have the following properties. + * @param options.allowImageDataAccess Indicates if access to pixels of the image is allowed. This value must be set to `true` if the layer will be drawn in 3D and [WebGL textures](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL) are required to display the layer. Loading of WebGL textures is dependent on [cross-domain access](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL#Cross-domain_textures) controls. This option allows cross-domain access to create WebGL textures. + * + */ fetchTile(level: number, row: number, column: number, options?: BaseTileLayerFetchTileOptions): IPromise; + /** + * Returns the bounds of the tile as an array of four numbers that be readily converted to an [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) object. The value for each item in the array is described in the following table: + * + * Index | Value + * ------|------ + * 0 | Minimum x-value + * 1 | Minimum y-value + * 2 | Maximum x-value + * 3 | Maximum y-value + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#getTileBounds) + * + * @param level The level of detail (LOD) of the tile. + * @param row The tile's row (y) position in the dataset. + * @param column The tiles column (x) position in the dataset. + * @param out Array for storing the tile bounds or extent. + * + */ getTileBounds(level: number, row: number, column: number, out?: number[]): number[]; + /** + * This method returns a URL to an image for a given level, row and column. Override this method to construct the URL for the image based on user interaction. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#getTileUrl) + * + * @param level Level of detail. This value is provided by the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param row Tile row. This value is provided by the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param column Tile column. This value is provided by the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * + */ getTileUrl(level: number, row: number, column: number): string | IPromise; + on(name: "layerview-create", eventHandler: BaseTileLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: BaseTileLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: BaseTileLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: BaseTileLayerLayerviewDestroyEventHandler): IHandle; } interface BaseTileLayerConstructor { + /** + * This class may be extended to create a custom [TileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html). Tile layers are composed of images, such as satellite imagery, that are composed of square tiles mosaicked together in columns and rows, giving the layer the appearance that it is one continuous image. These layers have several levels of detail (LOD) that permit users to zoom in to any region of the map and load additional tiles that depict features in higher resolution at larger map scales. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html) + */ + new(properties?: BaseTileLayerProperties): BaseTileLayer; } export const BaseTileLayer: BaseTileLayerConstructor; - interface BaseTileLayerProperties extends LayerProperties, ScaleRangeLayerProperties { + interface BaseTileLayerProperties extends LayerProperties, ScaleRangeLayerProperties, RefreshableLayerProperties { + /** + * The spatial reference of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#spatialReference) + * + * @default {@link module:esri/geometry/SpatialReference#WebMercator SpatialReference.WebMercator} + */ spatialReference?: SpatialReferenceProperties; + /** + * The tiling scheme information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#tileInfo) + */ tileInfo?: TileInfoProperties; } - export interface BaseTileLayerFetchTileOptions { + + export interface BaseTileLayerFetchTileOptions extends Object { + /** + * Indicates if access to pixels of the image is allowed. This value must be set to `true` if the layer will be drawn in 3D and [WebGL textures](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL) are required to display the layer. Loading of WebGL textures is dependent on [cross-domain access](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Tutorial/Using_textures_in_WebGL#Cross-domain_textures) controls. This option allows cross-domain access to create WebGL textures. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BaseTileLayer.html#fetchTile) + */ allowImageDataAccess?: boolean; } export interface BaseTileLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface BaseTileLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface CSVLayer extends Layer { + /** + * Copyright information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#copyright) + */ copyright: string; + /** + * The column delimiter. See the table below for possible values. + * + * | Value | Description| + * | --- | --- | + * | `,` | comma | + * | ` ` | space | + * | `;` | semicolon | + * | `|` | pipe | + * | `\t` | tab-delimited | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#delimiter) + */ delimiter: string; + /** + * Specifies how graphics are placed on the vertical axis (z). This property may only be used in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). See the [ElevationInfo sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-elevationinfo/index.html) for an example of how this property may be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#elevationInfo) + */ elevationInfo: CSVLayerElevationInfo; + /** + * Configures the method for decluttering overlapping features in the view. If this property is not set (or set to `null`), every feature is drawn individually. Currently this property is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) for point features with non-draped [Icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html) or [Text](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html) symbol layers. ![declutter](https://developers.arcgis.com/javascript/latest/assets/img/samples/city-points-declutter.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#featureReduction) + */ featureReduction: CSVLayerFeatureReduction; + /** + * An array of fields in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#fields) + */ fields: Field[]; + /** + * The label definition for this layer, specified as an array of [LabelClass](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html). Use this property to specify labeling properties for the layer. For labels to display in the view, the [labelsVisible](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#labelsVisible) property of this layer must be set to `true`. + * > **Known Limitations** There is no support for labeling in 2D. Labeling is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Each graphic can have only one label. Multiple [Label classes](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html) with different [where](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#where) clauses can be used to have different label styles on different features that belong to the same layer (for example blue labels for lakes and green labels for parks). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#labelingInfo) + */ labelingInfo: LabelClass[]; + /** + * Indicates whether to display labels for this layer. If `true`, labels will appear as defined in the [labelingInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#labelingInfo) property. + * > **Known Limitations** There is no support for labeling in 2D. Labeling is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#labelsVisible) + * + * @default false + */ labelsVisible: boolean; + /** + * The latitude field name. If not specified, the API will look for following field names in the CSV source: "lat", "latitude", "y", "ycenter", "latitude83", "latdecdeg", "POINT-Y". + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#latitudeField) + */ latitudeField: string; + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#legendEnabled) + * + * @default true + */ legendEnabled: boolean; + /** + * The longitude field name. If not specified, the API will look for following field names in the CSV source: "lon", "lng", "long", "longitude", "x", "xcenter", "longitude83", "longdecdeg", "POINT-X". + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#longitudeField) + */ longitudeField: string; + /** + * The maximum scale at which the layer is visible in the view. If the map is zoomed in beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a maximum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#maxScale) + * + * @default 0 + */ maxScale: number; + /** + * The minimum scale at which the layer is visible in the view. If the map is zoomed out beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a minimum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#minScale) + * + * @default 0 + */ minScale: number; + /** + * An array of field names to include in the CSVLayer. If not specified, the layer will include all fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#outFields) + */ outFields: string[]; + /** + * Indicates whether to display popups when features in the layer are clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#popupEnabled) + * + * @default true + */ popupEnabled: boolean; + /** + * The popup template for the layer. When set on the layer, the `popupTemplate` allows users to access attributes and display their values in the [view's popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#popup) when a feature is selected using text and/or charts. See the [PopupTemplate sample](https://developers.arcgis.com/javascript/latest/sample-code/intro-popuptemplate/index.html) for an example of how [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) interacts with a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#popupTemplate) + */ popupTemplate: PopupTemplate; + /** + * The renderer assigned to the layer. The renderer defines how to visualize each feature in the layer. Depending on the renderer type, features may be visualized with the same symbol, or with varying symbols based on the values of provided attribute fields or functions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#renderer) + */ renderer: Renderer; + /** + * Apply perspective scaling to screen-size point symbols in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). When `true`, screen sized objects such as [icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [labels](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html) or [callouts](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-Callout3D.html) integrate better in the 3D scene by applying a certain perspective projection to the sizing of features. This only applies when using a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). `layer.screenSizePerspectiveEnabled = true` ![screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-screenSize-perspective.png) `layer.screenSizePerspectiveEnabled = false` ![no-screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-no-screenSize-perspective.png) + * > **Known Limitations** Screen size perspective is currently not optimized for situations where the camera is very near the ground, or for scenes with point features located far from the ground surface. In these cases it may be better to turn off screen size perspective. As screen size perspective changes the size based on distance to the camera, it should be set to false when using {@link module:esri/renderers/Renderer#SizeVisualVariable size visual variables}. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#screenSizePerspectiveEnabled) + * + * @default true + */ screenSizePerspectiveEnabled: boolean; + /** + * The URL of the CSV file. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#url) + */ url: string; + on(name: "layerview-create", eventHandler: CSVLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: CSVLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: CSVLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: CSVLayerLayerviewDestroyEventHandler): IHandle; } interface CSVLayerConstructor { + /** + * The CSVLayer is a point layer based on a CSV file (.csv, .txt). CSV is a plain-text file format used to represent tabular data, including geographic point features (latitude, longitude). Typically the latitude coordinate is the Y value, and the longitude coordinate is the X value. Features from the CSV file are accessible via the API so you can query features and use them as input to geometry or geoprocessing services. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html) + */ + new(properties?: CSVLayerProperties): CSVLayer; } export const CSVLayer: CSVLayerConstructor; interface CSVLayerProperties extends LayerProperties { + /** + * Copyright information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#copyright) + */ copyright?: string; + /** + * The column delimiter. See the table below for possible values. + * + * | Value | Description| + * | --- | --- | + * | `,` | comma | + * | ` ` | space | + * | `;` | semicolon | + * | `|` | pipe | + * | `\t` | tab-delimited | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#delimiter) + */ delimiter?: string; + /** + * Specifies how graphics are placed on the vertical axis (z). This property may only be used in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). See the [ElevationInfo sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-elevationinfo/index.html) for an example of how this property may be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#elevationInfo) + */ elevationInfo?: CSVLayerElevationInfo; + /** + * Configures the method for decluttering overlapping features in the view. If this property is not set (or set to `null`), every feature is drawn individually. Currently this property is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) for point features with non-draped [Icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html) or [Text](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html) symbol layers. ![declutter](https://developers.arcgis.com/javascript/latest/assets/img/samples/city-points-declutter.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#featureReduction) + */ featureReduction?: CSVLayerFeatureReduction; + /** + * An array of fields in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#fields) + */ fields?: FieldProperties[]; + /** + * The label definition for this layer, specified as an array of [LabelClass](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html). Use this property to specify labeling properties for the layer. For labels to display in the view, the [labelsVisible](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#labelsVisible) property of this layer must be set to `true`. + * > **Known Limitations** There is no support for labeling in 2D. Labeling is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Each graphic can have only one label. Multiple [Label classes](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html) with different [where](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#where) clauses can be used to have different label styles on different features that belong to the same layer (for example blue labels for lakes and green labels for parks). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#labelingInfo) + */ labelingInfo?: LabelClassProperties[]; + /** + * Indicates whether to display labels for this layer. If `true`, labels will appear as defined in the [labelingInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#labelingInfo) property. + * > **Known Limitations** There is no support for labeling in 2D. Labeling is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#labelsVisible) + * + * @default false + */ labelsVisible?: boolean; + /** + * The latitude field name. If not specified, the API will look for following field names in the CSV source: "lat", "latitude", "y", "ycenter", "latitude83", "latdecdeg", "POINT-Y". + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#latitudeField) + */ latitudeField?: string; + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#legendEnabled) + * + * @default true + */ legendEnabled?: boolean; + /** + * The longitude field name. If not specified, the API will look for following field names in the CSV source: "lon", "lng", "long", "longitude", "x", "xcenter", "longitude83", "longdecdeg", "POINT-X". + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#longitudeField) + */ longitudeField?: string; + /** + * The maximum scale at which the layer is visible in the view. If the map is zoomed in beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a maximum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#maxScale) + * + * @default 0 + */ maxScale?: number; + /** + * The minimum scale at which the layer is visible in the view. If the map is zoomed out beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a minimum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#minScale) + * + * @default 0 + */ minScale?: number; + /** + * An array of field names to include in the CSVLayer. If not specified, the layer will include all fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#outFields) + */ outFields?: string[]; + /** + * Indicates whether to display popups when features in the layer are clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#popupEnabled) + * + * @default true + */ popupEnabled?: boolean; + /** + * The popup template for the layer. When set on the layer, the `popupTemplate` allows users to access attributes and display their values in the [view's popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#popup) when a feature is selected using text and/or charts. See the [PopupTemplate sample](https://developers.arcgis.com/javascript/latest/sample-code/intro-popuptemplate/index.html) for an example of how [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) interacts with a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#popupTemplate) + */ popupTemplate?: PopupTemplateProperties; + /** + * The renderer assigned to the layer. The renderer defines how to visualize each feature in the layer. Depending on the renderer type, features may be visualized with the same symbol, or with varying symbols based on the values of provided attribute fields or functions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#renderer) + */ renderer?: RendererProperties; + /** + * Apply perspective scaling to screen-size point symbols in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). When `true`, screen sized objects such as [icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [labels](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html) or [callouts](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-Callout3D.html) integrate better in the 3D scene by applying a certain perspective projection to the sizing of features. This only applies when using a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). `layer.screenSizePerspectiveEnabled = true` ![screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-screenSize-perspective.png) `layer.screenSizePerspectiveEnabled = false` ![no-screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-no-screenSize-perspective.png) + * > **Known Limitations** Screen size perspective is currently not optimized for situations where the camera is very near the ground, or for scenes with point features located far from the ground surface. In these cases it may be better to turn off screen size perspective. As screen size perspective changes the size based on distance to the camera, it should be set to false when using {@link module:esri/renderers/Renderer#SizeVisualVariable size visual variables}. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#screenSizePerspectiveEnabled) + * + * @default true + */ screenSizePerspectiveEnabled?: boolean; + /** + * The URL of the CSV file. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#url) + */ url?: string; } - export interface CSVLayerElevationInfo { + + export interface CSVLayerElevationInfo extends Object { + /** + * Defines how the graphic is placed with respect to the terrain surface. See the table below for a list of possible values. + * + * Mode | Description + * ------|------------ + * on-the-ground | Graphics are draped on the terrain surface. This is the default value for [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) + * geometries rendered with [ObjectSymbol3DLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html). + * relative-to-ground | Graphics are placed at an elevation relative to the terrain surface. The graphic's elevation is determined + * by summing up the terrain elevation and the result of `featureExpressionInfo` (if defined). This is the default value for [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries rendered with [IconSymbol3DLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html). absolute-height | Graphics are placed at an absolute height above sea level. This height is determined by the result of `featureExpressionInfo` (if defined). This mode doesn't take the elevation of the terrain into account. relative-to-scene | Graphics are aligned to buildings and other objects part of 3D Object [SceneLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) or [IntegratedMeshLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html), depending on which has higher elevation. If the graphic is not directly above a building or any other feature, it is aligned to the terrain surface elevation. If defined, the result of `featureExpressionInfo` is added to the 3D Object/terrain surface elevation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#elevationInfo) + */ mode: string; + /** + * An elevation offset, which is added to the vertical position of the graphic. If `unit` is not defined, the offset is in `meters`. When `mode = "on-the-ground"`, this property has no effect. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#elevationInfo) + */ offset?: number; + /** + * This object contains information about setting a custom height on the graphic. If this property is set, then z values are not considered for calculating graphic height. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#elevationInfo) + */ featureExpressionInfo?: CSVLayerElevationInfoFeatureExpressionInfo; + /** + * The unit for `featureExpressionInfo` and `offset` values. **Possible Values:** feet | meters | kilometers | miles | us-feet | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#elevationInfo) + */ unit?: string; } - export interface CSVLayerElevationInfoFeatureExpressionInfo { + + export interface CSVLayerElevationInfoFeatureExpressionInfo extends Object { + /** + * An [Arcade expression](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) evaluating to a number that determines the height of the graphic. When `mode = "on-the-ground"`, this property has no effect. For line and polygon geometries the result of the expression is the same for all vertices of a feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#elevationInfo) + */ expression?: string; } - export interface CSVLayerFeatureReduction { + + export interface CSVLayerFeatureReduction extends Object { + /** + * Type of the decluttering method. The only supported type at the moment is `"selection"`. In this method, some of the overlapping features are hidden such that none of the remaining features intersect on screen. Label deconfliction also respects this option and hides labels that would overlap with the features of this layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#featureReduction) + */ type: string; } export interface CSVLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface CSVLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface DynamicLayer { + /** + * The portal item from which the layer is loaded. This will load the layer along with any overridden properties (e.g. renderers, definition expressions, etc.) saved to the portal item, not the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-DynamicLayer.html#portalItem) + */ portalItem: PortalItem; + /** + * The URL to the REST endpoint of the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-DynamicLayer.html#url) + */ url: string; + /** + * This method fetches the image for the specified extent and size. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-DynamicLayer.html#fetchImage) + * + * @param extent The extent of the view. + * @param width The width of the view in pixels. + * @param height The height of the view in pixels. + * @param options The parameter options is an object with the following properties. + * @param options.allowImageDataAccess Indicates if the access to the pixels of the image is required. + * @param options.rotation The rotation in degrees of the exported image. Available since ArcGIS for Server 10.3. + * @param options.pixelRatio The ratio of the resolution in physical pixels of the image to the resolution it will be displayed at. + * + */ fetchImage(extent: Extent, width: number, height: number, options?: DynamicLayerFetchImageOptions): IPromise; + /** + * This method returns a URL to an image for a given extent, width and height. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-DynamicLayer.html#getImageUrl) + * + * @param extent The extent of the exported image. + * @param width The width of the view in pixels. + * @param height The height of the view in pixels. + * @param options The parameter options is an object with the following properties. + * @param options.pixelRatio The ratio of the resolution in physical pixels of the image to the resolution it will be displayed at. + * @param options.rotation The rotation in degrees of the exported image. Available since ArcGIS for Server 10.3. + * + */ getImageUrl(extent: Extent, width: number, height: number, options?: DynamicLayerGetImageUrlOptions): IPromise | string; } interface DynamicLayerConstructor { + + new(): DynamicLayer; } export const DynamicLayer: DynamicLayerConstructor; interface DynamicLayerProperties { + /** + * The portal item from which the layer is loaded. This will load the layer along with any overridden properties (e.g. renderers, definition expressions, etc.) saved to the portal item, not the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-DynamicLayer.html#portalItem) + */ portalItem?: PortalItemProperties; + /** + * The URL to the REST endpoint of the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-DynamicLayer.html#url) + */ url?: string; } - export interface DynamicLayerFetchImageOptions { + + export interface DynamicLayerFetchImageOptions extends Object { + /** + * Indicates if the access to the pixels of the image is required. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-DynamicLayer.html#fetchImage) + */ allowImageDataAccess?: boolean; + /** + * The rotation in degrees of the exported image. Available since ArcGIS for Server 10.3. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-DynamicLayer.html#fetchImage) + */ rotation?: number; + /** + * The ratio of the resolution in physical pixels of the image to the resolution it will be displayed at. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-DynamicLayer.html#fetchImage) + */ pixelRatio?: number; } - export interface DynamicLayerGetImageUrlOptions { + + export interface DynamicLayerGetImageUrlOptions extends Object { + /** + * The ratio of the resolution in physical pixels of the image to the resolution it will be displayed at. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-DynamicLayer.html#getImageUrl) + */ pixelRatio?: number; + /** + * The rotation in degrees of the exported image. Available since ArcGIS for Server 10.3. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-DynamicLayer.html#getImageUrl) + */ rotation?: number; } interface ElevationLayer extends Layer, ArcGISMapService, ArcGISCachedService, PortalLayer, TiledLayer { + /** + * URL pointing to the Elevation layer resource on an ArcGIS Image Server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#url) + */ url: string; + /** + * Requests a tile from the service and decodes the data into a linear array of elevation values. The returned promise resolves with a plain object describing the obtained elevation data for the tile. The object has the following properties: + * + * Property | Type | Description + * ----------|--------------|------------ + * values | Float32Array | The elevation values contained in the tile. + * width | number | The number of elevation values in one row of the tile. + * height | number | The number of elevation values in one column of the tile. + * maxZError | number | The upper bound for the compression error on the elevation values. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#fetchTile) + * + * @param level the tile level. + * @param row the tile row. + * @param column the tile column. + * @param noDataValue the value to use when a tile is partially missing data. + * + */ fetchTile(level: number, row: number, column: number, noDataValue?: number): IPromise; + /** + * Queries the service layer for elevation values for the given geometry. The returned result contains a copy of the geometry with z-values sampled from elevation data from the service. The resolution from which the elevation is queried can be set using the `demResolution` option. In many cases, `auto` demResolution can be used to get high quality elevation samples without the need to know exactly where the data in the service is located. This is particularly useful for services which combine elevation data from many sources (such as the world elevation service). If more control, or higher quality samples are required, use either `finest-contiguous` or a fixed `{number}` resolution. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#queryElevation) + * + * @param geometry The geometry to use for sampling elevation data. + * @param options Additional query options. See the table below. + * @param options.demResolution + * Controls the horizontal resolution (cell size) in meters from which elevation data is sampled (defaults to `auto`). See the table below for more details on the different settings. + * + * demResolution | Description + * -----------------------|------------- + * `auto` | Automatically chooses an appropriate resolution for each coordinate of the input geometry. The current implementation will try to use the finest available resolution given that the total required number of tile requests does not exceed a certain maximum amount (currently 100). Note that this may result in values being sampled from different resolutions. + * `finest-contiguous` | Sample elevation from the finest available resolution (cell size) across the entire geometry. + * `{number}` | Sample elevation from the resolution closest to the specified resolution (in meters). + * @param options.returnSampleInfo Indicates whether to return additional sample information for each coordinate. + * @param options.noDataValue The value to use when there is no data available. + * + */ queryElevation(geometry: Point | Multipoint | Polyline, options?: ElevationLayerQueryElevationOptions): IPromise; + on(name: "layerview-create", eventHandler: ElevationLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: ElevationLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: ElevationLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: ElevationLayerLayerviewDestroyEventHandler): IHandle; } interface ElevationLayerConstructor { + /** + * ElevationLayer is a tile layer used for rendering elevations in [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). A default [world elevation layer](http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer) can be added to the map by setting the [map's ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#ground) property to `world-elevation`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html) + */ + new(properties?: ElevationLayerProperties): ElevationLayer; fromJSON(json: any): ElevationLayer; @@ -1451,84 +5843,409 @@ declare namespace __esri { export const ElevationLayer: ElevationLayerConstructor; interface ElevationLayerProperties extends LayerProperties, ArcGISMapServiceProperties, ArcGISCachedServiceProperties, PortalLayerProperties, TiledLayerProperties { + /** + * URL pointing to the Elevation layer resource on an ArcGIS Image Server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#url) + */ url?: string; } - export interface ElevationLayerQueryElevationOptions { + + export interface ElevationLayerQueryElevationOptions extends Object { + /** + * Controls the horizontal resolution (cell size) in meters from which elevation data is sampled (defaults to `auto`). See the table below for more details on the different settings. + * + * demResolution | Description + * -----------------------|------------- + * `auto` | Automatically chooses an appropriate resolution for each coordinate of the input geometry. The current implementation will try to use the finest available resolution given that the total required number of tile requests does not exceed a certain maximum amount (currently 100). Note that this may result in values being sampled from different resolutions. + * `finest-contiguous` | Sample elevation from the finest available resolution (cell size) across the entire geometry. + * `{number}` | Sample elevation from the resolution closest to the specified resolution (in meters). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#queryElevation) + * + * @default auto + */ demResolution?: number | string; + /** + * Indicates whether to return additional sample information for each coordinate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#queryElevation) + * + * @default false + */ returnSampleInfo?: boolean; + /** + * The value to use when there is no data available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#queryElevation) + * + * @default 0 + */ noDataValue?: number; } - export interface ElevationLayerElevationQueryResult { + /** + * Object returned when [queryElevation()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#queryElevation) promise resolves: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#ElevationQueryResult) + */ + export interface ElevationLayerElevationQueryResult extends Object { + /** + * The geometry with sampled z-values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#ElevationQueryResult) + */ geometry: Point | Multipoint | Polyline; - sampleInfo: ElevationLayerElevationQueryResultSampleInfo[]; + /** + * Contains additional information about how the geometry was sampled. This property is present depending on whether the user set `options.returnSampleInfo = true`, for each coordinate in the geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#ElevationQueryResult) + */ + sampleInfo?: ElevationLayerElevationQueryResultSampleInfo[]; + /** + * The value used when there is no data available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#ElevationQueryResult) + */ noDataValue: number; } export interface ElevationLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface ElevationLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } - export interface ElevationLayerElevationQueryResultSampleInfo { + + export interface ElevationLayerElevationQueryResultSampleInfo extends Object { + /** + * The resolution at which the z-value was sampled. If no data was available for sampling for a given coordinate, the dem resolution value will be -1 for that coordinate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html#ElevationQueryResult) + */ demResolution: number; } - interface FeatureLayer extends Layer, PortalLayer, ScaleRangeLayer { - capabilities: FeatureLayerCapabilities; + interface FeatureLayer extends Layer, PortalLayer, ScaleRangeLayer, RefreshableLayer { + /** + * Indicates the layer's supported capabilities. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ + readonly capabilities: FeatureLayerCapabilities; + /** + * The copyright text as defined by the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#copyright) + */ copyright: string; + /** + * The SQL where clause used to filter features on the client. Only the features that satisfy the definition expression are displayed in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). Setting a definition expression is useful when the dataset is large and you don't want to bring all features to the client for analysis. Definition expressions may be set when a layer is constructed prior to it loading in the view or after it has been added to the map. If the definition expression is set after the layer has been added to the map, the view will automatically refresh itself to display the features that satisfy the new definition expression. + * > **Known Limitations** Definition expressions will not be honored when working with FeatureLayers created from client-side graphics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#definitionExpression) + */ definitionExpression: string; + /** + * The name of the layer's primary display field. The value of this property matches the name of one of the fields of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#displayField) + */ displayField: string; + /** + * Specifies how graphics are placed on the vertical axis (z). This property may only be used in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). See the [ElevationInfo sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-elevationinfo/index.html) for an example of how this property may be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) + */ elevationInfo: FeatureLayerElevationInfo; + /** + * Configures the method for decluttering overlapping features in the view. If this property is not set (or set to `null`), every feature is drawn individually. Currently this property is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) for point features with non-draped [Icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html) or [Text](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html) symbol layers. ![declutter](https://developers.arcgis.com/javascript/latest/assets/img/samples/city-points-declutter.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#featureReduction) + */ featureReduction: FeatureLayerFeatureReduction; + /** + * An array of fields in the layer. Each field represents an attribute that may contain a value for each feature in the layer. For example, a field named `POP_2015`, stores information about total population as a numeric value for each feature; this value represents the total number of people living within the geographic bounds of the feature. This property must be set in the constructor when creating a FeatureLayer from client-side [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). To create FeatureLayers from client-side graphics you must also set the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source), [objectIdField](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#spatialReference), and [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#geometryType) properties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields) + */ fields: Field[]; - gdbVersion: string; + /** + * The version of the geodatabase of the feature service data. Read the [Overview of versioning](https://desktop.arcgis.com/en/arcmap/latest/manage-data/geodatabases/an-overview-of-versioning.htm) topic for more details about this capability. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#gdbVersion) + */ + readonly gdbVersion: string; + /** + * The geometry type of features in the layer. All features must be of the same type. This property is read-only when the layer is created from a [url](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#url). However, when creating a FeatureLayer from client-side graphics, this property must be specified in the layer's constructor along with the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#spatialReference), [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields), and [objectIdField](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField) properties. **Possible Values:** point | mulitpoint | polyline | polygon | extent + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#geometryType) + */ geometryType: string; - hasAttachments: boolean; - hasM: boolean; - hasZ: boolean; + /** + * Value is `true` if attachments are enabled on the feature layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#hasAttachments) + * + * @default false + */ + readonly hasAttachments: boolean; + /** + * Indicates if the features in the layer have M values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#hasM) + * + * @default false + */ + readonly hasM: boolean; + /** + * Indicates if the features in the layer have Z values. See [elevationInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) for details regarding placement and rendering of graphics with z-values in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#hasZ) + * + * @default false + */ + readonly hasZ: boolean; + /** + * The label definition for this layer, specified as an array of [LabelClass](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html). Use this property to specify labeling properties for the layer such as label expression, placement, and size. For labels to display in the view, the [labelsVisible](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#labelsVisible) property of this layer must be set to `true`. + * > **Known Limitations** There is no support for labeling in 2D. Labeling is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Each graphic can have only one label. Multiple [Label classes](esri-layers-support-LabelClass.html) with different [where](esri-layers-support-LabelClass.html#where) clauses can be used to have different label styles on different features that belong to the same layer (for example blue labels for lakes and green labels for parks). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#labelingInfo) + */ labelingInfo: LabelClass[]; + /** + * Indicates whether to display labels for this layer. If `true`, labels will appear as defined in the [labelingInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#labelingInfo) property. + * > **Known Limitations** There is no support for labeling in 2D. Labeling is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#labelsVisible) + * + * @default false + */ labelsVisible: boolean; + /** + * The layer ID, or layer index, of a Feature Service layer. This is particularly useful when loading a single FeatureLayer with the [portalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#portalItem) property from a service containing multiple layers. You can specify this value in one of two scenarios: + * * When loading the layer via the [portalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#portalItem) property. + * * When pointing the layer [url](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#url) directly to the Feature Service. + * + * + * If a layerId is not specified in either of the above scenarios, then the first layer in the service (`layerId = 0`) is selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#layerId) + */ layerId: number; + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#legendEnabled) + * + * @default true + */ legendEnabled: boolean; + /** + * The name of one of the provided [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields) for each graphic containing a unique value or identifier for that graphic. This is required when constructing a FeatureLayer from a collection of client-side [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). When creating a FeatureLayer from client-side graphics, the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source), [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#spatialReference), and [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#geometryType) properties must also be set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField) + */ objectIdField: string; + /** + * An array of field names from the service to include in the FeatureLayer. If not specified, the layer will only return the `OBJECTID` field. To fetch the values from all fields in the layer, use `["*"]`. This is particularly useful when editing features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#outFields) + */ outFields: string[]; + /** + * Indicates whether to display popups when features in the layer are clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#popupEnabled) + * + * @default true + */ popupEnabled: boolean; + /** + * The popup template for the layer. When set on the layer, the `popupTemplate` allows users to access attributes and display their values in the [view's popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#popup) when a feature is selected using text and/or charts. See the [PopupTemplate sample](https://developers.arcgis.com/javascript/latest/sample-code/intro-popuptemplate/index.html) for an example of how [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) interacts with a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#popupTemplate) + */ popupTemplate: PopupTemplate; + /** + * The renderer assigned to the layer. The renderer defines how to visualize each feature in the layer. Depending on the renderer type, features may be visualized with the same symbol, or with varying symbols based on the values of provided attribute fields or functions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#renderer) + */ renderer: Renderer; + /** + * When `true`, indicates that M values will be returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#returnM) + * + * @default false + */ returnM: boolean; + /** + * When `true`, indicates that Z values will be returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#returnZ) + * + * @default false + */ returnZ: boolean; + /** + * Apply perspective scaling to screen-size point symbols in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). When `true`, screen sized objects such as [icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [labels](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html) or [callouts](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-Callout3D.html) integrate better in the 3D scene by applying a certain perspective projection to the sizing of features. This only applies when using a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). `layer.screenSizePerspectiveEnabled = true` ![screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-screenSize-perspective.png) `layer.screenSizePerspectiveEnabled = false` ![no-screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-no-screenSize-perspective.png) + * > **Known Limitations** Screen size perspective is currently not optimized for situations where the camera is very near the ground, or for scenes with point features located far from the ground surface. In these cases it may be better to turn off screen size perspective. As screen size perspective changes the size based on distance to the camera, it should be set to false when using {@link module:esri/renderers/Renderer#SizeVisualVariable size visual variables}. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#screenSizePerspectiveEnabled) + * + * @default true + */ screenSizePerspectiveEnabled: boolean; + /** + * A collection of [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) objects used to create a FeatureLayer. This property should only used when creating a FeatureLayer from client-side graphics. When creating a FeatureLayer from client-side graphics, the [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields), [objectIdField](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#spatialReference), and [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#geometryType) properties must also be set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source) + */ source: Collection; + /** + * The spatial reference of the layer. When creating the layer from a [url](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#url), the spatial reference is read from the service. This property should be set explicitly when creating a FeatureLayer from client-side graphics. When creating a FeatureLayer from client-side graphics, the [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields), [objectIdField](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField), [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source), and [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#geometryType) properties must also be set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#spatialReference) + */ spatialReference: SpatialReference; + /** + * An array of feature templates defined in the feature layer. See [ArcGIS Pro subtypes document](https://pro.arcgis.com/en/pro-app/help/data/geodatabases/overview/an-overview-of-subtypes.htm). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#templates) + */ templates: FeatureTemplate[]; - token: string; + /** + * Token generated by the token service using the specified userId and password. The recommended approach to pass a token on a layer is to use [IdentityManager.registerToken()](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#registerToken). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#token) + */ + readonly token: string; + /** + * The name of the field holding the type ID or subtypes for the features. See [ArcGIS Pro subtypes document](https://pro.arcgis.com/en/pro-app/help/data/geodatabases/overview/an-overview-of-subtypes.htm). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#typeIdField) + */ typeIdField: string; + /** + * An array of subtypes defined in the feature service exposed by ArcGIS REST API. Each item includes information about the type, such as the type ID, name, and definition expression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#types) + */ types: FeatureType[]; + /** + * The URL of the REST endpoint of the layer or service. The URL may either point to a resource on ArcGIS for Server, Portal for ArcGIS, or ArcGIS Online. If the url points directly to a service, then the layer must be specified in the [layerId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#layerId) property. If no [layerId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#layerId) is given, then the first layer in the service will be loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#url) + */ url: string; - version: number; + /** + * The version of ArcGIS Server in which the layer is published. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#version) + */ + readonly version: number; + /** + * Applies edits to features in a feature layer. New features can be created and existing features can be updated or deleted. Feature geometries and/or attributes may be modified. Only applicable to layers in a [feature service](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Feature_Service/02r3000000z2000000/). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdits) + * + * @param edits Object containing features to be added, updated or deleted. + * @param edits.addFeatures Array of features to be added. Values of non nullable fields must be provided when adding new features. Date fields must have [numeric](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) values representing universal time. + * @param edits.updateFeatures Array of features to be updated. Each feature must have valid [objectId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField). Values of non nullable fields must be provided when updating features. Date fields must have [numeric](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) values representing universal time. + * @param edits.deleteFeatures An array of features or objects to be deleted. When an array of features is passed, each feature must have a valid [objectId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField). When an array of objects is used, each object must have a valid `objectId` property. + * + */ applyEdits(edits: FeatureLayerApplyEditsEdits): IPromise; + /** + * Creates query parameters that can be used to fetch features that satisfy the layer's current filters, and definitions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#createQuery) + * + * + */ createQuery(): Query; + /** + * Returns the [Domain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Domain.html) associated with the given field name. The domain can be either a [CodedValueDomain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CodedValueDomain.html) or [RangeDomain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RangeDomain.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#getFieldDomain) + * + * @param fieldName Name of the field. + * @param options An object specifying additional options. See the object specification table below for the required properties of this object. + * @param options.feature The feature to which the [Domain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Domain.html) is assigned. + * + */ getFieldDomain(fieldName: string, options?: FeatureLayerGetFieldDomainOptions): Domain; - queryExtent(params?: Query): IPromise; - queryFeatureCount(params?: Query): IPromise; - queryFeatures(params?: Query): IPromise; - queryObjectIds(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against the feature service and returns the [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) of features that satisfy the query. If no parameters are specified, then the extent and count of all features satisfying the layer's configuration/filters are returned. This is valid only for [hosted feature services](http://doc.arcgis.com/en/arcgis-online/share-maps/hosted-web-layers.htm) on [arcgis.com](http://arcgis.com) and for ArcGIS Server 10.3.1 and later. + * > To query for the extent of features/graphics available to or visible in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) on the client rather than making a server-side query, you must use the [FeatureLayerView.queryExtent()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryExtent) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryExtent) + * + * @param params Specifies the attributes and spatial filter of the query. If no parameters are specified, then the extent and count of all features satisfying the layer's configuration/filters are returned. If working with a FeatureLayer created from a FeatureCollection (via [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source)), only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. + * + */ + queryExtent(params?: Query | QueryProperties): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against the feature service and returns the number of features that satisfy the query. If no parameters are specified, then the total number of features satisfying the layer's configuration/filters is returned. + * > To query for the count of features/graphics available to or visible in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) on the client rather than making a server-side query, you must use the [FeatureLayerView.queryFeatureCount()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatureCount) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryFeatureCount) + * + * @param params Specifies the attributes and spatial filter of the query. If no parameters are specified, then the total number of features satisfying the layer's configuration/filters is returned. If working with a FeatureLayer created from a FeatureCollection (via [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source)), only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. + * + */ + queryFeatureCount(params?: Query | QueryProperties): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against the feature service and returns a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html), which can be accessed using the `.then()` method once the promise resolves. A [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) contains an array of [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) features, which can be added to the [view's graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#graphics). This array will not be populated if zero results are found. + * > To query features/graphics available to or visible in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) on the client rather than making a server-side query, you must use the [FeatureLayerView.queryFeatures()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatures) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryFeatures) + * + * @param params Specifies the attributes and spatial filter of the query. If no parameters are specified, then all features satisfying the layer's configuration/filters are returned. If working with a FeatureLayer created from a FeatureCollection (via [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source)), only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. + * + */ + queryFeatures(params?: Query | QueryProperties): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against the feature service and returns an array of Object IDs for features that satisfy the input query. If no parameters are specified, then the Object IDs of all features satisfying the layer's configuration/filters are returned. + * > To query for ObjectIDs of features/graphics available to or visible in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) on the client rather than making a server-side query, you must use the [FeatureLayerView.queryObjectIds()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryObjectIds) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryObjectIds) + * + * @param params Specifies the attributes and spatial filter of the query. If no parameters are specified, then the Object IDs of all features satisfying the layer's configuration/filters are returned. If working with a FeatureLayer created from a FeatureCollection (via [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source)), only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. + * + */ + queryObjectIds(params?: Query | QueryProperties): IPromise; + on(name: "layerview-create", eventHandler: FeatureLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: FeatureLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: FeatureLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: FeatureLayerLayerviewDestroyEventHandler): IHandle; } interface FeatureLayerConstructor { + /** + * A FeatureLayer is a single layer that can be created from a [Map Service](http://server.arcgis.com/en/server/latest/publish-services/windows/what-is-a-map-service.htm) or [Feature Service](http://server.arcgis.com/en/server/latest/publish-services/windows/what-is-a-feature-service-.htm); ArcGIS Online or ArcGIS for Portal items; or from an array of client-side graphics. It is composed of discrete features, each of which has a [Geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) that allows it to be rendered in either a 2D [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) as a [graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) with spatial context. Features also contain data [attributes](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#attributes) that provide additional information about the real-world feature it represents; attributes may be viewed in [popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#popupTemplate) windows and used for [rendering](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) the layer. FeatureLayers may be [queried](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryFeatures), [analyzed](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html), and [rendered](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#renderer) to visualize data in a spatial context. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) + */ + new(properties?: FeatureLayerProperties): FeatureLayer; fromJSON(json: any): FeatureLayer; @@ -1536,238 +6253,870 @@ declare namespace __esri { export const FeatureLayer: FeatureLayerConstructor; - interface FeatureLayerProperties extends LayerProperties, PortalLayerProperties, ScaleRangeLayerProperties { - capabilities?: FeatureLayerCapabilities; + interface FeatureLayerProperties extends LayerProperties, PortalLayerProperties, ScaleRangeLayerProperties, RefreshableLayerProperties { + /** + * The copyright text as defined by the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#copyright) + */ copyright?: string; + /** + * The SQL where clause used to filter features on the client. Only the features that satisfy the definition expression are displayed in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). Setting a definition expression is useful when the dataset is large and you don't want to bring all features to the client for analysis. Definition expressions may be set when a layer is constructed prior to it loading in the view or after it has been added to the map. If the definition expression is set after the layer has been added to the map, the view will automatically refresh itself to display the features that satisfy the new definition expression. + * > **Known Limitations** Definition expressions will not be honored when working with FeatureLayers created from client-side graphics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#definitionExpression) + */ definitionExpression?: string; + /** + * The name of the layer's primary display field. The value of this property matches the name of one of the fields of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#displayField) + */ displayField?: string; + /** + * Specifies how graphics are placed on the vertical axis (z). This property may only be used in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). See the [ElevationInfo sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-elevationinfo/index.html) for an example of how this property may be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) + */ elevationInfo?: FeatureLayerElevationInfo; + /** + * Configures the method for decluttering overlapping features in the view. If this property is not set (or set to `null`), every feature is drawn individually. Currently this property is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) for point features with non-draped [Icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html) or [Text](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html) symbol layers. ![declutter](https://developers.arcgis.com/javascript/latest/assets/img/samples/city-points-declutter.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#featureReduction) + */ featureReduction?: FeatureLayerFeatureReduction; + /** + * An array of fields in the layer. Each field represents an attribute that may contain a value for each feature in the layer. For example, a field named `POP_2015`, stores information about total population as a numeric value for each feature; this value represents the total number of people living within the geographic bounds of the feature. This property must be set in the constructor when creating a FeatureLayer from client-side [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). To create FeatureLayers from client-side graphics you must also set the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source), [objectIdField](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#spatialReference), and [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#geometryType) properties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields) + */ fields?: FieldProperties[]; - gdbVersion?: string; + /** + * The geometry type of features in the layer. All features must be of the same type. This property is read-only when the layer is created from a [url](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#url). However, when creating a FeatureLayer from client-side graphics, this property must be specified in the layer's constructor along with the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#spatialReference), [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields), and [objectIdField](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField) properties. **Possible Values:** point | mulitpoint | polyline | polygon | extent + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#geometryType) + */ geometryType?: string; - hasAttachments?: boolean; - hasM?: boolean; - hasZ?: boolean; + /** + * The label definition for this layer, specified as an array of [LabelClass](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html). Use this property to specify labeling properties for the layer such as label expression, placement, and size. For labels to display in the view, the [labelsVisible](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#labelsVisible) property of this layer must be set to `true`. + * > **Known Limitations** There is no support for labeling in 2D. Labeling is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Each graphic can have only one label. Multiple [Label classes](esri-layers-support-LabelClass.html) with different [where](esri-layers-support-LabelClass.html#where) clauses can be used to have different label styles on different features that belong to the same layer (for example blue labels for lakes and green labels for parks). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#labelingInfo) + */ labelingInfo?: LabelClassProperties[]; + /** + * Indicates whether to display labels for this layer. If `true`, labels will appear as defined in the [labelingInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#labelingInfo) property. + * > **Known Limitations** There is no support for labeling in 2D. Labeling is only supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#labelsVisible) + * + * @default false + */ labelsVisible?: boolean; + /** + * The layer ID, or layer index, of a Feature Service layer. This is particularly useful when loading a single FeatureLayer with the [portalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#portalItem) property from a service containing multiple layers. You can specify this value in one of two scenarios: + * * When loading the layer via the [portalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#portalItem) property. + * * When pointing the layer [url](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#url) directly to the Feature Service. + * + * + * If a layerId is not specified in either of the above scenarios, then the first layer in the service (`layerId = 0`) is selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#layerId) + */ layerId?: number; + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#legendEnabled) + * + * @default true + */ legendEnabled?: boolean; + /** + * The name of one of the provided [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields) for each graphic containing a unique value or identifier for that graphic. This is required when constructing a FeatureLayer from a collection of client-side [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). When creating a FeatureLayer from client-side graphics, the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source), [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#spatialReference), and [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#geometryType) properties must also be set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField) + */ objectIdField?: string; + /** + * An array of field names from the service to include in the FeatureLayer. If not specified, the layer will only return the `OBJECTID` field. To fetch the values from all fields in the layer, use `["*"]`. This is particularly useful when editing features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#outFields) + */ outFields?: string[]; + /** + * Indicates whether to display popups when features in the layer are clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#popupEnabled) + * + * @default true + */ popupEnabled?: boolean; + /** + * The popup template for the layer. When set on the layer, the `popupTemplate` allows users to access attributes and display their values in the [view's popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#popup) when a feature is selected using text and/or charts. See the [PopupTemplate sample](https://developers.arcgis.com/javascript/latest/sample-code/intro-popuptemplate/index.html) for an example of how [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) interacts with a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#popupTemplate) + */ popupTemplate?: PopupTemplateProperties; + /** + * The renderer assigned to the layer. The renderer defines how to visualize each feature in the layer. Depending on the renderer type, features may be visualized with the same symbol, or with varying symbols based on the values of provided attribute fields or functions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#renderer) + */ renderer?: RendererProperties; + /** + * When `true`, indicates that M values will be returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#returnM) + * + * @default false + */ returnM?: boolean; + /** + * When `true`, indicates that Z values will be returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#returnZ) + * + * @default false + */ returnZ?: boolean; + /** + * Apply perspective scaling to screen-size point symbols in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). When `true`, screen sized objects such as [icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [labels](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html) or [callouts](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-Callout3D.html) integrate better in the 3D scene by applying a certain perspective projection to the sizing of features. This only applies when using a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). `layer.screenSizePerspectiveEnabled = true` ![screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-screenSize-perspective.png) `layer.screenSizePerspectiveEnabled = false` ![no-screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-no-screenSize-perspective.png) + * > **Known Limitations** Screen size perspective is currently not optimized for situations where the camera is very near the ground, or for scenes with point features located far from the ground surface. In these cases it may be better to turn off screen size perspective. As screen size perspective changes the size based on distance to the camera, it should be set to false when using {@link module:esri/renderers/Renderer#SizeVisualVariable size visual variables}. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#screenSizePerspectiveEnabled) + * + * @default true + */ screenSizePerspectiveEnabled?: boolean; + /** + * A collection of [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) objects used to create a FeatureLayer. This property should only used when creating a FeatureLayer from client-side graphics. When creating a FeatureLayer from client-side graphics, the [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields), [objectIdField](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#spatialReference), and [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#geometryType) properties must also be set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source) + */ source?: CollectionProperties; + /** + * The spatial reference of the layer. When creating the layer from a [url](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#url), the spatial reference is read from the service. This property should be set explicitly when creating a FeatureLayer from client-side graphics. When creating a FeatureLayer from client-side graphics, the [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fields), [objectIdField](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField), [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source), and [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#geometryType) properties must also be set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#spatialReference) + */ spatialReference?: SpatialReferenceProperties; + /** + * An array of feature templates defined in the feature layer. See [ArcGIS Pro subtypes document](https://pro.arcgis.com/en/pro-app/help/data/geodatabases/overview/an-overview-of-subtypes.htm). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#templates) + */ templates?: FeatureTemplateProperties[]; - token?: string; + /** + * The name of the field holding the type ID or subtypes for the features. See [ArcGIS Pro subtypes document](https://pro.arcgis.com/en/pro-app/help/data/geodatabases/overview/an-overview-of-subtypes.htm). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#typeIdField) + */ typeIdField?: string; + /** + * An array of subtypes defined in the feature service exposed by ArcGIS REST API. Each item includes information about the type, such as the type ID, name, and definition expression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#types) + */ types?: FeatureTypeProperties[]; + /** + * The URL of the REST endpoint of the layer or service. The URL may either point to a resource on ArcGIS for Server, Portal for ArcGIS, or ArcGIS Online. If the url points directly to a service, then the layer must be specified in the [layerId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#layerId) property. If no [layerId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#layerId) is given, then the first layer in the service will be loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#url) + */ url?: string; - version?: number; } - export interface FeatureEditResult { + /** + * FeatureEditResult represents the result of adding, updating or deleting a feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#FeatureEditResult) + */ + export interface FeatureEditResult extends Object { + /** + * Object Id of the feature that was edited. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#FeatureEditResult) + */ objectId: number; + /** + * If the edit failed, the edit result includes an error. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#FeatureEditResult) + */ error: FeatureEditResultError; } - export interface FeatureLayerApplyEditsEdits { + + export interface FeatureLayerApplyEditsEdits extends Object { + /** + * Array of features to be added. Values of non nullable fields must be provided when adding new features. Date fields must have [numeric](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) values representing universal time. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdits) + */ addFeatures?: Graphic[]; + /** + * Array of features to be updated. Each feature must have valid [objectId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField). Values of non nullable fields must be provided when updating features. Date fields must have [numeric](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) values representing universal time. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdits) + */ updateFeatures?: Graphic[]; + /** + * An array of features or objects to be deleted. When an array of features is passed, each feature must have a valid [objectId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#objectIdField). When an array of objects is used, each object must have a valid `objectId` property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdits) + */ deleteFeatures?: Graphic[] | any[]; } - export interface FeatureLayerCapabilities { + + export interface FeatureLayerCapabilities extends Object { + /** + * Indicates data capabilities that can be performed on features in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ data: FeatureLayerCapabilitiesData; + /** + * Indicates editing capabilities that can be performed on the features in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ editing: FeatureLayerCapabilitiesEditing; + /** + * Indicates operations that can be performed on features in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ operations: FeatureLayerCapabilitiesOperations; + /** + * Indicates query operations that can be performed on features in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ query: FeatureLayerCapabilitiesQuery; + /** + * Indicates if the layer's query operation supports querying features or records related to features in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ queryRelated: FeatureLayerCapabilitiesQueryRelated; } - export interface FeatureLayerCapabilitiesData { + + export interface FeatureLayerCapabilitiesData extends Object { + /** + * Indicates if the attachment is enabled on the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsAttachment: boolean; + /** + * Indicates if the features in the layer support M values. Requires ArcGIS Server service 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsM: boolean; + /** + * Indicates if the features in the layer support Z values. Requires ArcGIS Server service 10.1 or greater. See [elevationInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) for details regarding placement and rendering of graphics with z-values in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsZ: boolean; } - export interface FeatureLayerCapabilitiesEditing { + + export interface FeatureLayerCapabilitiesEditing extends Object { + /** + * Indicates if anonymous users can delete features created by others. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsDeleteByAnonymous: boolean; + /** + * Indicates if logged in users can delete features created by others. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsDeleteByOthers: boolean; + /** + * Indicates if the geometry of the features in the layer can be edited. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsGeometryUpdate: boolean; + /** + * Indicates if the `globalid` values provided by the client are used in [applyEdits](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdits). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsGlobalId: boolean; + /** + * Indicates if the `rollbackOnFailure` parameter can be set to `true` or `false` when running the synchronizeReplica operation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsRollbackOnFailure: boolean; + /** + * Indicates if anonymous users can update features created by others. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsUpdateByAnonymous: boolean; + /** + * Indicates if logged in users can update features created by others. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsUpdateByOthers: boolean; + /** + * Indicates if `m-values` must be provided when updating features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsUpdateWithoutM: boolean; + /** + * Indicates if the layer supports uploading attachments by [UploadId](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Item/02r3000000vq000000/). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsUploadWithItemId: boolean; } - export interface FeatureLayerCapabilitiesOperations { + + export interface FeatureLayerCapabilitiesOperations extends Object { + /** + * Indicates if new features can be [added](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdits) to the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsAdd: boolean; + /** + * Indicates if features can be [deleted](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdits) from the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsDelete: boolean; + /** + * Indicates if features in the layer can be [updated](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdits). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsUpdate: boolean; + /** + * Indicates if features in the layer can be [edited](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdits). Use `supportsAdd`, `supportsUpdate` and `supportsDelete` to determine which editing operations are supported. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsEditing: boolean; + /** + * Indicates if values of one or more field values in the layer can be updated. See the [Calculate REST operation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Calculate_Feature_Service_Layer/02r30000029n000000/) document for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsCalculate: boolean; + /** + * Indicates if features in the layer can be [queried](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryFeatures). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsQuery: boolean; + /** + * Indicates if the layer supports a SQL-92 expression or where clause. This operation is only supported in ArcGIS Online hosted feature services. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsValidateSql: boolean; } - export interface FeatureLayerCapabilitiesQuery { + + export interface FeatureLayerCapabilitiesQuery extends Object { + /** + * Indicates if the geometry centroid associated with each polygon feature can be returned. This operation is only supported in ArcGIS Online hosted feature services. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsCentroid: boolean; + /** + * Indicates if the layer's query operation supports a buffer distance for input geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsDistance: boolean; + /** + * Indicates if the layer supports queries for distinct values based on fields specified in the [outFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#outFields). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsDistinct: boolean; + /** + * Indicates if the layer's query response includes the extent of features. At 10.3, this option is only available for hosted feature services. At 10.3.1, it is available for hosted and non-hosted feature services. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsExtent: boolean; + /** + * Indicates if the layer's query response contains geometry attributes, including shape area and length attributes. This operation is only supported in ArcGIS Online hosted feature services. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsGeometryProperties: boolean; + /** + * Indicates if features returned in the query response can be ordered by one or more fields. Requires an ArcGIS Server service 10.3 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsOrderBy: boolean; + /** + * Indicates if the query response supports pagination. Requires an ArcGIS Server service 10.3 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsPagination: boolean; + /** + * Indicates if the query operation supports the projection of geometries onto a virtual grid. Requires an ArcGIS Server service 10.3 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsQuantization: boolean; + /** + * Indicates if the number of features returned by the query operation can be controlled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsResultType: boolean; + /** + * Indicates if the query operation supports SQL expressions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsSqlExpression: boolean; + /** + * Indicates if the query operation supports using standardized queries. Learn more about [standardized queries here](http://server.arcgis.com/en/server/latest/administer/linux/about-standardized-queries.htm). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsStandardizedQueriesOnly: boolean; + /** + * Indicates if the layer supports field-based statistical functions. Requires ArcGIS Server service 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsStatistics: boolean; } - export interface FeatureLayerCapabilitiesQueryRelated { + + export interface FeatureLayerCapabilitiesQueryRelated extends Object { + /** + * Indicates if the layer's query response includes the number of features or records related to features in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsCount: boolean; + /** + * Indicates if the related features or records returned in the query response can be ordered by one or more fields. Requires ArcGIS Server service 10.3 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsOrderBy: boolean; + /** + * Indicates if the query response supports pagination for related features or records. Requires ArcGIS Server service 10.3 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) + */ supportsPagination: boolean; } - export interface FeatureLayerElevationInfo { + + export interface FeatureLayerElevationInfo extends Object { + /** + * Defines how the graphic is placed with respect to the terrain surface. [returnZ](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#returnZ) must be set to `true` if z-values of the features should be considered for the elevation mode. If the geometry consists of multiple points (e.g. lines or polygons), the elevation is evaluated separately for each point. See the table below for a list of possible values. + * + * Mode | Description + * ------|------------ + * on-the-ground | Graphics are draped on the terrain surface. This is the default value for features with [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) or [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) geometries and features with [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries rendered with [ObjectSymbol3DLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html). + * relative-to-ground | Graphics are placed at an elevation relative to the terrain surface. The graphic's elevation is determined by summing up the terrain elevation and the geometry's z-value (if present). If `featureExpressionInfo` is defined, the result of the expression is used instead of the geometry’s z-value. `relative-to-ground` is the default value for [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries rendered with [IconSymbol3DLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html). + * absolute-height | Graphics are placed at an absolute height above sea level. This height is determined by the geometry's z-value (if present). If `featureExpressionInfo` is defined, the result of the expression is used instead of the geometry’s z-value. This mode doesn't take the elevation of the terrain into account. This is the default value of features with any geometry type where [hasZ](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#hasZ) is `true`. + * relative-to-scene | Graphics are aligned to buildings and other objects part of 3D Object [SceneLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) or [IntegratedMeshLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html), depending on which has higher elevation. If the graphic is not directly above a building or any other feature, it is aligned to the terrain surface elevation. If defined, the result of `featureExpressionInfo` is added to the 3D Object/terrain surface elevation. In this mode z-values are ignored. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) + */ mode: string; + /** + * An elevation offset, which is added to the vertical position of the graphic. If `unit` is not defined, the offset is in `meters`. When `mode = "on-the-ground"`, this property has no effect. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) + */ offset?: number; + /** + * This object contains information about setting a custom height on the graphic. If this property is set, then z values are not considered for calculating graphic height. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) + */ featureExpressionInfo?: FeatureLayerElevationInfoFeatureExpressionInfo; + /** + * The unit for `featureExpressionInfo` and `offset` values. It doesn't apply to z-values. **Possible Values:** feet | meters | kilometers | miles | us-feet | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) + */ unit?: string; } - export interface FeatureLayerElevationInfoFeatureExpressionInfo { + + export interface FeatureLayerElevationInfoFeatureExpressionInfo extends Object { + /** + * An [Arcade expression](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) evaluating to a number that determines the height of the graphic. If the geometry has z-values, they will be ignored and only `featureExpressionInfo` is used to calculate the vertical position of the graphic. When `mode = "on-the-ground"`, this property has no effect. For line and polygon geometries the result of the expression is the same for all vertices of a feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) + */ expression?: string; } - export interface FeatureLayerFeatureReduction { + + export interface FeatureLayerFeatureReduction extends Object { + /** + * Type of the decluttering method. The only supported type at the moment is `"selection"`. In this method, some of the overlapping features are hidden such that none of the remaining features intersect on screen. Label deconfliction also respects this option and hides labels that would overlap with the features of this layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#featureReduction) + */ type: string; } - export interface FeatureLayerGetFieldDomainOptions { + + export interface FeatureLayerGetFieldDomainOptions extends Object { + /** + * The feature to which the [Domain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Domain.html) is assigned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#getFieldDomain) + */ feature: Graphic; } export interface FeatureLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface FeatureLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } - export interface FeatureEditResultError { + + export interface FeatureEditResultError extends Object { + /** + * Error name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#FeatureEditResult) + */ name: string; + /** + * Message describing the error. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#FeatureEditResult) + */ message: string; } interface GeoRSSLayer extends Layer, ScaleRangeLayer { + /** + * Symbol used to represent line features from the GeoRSS feed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html#lineSymbol) + */ lineSymbol: SimpleLineSymbol; + /** + * Symbol used to represent point features from the GeoRSS feed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html#pointSymbol) + */ pointSymbol: PictureMarkerSymbol; + /** + * Symbol used to represent polygon features from the GeoRSS feed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html#polygonSymbol) + */ polygonSymbol: SimpleFillSymbol; + /** + * The URL pointing to a GeoRSS file. This must be publicly available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html#url) + */ url: string; + on(name: "layerview-create", eventHandler: GeoRSSLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: GeoRSSLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: GeoRSSLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: GeoRSSLayerLayerviewDestroyEventHandler): IHandle; } interface GeoRSSLayerConstructor { + /** + * The GeoRSSLayer class is used to create a layer based on [GeoRSS](http://www.georss.org/). GeoRSS is a way to add geographic information to an RSS feed. The GeoRSSLayer supports both `GeoRSS-Simple` and `GeoRSS GML` encodings, and multiple geometry types. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html) + */ + new(properties?: GeoRSSLayerProperties): GeoRSSLayer; } export const GeoRSSLayer: GeoRSSLayerConstructor; interface GeoRSSLayerProperties extends LayerProperties, ScaleRangeLayerProperties { + /** + * Symbol used to represent line features from the GeoRSS feed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html#lineSymbol) + */ lineSymbol?: SimpleLineSymbolProperties; + /** + * Symbol used to represent point features from the GeoRSS feed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html#pointSymbol) + */ pointSymbol?: PictureMarkerSymbolProperties; + /** + * Symbol used to represent polygon features from the GeoRSS feed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html#polygonSymbol) + */ polygonSymbol?: SimpleFillSymbolProperties; + /** + * The URL pointing to a GeoRSS file. This must be publicly available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html#url) + */ url?: string; } export interface GeoRSSLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface GeoRSSLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface GraphicsLayer extends Layer, ScaleRangeLayer { + /** + * Specifies how graphics are placed on the vertical axis (z). This property may only be used in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). See the [ElevationInfo sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-elevationinfo/index.html) for an example of how this property may be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#elevationInfo) + */ elevationInfo: GraphicsLayerElevationInfo; + /** + * A collection of [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) in the layer. Each graphic is a vector representation of the location of a real-world feature. Each graphic in a single GraphicsLayer may contain either a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html), [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html), or [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#geometry). In addition, each [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) in the collection may contain its own [attributes](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#attributes), [Symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol.html), and [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). To add a graphic to the GraphicsLayer use [add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#add), or [GraphicsLayer.graphics.add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#add). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#graphics) + */ graphics: Collection; + /** + * Apply perspective scaling to screen-size point symbols in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). When `true`, screen sized objects such as [icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [labels](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html) or [callouts](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-Callout3D.html) integrate better in the 3D scene by applying a certain perspective projection to the sizing of features. This only applies when using a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). `layer.screenSizePerspectiveEnabled = true` ![screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-screenSize-perspective.png) `layer.screenSizePerspectiveEnabled = false` ![no-screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-no-screenSize-perspective.png) + * > **Known Limitations** Screen size perspective is currently not optimized for situations where the camera is very near the ground, or for scenes with point features located far from the ground surface. In these cases it may be better to turn off screen size perspective. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#screenSizePerspectiveEnabled) + * + * @default true + */ screenSizePerspectiveEnabled: boolean; + /** + * Adds a graphic to the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#add) + * + * @param graphic The graphic to add to the layer. + * + */ add(graphic: Graphic): void; + /** + * Adds an array of graphics to the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#addMany) + * + * @param graphics The graphic(s) to add to the layer. + * + */ addMany(graphics: Graphic[]): void; + /** + * Removes a graphic from the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#remove) + * + * @param graphic The graphic to remove from the layer. + * + */ remove(graphic: Graphic): void; + /** + * Clears all the graphics from the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#removeAll) + * + * + */ removeAll(): void; + /** + * Removes an array of graphics from the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#removeMany) + * + * @param graphics The graphics to remove from the layer. + * + */ removeMany(graphics: Graphic[]): void; + on(name: "layerview-create", eventHandler: GraphicsLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: GraphicsLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: GraphicsLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: GraphicsLayerLayerviewDestroyEventHandler): IHandle; } interface GraphicsLayerConstructor { + /** + * A GraphicsLayer contains one or more client-side [Graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). Each [graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#graphics) in the GraphicsLayer is rendered in a [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) inside either a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) or a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). The [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#graphics) contain discrete vector [geometries](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) that represent real-world phenomena. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html) + */ + new(properties?: GraphicsLayerProperties): GraphicsLayer; } export const GraphicsLayer: GraphicsLayerConstructor; interface GraphicsLayerProperties extends LayerProperties, ScaleRangeLayerProperties { + /** + * Specifies how graphics are placed on the vertical axis (z). This property may only be used in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). See the [ElevationInfo sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-elevationinfo/index.html) for an example of how this property may be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#elevationInfo) + */ elevationInfo?: GraphicsLayerElevationInfo; + /** + * A collection of [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) in the layer. Each graphic is a vector representation of the location of a real-world feature. Each graphic in a single GraphicsLayer may contain either a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html), [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html), or [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#geometry). In addition, each [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) in the collection may contain its own [attributes](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#attributes), [Symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol.html), and [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). To add a graphic to the GraphicsLayer use [add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#add), or [GraphicsLayer.graphics.add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#add). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#graphics) + */ graphics?: CollectionProperties; + /** + * Apply perspective scaling to screen-size point symbols in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). When `true`, screen sized objects such as [icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [labels](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html) or [callouts](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-Callout3D.html) integrate better in the 3D scene by applying a certain perspective projection to the sizing of features. This only applies when using a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). `layer.screenSizePerspectiveEnabled = true` ![screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-screenSize-perspective.png) `layer.screenSizePerspectiveEnabled = false` ![no-screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-no-screenSize-perspective.png) + * > **Known Limitations** Screen size perspective is currently not optimized for situations where the camera is very near the ground, or for scenes with point features located far from the ground surface. In these cases it may be better to turn off screen size perspective. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#screenSizePerspectiveEnabled) + * + * @default true + */ screenSizePerspectiveEnabled?: boolean; } - export interface GraphicsLayerElevationInfo { + + export interface GraphicsLayerElevationInfo extends Object { + /** + * Defines how the graphic is placed with respect to the terrain surface. If the geometry consists of multiple points (e.g. lines or polygons), the elevation is evaluated separately for each point. See the table below for a list of possible values. + * + * Mode | Description + * ------|------------ + * on-the-ground | Graphics are placed on the terrain surface. + * relative-to-ground | Graphics are placed at an elevation relative to the terrain surface. The graphic's elevation is determined by summing up + * the terrain elevation, and the geometry's z-value (if present). In case `featureExpressionInfo` is defined, the result of the expression is used + * instead of the geometry’s z-value. absolute-height | Graphics are placed at an absolute height above sea level. This height is determined by the geometry's z-value (if present). If `featureExpressionInfo` is defined, the result of the expression is used instead of the geometry’s z-value. It doesn't take the elevation of the terrain into account. relative-to-scene | Graphics are aligned to buildings and other objects part of 3D Object [SceneLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) or [IntegratedMeshLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html), depending on which has higher elevation. If the graphic is not directly above a building or any other feature, it is aligned to the terrain surface elevation. If defined, the result of `featureExpressionInfo` is added to the 3D Object/terrain surface elevation. In this mode z-values are ignored. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#elevationInfo) + */ mode: string; + /** + * An elevation offset, which is added to the vertical position of the graphic. If `unit` is not defined, the offset is in `meters`. When `mode = "on-the-ground"`, this property has no effect. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#elevationInfo) + */ offset?: number; + /** + * This object contains information about setting a custom height on the graphic. If this property is set, then z values are not considered for calculating graphic height. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#elevationInfo) + */ featureExpressionInfo?: GraphicsLayerElevationInfoFeatureExpressionInfo; + /** + * The unit for `featureExpressionInfo` and `offset` values. It doesn't apply to z-values. **Possible Values:** feet | meters | kilometers | miles | us-feet | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#elevationInfo) + */ unit?: string; } - export interface GraphicsLayerElevationInfoFeatureExpressionInfo { + + export interface GraphicsLayerElevationInfoFeatureExpressionInfo extends Object { + /** + * An [Arcade expression](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) evaluating to a number that determines the height of the graphic. If the geometry has z-values, they will be ignored and only `featureExpressionInfo` is used to calculate the vertical position of the graphic. When `mode = "on-the-ground"`, this property has no effect. For line and polygon geometries the result of the expression is the same for all vertices of a feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html#elevationInfo) + */ expression?: string; } export interface GraphicsLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface GraphicsLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface GroupLayer extends Layer, LayersMixin, PortalLayer { + /** + * Indicates how to manage the visibility of the children layers. Possible values are described in the table below. + * + * Value | Description + * ------|------------ + * independent | Each child layer manages its visibility independent from other layers. + * inherited | Each child layer's visibility matches the [GroupLayer’s visibility](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html#visible). + * exclusive | Only one child layer is visible at a time. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html#visibilityMode) + */ visibilityMode: string; + on(name: "layerview-create", eventHandler: GroupLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: GroupLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: GroupLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: GroupLayerLayerviewDestroyEventHandler): IHandle; } interface GroupLayerConstructor { + /** + * GroupLayer provides the ability to organize several sublayers into one common layer. Suppose there are several [FeatureLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) that all represent water features in different dimensions. For example, wells (points), streams (lines), and lakes (polygons). The GroupLayer provides the functionality to treat them as one layer called "Water Features" even though they are stored as separate feature layers. To accomplish this, create a new GroupLayer and use the [add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html#add) method to add each of the water layers to the GroupLayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html) + */ + new(properties?: GroupLayerProperties): GroupLayer; fromJSON(json: any): GroupLayer; @@ -1776,34 +7125,89 @@ declare namespace __esri { export const GroupLayer: GroupLayerConstructor; interface GroupLayerProperties extends LayerProperties, LayersMixinProperties, PortalLayerProperties { + /** + * Indicates how to manage the visibility of the children layers. Possible values are described in the table below. + * + * Value | Description + * ------|------------ + * independent | Each child layer manages its visibility independent from other layers. + * inherited | Each child layer's visibility matches the [GroupLayer’s visibility](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html#visible). + * exclusive | Only one child layer is visible at a time. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html#visibilityMode) + */ visibilityMode?: string; } export interface GroupLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface GroupLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } - interface ImageryLayer extends Layer, ArcGISImageService, ScaleRangeLayer { + interface ImageryLayer extends Layer, ArcGISImageService, ScaleRangeLayer, RefreshableLayer { + /** + * A function that processes [pixelData](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-ImageryLayerView.html#pixelData). The `pixelData` object contains a [pixelBlock](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html) property that gives you access to all of the pixels in the raster on the client. Inside the `pixelFilter` you may loop through all the [pixels](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) found in the `pixelBlock` property of the `pixelData` object and process them. This function may be used to hide some pixels from the view, alter their values, and change their color. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#pixelFilter) + */ pixelFilter: Function; + /** + * Indicates whether to display popups when the layer is clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#popupEnabled) + * + * @default true + */ popupEnabled: boolean; + /** + * The portal item from which the layer is loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#portalItem) + */ portalItem: PortalItem; - token: string; + /** + * Token generated by the token service using the specified userId and password. The recommended approach to pass a token on a layer is to use [IdentityManager.registerToken()](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#registerToken). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#token) + */ + readonly token: string; + /** + * Executes the [pixelFilter](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#pixelFilter) function and redraws the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#redraw) + * + * + */ redraw(): void; + on(name: "layerview-create", eventHandler: ImageryLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: ImageryLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: ImageryLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: ImageryLayerLayerviewDestroyEventHandler): IHandle; } interface ImageryLayerConstructor { + /** + * Represents an image service resource as a layer. An ImageryLayer retrieves and displays data from image services. ImageryLayer allows you to and apply client side [pixel filtering](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#pixelFilter), server defined or client-defined [rendering rules](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#renderingRule) (e.g. remap, colormap), and [mosaic rules](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#mosaicRule). This layer is particularly useful when you need to interactively change pixel manipulation criteria and get an immediate response on the client. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html) + */ + new(properties?: ImageryLayerProperties): ImageryLayer; fromJSON(json: any): ImageryLayer; @@ -1811,33 +7215,68 @@ declare namespace __esri { export const ImageryLayer: ImageryLayerConstructor; - interface ImageryLayerProperties extends LayerProperties, ArcGISImageServiceProperties, ScaleRangeLayerProperties { + interface ImageryLayerProperties extends LayerProperties, ArcGISImageServiceProperties, ScaleRangeLayerProperties, RefreshableLayerProperties { + /** + * A function that processes [pixelData](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-ImageryLayerView.html#pixelData). The `pixelData` object contains a [pixelBlock](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html) property that gives you access to all of the pixels in the raster on the client. Inside the `pixelFilter` you may loop through all the [pixels](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) found in the `pixelBlock` property of the `pixelData` object and process them. This function may be used to hide some pixels from the view, alter their values, and change their color. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#pixelFilter) + */ pixelFilter?: Function; + /** + * Indicates whether to display popups when the layer is clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#popupEnabled) + * + * @default true + */ popupEnabled?: boolean; + /** + * The portal item from which the layer is loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#portalItem) + */ portalItem?: PortalItemProperties; - token?: string; } export interface ImageryLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface ImageryLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface IntegratedMeshLayer extends Layer, SceneService, PortalLayer { + /** + * Specifies how the mesh is placed on the vertical axis (z). This property only affects [IntegratedMeshLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html) when using the `absolute-height` mode. Integrated mesh layers always render in front of the ground surface, so setting negative offset values will not render them below the ground. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html#elevationInfo) + */ elevationInfo: IntegratedMeshLayerElevationInfo; + on(name: "layerview-create", eventHandler: IntegratedMeshLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: IntegratedMeshLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: IntegratedMeshLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: IntegratedMeshLayerLayerviewDestroyEventHandler): IHandle; } interface IntegratedMeshLayerConstructor { + /** + * The IntegratedMeshLayer is designed for visualizing accurate representations in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) of infrastructure and natural landscapes that are difficult to access. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html) + */ + new(properties?: IntegratedMeshLayerProperties): IntegratedMeshLayer; fromJSON(json: any): IntegratedMeshLayer; @@ -1846,39 +7285,90 @@ declare namespace __esri { export const IntegratedMeshLayer: IntegratedMeshLayerConstructor; interface IntegratedMeshLayerProperties extends LayerProperties, SceneServiceProperties, PortalLayerProperties { + /** + * Specifies how the mesh is placed on the vertical axis (z). This property only affects [IntegratedMeshLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html) when using the `absolute-height` mode. Integrated mesh layers always render in front of the ground surface, so setting negative offset values will not render them below the ground. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html#elevationInfo) + */ elevationInfo?: IntegratedMeshLayerElevationInfo; } - export interface IntegratedMeshLayerElevationInfo { + + export interface IntegratedMeshLayerElevationInfo extends Object { + /** + * Defines how the mesh is placed on the vertical axis (z). Currently only `absolute-height` is supported. + * + * Mode | Description + * ------|------------ + * absolute-height | The mesh is placed at an absolute height above sea level. This height is determined by summing up the `offset` value and the mesh's z-value. It doesn't take the elevation of the terrain into account. This is the only supported elevation mode for an IntegratedMeshLayer. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html#elevationInfo) + */ mode: string; + /** + * An elevation offset, which is added to the vertical position of the mesh. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html#elevationInfo) + * + * @default 0 + */ offset?: number; + /** + * The unit for `offset` values. **Possible Values:** feet | meters | kilometers | miles | us-feet | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html#elevationInfo) + * + * @default meters + */ + unit?: string; } export interface IntegratedMeshLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface IntegratedMeshLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface KMLLayer extends Layer, PortalLayer, ScaleRangeLayer { - allVisibleMapImages: Collection; - allVisiblePoints: Collection; - allVisiblePolygons: Collection; - allVisiblePolylines: Collection; + /** + * A collection of [KMLSublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html)s. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html#sublayers) + */ sublayers: Collection; + /** + * The publicly accessible URL for a .kml or .kmz file. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html#url) + */ url: string; + on(name: "layerview-create", eventHandler: KMLLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: KMLLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: KMLLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: KMLLayerLayerviewDestroyEventHandler): IHandle; } interface KMLLayerConstructor { + /** + * The KMLLayer class is used to create a layer based on a KML file (.kml, .kmz). KML is an XML-based file format used to represent geographic features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html) + */ + new(properties?: KMLLayerProperties): KMLLayer; fromJSON(json: any): KMLLayer; @@ -1887,75 +7377,240 @@ declare namespace __esri { export const KMLLayer: KMLLayerConstructor; interface KMLLayerProperties extends LayerProperties, PortalLayerProperties, ScaleRangeLayerProperties { - allVisibleMapImages?: CollectionProperties; - allVisiblePoints?: CollectionProperties; - allVisiblePolygons?: CollectionProperties; - allVisiblePolylines?: CollectionProperties; + /** + * A collection of [KMLSublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html)s. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html#sublayers) + */ sublayers?: CollectionProperties; + /** + * The publicly accessible URL for a .kml or .kmz file. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html#url) + */ url?: string; } export interface KMLLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface KMLLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface Layer extends Accessor, Loadable, Evented { + /** + * The full extent of the layer. By default, this is worldwide. This property may be used to set the extent of the view to match a layer's extent so that its features appear to fill the view. See the sample snippet below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#fullExtent) + */ fullExtent: Extent; + /** + * The unique ID assigned to the layer. If not set by the developer, it is automatically generated when the layer is loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#id) + */ id: string; + /** + * Indicates how the layer should display in the [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) widget. The known values are listed below. + * + * Value | Description + * ------|------------ + * show | The layer is visible in the table of contents. + * hide | The layer is hidden in the table of contents. + * hide-children | If the layer is a [GroupLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html), hide the children layers from the table of contents. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#listMode) + * + * @default show + */ listMode: string; - loaded: boolean; + /** + * Indicates whether the layer's resources have loaded. When `true`, all the properties of the object can be accessed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#loaded) + * + * @default false + */ + readonly loaded: boolean; + /** + * The opacity of the layer. This value can range between `1` and `0`, where `0` is 100 percent transparent and `1` is completely opaque. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#opacity) + * + * @default 1 + */ opacity: number; + /** + * The title of the layer used to identify it in places such as the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) and [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) widgets. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#title) + */ title: string; - type: string; + /** + * The layer type provides a convenient way to check the type of the layer without the need to import specific layer modules. **Possible values:** base-dynamic | base-elevation | base-tile | elevation | feature | graphics | group | imagery | integrated-mesh | map-image | open-street-map | point-cloud | scene | stream | tile | unknown | unsupported | vector-tile | web-tile + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#type) + */ + readonly type: string; + /** + * Indicates if the layer is visible in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). When `false`, the layer may still be added to a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) instance that is referenced in a view, but its features will not be visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#visible) + * + * @default true + */ visible: boolean; + /** + * Fetches custom attribution data for the layer when it becomes available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#fetchAttributionData) + * + * + */ fetchAttributionData(): IPromise; } interface LayerConstructor { + /** + * The layer is the most fundamental component of a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html). It is a collection of spatial data in the form of vector graphics or raster images that represent real-world phenomena. Layers may contain discrete features that store vector data or continuous cells/pixels that store raster data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) + */ + new(properties?: LayerProperties): Layer; + /** + * Creates a new layer instance from an ArcGIS Server URL. Depending on the URL, the returned layer type may be a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), [TileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html), [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html), [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html), [StreamLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html), [ElevationLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html) or [GroupLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html). This is useful when you work with various ArcGIS Server URLs, but you don't necessarily know which layer type(s) they create. This method creates the appropriate layer type for you. In case of a feature service or a scene service, when the URL points to the service and the service has multiple layers, the returned promise will resolve to a [GroupLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#fromArcGISServerUrl) + * + * @param params Input parameters for creating the layer. + * @param params.url The ArcGIS Server URL used to create the layer. + * @param params.properties Set any of the layer's properties here for constructing the layer instance (e.g. popupTemplate, renderer, etc.). + * + */ fromArcGISServerUrl(params: LayerFromArcGISServerUrlParams): IPromise; + /** + * Creates a new layer instance of the appropriate layer class from an ArcGIS Online or ArcGIS for Portal [portal item](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html). If the item points to a feature service with multiple layers, then a [GroupLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html) is created. If the item points to a service with a single layer, then it resolves to a layer of the same type of class as the service. See also: [isLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#isLayer) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#fromPortalItem) + * + * @param params The parameters for loading the portal item. + * @param params.portalItem The object representing an ArcGIS Online or ArcGIS for Portal item from which to load the layer. + * + */ fromPortalItem(params: LayerFromPortalItemParams): IPromise; } export const Layer: LayerConstructor; interface LayerProperties extends LoadableProperties { + /** + * The full extent of the layer. By default, this is worldwide. This property may be used to set the extent of the view to match a layer's extent so that its features appear to fill the view. See the sample snippet below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#fullExtent) + */ fullExtent?: ExtentProperties; + /** + * The unique ID assigned to the layer. If not set by the developer, it is automatically generated when the layer is loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#id) + */ id?: string; + /** + * Indicates how the layer should display in the [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) widget. The known values are listed below. + * + * Value | Description + * ------|------------ + * show | The layer is visible in the table of contents. + * hide | The layer is hidden in the table of contents. + * hide-children | If the layer is a [GroupLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html), hide the children layers from the table of contents. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#listMode) + * + * @default show + */ listMode?: string; - loaded?: boolean; + /** + * The opacity of the layer. This value can range between `1` and `0`, where `0` is 100 percent transparent and `1` is completely opaque. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#opacity) + * + * @default 1 + */ opacity?: number; + /** + * The title of the layer used to identify it in places such as the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) and [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) widgets. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#title) + */ title?: string; - type?: string; + /** + * Indicates if the layer is visible in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). When `false`, the layer may still be added to a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) instance that is referenced in a view, but its features will not be visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#visible) + * + * @default true + */ visible?: boolean; } - export interface LayerFromArcGISServerUrlParams { + + export interface LayerFromArcGISServerUrlParams extends Object { + /** + * The ArcGIS Server URL used to create the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#fromArcGISServerUrl) + */ url: string; + /** + * Set any of the layer's properties here for constructing the layer instance (e.g. popupTemplate, renderer, etc.). + * + * [Read more...](properties.html) + */ properties?: any; } - export interface LayerFromPortalItemParams { + + export interface LayerFromPortalItemParams extends Object { + /** + * The object representing an ArcGIS Online or ArcGIS for Portal item from which to load the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#fromPortalItem) + */ portalItem: PortalItem; } - interface MapImageLayer extends Layer, ArcGISMapService, ArcGISDynamicMapService, DynamicLayer, ScaleRangeLayer { + interface MapImageLayer extends Layer, ArcGISMapService, ArcGISDynamicMapService, DynamicLayer, ScaleRangeLayer, RefreshableLayer { + on(name: "layerview-create", eventHandler: MapImageLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: MapImageLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: MapImageLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: MapImageLayerLayerviewDestroyEventHandler): IHandle; } interface MapImageLayerConstructor { + /** + * MapImageLayer allows you to display and analyze data from [sublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#sublayers) defined in a [map service](http://server.arcgis.com/en/server/latest/publish-services/windows/what-is-a-map-service.htm), exporting images instead of features. Map service images are dynamically generated on the server based on a request, which includes an LOD (level of detail), a bounding box, dpi, spatial reference and other options. The exported image is of the entire map extent specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html) + */ + new(properties?: MapImageLayerProperties): MapImageLayer; fromJSON(json: any): MapImageLayer; @@ -1963,28 +7618,42 @@ declare namespace __esri { export const MapImageLayer: MapImageLayerConstructor; - interface MapImageLayerProperties extends LayerProperties, ArcGISMapServiceProperties, ArcGISDynamicMapServiceProperties, DynamicLayerProperties, ScaleRangeLayerProperties { + interface MapImageLayerProperties extends LayerProperties, ArcGISMapServiceProperties, ArcGISDynamicMapServiceProperties, DynamicLayerProperties, ScaleRangeLayerProperties, RefreshableLayerProperties { } export interface MapImageLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface MapImageLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface MapNotesLayer extends Layer, PortalLayer, ScaleRangeLayer { + on(name: "layerview-create", eventHandler: MapNotesLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: MapNotesLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: MapNotesLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: MapNotesLayerLayerviewDestroyEventHandler): IHandle; } interface MapNotesLayerConstructor { + /** + * The MapNotesLayer is used to create layers based on Map Notes within a WebMap or PortalItem. Map notes are part of web maps, and are typically created with ArcGIS Online MapViewer. For additional information, please refer to the ArcGIS Online documentation on how to [Add Map notes](http://doc.arcgis.com/en/arcgis-online/create-maps/add-layers.htm#ESRI_SECTION1_0C90A3B63ABD49D5B9535055991F4684). Within the [web map specification](https://developers.arcgis.com/web-map-specification/), map notes are a special type of [FeatureCollections](https://developers.arcgis.com/web-map-specification/objects/featureCollection/). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapNotesLayer.html) + */ + new(properties?: MapNotesLayerProperties): MapNotesLayer; fromJSON(json: any): MapNotesLayer; @@ -1997,23 +7666,49 @@ declare namespace __esri { } export interface MapNotesLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface MapNotesLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface ArcGISCachedService { + /** + * Contains information about the tiling scheme for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISCachedService.html#tileInfo) + */ tileInfo: TileInfo; + /** + * Creates a new instance of [this class]() and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input `json` parameter often comes from a response to a query operation in the REST API or a [toJSON()](http://pro.arcgis.com/en/pro-app/tool-reference/conversion/features-to-json.htm) method from another ArcGIS product. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for details and examples of when and how to use this function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISCachedService.html#fromJSON) + * + * @param json A JSON representation of the instance in the ArcGIS format. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Classification_objects/02r30000019z000000/) for examples of the structure of various input JSON objects. + * + */ fromJSON(json: any): any; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISCachedService.html#toJSON) + * + * + */ toJSON(): any; } interface ArcGISCachedServiceConstructor { + + new(properties?: ArcGISCachedServiceProperties): ArcGISCachedService; fromJSON(json: any): ArcGISCachedService; @@ -2022,76 +7717,362 @@ declare namespace __esri { export const ArcGISCachedService: ArcGISCachedServiceConstructor; interface ArcGISCachedServiceProperties { + /** + * Contains information about the tiling scheme for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISCachedService.html#tileInfo) + */ tileInfo?: TileInfoProperties; } interface ArcGISDynamicMapService { - allSublayers: Collection; + /** + * A flat [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of all the [sublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#sublayers) in the MapImageLayer including the sublayers of its sublayers. All sublayers are referenced in the order in which they are drawn in the view (bottom to top). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#allSublayers) + */ + readonly allSublayers: Collection; + /** + * The output dots per inch (DPI) of the MapImageLayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#dpi) + * + * @default 96 + */ dpi: number; + /** + * The version of the geodatabase of the map service data. Read the [Overview of versioning](https://desktop.arcgis.com/en/arcmap/latest/manage-data/geodatabases/an-overview-of-versioning.htm) topic for more details about this capability. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#gdbVersion) + */ gdbVersion: string; + /** + * The output image type. **Known Values:** png | png8 | png24 | png32 | jpg | pdf | bmp | gif | svg | pngjpg + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#imageFormat) + * + * @default png24 + */ imageFormat: string; + /** + * Indicates the maximum height of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#imageMaxHeight) + * + * @default 2048 + */ imageMaxHeight: number; + /** + * Indicates the maximum width of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#imageMaxWidth) + * + * @default 2048 + */ imageMaxWidth: number; + /** + * Indicates whether the background of the image exported by the service is transparent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#imageTransparency) + * + * @default true + */ imageTransparency: boolean; + /** + * A [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Sublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) objects that allow you to alter the properties of one or more sublayers of the MapImageLayer. If this property is not specified, all the sublayers from the service are displayed as defined in the service. If an empty array is passed to this property then none of the sublayers from the service are displayed in the layer. All sublayers are referenced in the order in which they are drawn in the view (bottom to top). They may be [added](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#add), [removed](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#remove), or [reordered](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#reorder) using the [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) methods. Because [Sublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) extends [Accessor](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html), its properties may be [watched](https://developers.arcgis.com/javascript/latest/guide/working-with-props/index.html#watchProperties). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#sublayers) + */ sublayers: Collection; + /** + * Returns a deep clone of a map service's [sublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) as defined by the service. This is useful for scenarios when the developer is unfamiliar with the service sublayers and needs to "reset" the layer's sublayers to match those defined by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#createServiceSublayers) + * + * + */ createServiceSublayers(): Collection; + /** + * Returns the sublayer with the given layerId. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#findSublayerById) + * + * @param id The [id](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#id) of the sublayer. + * + */ findSublayerById(id: number): Sublayer; + /** + * Gets the parameters of the exported image to use when calling the [export REST operation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Map/02r3000000v7000000/). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#getExportImageParameters) + * + * @param extent The extent of the exported image + * @param width The width of the exported image + * @param height The height of the exported image + * @param options The parameter options is an object with the following properties. + * @param options.rotation The rotation in degrees of the exported image. Available since ArcGIS for Server 10.3. + * + */ getExportImageParameters(extent: Extent, width: number, height: number, options?: ArcGISDynamicMapServiceGetExportImageParametersOptions): any; } interface ArcGISDynamicMapServiceConstructor { + + new(): ArcGISDynamicMapService; } export const ArcGISDynamicMapService: ArcGISDynamicMapServiceConstructor; interface ArcGISDynamicMapServiceProperties { - allSublayers?: CollectionProperties; + /** + * The output dots per inch (DPI) of the MapImageLayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#dpi) + * + * @default 96 + */ dpi?: number; + /** + * The version of the geodatabase of the map service data. Read the [Overview of versioning](https://desktop.arcgis.com/en/arcmap/latest/manage-data/geodatabases/an-overview-of-versioning.htm) topic for more details about this capability. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#gdbVersion) + */ gdbVersion?: string; + /** + * The output image type. **Known Values:** png | png8 | png24 | png32 | jpg | pdf | bmp | gif | svg | pngjpg + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#imageFormat) + * + * @default png24 + */ imageFormat?: string; + /** + * Indicates the maximum height of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#imageMaxHeight) + * + * @default 2048 + */ imageMaxHeight?: number; + /** + * Indicates the maximum width of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#imageMaxWidth) + * + * @default 2048 + */ imageMaxWidth?: number; + /** + * Indicates whether the background of the image exported by the service is transparent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#imageTransparency) + * + * @default true + */ imageTransparency?: boolean; + /** + * A [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Sublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) objects that allow you to alter the properties of one or more sublayers of the MapImageLayer. If this property is not specified, all the sublayers from the service are displayed as defined in the service. If an empty array is passed to this property then none of the sublayers from the service are displayed in the layer. All sublayers are referenced in the order in which they are drawn in the view (bottom to top). They may be [added](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#add), [removed](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#remove), or [reordered](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#reorder) using the [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) methods. Because [Sublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) extends [Accessor](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html), its properties may be [watched](https://developers.arcgis.com/javascript/latest/guide/working-with-props/index.html#watchProperties). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#sublayers) + */ sublayers?: CollectionProperties; } - export interface ArcGISDynamicMapServiceGetExportImageParametersOptions { + + export interface ArcGISDynamicMapServiceGetExportImageParametersOptions extends Object { + /** + * The rotation in degrees of the exported image. Available since ArcGIS for Server 10.3. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISDynamicMapService.html#getExportImageParameters) + */ rotation?: number; } interface ArcGISImageService { + /** + * The compression quality value. This controls how much loss the image will be subjected to. Only valid when using `jpg` [image format](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#format). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#compressionQuality) + */ compressionQuality: number; + /** + * The output image compression tolerance value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#compressionTolerance) + * + * @default 0.01 + */ compressionTolerance: number; + /** + * The copyright text as defined by the image service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#copyright) + */ copyright: string; + /** + * The SQL where clause used to filter rasters on the client. Only the rasters that satisfy the definition expression are displayed in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#definitionExpression) + */ definitionExpression: string; + /** + * An array of fields in the layer for which a [Domain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Domain.html) has been defined. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#domainFields) + */ domainFields: Field[]; + /** + * An array of fields in the layer. Each field represents an attribute that may contain a value for each raster in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#fields) + */ fields: Field[]; + /** + * The output image type. The default value is `lerc` if a [pixelFilter](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#pixelFilter) is set on the layer. **Known Values:** png | png8 | png24 | png32 | jpg | bmp | gif | jpgpng | lerc + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#format) + * + * @default jpgpng + */ format: string; + /** + * The full extent of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#fullExtent) + */ fullExtent: Extent; + /** + * Indicates if the Image Service has [multidimensionalInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#multidimensionalInfo). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#hasMultidimensions) + */ hasMultidimensions: boolean; + /** + * Indicates if the Image Service has a [raster attribute table](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#rasterAttributeTable). If `true`, the raster attribute table can be accessed with the [rasterAttributeTable](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#rasterAttributeTable) property after the layer has [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#loaded). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#hasRasterAttributeTable) + */ hasRasterAttributeTable: boolean; + /** + * Indicates the maximum height of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#imageMaxHeight) + * + * @default 4100 + */ imageMaxHeight: number; + /** + * Indicates the maximum width of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#imageMaxWidth) + * + * @default 15000 + */ imageMaxWidth: number; + /** + * Defines how overlapping images should be mosaicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#mosaicRule) + */ mosaicRule: MosaicRule; + /** + * The multidimensional information associated with the service. This will have a value if `serviceInfo` has `hasMultidimensionalInfo = true`. If defined, multidimensional information contains various "dimensions" of data for a particular value, such as time, depth, altitude, etc. Defining slices of particular dimensions in the layer is handled with the [multidimensionalDefinition](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#multidimensionalDefinition) property of the [mosaicRule](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#mosaicRule). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#multidimensionalInfo) + */ multidimensionalInfo: any; + /** + * The pixel type. **Known Values:** s8 | s16 | s32 | u8 | u16 | u32 | f32 | f64 + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#pixelType) + */ pixelType: string; + /** + * The popup template for the layer. When set on the layer, the popupTemplate allows users to access attributes and display their values using text and/or charts in the [view's popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#popup) when a pixel is clicked. See [this sample](https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-popup/index.html) for an example of how [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) interacts with an [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#popupTemplate) + */ popupTemplate: PopupTemplate; + /** + * The raster attribute table associated with the service. To access the raster attribute table, the layer must be [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#loaded). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#rasterAttributeTable) + */ rasterAttributeTable: any; + /** + * Prefix used to define the fields from the raster attribute table. It's primarily used for [popups](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#rasterAttributeTableFieldPrefix) + * + * @default Raster. + */ rasterAttributeTableFieldPrefix: string; + /** + * A complete list of fields that consists of fields from the layer, pixel value fields and the attribute table fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#rasterFields) + */ rasterFields: Field[]; + /** + * Specifies the rule for how the requested image should be rendered. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#renderingRule) + */ renderingRule: RasterFunction; - spatialReference: SpatialReference; + /** + * The spatial reference of the image service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#spatialReference) + */ + readonly spatialReference: SpatialReference; + /** + * The URL to the REST endpoint of the layer. The URL may either point to a resource on ArcGIS for Server, Portal for ArcGIS, or ArcGIS Online. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#url) + */ url: string; - version: number; + /** + * The version of ArcGIS Server in which the image service is published. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#version) + */ + readonly version: number; + /** + * Returns an image using the [export REST operation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Image/02r3000000wm000000/) that displays data from an [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#fetchImage) + * + * @param extent The extent of the image to export. + * @param width The width of the image in pixels. + * @param height The height of the image in pixels. + * + */ fetchImage(extent: Extent, width: number, height: number): IPromise; + /** + * Creates a new instance of [this class]() and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input `json` parameter often comes from a response to a query operation in the REST API or a [toJSON()](http://pro.arcgis.com/en/pro-app/tool-reference/conversion/features-to-json.htm) method from another ArcGIS product. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for details and examples of when and how to use this function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#fromJSON) + * + * @param json A JSON representation of the instance in the ArcGIS format. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Classification_objects/02r30000019z000000/) for examples of the structure of various input JSON objects. + * + */ fromJSON(json: any): any; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#toJSON) + * + * + */ toJSON(): any; } interface ArcGISImageServiceConstructor { + + new(properties?: ArcGISImageServiceProperties): ArcGISImageService; fromJSON(json: any): ArcGISImageService; @@ -2100,39 +8081,174 @@ declare namespace __esri { export const ArcGISImageService: ArcGISImageServiceConstructor; interface ArcGISImageServiceProperties { + /** + * The compression quality value. This controls how much loss the image will be subjected to. Only valid when using `jpg` [image format](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#format). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#compressionQuality) + */ compressionQuality?: number; + /** + * The output image compression tolerance value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#compressionTolerance) + * + * @default 0.01 + */ compressionTolerance?: number; + /** + * The copyright text as defined by the image service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#copyright) + */ copyright?: string; + /** + * The SQL where clause used to filter rasters on the client. Only the rasters that satisfy the definition expression are displayed in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#definitionExpression) + */ definitionExpression?: string; + /** + * An array of fields in the layer for which a [Domain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Domain.html) has been defined. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#domainFields) + */ domainFields?: FieldProperties[]; + /** + * An array of fields in the layer. Each field represents an attribute that may contain a value for each raster in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#fields) + */ fields?: FieldProperties[]; + /** + * The output image type. The default value is `lerc` if a [pixelFilter](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#pixelFilter) is set on the layer. **Known Values:** png | png8 | png24 | png32 | jpg | bmp | gif | jpgpng | lerc + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#format) + * + * @default jpgpng + */ format?: string; + /** + * The full extent of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#fullExtent) + */ fullExtent?: ExtentProperties; + /** + * Indicates if the Image Service has [multidimensionalInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#multidimensionalInfo). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#hasMultidimensions) + */ hasMultidimensions?: boolean; + /** + * Indicates if the Image Service has a [raster attribute table](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#rasterAttributeTable). If `true`, the raster attribute table can be accessed with the [rasterAttributeTable](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#rasterAttributeTable) property after the layer has [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#loaded). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#hasRasterAttributeTable) + */ hasRasterAttributeTable?: boolean; + /** + * Indicates the maximum height of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#imageMaxHeight) + * + * @default 4100 + */ imageMaxHeight?: number; + /** + * Indicates the maximum width of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#imageMaxWidth) + * + * @default 15000 + */ imageMaxWidth?: number; + /** + * Defines how overlapping images should be mosaicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#mosaicRule) + */ mosaicRule?: MosaicRuleProperties; + /** + * The multidimensional information associated with the service. This will have a value if `serviceInfo` has `hasMultidimensionalInfo = true`. If defined, multidimensional information contains various "dimensions" of data for a particular value, such as time, depth, altitude, etc. Defining slices of particular dimensions in the layer is handled with the [multidimensionalDefinition](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#multidimensionalDefinition) property of the [mosaicRule](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#mosaicRule). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#multidimensionalInfo) + */ multidimensionalInfo?: any; + /** + * The pixel type. **Known Values:** s8 | s16 | s32 | u8 | u16 | u32 | f32 | f64 + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#pixelType) + */ pixelType?: string; + /** + * The popup template for the layer. When set on the layer, the popupTemplate allows users to access attributes and display their values using text and/or charts in the [view's popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#popup) when a pixel is clicked. See [this sample](https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-popup/index.html) for an example of how [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) interacts with an [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#popupTemplate) + */ popupTemplate?: PopupTemplateProperties; + /** + * The raster attribute table associated with the service. To access the raster attribute table, the layer must be [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#loaded). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#rasterAttributeTable) + */ rasterAttributeTable?: any; + /** + * Prefix used to define the fields from the raster attribute table. It's primarily used for [popups](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#rasterAttributeTableFieldPrefix) + * + * @default Raster. + */ rasterAttributeTableFieldPrefix?: string; + /** + * A complete list of fields that consists of fields from the layer, pixel value fields and the attribute table fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#rasterFields) + */ rasterFields?: FieldProperties[]; + /** + * Specifies the rule for how the requested image should be rendered. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#renderingRule) + */ renderingRule?: RasterFunctionProperties; - spatialReference?: SpatialReferenceProperties; + /** + * The URL to the REST endpoint of the layer. The URL may either point to a resource on ArcGIS for Server, Portal for ArcGIS, or ArcGIS Online. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISImageService.html#url) + */ url?: string; - version?: number; } interface ArcGISMapService { + /** + * The copyright text as defined by the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISMapService.html#copyright) + */ copyright: string; + /** + * The full extent of the layer as defined by the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISMapService.html#fullExtent) + */ fullExtent: Extent; - spatialReference: SpatialReference; - token: string; + /** + * The spatial reference of the layer as defined by the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISMapService.html#spatialReference) + */ + readonly spatialReference: SpatialReference; + /** + * Token generated by the token service using the specified userId and password. The recommended approach to pass a token on a layer is to use [IdentityManager.registerToken()](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#registerToken). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISMapService.html#token) + */ + readonly token: string; } interface ArcGISMapServiceConstructor { + + new(properties?: ArcGISMapServiceProperties): ArcGISMapService; fromJSON(json: any): ArcGISMapService; @@ -2141,17 +8257,32 @@ declare namespace __esri { export const ArcGISMapService: ArcGISMapServiceConstructor; interface ArcGISMapServiceProperties { + /** + * The copyright text as defined by the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISMapService.html#copyright) + */ copyright?: string; + /** + * The full extent of the layer as defined by the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ArcGISMapService.html#fullExtent) + */ fullExtent?: ExtentProperties; - spatialReference?: SpatialReferenceProperties; - token?: string; } interface PortalLayer { + /** + * The portal item from which the layer is loaded. If the portal item references a Feature Service or Scene Service, then you can specify a single layer to load with the [layerId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-PortalLayer.html#layerId) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-PortalLayer.html#portalItem) + */ portalItem: PortalItem; } interface PortalLayerConstructor { + + new(properties?: PortalLayerProperties): PortalLayer; fromJSON(json: any): PortalLayer; @@ -2160,35 +8291,149 @@ declare namespace __esri { export const PortalLayer: PortalLayerConstructor; interface PortalLayerProperties { + /** + * The portal item from which the layer is loaded. If the portal item references a Feature Service or Scene Service, then you can specify a single layer to load with the [layerId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-PortalLayer.html#layerId) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-PortalLayer.html#portalItem) + */ portalItem?: PortalItemProperties; } + interface RefreshableLayer { + /** + * Refresh interval of the layer in minutes. Minimum refresh interval is 0.1 minute (6 seconds). Value of `0` indicates no refresh. + * > **Known Limitations** Refreshing is only supported in 2D [MapViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-RefreshableLayer.html#refreshInterval) + * + * @default 0 + */ + refreshInterval: number; + + /** + * Fetches all the data for the layer. + * > **Known Limitations** Refreshing is only supported in 2D [MapViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-RefreshableLayer.html#refresh) + * + * + */ + refresh(): void; + } + + interface RefreshableLayerConstructor { + + + new(): RefreshableLayer; + } + + export const RefreshableLayer: RefreshableLayerConstructor; + + interface RefreshableLayerProperties { + /** + * Refresh interval of the layer in minutes. Minimum refresh interval is 0.1 minute (6 seconds). Value of `0` indicates no refresh. + * > **Known Limitations** Refreshing is only supported in 2D [MapViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-RefreshableLayer.html#refreshInterval) + * + * @default 0 + */ + refreshInterval?: number; + } + interface ScaleRangeLayer { + /** + * The maximum scale at which the layer is visible in the view. If the map is zoomed in beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a maximum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ScaleRangeLayer.html#maxScale) + * + * @default 0 + */ maxScale: number; + /** + * The minimum scale at which the layer is visible in the view. If the map is zoomed out beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a minimum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ScaleRangeLayer.html#minScale) + * + * @default 0 + */ minScale: number; } interface ScaleRangeLayerConstructor { + + new(): ScaleRangeLayer; } export const ScaleRangeLayer: ScaleRangeLayerConstructor; interface ScaleRangeLayerProperties { + /** + * The maximum scale at which the layer is visible in the view. If the map is zoomed in beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a maximum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ScaleRangeLayer.html#maxScale) + * + * @default 0 + */ maxScale?: number; + /** + * The minimum scale at which the layer is visible in the view. If the map is zoomed out beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a minimum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ScaleRangeLayer.html#minScale) + * + * @default 0 + */ minScale?: number; } interface SceneService { + /** + * The copyright text as defined by the scene service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#copyright) + */ copyright: string; + /** + * The layer ID, or layer index, of a Scene Service layer. This is particularly useful when loading a single SceneLayer with the [portalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#portalItem) property from a service containing multiple layers. You can specify this value in one of two scenarios: + * * When loading the layer via the [portalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#portalItem) property. + * * When pointing the layer [url](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#url) directly to the Scene Service. + * + * + * If a layerId is not specified in either of the above scenarios, then the first layer in the service (`layerId = 0`) is selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#layerId) + */ layerId: number; + /** + * The spatial reference of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#spatialReference) + */ spatialReference: SpatialReference; - token: string; + /** + * Token generated by the token service using the specified userId and password. The recommended approach to pass a token on a layer is to use [IdentityManager.registerToken()](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#registerToken). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#token) + */ + readonly token: string; + /** + * The URL of the REST endpoint of the layer or scene service. The URL may either point to a resource on ArcGIS Server, Portal for ArcGIS, or ArcGIS Online. The layer may be specified using the [layerId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#layerId) property when the url points directly to a service and not a specific layer. If [layerId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#layerId) is not specified, then it will default to the first layer in the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#url) + */ url: string; - version: SceneServiceVersion; + /** + * The version of the scene service specification used for this service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#version) + */ + readonly version: SceneServiceVersion; } interface SceneServiceConstructor { + + new(properties?: SceneServiceProperties): SceneService; fromJSON(json: any): SceneService; @@ -2197,28 +8442,77 @@ declare namespace __esri { export const SceneService: SceneServiceConstructor; interface SceneServiceProperties { + /** + * The copyright text as defined by the scene service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#copyright) + */ copyright?: string; + /** + * The layer ID, or layer index, of a Scene Service layer. This is particularly useful when loading a single SceneLayer with the [portalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#portalItem) property from a service containing multiple layers. You can specify this value in one of two scenarios: + * * When loading the layer via the [portalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#portalItem) property. + * * When pointing the layer [url](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#url) directly to the Scene Service. + * + * + * If a layerId is not specified in either of the above scenarios, then the first layer in the service (`layerId = 0`) is selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#layerId) + */ layerId?: number; + /** + * The spatial reference of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#spatialReference) + */ spatialReference?: SpatialReferenceProperties; - token?: string; + /** + * The URL of the REST endpoint of the layer or scene service. The URL may either point to a resource on ArcGIS Server, Portal for ArcGIS, or ArcGIS Online. The layer may be specified using the [layerId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#layerId) property when the url points directly to a service and not a specific layer. If [layerId](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#layerId) is not specified, then it will default to the first layer in the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#url) + */ url?: string; - version?: SceneServiceVersion; } - export interface SceneServiceVersion { + + export interface SceneServiceVersion extends Object { + /** + * The major version of the scene layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#version) + */ major: number; + /** + * The minor version of the scene layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#version) + */ minor: number; + /** + * The complete version string of the scene layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-SceneService.html#version) + */ versionString: string; } interface OpenStreetMapLayer extends WebTileLayer { + on(name: "layerview-create", eventHandler: OpenStreetMapLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: OpenStreetMapLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: OpenStreetMapLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: OpenStreetMapLayerLayerviewDestroyEventHandler): IHandle; } interface OpenStreetMapLayerConstructor { + /** + * Allows you to use [basemaps](http://wiki.openstreetmap.org/wiki/List_of_OSM-based_services) from [OpenStreetMap](http://www.openstreetmap.org/). Set the [tileservers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-OpenStreetMapLayer.html#tileServers) property to change which OpenStreetMap tiles you want to use. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-OpenStreetMapLayer.html) + */ + new(properties?: OpenStreetMapLayerProperties): OpenStreetMapLayer; fromJSON(json: any): OpenStreetMapLayer; @@ -2231,28 +8525,64 @@ declare namespace __esri { } export interface OpenStreetMapLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface OpenStreetMapLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface PointCloudLayer extends Layer, SceneService, PortalLayer { + /** + * Specifies how points are placed on the vertical axis (z). This property only affects [PointCloudLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html) when using the `absolute-height` mode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html#elevationInfo) + */ elevationInfo: PointCloudLayerElevationInfo; + /** + * An array of fields accessible in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html#fields) + */ fields: Field[]; + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html#legendEnabled) + * + * @default true + */ legendEnabled: boolean; + /** + * The renderer assigned to the layer. The renderer defines how to visualize each point in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html#renderer) + */ renderer: PointCloudRenderer; + on(name: "layerview-create", eventHandler: PointCloudLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: PointCloudLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: PointCloudLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: PointCloudLayerLayerviewDestroyEventHandler): IHandle; } interface PointCloudLayerConstructor { + /** + * The PointCloudLayer is designed for visualizing large collections of points in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html) + */ + new(properties?: PointCloudLayerProperties): PointCloudLayer; fromJSON(json: any): PointCloudLayer; @@ -2261,56 +8591,248 @@ declare namespace __esri { export const PointCloudLayer: PointCloudLayerConstructor; interface PointCloudLayerProperties extends LayerProperties, SceneServiceProperties, PortalLayerProperties { + /** + * Specifies how points are placed on the vertical axis (z). This property only affects [PointCloudLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html) when using the `absolute-height` mode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html#elevationInfo) + */ elevationInfo?: PointCloudLayerElevationInfo; + /** + * An array of fields accessible in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html#fields) + */ fields?: FieldProperties[]; + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html#legendEnabled) + * + * @default true + */ legendEnabled?: boolean; + /** + * The renderer assigned to the layer. The renderer defines how to visualize each point in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html#renderer) + */ renderer?: PointCloudRendererProperties; } export interface PointCloudLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface PointCloudLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } - export interface PointCloudLayerElevationInfo { + + export interface PointCloudLayerElevationInfo extends Object { + /** + * Defines how the points are placed on the vertical axis (z). Currently only `absolute-height` mode is supported. + * + * Mode | Description + * ------|------------ + * absolute-height | Points are placed at an absolute height above sea level. This height is determined by summing up the `offset` value and the point's z-value. It doesn't take the elevation of the terrain into account. This is the only supported elevation mode for a [PointCloudLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html#elevationInfo) + */ mode: string; + /** + * An elevation offset, which is added to the vertical position of each point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html#elevationInfo) + * + * @default 0 + */ offset?: number; + /** + * The unit for `offset` values. **Possible Values:** feet | meters | kilometers | miles | us-feet | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html#elevationInfo) + * + * @default meters + */ + unit?: string; } interface SceneLayer extends Layer, SceneService, PortalLayer { + /** + * The SQL where clause used to filter features on the client. Only the features that satisfy the definition expression are displayed in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). Setting a definition expression is useful when only a subset of the data in the layer should be displayed. Setting the definition expression of a layer automatically updates all layer views. If the definition expression is set after the layer has been added to the map, the view will automatically refresh itself to display the features that satisfy the new definition expression. Important to note is that the initial loading time of the features remains unchanged, even if they are filtered. This happens because, as opposed to Feature Layers, feature filtering is done client-side. As a result all features need to be downloaded always for filter evaluation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#definitionExpression) + */ definitionExpression: string; + /** + * Specifies how graphics are placed on the vertical axis (z). See the [ElevationInfo sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-elevationinfo/index.html) for an example of how this property may be used. This property only affects 3D Object [SceneLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) when using the `absolute-height` mode. [SceneLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) with [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries support all the elevation modes listed below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#elevationInfo) + */ elevationInfo: SceneLayerElevationInfo; + /** + * Configures the method for decluttering overlapping features in the view. If this property is not set (or set to `null`), every feature is drawn individually. This property is only supported for point scene layers with non-draped [Icon](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html) or [Text](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html) symbol layers. [![declutter](https://developers.arcgis.com/javascript/latest/assets/img/samples/city-points-declutter.gif)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-point-styles/index.html) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#featureReduction) + */ featureReduction: SceneLayerFeatureReduction; + /** + * An array of fields accessible in the layer. Depending on the scene service, fields may have limited support for certain capabilities. Use [getFieldUsageInfo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#getFieldUsageInfo) to query the contexts (rendering, labeling, popups or querying) for which a particular field may be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#fields) + */ fields: Field[]; + /** + * The geometry type of features in the layer. **Possible Values:** point | mesh + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#geometryType) + */ geometryType: string; + /** + * The label definition for this layer, specified as an array of [LabelClass](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html). Use this property to specify labeling properties for the layer such as label expression, placement, and size. For labels to display in the view, the [labelsVisible](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#labelsVisible) property of this layer must be set to `true`. + * > **Known Limitations** This property is only relevant to SceneLayers with [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries. This property has no effect on SceneLayers with other geometry types. Each point can have only one label. Multiple [Label classes](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html) with different [where](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#where) clauses can be used to have different label styles on different features that belong to the same layer (for example blue labels for lakes and green labels for parks). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#labelingInfo) + */ labelingInfo: LabelClass[]; + /** + * Indicates whether to display labels for this layer. If `true`, labels will appear as defined in the [labelingInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#labelingInfo) property. This property is only relevant to SceneLayers with [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries. This property has no effect on SceneLayers with other geometry types. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#labelsVisible) + * + * @default false + */ labelsVisible: boolean; + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#legendEnabled) + * + * @default true + */ legendEnabled: boolean; + /** + * The name of the field containing each graphic's Object ID. If this is not explicitly specified, this is automatically derived from the [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#fields) of the service by taking the first field of type `oid`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#objectIdField) + */ objectIdField: string; + /** + * Indicates whether to display popups when features in the layer are clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#popupEnabled) + * + * @default true + */ popupEnabled: boolean; + /** + * The popup template for the layer. When set on the layer, the `popupTemplate` allows users to access attributes and display their values in the [view's popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#popup) when a feature is selected using text and/or charts. See the [PopupTemplate sample](https://developers.arcgis.com/javascript/latest/sample-code/intro-popuptemplate/index.html) for an example of how [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) interacts with a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). Setting a [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) on this layer type is done in the same way as a FeatureLayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#popupTemplate) + */ popupTemplate: PopupTemplate; + /** + * The renderer assigned to the layer. The renderer defines how to visualize each feature in the layer. Depending on the renderer type, features may be visualized with the same symbol, or with varying symbols based on the values of provided attribute fields or functions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#renderer) + */ renderer: Renderer; + /** + * Apply perspective scaling to screen-size point symbols in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). When `true`, screen sized objects such as [icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [labels](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html) or [callouts](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-Callout3D.html) integrate better in the 3D scene by applying a certain perspective projection to the sizing of features. This only applies when using a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). `layer.screenSizePerspectiveEnabled = true` ![screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-screenSize-perspective.png) `layer.screenSizePerspectiveEnabled = false` ![no-screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-no-screenSize-perspective.png) + * > **Known Limitations** Screen size perspective is currently not optimized for situations where the camera is very near the ground, or for scenes with point features located far from the ground surface. In these cases it may be better to turn off screen size perspective. As screen size perspective changes the size based on distance to the camera, it should be set to false when using {@link module:esri/renderers/Renderer#SizeVisualVariable size visual variables}. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#screenSizePerspectiveEnabled) + * + * @default true + */ screenSizePerspectiveEnabled: boolean; + /** + * Creates a query object that can be used to fetch features that satisfy the layer's current definition expression. The query should only be used on the layer and not on the layer view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#createQuery) + * + * + */ createQuery(): Query; + /** + * Gets field usage information. The usage of a field depends on whether it is stored as part of the scene service cache. The returned object contains the following usage information: + * + * Property | Type | Description + * ----------------------|---------|------------ + * supportsRenderer | boolean | Indicates that a field can be used in a renderer (e.g. in visual variables), [see renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#renderer). + * supportsLabelingInfo | boolean | Indicates that a field can be used for labeling, [see labelingInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#labelingInfo). + * supportsPopupTemplate | boolean | Indicates that a field can be used in a popup template, [see popupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#popupTemplate). + * supportsLayerQuery | boolean | Indicates that a field can be used in layer queries, [see queryFeatures()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#queryFeatures). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#getFieldUsageInfo) + * + * @param fieldName The name of the field to get usage info for. + * + */ getFieldUsageInfo(fieldName: string): any; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against the service and returns the 2D [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) of features that satisfy the query. At the moment the 3D Extent can be returned by using [SceneLayerView.queryExtent()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-SceneLayerView.html#queryExtent), but this will return the 3D extent only for features currently in the view. The query succeeds only if the layer's `supportsLayerQuery` capability is enabled. Use the [getFieldUsageInfo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#getFieldUsageInfo) method to check if the layer supports queries. If querying is not enabled, then an error with the name `scenelayer:query-not-available` is thrown. Read more about queries in the Query section of the class description above. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#queryExtent) + * + * @param params Specifies the query parameters. + * + */ queryExtent(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against the service and returns the number of the features that satisfy the query. The query succeeds only if the layer's `supportsLayerQuery` capability is enabled. Use the [getFieldUsageInfo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#getFieldUsageInfo) method to check if the layer supports queries. If querying is not enabled, then an error with the name `scenelayer:query-not-available` is thrown. Read more about queries in the Query section of the class description above. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#queryFeatureCount) + * + * @param params Specifies the query parameters. + * + */ queryFeatureCount(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against the service and returns a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). The query succeeds only if the layer's `supportsLayerQuery` capability is enabled. Use the [getFieldUsageInfo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#getFieldUsageInfo) method to check if the layer supports queries. If querying is not enabled, then an error with the name `scenelayer:query-not-available` is thrown. Read more about queries in the Query section of the class description above. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#queryFeatures) + * + * @param params Specifies the query parameters. + * + */ queryFeatures(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against the service and returns an array of the ObjectIDs of features that satisfy the input query. The query succeeds only if the layer's `supportsLayerQuery` capability is enabled. Use the [getFieldUsageInfo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#getFieldUsageInfo) method to check if the layer supports queries. If querying is not enabled, then an error with the name `scenelayer:query-not-available` is thrown. Read more about queries in the Query section of the class description above. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#queryObjectIds) + * + * @param params Specifies the query parameters. + * + */ queryObjectIds(params?: Query): IPromise; + on(name: "layerview-create", eventHandler: SceneLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: SceneLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: SceneLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: SceneLayerLayerviewDestroyEventHandler): IHandle; } interface SceneLayerConstructor { + /** + * The SceneLayer is a layer type designed for on-demand streaming and displaying large amounts of data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). SceneLayers support two geometry types: [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) and 3D Objects (e.g. Buildings). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) + */ + new(properties?: SceneLayerProperties): SceneLayer; fromJSON(json: any): SceneLayer; @@ -2319,55 +8841,209 @@ declare namespace __esri { export const SceneLayer: SceneLayerConstructor; interface SceneLayerProperties extends LayerProperties, SceneServiceProperties, PortalLayerProperties { + /** + * The SQL where clause used to filter features on the client. Only the features that satisfy the definition expression are displayed in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). Setting a definition expression is useful when only a subset of the data in the layer should be displayed. Setting the definition expression of a layer automatically updates all layer views. If the definition expression is set after the layer has been added to the map, the view will automatically refresh itself to display the features that satisfy the new definition expression. Important to note is that the initial loading time of the features remains unchanged, even if they are filtered. This happens because, as opposed to Feature Layers, feature filtering is done client-side. As a result all features need to be downloaded always for filter evaluation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#definitionExpression) + */ definitionExpression?: string; + /** + * Specifies how graphics are placed on the vertical axis (z). See the [ElevationInfo sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-elevationinfo/index.html) for an example of how this property may be used. This property only affects 3D Object [SceneLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) when using the `absolute-height` mode. [SceneLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) with [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries support all the elevation modes listed below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#elevationInfo) + */ elevationInfo?: SceneLayerElevationInfo; + /** + * Configures the method for decluttering overlapping features in the view. If this property is not set (or set to `null`), every feature is drawn individually. This property is only supported for point scene layers with non-draped [Icon](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html) or [Text](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html) symbol layers. [![declutter](https://developers.arcgis.com/javascript/latest/assets/img/samples/city-points-declutter.gif)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-point-styles/index.html) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#featureReduction) + */ featureReduction?: SceneLayerFeatureReduction; + /** + * An array of fields accessible in the layer. Depending on the scene service, fields may have limited support for certain capabilities. Use [getFieldUsageInfo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#getFieldUsageInfo) to query the contexts (rendering, labeling, popups or querying) for which a particular field may be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#fields) + */ fields?: FieldProperties[]; + /** + * The geometry type of features in the layer. **Possible Values:** point | mesh + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#geometryType) + */ geometryType?: string; + /** + * The label definition for this layer, specified as an array of [LabelClass](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html). Use this property to specify labeling properties for the layer such as label expression, placement, and size. For labels to display in the view, the [labelsVisible](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#labelsVisible) property of this layer must be set to `true`. + * > **Known Limitations** This property is only relevant to SceneLayers with [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries. This property has no effect on SceneLayers with other geometry types. Each point can have only one label. Multiple [Label classes](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html) with different [where](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#where) clauses can be used to have different label styles on different features that belong to the same layer (for example blue labels for lakes and green labels for parks). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#labelingInfo) + */ labelingInfo?: LabelClassProperties[]; + /** + * Indicates whether to display labels for this layer. If `true`, labels will appear as defined in the [labelingInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#labelingInfo) property. This property is only relevant to SceneLayers with [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries. This property has no effect on SceneLayers with other geometry types. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#labelsVisible) + * + * @default false + */ labelsVisible?: boolean; + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#legendEnabled) + * + * @default true + */ legendEnabled?: boolean; + /** + * The name of the field containing each graphic's Object ID. If this is not explicitly specified, this is automatically derived from the [fields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#fields) of the service by taking the first field of type `oid`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#objectIdField) + */ objectIdField?: string; + /** + * Indicates whether to display popups when features in the layer are clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#popupEnabled) + * + * @default true + */ popupEnabled?: boolean; + /** + * The popup template for the layer. When set on the layer, the `popupTemplate` allows users to access attributes and display their values in the [view's popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#popup) when a feature is selected using text and/or charts. See the [PopupTemplate sample](https://developers.arcgis.com/javascript/latest/sample-code/intro-popuptemplate/index.html) for an example of how [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) interacts with a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). Setting a [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) on this layer type is done in the same way as a FeatureLayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#popupTemplate) + */ popupTemplate?: PopupTemplateProperties; + /** + * The renderer assigned to the layer. The renderer defines how to visualize each feature in the layer. Depending on the renderer type, features may be visualized with the same symbol, or with varying symbols based on the values of provided attribute fields or functions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#renderer) + */ renderer?: RendererProperties; + /** + * Apply perspective scaling to screen-size point symbols in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). When `true`, screen sized objects such as [icons](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [labels](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html) or [callouts](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-Callout3D.html) integrate better in the 3D scene by applying a certain perspective projection to the sizing of features. This only applies when using a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). `layer.screenSizePerspectiveEnabled = true` ![screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-screenSize-perspective.png) `layer.screenSizePerspectiveEnabled = false` ![no-screen-size-perspective](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-no-screenSize-perspective.png) + * > **Known Limitations** Screen size perspective is currently not optimized for situations where the camera is very near the ground, or for scenes with point features located far from the ground surface. In these cases it may be better to turn off screen size perspective. As screen size perspective changes the size based on distance to the camera, it should be set to false when using {@link module:esri/renderers/Renderer#SizeVisualVariable size visual variables}. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#screenSizePerspectiveEnabled) + * + * @default true + */ screenSizePerspectiveEnabled?: boolean; } export interface SceneLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface SceneLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } - export interface SceneLayerElevationInfo { + + export interface SceneLayerElevationInfo extends Object { + /** + * Defines how the graphic is placed with respect to the terrain surface. See the table below for a list of possible values. + * + * Mode | Description + * ------|------------ + * on-the-ground | Graphics are draped on the terrain surface. This is the default value for features with [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries rendered with [ObjectSymbol3DLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html). + * relative-to-ground | The graphic is placed at an elevation relative to the terrain surface. The graphic's elevation is determined by summing up the terrain elevation, the `offset` value and the geometry's z-value (if present). This is the default value for [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries rendered with [IconSymbol3DLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html). + * absolute-height | Graphics are placed at an absolute height above sea level. This height is determined by summing up the `offset` value and the geometry's z-value (if present). It doesn't take the elevation of the terrain into account. This is the default value for features with 3D Object geometries and [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries where [hasZ](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#hasZ) is `true`. + * relative-to-scene | Graphics are aligned to buildings and other objects part of 3D Object [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) or [IntegratedMeshLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMeshLayer.html), depending on which has higher elevation. If the graphic is not directly above a building or any other feature, it is aligned to the terrain surface elevation. If present, z-values will be ignored. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#elevationInfo) + */ mode: string; + /** + * An elevation offset which is added to the vertical position of the graphic. When `mode = "on-the-ground"`, this property has no effect. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#elevationInfo) + * + * @default 0 + */ offset?: number; + /** + * The unit for `offset` values. **Possible Values:** feet | meters | kilometers | miles | us-feet | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#elevationInfo) + * + * @default meters + */ + unit?: string; } - export interface SceneLayerFeatureReduction { + + export interface SceneLayerFeatureReduction extends Object { + /** + * Type of the decluttering method. The only supported type at the moment is `"selection"`. In this method, some of the overlapping features are hidden such that none of the remaining features intersect on screen. Label deconfliction also respects this option and hides labels that would overlap with the features of this layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#featureReduction) + */ type: string; } interface StreamLayer extends FeatureLayer { - filter: StreamLayerFilter; + /** + * Contains the attribute and spatial filters used to filter messages sent to the client by a Stream Service. This property can be set in the constructor but is `read-only` after the layer is created. To change the filter after the layer is created, use the [updateFilter()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#updateFilter) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#filter) + */ + readonly filter: StreamLayerFilter; + /** + * An extent object used to filter features. Only features intersecting the extent are displayed in the view. Instead of using this property, use [StreamLayer.filter.geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#filter) when creating the service or [StreamLayer.updateFilter()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#updateFilter) when changing the spatial filter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#geometryDefinition) + */ geometryDefinition: Extent; + /** + * Maximum number of features to show per trackId + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#maximumTrackPoints) + */ maximumTrackPoints: number; + /** + * Options for purging stale features. Use these options to avoid overloading the browser with graphics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#purgeOptions) + */ purgeOptions: StreamLayerPurgeOptions; + /** + * Updates the [filter](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#filter) on the layer. The filter is updated on all views that contain the layer. If the input `filterChanges` object is `undefined` or `null`, the spatial and attribute filters are removed. To update the filter on a single layer view associated with the layer, use the [StreamLayerView.updateFilter()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#updateFilter) method after getting the layer view object. Filter changes only apply to incoming features. Features already displayed in the view are not filtered. Therefore, you may want to clear the graphics in the layer view prior to applying a new filter. To do so, get the layer view then call [removeAll()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#removeAll) on the [StreamLayerView.graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#graphics). You may also filter features already present in the view using the [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) methods. See the examples below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#updateFilter) + * + * @param filterChanges Updates the spatial and attribute [filters](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#filter) on the layer and all of its associated views. If `null`, all filters are cleared. + * @param filterChanges.geometry A spatial filter for filtering features. Only features that intersect the given geometry are displayed in the view(s). If `null`, the spatial filter is cleared. + * @param filterChanges.where A SQL where clause used to filter features by attributes. If `null`, the attribute filter is cleared. + * + */ updateFilter(filterChanges: StreamLayerUpdateFilterFilterChanges): IPromise; + on(name: "layerview-create", eventHandler: StreamLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: StreamLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: StreamLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: StreamLayerLayerviewDestroyEventHandler): IHandle; } interface StreamLayerConstructor { + /** + * The stream layer extends the feature layer to add the ability to connect to a stream of data using HTML5 WebSockets. It connects to a server that emits geographic features continuously. While the feature layer is used to map relatively static data, the stream layer is suitable when you would like to map dynamic streams of data that are unbounded and continuous. When a stream layer is added to a map, users are able to see real-time updates pushed out by the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html) + */ + new(properties?: StreamLayerProperties): StreamLayer; fromJSON(json: any): StreamLayer; @@ -2376,44 +9052,116 @@ declare namespace __esri { export const StreamLayer: StreamLayerConstructor; interface StreamLayerProperties extends FeatureLayerProperties { + /** + * Contains the attribute and spatial filters used to filter messages sent to the client by a Stream Service. This property can be set in the constructor but is `read-only` after the layer is created. To change the filter after the layer is created, use the [updateFilter()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#updateFilter) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#filter) + */ filter?: StreamLayerFilter; + /** + * An extent object used to filter features. Only features intersecting the extent are displayed in the view. Instead of using this property, use [StreamLayer.filter.geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#filter) when creating the service or [StreamLayer.updateFilter()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#updateFilter) when changing the spatial filter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#geometryDefinition) + */ geometryDefinition?: ExtentProperties; + /** + * Maximum number of features to show per trackId + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#maximumTrackPoints) + */ maximumTrackPoints?: number; + /** + * Options for purging stale features. Use these options to avoid overloading the browser with graphics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#purgeOptions) + */ purgeOptions?: StreamLayerPurgeOptions; } export interface StreamLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface StreamLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } - export interface StreamLayerFilter { + + export interface StreamLayerFilter extends Object { + /** + * A spatial filter for filtering features. Only features that intersect the given geometry are displayed in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#filter) + */ geometry?: Extent; + /** + * A SQL where clause used to filter features by attributes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#filter) + */ where?: string; } - export interface StreamLayerPurgeOptions { + + export interface StreamLayerPurgeOptions extends Object { + /** + * The maximum number of features to display. Excess features are purged from the beginning of the graphics array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#purgeOptions) + */ displayCount: number; + /** + * The maximum time in minutes that a feature should be kept. After this time, the feature is removed from the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#purgeOptions) + */ age: number; } - export interface StreamLayerUpdateFilterFilterChanges { + + export interface StreamLayerUpdateFilterFilterChanges extends Object { + /** + * A spatial filter for filtering features. Only features that intersect the given geometry are displayed in the view(s). If `null`, the spatial filter is cleared. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#updateFilter) + */ geometry: Extent; + /** + * A SQL where clause used to filter features by attributes. If `null`, the attribute filter is cleared. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#updateFilter) + */ where: string; } interface CodedValueDomain extends Domain { + /** + * An array of the coded values in the domain. See the object specification table below for the properties each item in the array should contain. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CodedValueDomain.html#codedValues) + */ codedValues: CodedValueDomainCodedValues[]; + /** + * Returns the name of the coded-value associated with the specified code. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CodedValueDomain.html#getName) + * + * @param code The code associated with the desired name. + * + */ getName(code: string | number): string; } interface CodedValueDomainConstructor { + + new(properties?: CodedValueDomainProperties): CodedValueDomain; fromJSON(json: any): CodedValueDomain; @@ -2422,35 +9170,99 @@ declare namespace __esri { export const CodedValueDomain: CodedValueDomainConstructor; interface CodedValueDomainProperties extends DomainProperties { + /** + * An array of the coded values in the domain. See the object specification table below for the properties each item in the array should contain. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CodedValueDomain.html#codedValues) + */ codedValues?: CodedValueDomainCodedValues[]; } - export interface CodedValueDomainCodedValues { + + export interface CodedValueDomainCodedValues extends Object { + /** + * The name of the coded value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CodedValueDomain.html#codedValues) + */ name: string; + /** + * The value of the code. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CodedValueDomain.html#codedValues) + */ code: string | number; } interface DimensionalDefinition { + /** + * The dimension associated with the variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-DimensionalDefinition.html#dimensionName) + */ dimensionName: string; + /** + * Indicates whether the values indicate slices (rather than ranges). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-DimensionalDefinition.html#isSlice) + * + * @default false + */ isSlice: boolean; + /** + * An array of tuples [min, max] each defining a range of valid values along the specified dimension. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-DimensionalDefinition.html#values) + */ values: any[]; + /** + * The variable name by which to filter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-DimensionalDefinition.html#variableName) + */ variableName: string; + /** + * Returns a serialized JSON object representation of the dimensional definition in the format of the ArcGIS Platform. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-DimensionalDefinition.html#toJSON) + * + * + */ toJSON(): any; } interface DimensionalDefinitionConstructor { + /** + * A dimensional definition defines a filter based on one variable and one dimension. You can filter with one or multiple dimensional slices. Instances of this class are typically used when filtering data based on [slices](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-DimensionalDefinition.html#isSlice) or ranges in one or more dimensions with [MosaicRule](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-DimensionalDefinition.html) + */ + + new(properties?: any): DimensionalDefinition; } export const DimensionalDefinition: DimensionalDefinitionConstructor; interface Domain extends Accessor, JSONSupport { + /** + * The domain name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Domain.html#name) + */ name: string; + /** + * The domain type. **Possible Values:** range | coded-value | inherited + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Domain.html#type) + */ type: string; } interface DomainConstructor { + + new(properties?: DomainProperties): Domain; fromJSON(json: any): Domain; @@ -2459,19 +9271,56 @@ declare namespace __esri { export const Domain: DomainConstructor; interface DomainProperties { + /** + * The domain name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Domain.html#name) + */ name?: string; + /** + * The domain type. **Possible Values:** range | coded-value | inherited + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Domain.html#type) + */ type?: string; } interface FeatureTemplate extends Accessor, JSONSupport { + /** + * Description of the feature template. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#description) + */ description: string; + /** + * Name of the default drawing tool defined for the template to create a feature. **Known Values:** auto-complete-polygon | circle | ellipse | freehand | line | none | point | polygon | rectangle | arrow | triangle | left-arrow | right-arrow | up-arrow | down-arrow + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#drawingTool) + */ drawingTool: string; + /** + * Name of the feature template. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#name) + */ name: string; + /** + * An instance of the prototypical feature described by the [feature template](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html). It specifies default values for the attribute fields and does not contain geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#prototype) + */ prototype: any; + /** + * An object used to create a thumbnail image that represents a feature type in the feature template. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#thumbnail) + */ thumbnail: FeatureTemplateThumbnail; } interface FeatureTemplateConstructor { + + new(properties?: FeatureTemplateProperties): FeatureTemplate; fromJSON(json: any): FeatureTemplate; @@ -2480,28 +9329,96 @@ declare namespace __esri { export const FeatureTemplate: FeatureTemplateConstructor; interface FeatureTemplateProperties { + /** + * Description of the feature template. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#description) + */ description?: string; + /** + * Name of the default drawing tool defined for the template to create a feature. **Known Values:** auto-complete-polygon | circle | ellipse | freehand | line | none | point | polygon | rectangle | arrow | triangle | left-arrow | right-arrow | up-arrow | down-arrow + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#drawingTool) + */ drawingTool?: string; + /** + * Name of the feature template. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#name) + */ name?: string; + /** + * An instance of the prototypical feature described by the [feature template](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html). It specifies default values for the attribute fields and does not contain geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#prototype) + */ prototype?: any; + /** + * An object used to create a thumbnail image that represents a feature type in the feature template. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#thumbnail) + */ thumbnail?: FeatureTemplateThumbnail; } - export interface FeatureTemplateThumbnail { + + export interface FeatureTemplateThumbnail extends Object { + /** + * The MIME type of the image. **Known Values:** image | png | jpg | jpeg + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#thumbnail) + */ contentType: any; + /** + * The [base64EncodedImageData](https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding) presenting the thumbnail image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#thumbnail) + */ imageData: string; + /** + * The height of the thumbnail. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#thumbnail) + */ height: number; + /** + * The width of the thumbnail. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html#thumbnail) + */ width: number; } interface FeatureType extends Accessor, JSONSupport { + /** + * Domains associated with the feature type. It is an object where the name of each property corresponds with the name of a field containing a domain. If a field's domain is an instance of [InheritedDomain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-InheritedDomain.html), the application will use the domain defined for the field from the layer. If the domain is an instance of [CodedValueDomain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CodedValueDomain.html) or [RangeDomain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RangeDomain.html) then the domain is defined specifically for the given feature type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureType.html#domains) + */ domains: any; + /** + * The feature type identifier. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureType.html#id) + */ id: number | string; + /** + * The feature type name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureType.html#name) + */ name: string; + /** + * Array of [feature templates](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html) associated with the feature type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureType.html#templates) + */ templates: FeatureTemplate[]; } interface FeatureTypeConstructor { + + new(properties?: FeatureTypeProperties): FeatureType; fromJSON(json: any): FeatureType; @@ -2510,23 +9427,80 @@ declare namespace __esri { export const FeatureType: FeatureTypeConstructor; interface FeatureTypeProperties { + /** + * Domains associated with the feature type. It is an object where the name of each property corresponds with the name of a field containing a domain. If a field's domain is an instance of [InheritedDomain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-InheritedDomain.html), the application will use the domain defined for the field from the layer. If the domain is an instance of [CodedValueDomain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-CodedValueDomain.html) or [RangeDomain](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RangeDomain.html) then the domain is defined specifically for the given feature type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureType.html#domains) + */ domains?: any; + /** + * The feature type identifier. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureType.html#id) + */ id?: number | string; + /** + * The feature type name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureType.html#name) + */ name?: string; + /** + * Array of [feature templates](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureTemplate.html) associated with the feature type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FeatureType.html#templates) + */ templates?: FeatureTemplateProperties[]; } interface Field extends Accessor, JSONSupport { + /** + * The alias name for the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#alias) + */ alias: string; + /** + * The domain associated with the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#domain) + */ domain: Domain; + /** + * Indicates whether the field is editable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#editable) + */ editable: boolean; + /** + * The field length. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#length) + */ length: number; + /** + * The name of the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#name) + */ name: string; + /** + * Indicates if the field can accept `null` values. *Requires ArcGIS Server version 10.1 or greater.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#nullable) + */ nullable: boolean; + /** + * The data type of the field. **Possible Values:** small-integer | integer | single | double | long | string | date | oid | geometry | blob | raster | guid | global-id | xml + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#type) + */ type: string; } interface FieldConstructor { + + new(properties?: FieldProperties): Field; fromJSON(json: any): Field; @@ -2535,46 +9509,202 @@ declare namespace __esri { export const Field: FieldConstructor; interface FieldProperties { + /** + * The alias name for the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#alias) + */ alias?: string; + /** + * The domain associated with the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#domain) + */ domain?: DomainProperties; + /** + * Indicates whether the field is editable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#editable) + */ editable?: boolean; + /** + * The field length. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#length) + */ length?: number; + /** + * The name of the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#name) + */ name?: string; + /** + * Indicates if the field can accept `null` values. *Requires ArcGIS Server version 10.1 or greater.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#nullable) + */ nullable?: boolean; + /** + * The data type of the field. **Possible Values:** small-integer | integer | single | double | long | string | date | oid | geometry | blob | raster | guid | global-id | xml + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#type) + */ type?: string; } interface ImageParameters extends Accessor { + /** + * Dots per inch setting for an module:esri/layersMapImageLayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#dpi) + * + * @default 96 + */ dpi: number; + /** + * Extent of map to be exported. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#extent) + */ extent: Extent; + /** + * Map image format. **Known Values:** png | png8 | png24 | png32 | jpg | pdf | bmp | gif | svg + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#format) + * + * @default png8 + */ format: string; + /** + * Requested image height in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#height) + */ height: number; + /** + * Spatial reference of exported map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#imageSpatialReference) + */ imageSpatialReference: SpatialReference; + /** + * Array of layer definition expressions that allows you to filter the features of individual layers in the exported map image. Layer definitions with semicolons or colons are supported if using a map service published using ArcGIS Server 10 or later. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#layerDefinitions) + */ layerDefinitions: string[]; + /** + * A list of layer IDs, that represent which layers to include in the exported map. Use in combination with [layerOption](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#layerOption) to specify how layer visibility is handled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#layerIds) + */ layerIds: number[]; + /** + * The option for displaying or hiding the layer. **Known Values:** show | hide | include | exclude + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#layerOption) + */ layerOption: string; + /** + * Indicates whether or not the background of the dynamic image is transparent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#transparent) + * + * @default true + */ transparent: boolean; + /** + * Requested image width in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#width) + */ width: number; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#toJSON) + * + * + */ toJSON(): any; } interface ImageParametersConstructor { + + new(properties?: ImageParametersProperties): ImageParameters; } export const ImageParameters: ImageParametersConstructor; interface ImageParametersProperties { + /** + * Dots per inch setting for an module:esri/layersMapImageLayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#dpi) + * + * @default 96 + */ dpi?: number; + /** + * Extent of map to be exported. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#extent) + */ extent?: ExtentProperties; + /** + * Map image format. **Known Values:** png | png8 | png24 | png32 | jpg | pdf | bmp | gif | svg + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#format) + * + * @default png8 + */ format?: string; + /** + * Requested image height in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#height) + */ height?: number; + /** + * Spatial reference of exported map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#imageSpatialReference) + */ imageSpatialReference?: SpatialReferenceProperties; + /** + * Array of layer definition expressions that allows you to filter the features of individual layers in the exported map image. Layer definitions with semicolons or colons are supported if using a map service published using ArcGIS Server 10 or later. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#layerDefinitions) + */ layerDefinitions?: string[]; + /** + * A list of layer IDs, that represent which layers to include in the exported map. Use in combination with [layerOption](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#layerOption) to specify how layer visibility is handled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#layerIds) + */ layerIds?: number[]; + /** + * The option for displaying or hiding the layer. **Known Values:** show | hide | include | exclude + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#layerOption) + */ layerOption?: string; + /** + * Indicates whether or not the background of the dynamic image is transparent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#transparent) + * + * @default true + */ transparent?: boolean; + /** + * Requested image width in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-ImageParameters.html#width) + */ width?: number; } @@ -2582,6 +9712,8 @@ declare namespace __esri { } interface InheritedDomainConstructor { + + new(properties?: InheritedDomainProperties): InheritedDomain; fromJSON(json: any): InheritedDomain; @@ -2594,20 +9726,53 @@ declare namespace __esri { } interface KMLSublayer extends Accessor, JSONSupport { + /** + * Description for the KML sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#description) + */ description: string; + /** + * The id for the KML sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#id) + */ id: number; + /** + * The [KMLLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html) to which the sublayer belongs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#layer) + */ layer: KMLLayer; - mapImages: Collection; - networkLink: KMLSublayerNetworkLink; - points: Collection; - polygons: Collection; - polylines: Collection; + /** + * Network link info for the current layer. A link info object with properties that describe the network link. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#networkLink) + */ + networkLink: any; + /** + * A collection of [KMLSublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#sublayers) + */ sublayers: Collection; + /** + * The title of the KML sublayer used to identify it in places such as the [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) and [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widgets. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#title) + */ title: string; + /** + * Indicates if the sublayer is visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#visible) + */ visible: boolean; } interface KMLSublayerConstructor { + + new(properties?: KMLSublayerProperties): KMLSublayer; fromJSON(json: any): KMLSublayer; @@ -2616,47 +9781,122 @@ declare namespace __esri { export const KMLSublayer: KMLSublayerConstructor; interface KMLSublayerProperties { + /** + * Description for the KML sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#description) + */ description?: string; + /** + * The id for the KML sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#id) + */ id?: number; + /** + * The [KMLLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html) to which the sublayer belongs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#layer) + */ layer?: KMLLayerProperties; - mapImages?: CollectionProperties; - networkLink?: KMLSublayerNetworkLink; - points?: CollectionProperties; - polygons?: CollectionProperties; - polylines?: CollectionProperties; + /** + * Network link info for the current layer. A link info object with properties that describe the network link. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#networkLink) + */ + networkLink?: any; + /** + * A collection of [KMLSublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#sublayers) + */ sublayers?: CollectionProperties; + /** + * The title of the KML sublayer used to identify it in places such as the [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) and [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widgets. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#title) + */ title?: string; + /** + * Indicates if the sublayer is visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-KMLSublayer.html#visible) + */ visible?: boolean; } - export interface KMLSublayerNetworkLink { - id: number; - name: string; - description: string; - visibility: number; - refreshMode: string; - refreshInterval: number; - viewRefreshMode: string; - viewRefreshTime: number; - viewBoundScale: number; - viewFormat: string; - httpQuery: string; - } - interface LabelClass extends Accessor, JSONSupport { + /** + * Defines the content of label text for [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). If working with [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), use [labelExpressionInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpressionInfo) instead. Attribute values may be included in labels using SQL syntax. To include an attribute value in a label, wrap the name of the field in square brackets `[]`. See the example snippet below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpression) + */ labelExpression: string; + /** + * Defines the content of label text for [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). If working with [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html), use [labelExpression](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpression) instead. Attribute values may be included in label expressions. To include an attribute value in a label, wrap the name of the field in curly braces. See the example snippet below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpressionInfo) + */ labelExpressionInfo: LabelClassLabelExpressionInfo; + /** + * The position of the label. Known values are based on the feature type. This property requires a value for labels to be visible. **Known Values (Points):** above-center | above-left | above-right | below-center | below-left | below-right | center-center | center-left | center-right **Known Values (Polylines):** above-after | above-along | above-before | above-start | above-end | below-after | below-along | below-before | below-start | below-end | center-after | center-along | center-before | center-start | center-end **Known Values (Polygons):** always-horizontal + * > **Known Limitations** Currently, if the label has a [line callout](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html) then only "above-center" is supported. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelPlacement) + */ labelPlacement: string; + /** + * The maximum scale to show labels. The value of maxScale should always be less than the value of [minScale](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#minScale). If the value is `0`, then the label's visibility isn't dependent on maximum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#maxScale) + * + * @default 0 + */ maxScale: number; + /** + * The minimum scale to show labels. The value of minScale should always be greater than the value of [maxScale](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#maxScale). If the value of this property is `0`, then the visibility of labels isn't dependent on minimum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#minScale) + * + * @default 0 + */ minScale: number; + /** + * Defines the symbol used for rendering the label. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#symbol) + */ symbol: TextSymbol | LabelSymbol3D; + /** + * Indicates whether to use domain names if the fields in the [labelExpression](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpression) or [labelExpressionInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpressionInfo) have domains. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#useCodedValues) + */ useCodedValues: boolean; + /** + * A SQL where clause used to determine the features to which the label class should be applied. When specified, only features evaluating to `true` based on this expression will be labeled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#where) + */ where: string; + /** + * Creates a deep clone of the LabelClass. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#clone) + * + * + */ clone(): LabelClass; } interface LabelClassConstructor { + /** + * Defines label expressions, symbols, scale ranges, label priorities, and sets of label placement options for different groups of labels on a layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html) + */ + new(properties?: LabelClassProperties): LabelClass; fromJSON(json: any): LabelClass; @@ -2665,29 +9905,107 @@ declare namespace __esri { export const LabelClass: LabelClassConstructor; interface LabelClassProperties { + /** + * Defines the content of label text for [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). If working with [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), use [labelExpressionInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpressionInfo) instead. Attribute values may be included in labels using SQL syntax. To include an attribute value in a label, wrap the name of the field in square brackets `[]`. See the example snippet below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpression) + */ labelExpression?: string; + /** + * Defines the content of label text for [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). If working with [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html), use [labelExpression](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpression) instead. Attribute values may be included in label expressions. To include an attribute value in a label, wrap the name of the field in curly braces. See the example snippet below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpressionInfo) + */ labelExpressionInfo?: LabelClassLabelExpressionInfo; + /** + * The position of the label. Known values are based on the feature type. This property requires a value for labels to be visible. **Known Values (Points):** above-center | above-left | above-right | below-center | below-left | below-right | center-center | center-left | center-right **Known Values (Polylines):** above-after | above-along | above-before | above-start | above-end | below-after | below-along | below-before | below-start | below-end | center-after | center-along | center-before | center-start | center-end **Known Values (Polygons):** always-horizontal + * > **Known Limitations** Currently, if the label has a [line callout](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html) then only "above-center" is supported. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelPlacement) + */ labelPlacement?: string; + /** + * The maximum scale to show labels. The value of maxScale should always be less than the value of [minScale](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#minScale). If the value is `0`, then the label's visibility isn't dependent on maximum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#maxScale) + * + * @default 0 + */ maxScale?: number; + /** + * The minimum scale to show labels. The value of minScale should always be greater than the value of [maxScale](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#maxScale). If the value of this property is `0`, then the visibility of labels isn't dependent on minimum scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#minScale) + * + * @default 0 + */ minScale?: number; + /** + * Defines the symbol used for rendering the label. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#symbol) + */ symbol?: TextSymbolProperties | LabelSymbol3DProperties; + /** + * Indicates whether to use domain names if the fields in the [labelExpression](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpression) or [labelExpressionInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpressionInfo) have domains. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#useCodedValues) + */ useCodedValues?: boolean; + /** + * A SQL where clause used to determine the features to which the label class should be applied. When specified, only features evaluating to `true` based on this expression will be labeled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#where) + */ where?: string; } - export interface LabelClassLabelExpressionInfo { + + export interface LabelClassLabelExpressionInfo extends Object { + /** + * The expression defining the content of the label text. **Deprecated as of v4.5. Use `expression` instead.** + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpressionInfo) + */ value?: string; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression that evaluates to a string used to label features in the layer. The most simple expressions return field values. For example, to label a layer of cities with their names, simply reference the field value with the global variable: `$feature.CITY_NAME`. Expressions can be more sophisticated and use logical functions. This may be useful if you want to use classed labels. For example, the following expression appends `city` to the end of the label if the feature's population field contains a number greater than 10,000. Otherwise, `town` is appended to the end of the label. `IIF($feature.POPULATION > 10000, $feature.NAME + ' city', $feature.NAME + ' town')` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html#labelExpressionInfo) + */ expression: string; } interface LOD extends Accessor, JSONSupport { + /** + * ID for each level. The top most level is `0`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LOD.html#level) + */ level: number; + /** + * String to be used when constructing a URL to access a tile from this LOD. If `levelValue` is not defined, level will be used for the tile access URL. This property is useful when an LOD object represents a WMTS TileMatrix with non-numeric matrix identifiers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LOD.html#levelValue) + */ levelValue: string; + /** + * Resolution in map units of each pixel in a tile for each level. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LOD.html#resolution) + */ resolution: number; + /** + * Scale for each level. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LOD.html#scale) + */ scale: number; } interface LODConstructor { + + new(properties?: LODProperties): LOD; fromJSON(json: any): LOD; @@ -2696,23 +10014,84 @@ declare namespace __esri { export const LOD: LODConstructor; interface LODProperties { + /** + * ID for each level. The top most level is `0`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LOD.html#level) + */ level?: number; + /** + * String to be used when constructing a URL to access a tile from this LOD. If `levelValue` is not defined, level will be used for the tile access URL. This property is useful when an LOD object represents a WMTS TileMatrix with non-numeric matrix identifiers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LOD.html#levelValue) + */ levelValue?: string; + /** + * Resolution in map units of each pixel in a tile for each level. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LOD.html#resolution) + */ resolution?: number; + /** + * Scale for each level. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LOD.html#scale) + */ scale?: number; } interface MapImage extends Accessor, JSONSupport { + /** + * The extent of the exported map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#extent) + */ extent: Extent; + /** + * The requested image height in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#height) + */ height: number; + /** + * URL to the returned image. The image format must be of a type supported by the HTML `` tag. **Known Values:** gif | jpg | png | bmp + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#href) + */ href: string; + /** + * The opacity of the image. Value can be any number between `0` and `1` where `0` is 100% transparent, `0.5` is 50% transparent and `1` is fully opaque. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#opacity) + * + * @default 1 + */ opacity: number; + /** + * Scale of the requested dynamic map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#scale) + */ scale: number; + /** + * Indicates if the requested image is visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#visible) + * + * @default true + */ visible: boolean; + /** + * The requested image width in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#width) + */ width: number; } interface MapImageConstructor { + + new(properties?: MapImageProperties): MapImage; fromJSON(json: any): MapImage; @@ -2721,29 +10100,126 @@ declare namespace __esri { export const MapImage: MapImageConstructor; interface MapImageProperties { + /** + * The extent of the exported map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#extent) + */ extent?: ExtentProperties; + /** + * The requested image height in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#height) + */ height?: number; + /** + * URL to the returned image. The image format must be of a type supported by the HTML `` tag. **Known Values:** gif | jpg | png | bmp + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#href) + */ href?: string; + /** + * The opacity of the image. Value can be any number between `0` and `1` where `0` is 100% transparent, `0.5` is 50% transparent and `1` is fully opaque. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#opacity) + * + * @default 1 + */ opacity?: number; + /** + * Scale of the requested dynamic map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#scale) + */ scale?: number; + /** + * Indicates if the requested image is visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#visible) + * + * @default true + */ visible?: boolean; + /** + * The requested image width in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MapImage.html#width) + */ width?: number; } interface MosaicRule extends Accessor, JSONSupport { + /** + * Indicates whether the sort should be ascending. This property applies to all mosaic [methods](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#method) where an ordering is defined except `seamline`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#ascending) + * + * @default true + */ ascending: boolean; + /** + * An array of raster Ids. All the rasters with the given list of raster Ids are selected to participate in the mosaic. The rasters will be visible at all pixel sizes regardless of the minimum and maximum pixel size range of the locked rasters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#lockRasterIds) + */ lockRasterIds: number[]; + /** + * The mosaic method determines how the selected rasters are ordered. **Known Values:** none | center | nadir | viewpoint | attribute | lock-raster | northwest | seamline + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#method) + */ method: string; + /** + * A multiple dimensional service can have multiple dimensions for one or more variables. Use multiDimensionalDefinitions to filter data based on a slice or range of data. For example, a single ImageryLayer may have a `depth` dimension storing sea temperatures for the same pixel location at various depths. Another dimension could be `time`, where the same pixel stores multiple values based on a window of time. This property can be used to filter and display ImageryLayer pixels for specific "slices" in those dimensions (e.g. display sea temperature at 1000m below sea level for a specific week in the year). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#multidimensionalDefinition) + */ multidimensionalDefinition: DimensionalDefinition[]; + /** + * Defines a selection using a set of ObjectIDs. This property applies to all mosaic methods. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#objectIds) + */ objectIds: number[]; + /** + * Defines the mosaic operation used to resolve overlapping pixels. **Known Values:** first | last | min | max | mean | blend + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#operation) + */ operation: string; + /** + * The name of the attribute field that is used with a constant sortValue to define the mosaicking order when the mosaic [method](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#method) is set to `attribute`. The ordering is defined by the absolute value of the difference between the specified sort field value and the sort base value. For example, if the sort field is `Month` and the sort value is `7 (July)`, then the ordering is defined by `ABS(Month -7)`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#sortField) + */ sortField: string; + /** + * A constant value defining a reference or base value for the sort field when the mosaic [method](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#method) is set to `attribute`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#sortValue) + */ sortValue: string; + /** + * Defines the viewpoint location on which the ordering is defined based on the distance from the viewpoint and the nadir of rasters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#viewpoint) + */ viewpoint: Point; + /** + * The where clause determines which rasters will participate in the mosaic. This property applies to all mosaic methods. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#where) + */ where: string; } interface MosaicRuleConstructor { + /** + * Specifies the mosaic rule when defining how individual images should be mosaicked. It specifies selection, mosaic method, sort order, overlapping pixel resolution, etc. Mosaic rules are for mosaicking rasters in the mosaic dataset. A mosaic rule is used to define: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html) + */ + new(properties?: MosaicRuleProperties): MosaicRule; fromJSON(json: any): MosaicRule; @@ -2752,64 +10228,248 @@ declare namespace __esri { export const MosaicRule: MosaicRuleConstructor; interface MosaicRuleProperties { + /** + * Indicates whether the sort should be ascending. This property applies to all mosaic [methods](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#method) where an ordering is defined except `seamline`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#ascending) + * + * @default true + */ ascending?: boolean; + /** + * An array of raster Ids. All the rasters with the given list of raster Ids are selected to participate in the mosaic. The rasters will be visible at all pixel sizes regardless of the minimum and maximum pixel size range of the locked rasters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#lockRasterIds) + */ lockRasterIds?: number[]; + /** + * The mosaic method determines how the selected rasters are ordered. **Known Values:** none | center | nadir | viewpoint | attribute | lock-raster | northwest | seamline + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#method) + */ method?: string; + /** + * A multiple dimensional service can have multiple dimensions for one or more variables. Use multiDimensionalDefinitions to filter data based on a slice or range of data. For example, a single ImageryLayer may have a `depth` dimension storing sea temperatures for the same pixel location at various depths. Another dimension could be `time`, where the same pixel stores multiple values based on a window of time. This property can be used to filter and display ImageryLayer pixels for specific "slices" in those dimensions (e.g. display sea temperature at 1000m below sea level for a specific week in the year). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#multidimensionalDefinition) + */ multidimensionalDefinition?: DimensionalDefinition[]; + /** + * Defines a selection using a set of ObjectIDs. This property applies to all mosaic methods. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#objectIds) + */ objectIds?: number[]; + /** + * Defines the mosaic operation used to resolve overlapping pixels. **Known Values:** first | last | min | max | mean | blend + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#operation) + */ operation?: string; + /** + * The name of the attribute field that is used with a constant sortValue to define the mosaicking order when the mosaic [method](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#method) is set to `attribute`. The ordering is defined by the absolute value of the difference between the specified sort field value and the sort base value. For example, if the sort field is `Month` and the sort value is `7 (July)`, then the ordering is defined by `ABS(Month -7)`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#sortField) + */ sortField?: string; + /** + * A constant value defining a reference or base value for the sort field when the mosaic [method](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#method) is set to `attribute`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#sortValue) + */ sortValue?: string; + /** + * Defines the viewpoint location on which the ordering is defined based on the distance from the viewpoint and the nadir of rasters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#viewpoint) + */ viewpoint?: PointProperties; + /** + * The where clause determines which rasters will participate in the mosaic. This property applies to all mosaic methods. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MosaicRule.html#where) + */ where?: string; } interface PixelBlock extends Accessor { + /** + * The height (or number of rows) of the PixelBlock in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#height) + */ height: number; + /** + * An array of numbers representing pixels to show and pixels to hide from the view. The length of this array is [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#height) * [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#width). It's arranged row by row in this format: `[p_00, p_10, p_20, ... p_10, p_11, .....]` where `p_xy` is the pixel value at the column `x` and row `y`. The mask is per pixel, not per band. Items in the mask array with a value of `0` indicates [pixels](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) to not display in the view at that index. Items with a value of `1` indicate to display the [pixels](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) at there corresponding indices. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#mask) + */ mask: number[]; + /** + * A two dimensional array representing the pixels from the Image Service displayed on the client. The length of the first dimension is the same as the number of bands in the layer. The length of the second dimension is [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#height) * [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#width). The length of each band is the same. The pixels in each band are arranged row by row in this format: `[p_00, p_10, p_20, ... p_10, p_11, ...]` where `p_xy` is the pixel value at the column `x` and row `y`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) + */ pixels: number[][]; + /** + * The pixel type. **Known Values:** s8 | s16 | s32 | u8 | u16 | u32 | f32 | f64 + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixelType) + */ pixelType: string; + /** + * An array of objects containing numeric statistical properties. Each object has the following specification if defined: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#statistics) + */ statistics: PixelBlockStatistics[]; + /** + * The width (or number of columns) of the PixelBlock in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#width) + */ width: number; + /** + * Adds another plane to the PixelBlock. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#addData) + * + * @param planeData The data to add to the PixelBlock. + * @param planeData.pixels A two dimensional array representing the pixels to add. + * @param planeData.statistics An array of objects containing numeric statistical properties. See [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#statistics) for details on the specifications of each object. + * + */ addData(planeData: PixelBlockAddDataPlaneData): void; + /** + * Returns pixels and masks using a single array in bip format (e.g. [p_00_r, p_00_g, p_00_b, p_00_a, p_10_r, p_10_g, p_10_b, p_10_a, .....]). Use this method to get an unsigned 8 bit pixel array. The result can be used to create a webgl texture. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#getAsRGBA) + * + * + */ getAsRGBA(): number[]; + /** + * Similar to [getAsRGBA](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#getAsRGBA), but returns floating point data. The result can be used to create a webgl texture (OES_texture_float). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#getAsRGBAFloat) + * + * + */ getAsRGBAFloat(): number[]; + /** + * Returns the plane band count of the PixelBlock. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#getPlaneCount) + * + * + */ getPlaneCount(): number; } interface PixelBlockConstructor { + + new(properties?: PixelBlockProperties): PixelBlock; } export const PixelBlock: PixelBlockConstructor; interface PixelBlockProperties { + /** + * The height (or number of rows) of the PixelBlock in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#height) + */ height?: number; + /** + * An array of numbers representing pixels to show and pixels to hide from the view. The length of this array is [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#height) * [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#width). It's arranged row by row in this format: `[p_00, p_10, p_20, ... p_10, p_11, .....]` where `p_xy` is the pixel value at the column `x` and row `y`. The mask is per pixel, not per band. Items in the mask array with a value of `0` indicates [pixels](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) to not display in the view at that index. Items with a value of `1` indicate to display the [pixels](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) at there corresponding indices. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#mask) + */ mask?: number[]; + /** + * A two dimensional array representing the pixels from the Image Service displayed on the client. The length of the first dimension is the same as the number of bands in the layer. The length of the second dimension is [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#height) * [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#width). The length of each band is the same. The pixels in each band are arranged row by row in this format: `[p_00, p_10, p_20, ... p_10, p_11, ...]` where `p_xy` is the pixel value at the column `x` and row `y`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) + */ pixels?: number[][]; + /** + * The pixel type. **Known Values:** s8 | s16 | s32 | u8 | u16 | u32 | f32 | f64 + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixelType) + */ pixelType?: string; + /** + * An array of objects containing numeric statistical properties. Each object has the following specification if defined: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#statistics) + */ statistics?: PixelBlockStatistics[]; + /** + * The width (or number of columns) of the PixelBlock in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#width) + */ width?: number; } - export interface PixelBlockAddDataPlaneData { + + export interface PixelBlockAddDataPlaneData extends Object { + /** + * A two dimensional array representing the pixels to add. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#addData) + */ pixels: number[][]; + /** + * An array of objects containing numeric statistical properties. See [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#statistics) for details on the specifications of each object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#addData) + */ statistics: any[]; } - export interface PixelBlockStatistics { + + export interface PixelBlockStatistics extends Object { + /** + * The maximum pixel value in the [pixels](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#statistics) + */ maxValue?: number; + /** + * The minimum pixel value in the [pixels](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#statistics) + */ minValue?: number; + /** + * Value representing areas of no data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#statistics) + */ noDataValue?: number; } interface RangeDomain extends Domain { + /** + * The maximum valid value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RangeDomain.html#maxValue) + */ maxValue: number; + /** + * The minimum valid value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RangeDomain.html#minValue) + */ minValue: number; } interface RangeDomainConstructor { + + new(properties?: RangeDomainProperties): RangeDomain; fromJSON(json: any): RangeDomain; @@ -2818,18 +10478,56 @@ declare namespace __esri { export const RangeDomain: RangeDomainConstructor; interface RangeDomainProperties extends DomainProperties { + /** + * The maximum valid value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RangeDomain.html#maxValue) + */ maxValue?: number; + /** + * The minimum valid value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RangeDomain.html#minValue) + */ minValue?: number; } interface RasterFunction extends Accessor, JSONSupport { + /** + * The arguments for the raster function. The structure depends on the function specified. See [raster functions](http://resources.arcgis.com/en/help/arcgis-rest-api/#/Raster_Function_Objects/02r3000000rv000000/) for a list of functions and their arguments. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RasterFunction.html#functionArguments) + */ functionArguments: any; + /** + * The raster function name. See [raster functions](http://resources.arcgis.com/en/help/arcgis-rest-api/#/Raster_Function_Objects/02r3000000rv000000/) for a list of functions and their arguments. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RasterFunction.html#functionName) + */ functionName: string; + /** + * Defines the pixel type of the output image. **Known Values:** c128 | c64 | f32 | f64 | s16 | s32 | s8 | u1 | u16 | u2 | u32 | u4 | u8 | unknown + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RasterFunction.html#outputPixelType) + * + * @default unknown + */ outputPixelType: string; + /** + * The variable name for the raster function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RasterFunction.html#variableName) + */ variableName: any; } interface RasterFunctionConstructor { + /** + * Specifies processing to be done to the image service. See [raster functions](http://resources.arcgis.com/en/help/arcgis-rest-api/#/Raster_Function_Objects/02r3000000rv000000/) for a list of functions and their [arguments](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RasterFunction.html#functionArguments). The following image shows a landcover ImageryLayer rendered with two chained client-side raster functions used to reclass pixel values (Remap) and assign each pixel a new color (Colormap). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RasterFunction.html) + */ + new(properties?: RasterFunctionProperties): RasterFunction; fromJSON(json: any): RasterFunction; @@ -2838,145 +10536,754 @@ declare namespace __esri { export const RasterFunction: RasterFunctionConstructor; interface RasterFunctionProperties { + /** + * The arguments for the raster function. The structure depends on the function specified. See [raster functions](http://resources.arcgis.com/en/help/arcgis-rest-api/#/Raster_Function_Objects/02r3000000rv000000/) for a list of functions and their arguments. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RasterFunction.html#functionArguments) + */ functionArguments?: any; + /** + * The raster function name. See [raster functions](http://resources.arcgis.com/en/help/arcgis-rest-api/#/Raster_Function_Objects/02r3000000rv000000/) for a list of functions and their arguments. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RasterFunction.html#functionName) + */ functionName?: string; + /** + * Defines the pixel type of the output image. **Known Values:** c128 | c64 | f32 | f64 | s16 | s32 | s8 | u1 | u16 | u2 | u32 | u4 | u8 | unknown + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RasterFunction.html#outputPixelType) + * + * @default unknown + */ outputPixelType?: string; + /** + * The variable name for the raster function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-RasterFunction.html#variableName) + */ variableName?: any; } interface Sublayer extends Accessor { + /** + * A SQL where clause used to filter features in the image. Only the features that satisfy the definition expression are displayed in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). Definition expressions may be set when a sublayer is constructed prior to it loading in the view or after it has been added to the MapImageLayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#definitionExpression) + */ definitionExpression: string; + /** + * The sublayer's layer ID. When a [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#source) is not defined on the layer, this value represents the id of the sublayer defined by the map service. If creating a [DynamicDataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicDataLayer) or a [MapDataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#MapDataLayer) and adding it to the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#source) property of the sublayer, the value of this property can be anything set by the developer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#id) + */ id: number; + /** + * The label definition for this layer, specified as an array of [LabelClass](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html) objects. Use this property to specify labeling properties for the layer such as label expression, placement, and size. For labels to display in the view, the [labelsVisible](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#labelsVisible) property of the sublayer must be `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#labelingInfo) + */ labelingInfo: LabelClass[]; + /** + * Indicates if labels for the sublayer will be visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#labelsVisible) + * + * @default false + */ labelsVisible: boolean; + /** + * The [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html) to which the sublayer belongs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#layer) + */ layer: MapImageLayer; + /** + * Indicates whether the layer will be included in the legend. When `false`, the layer will be excluded from the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#legendEnabled) + * + * @default true + */ legendEnabled: boolean; + /** + * The maximum scale at which the layer is visible in the view. If the map is zoomed in beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a maximum scale. The user or developer can only set `minScale` and `maxScale` if the new values are within the scale range defined in the map service. + * ```js + * // the service specifies minScale = 10000 and maxScale = 500000 + * + * // this is valid + * sublayer.minScale = 30000; + * sublayer.maxScale = 100000; + * + * // this is not valid because the values are + * // outside the range specified by the service + * sublayer.minScale = 5000; + * sublayer.maxScale = 1000000; + * ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#maxScale) + */ maxScale: number; + /** + * The minimum scale at which the layer is visible in the view. If the map is zoomed out beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a maximum scale. The user or developer can only set `minScale` and `maxScale` if the new values are within the scale range defined in the map service. + * ```js + * // the service specifies minScale = 10000 and maxScale = 500000 + * + * // this is valid + * sublayer.minScale = 30000; + * sublayer.maxScale = 100000; + * + * // this is not valid because the values are + * // outside the range specified by the service + * sublayer.minScale = 5000; + * sublayer.maxScale = 1000000; + * ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#minScale) + */ minScale: number; + /** + * The level of opacity to set on the sublayer on a scale from 0.0 - 1.0 where `0` is fully transparent and `1.0` is fully opaque. If the [MapImageLayer.opacity](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#opacity) is set, the actual opacity value of the sublayer will be the value of [MapImageLayer.opacity](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#opacity) multiplied by the sublayer's opacity. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#opacity) + */ opacity: number; + /** + * The popup template for the sublayer. When set, the `popupTemplate` allows users to access attributes and display their values in the [view's popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#popup) when the user clicks the image. Sublayers with a [RasterDataSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#RasterDataSource) cannot be queried and therefore do not support [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#popupTemplate) + */ popupTemplate: PopupTemplate; + /** + * The renderer to apply to the sublayer. This value overrides the renderer read from the map service. + * > **Known Limitations** + * * [3D symbols](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3D.html) are not supported in renderers set on MapImageLayer sublayers. + * * [visual variables](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#visualVariables) are not supported in renderers set on MapImageLayer sublayers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#renderer) + */ renderer: Renderer; + /** + * An object that allows you to create a dynamic layer with data either from the map service sublayers or data from a registered workspace. See [DynamicMapLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicMapLayer) for creating dynamic layers from map service layers for on the fly rendering, labeling, and filtering (definition expressions). To create dynamic layers from other sources in registered workspaces such as tables and table joins, see [DynamicDataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicDataLayer). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#source) + */ source: DynamicMapLayer | DynamicDataLayer; + /** + * If a sublayer contains sublayers, this property is a [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Sublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) objects belonging to the given sublayer with sublayers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#sublayers) + */ sublayers: Collection; + /** + * The title of the sublayer used to identify it in places such as the [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) and [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widgets. This value can be defined in the map service or programmatically by the developer. It can also be useful for finding a specific sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#title) + */ title: string; + /** + * The URL to the REST endpoint of the sublayer. This allows you to view the schema of fields and query tables located in registered workspaces. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#url) + */ url: string; + /** + * Indicates if the layer is visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#visible) + */ visible: boolean; + /** + * Creates a deep clone of the sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#clone) + * + * + */ clone(): Sublayer; + /** + * Creates a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) object with default values representing the layer's state, including filters (definition expression) on the layer's features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#createQuery) + * + * + */ createQuery(): Query; - queryFeatures(params?: Query): IPromise; + /** + * Executes a [query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html) against features in the sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#queryFeatures) + * + * @param params Specifies the attributes and spatial filter of the query. If no parameters are specified, then all features satisfying the layer's configuration/filters are returned. + * + */ + queryFeatures(params?: Query | QueryProperties): IPromise; } interface SublayerConstructor { + /** + * Represents a sublayer in a [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). MapImageLayer allows you to display, query, and analyze layers from data defined in a [map service](http://server.arcgis.com/en/server/latest/publish-services/windows/what-is-a-map-service.htm). Map services contain sublayers with properties such as [renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#renderer), [labelingInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#labelingInfo), and [definitionExpression](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#definitionExpression), and others that are defined on the server. The properties of each sublayer on the map service may be dynamically changed by the user or developer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) + */ + new(properties?: SublayerProperties): Sublayer; } export const Sublayer: SublayerConstructor; interface SublayerProperties { + /** + * A SQL where clause used to filter features in the image. Only the features that satisfy the definition expression are displayed in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). Definition expressions may be set when a sublayer is constructed prior to it loading in the view or after it has been added to the MapImageLayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#definitionExpression) + */ definitionExpression?: string; + /** + * The sublayer's layer ID. When a [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#source) is not defined on the layer, this value represents the id of the sublayer defined by the map service. If creating a [DynamicDataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicDataLayer) or a [MapDataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#MapDataLayer) and adding it to the [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#source) property of the sublayer, the value of this property can be anything set by the developer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#id) + */ id?: number; + /** + * The label definition for this layer, specified as an array of [LabelClass](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LabelClass.html) objects. Use this property to specify labeling properties for the layer such as label expression, placement, and size. For labels to display in the view, the [labelsVisible](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#labelsVisible) property of the sublayer must be `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#labelingInfo) + */ labelingInfo?: LabelClassProperties[]; + /** + * Indicates if labels for the sublayer will be visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#labelsVisible) + * + * @default false + */ labelsVisible?: boolean; + /** + * The [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html) to which the sublayer belongs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#layer) + */ layer?: MapImageLayerProperties; + /** + * Indicates whether the layer will be included in the legend. When `false`, the layer will be excluded from the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#legendEnabled) + * + * @default true + */ legendEnabled?: boolean; + /** + * The maximum scale at which the layer is visible in the view. If the map is zoomed in beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a maximum scale. The user or developer can only set `minScale` and `maxScale` if the new values are within the scale range defined in the map service. + * ```js + * // the service specifies minScale = 10000 and maxScale = 500000 + * + * // this is valid + * sublayer.minScale = 30000; + * sublayer.maxScale = 100000; + * + * // this is not valid because the values are + * // outside the range specified by the service + * sublayer.minScale = 5000; + * sublayer.maxScale = 1000000; + * ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#maxScale) + */ maxScale?: number; + /** + * The minimum scale at which the layer is visible in the view. If the map is zoomed out beyond this scale, the layer will not be visible. A value of `0` means the layer does not have a maximum scale. The user or developer can only set `minScale` and `maxScale` if the new values are within the scale range defined in the map service. + * ```js + * // the service specifies minScale = 10000 and maxScale = 500000 + * + * // this is valid + * sublayer.minScale = 30000; + * sublayer.maxScale = 100000; + * + * // this is not valid because the values are + * // outside the range specified by the service + * sublayer.minScale = 5000; + * sublayer.maxScale = 1000000; + * ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#minScale) + */ minScale?: number; + /** + * The level of opacity to set on the sublayer on a scale from 0.0 - 1.0 where `0` is fully transparent and `1.0` is fully opaque. If the [MapImageLayer.opacity](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#opacity) is set, the actual opacity value of the sublayer will be the value of [MapImageLayer.opacity](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#opacity) multiplied by the sublayer's opacity. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#opacity) + */ opacity?: number; + /** + * The popup template for the sublayer. When set, the `popupTemplate` allows users to access attributes and display their values in the [view's popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#popup) when the user clicks the image. Sublayers with a [RasterDataSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#RasterDataSource) cannot be queried and therefore do not support [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#popupTemplate) + */ popupTemplate?: PopupTemplateProperties; + /** + * The renderer to apply to the sublayer. This value overrides the renderer read from the map service. + * > **Known Limitations** + * * [3D symbols](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3D.html) are not supported in renderers set on MapImageLayer sublayers. + * * [visual variables](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#visualVariables) are not supported in renderers set on MapImageLayer sublayers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#renderer) + */ renderer?: RendererProperties; + /** + * An object that allows you to create a dynamic layer with data either from the map service sublayers or data from a registered workspace. See [DynamicMapLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicMapLayer) for creating dynamic layers from map service layers for on the fly rendering, labeling, and filtering (definition expressions). To create dynamic layers from other sources in registered workspaces such as tables and table joins, see [DynamicDataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicDataLayer). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#source) + */ source?: DynamicMapLayer | DynamicDataLayer; + /** + * If a sublayer contains sublayers, this property is a [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Sublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) objects belonging to the given sublayer with sublayers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#sublayers) + */ sublayers?: CollectionProperties; + /** + * The title of the sublayer used to identify it in places such as the [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) and [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widgets. This value can be defined in the map service or programmatically by the developer. It can also be useful for finding a specific sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#title) + */ title?: string; + /** + * The URL to the REST endpoint of the sublayer. This allows you to view the schema of fields and query tables located in registered workspaces. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#url) + */ url?: string; + /** + * Indicates if the layer is visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#visible) + */ visible?: boolean; } - export interface DynamicDataLayer { + /** + * A dynamic data layer is a layer created on-the-fly with data stored in a [registered workspace](https://server.arcgis.com/en/server/latest/publish-services/windows/overview-register-data-with-arcgis-server.htm). This is data that can be rendered and queried on the fly, but that isn't explicitly exposed as a service sublayer. Depending on the type of data source, these layers are classified as one of the following: + * + * Data source | Description + * ------------|------------ + * [TableDataSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#TableDataSource) | A feature class with geometries or table without geometries. When a table data source does not contain geometries, it may be used as one of the sources in a [join operation](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#JoinTableDataSource). Feature class tables may be used on their own since they contain a geometry field. + * [QueryTableDataSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#QueryTableDataSource) | A feature class or table that may be queried on the fly with a SQL where clause. This data source is useful for scenarios where you have a table containing unique geometries and another table with multiple records that match to each geometry. You can use the QueryTableDataSource to select only a subset of those matching records (so records in both tables have a one-to-one relationship with each other) and join them to the table with geometries. + * [RasterDataSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#RasterDataSource) | A raster dataset used for visualization purposes only. + * [JoinTableDataSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#JoinTableDataSource) | This data source consists of two data sources joined by a common attribute or key. The left table data source typically contains geometries, while the right source may be a table or query table without geometries. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicDataLayer) + */ + export interface DynamicDataLayer extends Object { + /** + * This value is always `data-layer` and is inferred when the `dataSource` property is set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicDataLayer) + */ type: string; + /** + * A table, feature class, or raster that resides in a registered workspace (either a folder or geodatabase). The data sources are not visible in the Services Directory by default. They may be viewed, published, and configured using the ArcGIS Server Manager. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicDataLayer) + */ dataSource: TableDataSource | QueryTableDataSource | RasterDataSource | JoinTableDataSource; + /** + * Controls field visibility in the layer. Only specified fields will be visible. If `null`, all fields are visible in the dynamic layer. The specification for a field object is provided below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicDataLayer) + */ fields: DynamicDataLayerFields[]; } - export interface DynamicMapLayer { + /** + * A dynamic map layer refers to a layer published in a map service that has dynamic layers enabled. This layer type may be used to create multiple [sublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#sublayers) that point to the same service layer, but are assigned different definition expressions, renderers, and other properties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicMapLayer) + */ + export interface DynamicMapLayer extends Object { + /** + * This value is always `map-layer` and is inferred when the `mapLayerId` property is set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicMapLayer) + */ type: string; + /** + * The [id](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#id) of the service sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicMapLayer) + */ mapLayerId: number; + /** + * An optional property for specifying the GDB version. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicMapLayer) + */ gdbVersion: string; } - export interface JoinTableDataSource { + /** + * The result of an on-the-fly join operation at runtime. Nested joins are supported. To use nested joins, set either `leftTableSource` or `rightTableSource` to `join-table`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#JoinTableDataSource) + */ + export interface JoinTableDataSource extends Object { + /** + * This value is always `join-table` and is inferred when other join table properties of this object are set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#JoinTableDataSource) + */ type: string; + /** + * The field name used for joining or matching records in the left table to records in the right table. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#JoinTableDataSource) + */ leftTableKey: string; + /** + * The field name used for joining or matching records in the right table to records in the left table. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#JoinTableDataSource) + */ rightTableKey: string; + /** + * The left table for joining to the right table source. This can either be a dynamic map layer or a dynamic data layer. The dynamic data layer may contain another join data source used for nested joining. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#JoinTableDataSource) + */ leftTableSource: DynamicMapLayer | DynamicDataLayer; + /** + * The right table for joining to the left table source. This can either be a dynamic map layer or a dynamic data layer. The dynamic data layer may contain another join data source used for nested joining. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#JoinTableDataSource) + */ rightTableSource: DynamicMapLayer | DynamicDataLayer; + /** + * The type of join that will be performed. + * + * Possible Value | Description + * ---------------|------------ + * left-outer-join | Unmatched records in the left table source are preserved and joined with `null` values in the right table source. + * left-inner-join | Records in the left table source are discarded if they are unmatched with records in the right table source. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#JoinTableDataSource) + */ joinType: string; } - export interface QueryTableDataSource { + /** + * A query table is a feature class or table defined by a SQL query on the fly. Query layers allow both spatial and nonspatial information stored in a database to be easily integrated into map service operations. Since a query table uses SQL to directly query database tables and views, spatial information used by a query table is not required to be in a geodatabase. This data source is useful for scenarios where you have a table containing multiple records that match to a single geometry in either another table or a map service layer. You can use the QueryTableDataSource to select only a subset of those matching records and join them to the table with geometries so records in both tables have a one-to-one relationship with each other. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#QueryTableDataSource) + */ + export interface QueryTableDataSource extends Object { + /** + * This value is always `query-table` and is inferred when the `query` property of this object is set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#QueryTableDataSource) + */ type: string; + /** + * The workspace where the data resides (defined in ArcGIS Server Manager). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#QueryTableDataSource) + */ workspaceId: string; + /** + * The SQL query used to filter records. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#QueryTableDataSource) + */ query: string; + /** + * The field name(s) containing the unique IDs for each record in the table. This can be a comma separated list if the query table is used in a [JoinTableDataSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#JoinDataTableSource). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#QueryTableDataSource) + */ oidFields: string; + /** + * The spatial reference of the geometry of each feature in the table source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#QueryTableDataSource) + */ spatialReference: SpatialReference; + /** + * The geometry type of each record in the table. **Possible Values:** point | multipoint | polyline | polygon | multipatch + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#QueryTableDataSource) + */ geometryType: string; } - export interface RasterDataSource { + /** + * A file-based raster that resides in a registered raster workspace. The raster may only be displayed in the view, not queried or assigned a renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#RasterDataSource) + */ + export interface RasterDataSource extends Object { + /** + * This value is always `raster`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#RasterDataSource) + */ type: string; + /** + * The workspace where the raster resides as defined in the ArcGIS Server Manager. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#RasterDataSource) + */ workspaceId: string; + /** + * The name of the raster in the registered workspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#RasterDataSource) + */ dataSourceName: string; } - export interface TableDataSource { + /** + * A table or feature class that resides in a registered workspace (either a folder or geodatabase). In the case of a geodatabase, if versioned, use `version` to switch to an alternate geodatabase version. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#TableDataSource) + */ + export interface TableDataSource extends Object { + /** + * This value is always `table`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#TableDataSource) + */ type: string; + /** + * The workspace where the table resides as defined in the ArcGIS Server Manager. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#TableDataSource) + */ workspaceId: string; + /** + * The name of the table in the registered workspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#TableDataSource) + */ dataSourceName: string; + /** + * References the geodatabase version if multiple versions exist in the geodatabase. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#TableDataSource) + */ gdbVersion: string; } - export interface DynamicDataLayerFields { + + export interface DynamicDataLayerFields extends Object { + /** + * The name of the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicDataLayer) + */ name: string; + /** + * The alias of the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#DynamicDataLayer) + */ alias: string; } interface TileInfo extends Accessor, JSONSupport { + /** + * The dots per inch (DPI) of the tiling scheme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#dpi) + */ dpi: number; + /** + * Image format of the cached tiles. **Possible Values:** png | png24 | png32 | jpg | dib | tiff | emf | ps | pdf | gif | svg | svgz | mixed | lerc + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#format) + */ format: string; + /** + * Indicates if the tiling scheme supports wrap around. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#isWrappable) + */ isWrappable: boolean; + /** + * An array of levels of detail that define the tiling scheme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#lods) + */ lods: LOD[]; + /** + * The tiling scheme origin. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#origin) + */ origin: Point; + /** + * Size of tiles in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#size) + */ size: number[]; + /** + * The spatial reference of the tiling schema. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#spatialReference) + */ spatialReference: SpatialReference; + + /** + * Utility method used to convert a scale value to its corresponding zoom value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#scaleToZoom) + * + * @param scale The scale value to convert. + * + */ + scaleToZoom(scale: number): number; + /** + * Utility method used to convert a zoom value to its corresponding scale value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#zoomToScale) + * + * @param zoom The zoom value to convert. + * + */ + zoomToScale(zoom: number): number; } interface TileInfoConstructor { + + new(properties?: TileInfoProperties): TileInfo; + + /** + * A convenience method used to create a new TileInfo instance with preset properties like [LODs](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#lods). Optionally, properties such as `size`, `scales[]`, and a `[SpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html)` can also be set to calculate [LODs](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#lods) for each TileInfo. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#create) + * + * @param options An object that contains the size, scales, and/or [SpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html) used to compute the new TileInfo instance. + * @param options.size The size of each tile in pixels. + * @param options.spatialReference The spatial reference for the new TileInfo instance. If the spatial reference is not WGS84 nor WebMercator, the origin of the TileInfo is `0.0`. + * @param options.scales An array of scale values to use for the TileInfo. If none are specified, the scales from the [ArcGIS Online basemaps](https://www.arcgis.com/home/group.html?id=702026e41f6641fb85da88efe79dc166#overview) are used from level 0 through 24. + * + */ + create(options?: TileInfoCreateOptions): TileInfo; + fromJSON(json: any): TileInfo; } export const TileInfo: TileInfoConstructor; interface TileInfoProperties { + /** + * The dots per inch (DPI) of the tiling scheme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#dpi) + */ dpi?: number; + /** + * Image format of the cached tiles. **Possible Values:** png | png24 | png32 | jpg | dib | tiff | emf | ps | pdf | gif | svg | svgz | mixed | lerc + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#format) + */ format?: string; + /** + * Indicates if the tiling scheme supports wrap around. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#isWrappable) + */ isWrappable?: boolean; + /** + * An array of levels of detail that define the tiling scheme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#lods) + */ lods?: LODProperties[]; + /** + * The tiling scheme origin. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#origin) + */ origin?: PointProperties; + /** + * Size of tiles in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#size) + */ size?: number[]; + /** + * The spatial reference of the tiling schema. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#spatialReference) + */ spatialReference?: SpatialReferenceProperties; } + + export interface TileInfoCreateOptions extends Object { + /** + * The size of each tile in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#create) + * + * @default 256 + */ + size?: number; + /** + * The spatial reference for the new TileInfo instance. If the spatial reference is not WGS84 nor WebMercator, the origin of the TileInfo is `0.0`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#create) + * + * @default WebMercator + */ + spatialReference?: SpatialReference; + /** + * An array of scale values to use for the TileInfo. If none are specified, the scales from the [ArcGIS Online basemaps](https://www.arcgis.com/home/group.html?id=702026e41f6641fb85da88efe79dc166#overview) are used from level 0 through 24. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileInfo.html#create) + * + * @default The scales provided by ArcGIS Online basemaps + */ + scales?: number[]; + } + interface TileMatrixSet extends Accessor, JSONSupport { + /** + * The full extent of the TileMatrixSet. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html#fullExtent) + */ fullExtent: Extent; + /** + * The unique ID assigned to the TileMatrixSet. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html#id) + */ id: string; + /** + * The tiling scheme information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html#tileInfo) + */ tileInfo: TileInfo; + /** + * Creates a deep clone of this TileMatrixSet. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html#clone) + * + * + */ clone(): TileMatrixSet; } interface TileMatrixSetConstructor { + + new(properties?: TileMatrixSetProperties): TileMatrixSet; fromJSON(json: any): TileMatrixSet; @@ -2985,45 +11292,256 @@ declare namespace __esri { export const TileMatrixSet: TileMatrixSetConstructor; interface TileMatrixSetProperties { + /** + * The full extent of the TileMatrixSet. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html#fullExtent) + */ fullExtent?: ExtentProperties; + /** + * The unique ID assigned to the TileMatrixSet. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html#id) + */ id?: string; + /** + * The tiling scheme information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html#tileInfo) + */ tileInfo?: TileInfoProperties; } - interface WMSSublayer { + interface WMSSublayer extends Accessor { + /** + * Description for the WMS sublayer. This defaults to the value of the Abstract property from the WMS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#description) + */ description: string; + /** + * The full extent of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#fullExtent) + */ fullExtent: Extent; + /** + * The id for the WMS sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#id) + */ id: number; + /** + * The [WMSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html) to which the sublayer belongs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#layer) + */ layer: WMSLayer; + /** + * Indicates whether the layer will be included in the legend. When `false`, the layer will be excluded from the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#legendEnabled) + * + * @default true + */ legendEnabled: boolean; + /** + * A string url pointing to a legend image for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#legendUrl) + */ legendUrl: string; + /** + * Name of the WMS sublayer. This defaults to the value of the Name property from the WMS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#name) + */ name: string; + /** + * Indicates whether to display popups when features in the layer are clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#popupEnabled) + * + * @default false + */ popupEnabled: boolean; + /** + * Indicates if the layer can be queried, i.e. the service supports GetFeatureInfo with either text/html or text/plain formats. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#queryable) + * + * @default false + */ queryable: boolean; + /** + * List of spatialReferences (WKID) derived from the CRS elements of the first layer in the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#spatialReferences) + */ spatialReferences: number[]; + /** + * A collection of [WMSSublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html)s. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#sublayers) + */ sublayers: Collection; + /** + * The title of the WMS sublayer used to identify it in places such as the [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) and [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widgets. This defaults to the value of the Title property from the WMS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#title) + */ title: string; + /** + * Indicates if the layer is visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#visible) + */ visible: boolean; + /** + * Creates a deep clone of the WMS sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#clone) + * + * + */ clone(): WMSSublayer; } interface WMSSublayerConstructor { - new(properties?: any): WMSSublayer; + + + new(properties?: WMSSublayerProperties): WMSSublayer; } export const WMSSublayer: WMSSublayerConstructor; + interface WMSSublayerProperties { + /** + * Description for the WMS sublayer. This defaults to the value of the Abstract property from the WMS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#description) + */ + description?: string; + /** + * The full extent of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#fullExtent) + */ + fullExtent?: ExtentProperties; + /** + * The id for the WMS sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#id) + */ + id?: number; + /** + * The [WMSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html) to which the sublayer belongs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#layer) + */ + layer?: WMSLayerProperties; + /** + * Indicates whether the layer will be included in the legend. When `false`, the layer will be excluded from the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#legendEnabled) + * + * @default true + */ + legendEnabled?: boolean; + /** + * A string url pointing to a legend image for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#legendUrl) + */ + legendUrl?: string; + /** + * Name of the WMS sublayer. This defaults to the value of the Name property from the WMS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#name) + */ + name?: string; + /** + * Indicates whether to display popups when features in the layer are clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#popupEnabled) + * + * @default false + */ + popupEnabled?: boolean; + /** + * Indicates if the layer can be queried, i.e. the service supports GetFeatureInfo with either text/html or text/plain formats. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#queryable) + * + * @default false + */ + queryable?: boolean; + /** + * List of spatialReferences (WKID) derived from the CRS elements of the first layer in the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#spatialReferences) + */ + spatialReferences?: number[]; + /** + * A collection of [WMSSublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html)s. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#sublayers) + */ + sublayers?: CollectionProperties; + /** + * The title of the WMS sublayer used to identify it in places such as the [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) and [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widgets. This defaults to the value of the Title property from the WMS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#title) + */ + title?: string; + /** + * Indicates if the layer is visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#visible) + */ + visible?: boolean; + } + interface WMTSStyle extends Accessor, JSONSupport { + /** + * Description for the WMTS style. This defaults to the value of the Abstract property from the WMTS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html#description) + */ description: string; + /** + * The unique ID assigned to the style. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html#id) + */ id: string; + /** + * The URL to the legend which gets used in [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widget. This defaults to the value of the LegendURL property from the WMTS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html#legendUrl) + */ legendUrl: string; + /** + * The title of the WMTS style. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html#title) + */ title: string; + /** + * Creates a deep clone of the WMTSStyle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html#clone) + * + * + */ clone(): WMTSStyle; } interface WMTSStyleConstructor { + + new(properties?: WMTSStyleProperties): WMTSStyle; fromJSON(json: any): WMTSStyle; @@ -3032,30 +11550,119 @@ declare namespace __esri { export const WMTSStyle: WMTSStyleConstructor; interface WMTSStyleProperties { + /** + * Description for the WMTS style. This defaults to the value of the Abstract property from the WMTS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html#description) + */ description?: string; + /** + * The unique ID assigned to the style. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html#id) + */ id?: string; + /** + * The URL to the legend which gets used in [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widget. This defaults to the value of the LegendURL property from the WMTS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html#legendUrl) + */ legendUrl?: string; + /** + * The title of the WMTS style. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html#title) + */ title?: string; } interface WMTSSublayer extends Accessor, JSONSupport { + /** + * Description for the WMTS sublayer. This defaults to the value of the Abstract property from the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#description) + */ description: string; + /** + * The full extent of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#fullExtent) + */ fullExtent: Extent; + /** + * The unique ID assigned to the sublayer. If not set by the developer, it is automatically generated when the layer is loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#id) + */ id: string; + /** + * The map image format (MIME type) to request. Defaults to the first item in [imageFormats](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#imageFormats). Must be one of the supported [imageFormats](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#imageFormats). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#imageFormat) + */ imageFormat: string; + /** + * Supported image formats as retrieved from the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#imageFormats) + */ imageFormats: string[]; + /** + * The [WMTSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html) to which the sublayer belongs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#layer) + */ layer: WMTSLayer; + /** + * The [WMTSStyle](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html) to request. Defaults to the id of the first item in [styles](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#styles). Should be one of the supported [styles](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#styles). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#styleId) + */ styleId: string; + /** + * A collection of supported [WMTSStyle](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html)s as retrieved from the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#styles) + */ styles: Collection; + /** + * The [TileMatrixSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html) to request. Defaults to the first item in [tileMatrixSets](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSet) that matches the spatialReference of the view. Must be one of the supported [tileMatrixSets](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSet). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSet) + */ tileMatrixSet: TileMatrixSet; + /** + * The id of the [TileMatrixSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html) to request. Defaults to the id of the first item in [tileMatrixSets](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSet) that matches the spatialReference of the view. Must be one of the supported [tileMatrixSets](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSet). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSetId) + */ tileMatrixSetId: string; + /** + * A collection of supported [TileMatrixSets](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSets) + */ tileMatrixSets: Collection; + /** + * The title of the WMTS sublayer used to identify it in places such as the [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) and [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widgets. This defaults to the value of the Title property from the WMTS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#title) + */ title: string; + /** + * Creates a deep clone of the WMTS sublayer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#clone) + * + * + */ clone(): WMTSSublayer; } interface WMTSSublayerConstructor { + + new(properties?: WMTSSublayerProperties): WMTSSublayer; fromJSON(json: any): WMTSSublayer; @@ -3064,25 +11671,92 @@ declare namespace __esri { export const WMTSSublayer: WMTSSublayerConstructor; interface WMTSSublayerProperties { + /** + * Description for the WMTS sublayer. This defaults to the value of the Abstract property from the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#description) + */ description?: string; + /** + * The full extent of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#fullExtent) + */ fullExtent?: ExtentProperties; + /** + * The unique ID assigned to the sublayer. If not set by the developer, it is automatically generated when the layer is loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#id) + */ id?: string; + /** + * The map image format (MIME type) to request. Defaults to the first item in [imageFormats](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#imageFormats). Must be one of the supported [imageFormats](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#imageFormats). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#imageFormat) + */ imageFormat?: string; + /** + * Supported image formats as retrieved from the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#imageFormats) + */ imageFormats?: string[]; + /** + * The [WMTSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html) to which the sublayer belongs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#layer) + */ layer?: WMTSLayerProperties; + /** + * The [WMTSStyle](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html) to request. Defaults to the id of the first item in [styles](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#styles). Should be one of the supported [styles](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#styles). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#styleId) + */ styleId?: string; + /** + * A collection of supported [WMTSStyle](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSStyle.html)s as retrieved from the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#styles) + */ styles?: CollectionProperties; + /** + * The [TileMatrixSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html) to request. Defaults to the first item in [tileMatrixSets](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSet) that matches the spatialReference of the view. Must be one of the supported [tileMatrixSets](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSet). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSet) + */ tileMatrixSet?: TileMatrixSetProperties; + /** + * The id of the [TileMatrixSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html) to request. Defaults to the id of the first item in [tileMatrixSets](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSet) that matches the spatialReference of the view. Must be one of the supported [tileMatrixSets](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSet). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSetId) + */ tileMatrixSetId?: string; + /** + * A collection of supported [TileMatrixSets](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-TileMatrixSet.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#tileMatrixSets) + */ tileMatrixSets?: CollectionProperties; + /** + * The title of the WMTS sublayer used to identify it in places such as the [LayerList](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html) and [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widgets. This defaults to the value of the Title property from the WMTS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#title) + */ title?: string; } interface TiledLayer { + /** + * The tiling scheme information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TiledLayer.html#tileInfo) + */ tileInfo: TileInfo; } interface TiledLayerConstructor { + + new(properties?: TiledLayerProperties): TiledLayer; fromJSON(json: any): TiledLayer; @@ -3091,26 +11765,90 @@ declare namespace __esri { export const TiledLayer: TiledLayerConstructor; interface TiledLayerProperties { + /** + * The tiling scheme information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TiledLayer.html#tileInfo) + */ tileInfo?: TileInfoProperties; } - interface TileLayer extends Layer, ArcGISMapService, ArcGISCachedService, ScaleRangeLayer, PortalLayer, TiledLayer { - attributionDataUrl: string; - hasAttributionData: boolean; + interface TileLayer extends Layer, ArcGISMapService, ArcGISCachedService, RefreshableLayer, ScaleRangeLayer, PortalLayer, TiledLayer { + /** + * The URL that points to the location of the layer's attribution data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html#attributionDataUrl) + */ + readonly attributionDataUrl: string; + /** + * Indicates if the layer has attribution data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html#hasAttributionData) + */ + readonly hasAttributionData: boolean; + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html#legendEnabled) + * + * @default true + */ legendEnabled: boolean; + /** + * An array of tile servers used for changing map tiles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html#tileServers) + */ tileServers: string[]; + /** + * The URL of the REST endpoint of the layer. The URL may either point to a resource on ArcGIS for Server, Portal for ArcGIS, or ArcGIS Online. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html#url) + */ url: string; + /** + * This method fetches a tile for the given level, row and column present in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html#fetchTile) + * + * @param level Level of detail of the tile to fetch. This value is provided by [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param row The row(y) position of the tile fetch. This value is provided by [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param column The column(x) position of the tile to fetch. This value is provided by [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html). + * @param options Optional settings for the tile request. The options have the following properties. + * @param options.allowImageDataAccess Indicates if the access to pixels of the image is allowed. + * + */ fetchTile(level: number, row: number, column: number, options?: TileLayerFetchTileOptions): IPromise; + /** + * This method returns a URL to a tile for a given level, row and column. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html#getTileUrl) + * + * @param level The requested tile's level. + * @param row The requested tile's row. + * @param col The requested tile's column. + * + */ getTileUrl(level: number, row: number, col: number): string; + on(name: "layerview-create", eventHandler: TileLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: TileLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: TileLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: TileLayerLayerviewDestroyEventHandler): IHandle; } interface TileLayerConstructor { + /** + * The TileLayer allows you work with a cached [map service](http://server.arcgis.com/en/server/latest/publish-services/windows/what-is-a-map-service.htm) exposed by the ArcGIS Server REST API and add it to a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) as a tile layer. A cached service accesses tiles from a cache instead of dynamically rendering images. Because they are cached, tiled layers render faster than [MapImageLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). To create an instance of TileLayer, you must reference the URL of the cached map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html) + */ + new(properties?: TileLayerProperties): TileLayer; fromJSON(json: any): TileLayer; @@ -3118,36 +11856,71 @@ declare namespace __esri { export const TileLayer: TileLayerConstructor; - interface TileLayerProperties extends LayerProperties, ArcGISMapServiceProperties, ArcGISCachedServiceProperties, ScaleRangeLayerProperties, PortalLayerProperties, TiledLayerProperties { - attributionDataUrl?: string; - hasAttributionData?: boolean; + interface TileLayerProperties extends LayerProperties, ArcGISMapServiceProperties, ArcGISCachedServiceProperties, RefreshableLayerProperties, ScaleRangeLayerProperties, PortalLayerProperties, TiledLayerProperties { + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html#legendEnabled) + * + * @default true + */ legendEnabled?: boolean; + /** + * An array of tile servers used for changing map tiles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html#tileServers) + */ tileServers?: string[]; + /** + * The URL of the REST endpoint of the layer. The URL may either point to a resource on ArcGIS for Server, Portal for ArcGIS, or ArcGIS Online. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html#url) + */ url?: string; } export interface TileLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface TileLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } - export interface TileLayerFetchTileOptions { + + export interface TileLayerFetchTileOptions extends Object { + /** + * Indicates if the access to pixels of the image is allowed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html#fetchTile) + */ allowImageDataAccess?: boolean; } interface UnknownLayer extends Layer { + on(name: "layerview-create", eventHandler: UnknownLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: UnknownLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: UnknownLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: UnknownLayerLayerviewDestroyEventHandler): IHandle; } interface UnknownLayerConstructor { + /** + * Represents a layer whose type could not be determined. For example, when loading a layer from a URL and the layer type cannot be determined, then it is represented as an instance of this class. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-UnknownLayer.html) + */ + new(properties?: UnknownLayerProperties): UnknownLayer; } @@ -3158,23 +11931,33 @@ declare namespace __esri { } export interface UnknownLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface UnknownLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface UnsupportedLayer extends Layer { + on(name: "layerview-create", eventHandler: UnsupportedLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: UnsupportedLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: UnsupportedLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: UnsupportedLayerLayerviewDestroyEventHandler): IHandle; } interface UnsupportedLayerConstructor { + + new(properties?: UnsupportedLayerProperties): UnsupportedLayer; } @@ -3185,31 +11968,84 @@ declare namespace __esri { } export interface UnsupportedLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface UnsupportedLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface VectorTileLayer extends Layer, PortalLayer, ScaleRangeLayer, TiledLayer { - attributionDataUrl: string; - currentStyleInfo: VectorTileLayerCurrentStyleInfo; + /** + * The URL that points to the location of the layer's attribution data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#attributionDataUrl) + */ + readonly attributionDataUrl: string; + /** + * The current style information of the VectorTileLayer. See the object specification below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#currentStyleInfo) + */ + readonly currentStyleInfo: VectorTileLayerCurrentStyleInfo; + /** + * The spatial reference of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#spatialReference) + */ spatialReference: SpatialReference; - token: string; - url: string | any; + /** + * A style JSON object of vector tiles that will be used to render the layer. If initializing the layer with a style JSON object, the tiles are fetched from the tile servers specified in the style object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#style) + */ + style: any; + /** + * Token generated by the token service using the specified userId and password. The recommended approach to pass a token on a layer is to use [IdentityManager.registerToken()](https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#registerToken). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#token) + */ + readonly token: string; + /** + * The URL to the vector tile service, or the URL to the style resource of vector tiles that will be used to render the layer. If specifying a URL to a style, the tiles are fetched from the tile servers specified in the style object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#url) + */ + url: string; + /** + * Loads a style to render a layer from the specified URL to a style resource or style JSON object. It is equivalent of changing the entire CSS style sheet for web page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#loadStyle) + * + * @param style The URL to a style of vector tiles or style JSON object. + * + */ loadStyle(style: string | any): IPromise; + on(name: "layerview-create", eventHandler: VectorTileLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: VectorTileLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: VectorTileLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: VectorTileLayerLayerviewDestroyEventHandler): IHandle; } interface VectorTileLayerConstructor { + /** + * A VectorTileLayer accesses cached tiles of data and renders it in vector format. It is similar to a [WebTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html) in the context of caching; however, a [WebTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html) renders as a series of images, not vector data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html) + */ + new(properties?: VectorTileLayerProperties): VectorTileLayer; fromJSON(json: any): VectorTileLayer; @@ -3218,46 +12054,131 @@ declare namespace __esri { export const VectorTileLayer: VectorTileLayerConstructor; interface VectorTileLayerProperties extends LayerProperties, PortalLayerProperties, ScaleRangeLayerProperties, TiledLayerProperties { - attributionDataUrl?: string; - currentStyleInfo?: VectorTileLayerCurrentStyleInfo; + /** + * The spatial reference of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#spatialReference) + */ spatialReference?: SpatialReferenceProperties; - token?: string; - url?: string | any; + /** + * A style JSON object of vector tiles that will be used to render the layer. If initializing the layer with a style JSON object, the tiles are fetched from the tile servers specified in the style object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#style) + */ + style?: any; + /** + * The URL to the vector tile service, or the URL to the style resource of vector tiles that will be used to render the layer. If specifying a URL to a style, the tiles are fetched from the tile servers specified in the style object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#url) + */ + url?: string; } export interface VectorTileLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface VectorTileLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } - export interface VectorTileLayerCurrentStyleInfo { + + export interface VectorTileLayerCurrentStyleInfo extends Object { + /** + * The URL of a vector tile service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#currentStyleInfo) + */ serviceUrl: string; + /** + * The URL of a style for vector tiles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#currentStyleInfo) + */ styleUrl: string; + /** + * The sprite URL included in a style. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#currentStyleInfo) + */ spriteUrl: string; + /** + * The template URL of font sets for vector tiles. The URL includes `{fontstack}` and `{range}` tokens. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#currentStyleInfo) + */ glyphsUrl: string; + /** + * Style JSON object for vector tiles. Style object includes `version` of the style specification, `sprite` and `glyphs` properties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#currentStyleInfo) + */ style: any; + /** + * Vector tile service information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html#currentStyleInfo) + */ layerDefinition: any; } - interface WebTileLayer extends Layer, TiledLayer, ScaleRangeLayer { + interface WebTileLayer extends Layer, TiledLayer, ScaleRangeLayer, RefreshableLayer { + /** + * The attribution information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#copyright) + */ copyright: string; - spatialReference: SpatialReference; + /** + * The spatial reference of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#spatialReference) + * + * @default Web Mercator Auxiliary Sphere (wkid: 3857) + */ + readonly spatialReference: SpatialReference; + /** + * A string of subDomain names where tiles are served to speed up tile retrieval. If subDomains are specified, the [urlTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#urlTemplate) should include a `{subDomain}` place holder. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#subDomains) + */ subDomains: string[]; + /** + * The tile server names for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#tileServers) + */ tileServers: string[]; + /** + * URL template for the hosted tiles. The `urlTemplate` should contain a `{subDomain}` place holder if [subDomains](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#subDomains) are specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#urlTemplate) + */ urlTemplate: string; + on(name: "layerview-create", eventHandler: WebTileLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: WebTileLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: WebTileLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: WebTileLayerLayerviewDestroyEventHandler): IHandle; } interface WebTileLayerConstructor { + /** + * WebTileLayer provides a simple way to add non-ArcGIS Server map tiles as a layer to a map. The constructor takes a URL template that usually follows a pattern of `http://some.domain.com/{level}/{col}/{row}/` where `level` corresponds to a zoom level, and `column` and `row` represent tile column and row, respectively. This pattern is not required, but is the most common one currently on the web. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html) + */ + new(properties?: WebTileLayerProperties): WebTileLayer; fromJSON(json: any): WebTileLayer; @@ -3265,53 +12186,197 @@ declare namespace __esri { export const WebTileLayer: WebTileLayerConstructor; - interface WebTileLayerProperties extends LayerProperties, TiledLayerProperties, ScaleRangeLayerProperties { + interface WebTileLayerProperties extends LayerProperties, TiledLayerProperties, ScaleRangeLayerProperties, RefreshableLayerProperties { + /** + * The attribution information for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#copyright) + */ copyright?: string; - spatialReference?: SpatialReferenceProperties; + /** + * A string of subDomain names where tiles are served to speed up tile retrieval. If subDomains are specified, the [urlTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#urlTemplate) should include a `{subDomain}` place holder. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#subDomains) + */ subDomains?: string[]; + /** + * The tile server names for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#tileServers) + */ tileServers?: string[]; + /** + * URL template for the hosted tiles. The `urlTemplate` should contain a `{subDomain}` place holder if [subDomains](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#subDomains) are specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html#urlTemplate) + */ urlTemplate?: string; } export interface WebTileLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface WebTileLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } - interface WMSLayer extends Layer, PortalLayer, ScaleRangeLayer { + interface WMSLayer extends Layer, PortalLayer, ScaleRangeLayer, RefreshableLayer { + /** + * Copyright information for the WMS service. This defaults to the value of the AccessConstraints property from the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#copyright) + */ copyright: string; + /** + * Use this to append different custom parameters to the WMS map requests. The custom layer parameters are applied to GetMap and GetFeatureInfo. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#customLayerParameters) + */ customLayerParameters: any; + /** + * Use this to append custom parameters to all WMS requests. The custom parameters are applied to GetCapabilities, GetMap and GetFeatureInfo. For example, if an access key is required, the key can be configured as a custom parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#customParameters) + */ customParameters: any; + /** + * Description for the WMS layer. This defaults to the value of the Abstract property from the WMS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#description) + */ description: string; + /** + * Return format of feature information (MIME type). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#featureInfoFormat) + */ featureInfoFormat: string; + /** + * The URL for the WMS GetFeatureInfo call. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#featureInfoUrl) + */ featureInfoUrl: string; + /** + * All bounding boxes defined for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#fullExtents) + */ fullExtents: Extent[]; + /** + * The map image format (MIME type) to request. Defaults to `image/png` if the WMS service supports it. If not, it defaults to the value of the first `` in `` in the GetCapabilities response. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#imageFormat) + */ imageFormat: string; + /** + * Indicates the maximum height of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#imageMaxHeight) + * + * @default 2048 + */ imageMaxHeight: number; + /** + * Indicates the maximum height of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#imageMaxWidth) + * + * @default 2048 + */ imageMaxWidth: number; + /** + * Indicates whether the background of the image exported by the service is transparent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#imageTransparency) + * + * @default true + */ imageTransparency: boolean; + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#legendEnabled) + * + * @default true + */ legendEnabled: boolean; + /** + * The spatial reference of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#spatialReference) + */ spatialReference: SpatialReference; + /** + * List of spatialReference well known ids derived from the CRS elements of the first layer in the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#spatialReferences) + */ spatialReferences: number[]; + /** + * A collection of [WMSSublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html)s. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#sublayers) + */ sublayers: Collection; + /** + * The URL of the WMS service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#url) + */ url: string; + /** + * Version of the [WMS specification](http://www.opengeospatial.org/standards/wms) to use. For example, `1.3.0`, `1.1.1`, `1.1` or `1.0`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#version) + */ version: string; + /** + * Fetching the WMS image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#fetchImage) + * + * @param extent The extent of the view. + * @param width The width of the view in pixels. + * @param height The height of the view in pixels. + * @param options The parameter options is an object with the following properties. + * @param options.allowImageDataAccess Indicates if the access to the pixels of the image is required. + * @param options.pixelRatio The ratio of the resolution in physical pixels of the image to the resolution it will be displayed at. + * @param options.rotation The rotation in degrees of the exported image. + * + */ fetchImage(extent: Extent, width: number, height: number, options?: WMSLayerFetchImageOptions): IPromise; + /** + * Returns a [WMSSublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html) based on the given sublayer id. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#findSublayerById) + * + * @param id The [id](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html#id) of the WMS sublayer. + * + */ findSublayerById(id: number): WMSSublayer; + on(name: "layerview-create", eventHandler: WMSLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: WMSLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: WMSLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: WMSLayerLayerviewDestroyEventHandler): IHandle; } interface WMSLayerConstructor { + + new(properties?: WMSLayerProperties): WMSLayer; fromJSON(json: any): WMSLayer; @@ -3319,61 +12384,230 @@ declare namespace __esri { export const WMSLayer: WMSLayerConstructor; - interface WMSLayerProperties extends LayerProperties, PortalLayerProperties, ScaleRangeLayerProperties { + interface WMSLayerProperties extends LayerProperties, PortalLayerProperties, ScaleRangeLayerProperties, RefreshableLayerProperties { + /** + * Copyright information for the WMS service. This defaults to the value of the AccessConstraints property from the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#copyright) + */ copyright?: string; + /** + * Use this to append different custom parameters to the WMS map requests. The custom layer parameters are applied to GetMap and GetFeatureInfo. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#customLayerParameters) + */ customLayerParameters?: any; + /** + * Use this to append custom parameters to all WMS requests. The custom parameters are applied to GetCapabilities, GetMap and GetFeatureInfo. For example, if an access key is required, the key can be configured as a custom parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#customParameters) + */ customParameters?: any; + /** + * Description for the WMS layer. This defaults to the value of the Abstract property from the WMS GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#description) + */ description?: string; + /** + * Return format of feature information (MIME type). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#featureInfoFormat) + */ featureInfoFormat?: string; + /** + * The URL for the WMS GetFeatureInfo call. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#featureInfoUrl) + */ featureInfoUrl?: string; + /** + * All bounding boxes defined for the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#fullExtents) + */ fullExtents?: ExtentProperties[]; + /** + * The map image format (MIME type) to request. Defaults to `image/png` if the WMS service supports it. If not, it defaults to the value of the first `` in `` in the GetCapabilities response. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#imageFormat) + */ imageFormat?: string; + /** + * Indicates the maximum height of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#imageMaxHeight) + * + * @default 2048 + */ imageMaxHeight?: number; + /** + * Indicates the maximum height of the image exported by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#imageMaxWidth) + * + * @default 2048 + */ imageMaxWidth?: number; + /** + * Indicates whether the background of the image exported by the service is transparent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#imageTransparency) + * + * @default true + */ imageTransparency?: boolean; + /** + * Indicates whether the layer will be included in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#legendEnabled) + * + * @default true + */ legendEnabled?: boolean; + /** + * The spatial reference of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#spatialReference) + */ spatialReference?: SpatialReferenceProperties; + /** + * List of spatialReference well known ids derived from the CRS elements of the first layer in the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#spatialReferences) + */ spatialReferences?: number[]; - sublayers?: CollectionProperties; + /** + * A collection of [WMSSublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMSSublayer.html)s. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#sublayers) + */ + sublayers?: CollectionProperties; + /** + * The URL of the WMS service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#url) + */ url?: string; + /** + * Version of the [WMS specification](http://www.opengeospatial.org/standards/wms) to use. For example, `1.3.0`, `1.1.1`, `1.1` or `1.0`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#version) + */ version?: string; } export interface WMSLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface WMSLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } - export interface WMSLayerFetchImageOptions { + + export interface WMSLayerFetchImageOptions extends Object { + /** + * Indicates if the access to the pixels of the image is required. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#fetchImage) + */ allowImageDataAccess?: boolean; + /** + * The ratio of the resolution in physical pixels of the image to the resolution it will be displayed at. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#fetchImage) + */ pixelRatio?: number; + /** + * The rotation in degrees of the exported image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMSLayer.html#fetchImage) + */ rotation?: number; } - interface WMTSLayer extends Layer, PortalLayer, ScaleRangeLayer { + interface WMTSLayer extends Layer, PortalLayer, ScaleRangeLayer, RefreshableLayer { + /** + * Currently active sublayer. Defaults to the first sublayer in [sublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#sublayers). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#activeLayer) + */ activeLayer: WMTSSublayer; + /** + * Copyright information for the WMTS service. This defaults to the value of the AccessConstraints property from the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#copyright) + */ copyright: string; + /** + * Use this to append different custom parameters to the WMTS tile requests. The custom layer parameters are applied to GetTile. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#customLayerParameters) + */ customLayerParameters: any; + /** + * Use this to append custom parameters to all WMTS requests. The custom parameters are applied to GetCapabilities and GetTile. For example, if an access key is required, the key can be configured as a custom parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#customParameters) + */ customParameters: any; + /** + * The service mode for the WMTS layer. If not specified, the API will first make a getCapabilities request using `RESTful`. If that fails, it will try using `KVP`. **Possible Values:** RESTful | KVP + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#serviceMode) + * + * @default RESTful + */ serviceMode: string; + /** + * A collection of [WMTSSublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html) objects. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#sublayers) + */ sublayers: Collection; + /** + * The URL of the WMTS service. The URL for the GetCapabilities is created based on the url and serviceMode properties. For example https://gibs.earthdata.nasa.gov/wmts/epsg4326/best. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#url) + */ url: string; + /** + * Version of the [WMTS specification](http://www.opengeospatial.org/standards/wmts) to use. Probably `1.0.0`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#version) + */ version: string; + /** + * Returns a [WMTSSublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html) based on the given sublayer id. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#findSublayerById) + * + * @param id The [id](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html#id) of the WMTS sublayer. + * + */ findSublayerById(id: string): WMTSSublayer; + on(name: "layerview-create", eventHandler: WMTSLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: WMTSLayerLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: WMTSLayerLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: WMTSLayerLayerviewDestroyEventHandler): IHandle; } interface WMTSLayerConstructor { + + new(properties?: WMTSLayerProperties): WMTSLayer; fromJSON(json: any): WMTSLayer; @@ -3381,58 +12615,239 @@ declare namespace __esri { export const WMTSLayer: WMTSLayerConstructor; - interface WMTSLayerProperties extends LayerProperties, PortalLayerProperties, ScaleRangeLayerProperties { + interface WMTSLayerProperties extends LayerProperties, PortalLayerProperties, ScaleRangeLayerProperties, RefreshableLayerProperties { + /** + * Currently active sublayer. Defaults to the first sublayer in [sublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#sublayers). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#activeLayer) + */ activeLayer?: WMTSSublayerProperties; + /** + * Copyright information for the WMTS service. This defaults to the value of the AccessConstraints property from the GetCapabilities request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#copyright) + */ copyright?: string; + /** + * Use this to append different custom parameters to the WMTS tile requests. The custom layer parameters are applied to GetTile. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#customLayerParameters) + */ customLayerParameters?: any; + /** + * Use this to append custom parameters to all WMTS requests. The custom parameters are applied to GetCapabilities and GetTile. For example, if an access key is required, the key can be configured as a custom parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#customParameters) + */ customParameters?: any; + /** + * The service mode for the WMTS layer. If not specified, the API will first make a getCapabilities request using `RESTful`. If that fails, it will try using `KVP`. **Possible Values:** RESTful | KVP + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#serviceMode) + * + * @default RESTful + */ serviceMode?: string; + /** + * A collection of [WMTSSublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-WMTSSublayer.html) objects. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#sublayers) + */ sublayers?: CollectionProperties; + /** + * The URL of the WMTS service. The URL for the GetCapabilities is created based on the url and serviceMode properties. For example https://gibs.earthdata.nasa.gov/wmts/epsg4326/best. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#url) + */ url?: string; + /** + * Version of the [WMTS specification](http://www.opengeospatial.org/standards/wmts) to use. Probably `1.0.0`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WMTSLayer.html#version) + */ version?: string; } export interface WMTSLayerLayerviewCreateEvent { + layerView: LayerView; + view: View; } export interface WMTSLayerLayerviewDestroyEvent { + layerView: LayerView; + view: View; } interface Map extends Accessor, LayersMixin { - allLayers: Collection; + /** + * A flat collection of all the [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) in the map. This collection contains [basemap layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap), [operational layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers) and [ground layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#ground). [Group Layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html) and their [children layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html#layers) are also part of this collection. Reference layers in the basemap will always be included at the end of the collection. Layers should not be added directly to this collection. They must only be added via the [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers), [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) or [ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#ground) properties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#allLayers) + */ + readonly allLayers: Collection; + /** + * Specifies a basemap for the map. The basemap is a set of tile layers that give geographic context to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and the other [operational layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers) in the map. This value can be an instance of [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) or one of the strings listed in the table below. + * + * Value | Description + * ------|------------ + * streets | ![basemap-streets](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets.jpg) + * satellite | ![basemap-satellite](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/satellite.jpg) + * hybrid | ![basemap-hybrid](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/hybrid.jpg) + * topo | ![basemap-topo](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/topo.jpg) + * gray | ![basemap-gray](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/gray.jpg) + * dark-gray | ![basemap-dark-gray](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/dark-gray.jpg) + * oceans | ![basemap-oceans](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/oceans.jpg) + * national-geographic | ![basemap-national-geographic](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/national-geographic.jpg) + * terrain | ![basemap-terrain](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/terrain.jpg) + * osm | ![basemap-osm](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/osm.jpg) + * dark-gray-vector | ![dark-gray-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/dark-gray.jpg) + * gray-vector | ![gray-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/gray.jpg) + * streets-vector | ![streets-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets.jpg) + * topo-vector | ![topo-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/topo.jpg) + * streets-night-vector | ![streets-night-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets-night.jpg) + * streets-relief-vector | ![streets-relief-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets-relief.jpg) + * streets-navigation-vector | ![streets-navigation-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets-navigation.jpg) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) + */ basemap: Basemap; + /** + * Specifies the surface properties for the map. This property is only relevant when adding the map to a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). It renders the terrain or topographical variations in the real world on the map's surface with a collection of [ElevationLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html). This value can be an instance of [Ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html), or the string `world-elevation` for a default instance of ground using the [World Elevation Service](https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer). The ground may not be set to `null` or `undefined`, it is guaranteed to always contain an instance of type [Ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html). The elevation can be removed from the ground by setting the ground property to a new empty [Ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html) instance or by removing all the ground layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#ground) + */ ground: Ground; } interface MapConstructor { + /** + * The Map class contains properties and methods for storing, managing, and overlaying [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers) common to both 2D and 3D viewing. Layers can be added and removed from the map, but are rendered via a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) (for viewing data in 2D) or a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) (for viewing data in 3D). Thus a map instance is a simple container that holds the layers, while the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is the means of displaying and interacting with a map's layers and basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) + */ + new(properties?: MapProperties): Map; } export const Map: MapConstructor; interface MapProperties extends LayersMixinProperties { - allLayers?: CollectionProperties; - basemap?: BasemapProperties; - ground?: GroundProperties; + /** + * Specifies a basemap for the map. The basemap is a set of tile layers that give geographic context to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and the other [operational layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers) in the map. This value can be an instance of [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) or one of the strings listed in the table below. + * + * Value | Description + * ------|------------ + * streets | ![basemap-streets](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets.jpg) + * satellite | ![basemap-satellite](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/satellite.jpg) + * hybrid | ![basemap-hybrid](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/hybrid.jpg) + * topo | ![basemap-topo](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/topo.jpg) + * gray | ![basemap-gray](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/gray.jpg) + * dark-gray | ![basemap-dark-gray](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/dark-gray.jpg) + * oceans | ![basemap-oceans](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/oceans.jpg) + * national-geographic | ![basemap-national-geographic](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/national-geographic.jpg) + * terrain | ![basemap-terrain](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/terrain.jpg) + * osm | ![basemap-osm](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/osm.jpg) + * dark-gray-vector | ![dark-gray-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/dark-gray.jpg) + * gray-vector | ![gray-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/gray.jpg) + * streets-vector | ![streets-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets.jpg) + * topo-vector | ![topo-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/topo.jpg) + * streets-night-vector | ![streets-night-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets-night.jpg) + * streets-relief-vector | ![streets-relief-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets-relief.jpg) + * streets-navigation-vector | ![streets-navigation-vector](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets-navigation.jpg) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) + */ + basemap?: BasemapProperties | string; + /** + * Specifies the surface properties for the map. This property is only relevant when adding the map to a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). It renders the terrain or topographical variations in the real world on the map's surface with a collection of [ElevationLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ElevationLayer.html). This value can be an instance of [Ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html), or the string `world-elevation` for a default instance of ground using the [World Elevation Service](https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer). The ground may not be set to `null` or `undefined`, it is guaranteed to always contain an instance of type [Ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html). The elevation can be removed from the ground by setting the ground property to a new empty [Ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html) instance or by removing all the ground layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#ground) + */ + ground?: GroundProperties | string; } interface PopupTemplate extends Accessor, JSONSupport { - actions: Collection>; + /** + * A [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html) objects. Each object represents an action or function that may be executed by clicking the icon or image symbolizing them in the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html). By default, every [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) has a `zoom-to` action styled with a magnifying glass icon ![popupTemplate-zoom-action](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/popuptemplate-zoom-action.png). When this icon is clicked, the view zooms in four LODs and centers on the selected feature. PopupTemplates do not have default actions. To override actions on the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) using PopupTemplate see [overwriteActions](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#overwriteActions). Actions defined in a PopupTemplate will only appear in the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) for features or layers that apply that particular PopupTemplate. The order of each action in the popup is the same order in which they appear in the actions [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html). The [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event:trigger-action) event in [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) fires each time an action in the popup is clicked. This event should be used to execute custom code for each action clicked. For example, if you would like to add a `zoom-out` action to the PopupTemplate that zooms the view out several LODs, you would define the zoom-out code in a separate function. Then you would call the custom `zoom-out` function in the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event:trigger-action) event handler. See the sample code snippet below for more details on how this works. Actions are defined with the properties listed in the [Action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html) class. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#actions) + */ + actions: Collection; + /** + * The template for defining and formatting a popup's content. Content may be defined with one of four types of values. + * * **String** - A popup's content can be a simple text or string value referencing field values or [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expressions. Expressions must be defined in the [expressionInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#expressionInfos) property. These values are referenced via placeholders. Within the string, placeholders are denoted by `{fieldName}` or `{expression/expressionName}` which are used to specify which values from field attributes or expressions to display within certain locations in the string. When the application runs, substitution occurs and the placeholder is replaced with the actual attribute or expression value for the selected feature. The string can also include HTML markup and formatting functions. + * * **Popup elements** - You can also display content as popup elements defined as an array of Objects. These elements can be used individually or combined. The order in which they are set determines how they display within the popup. See the items below describing each element. + * * **text** - Object that provides descriptive text as content. This object must be defined using the [text popup element specification table](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#text). + * * **media** - Array of objects used to display media such as charts and/or images. This object must be defined using the [media popup element specification table](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media). + * * **fields** - Array of [fieldInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) objects. If `fieldInfos` is not set directly within the `content` property, the popup will display whatever is set in the [PopupTemplate.fieldInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) property. This must be defined using the [fields popup element specification table](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fields). + * * **attachments** - Array of attachmentInfos objects listed in the popup. This object must be defined using the [attachments popup element specification table](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#attachments). + * * **promise** - The PopupTemplate's content may also be defined with a promise that resolves to any of the above-mentioned elements. This is useful for cases when you run a task or execute a query and want to display the results in the popup. Simply pass the promise to the popupTemplate's content and ensure that it resolves to a string or other popup element. + * * **function** - Content may be defined with a JavaScript function that returns any of the above-mentioned elements. This is handy when your popup requires additional processing or functionality than what is provided with the four content types listed above. For example, let’s assume that you would like to display charts using third-party JavaScript libraries or categorize information into separate tabs. In these cases, you can use a function that returns either a string, a reference to an HTML element, a popup element, or a promise. When the feature is clicked, the feature is passed as an argument to the function and provides access to the feature’s graphic and attributes. The function then executes and returns a value to display in the popup template. It is also possible to check a specific feature attribute and determine whether to apply a function based on its value. Out-of-the-box formatting functions can be used to format date, time, and number values. The syntax for using an out-of-the-box formatting function is: `{field-name:format-function-name(option-a: value, option-b: value)}` + * + * + * The formatter functions are described below: + * + * Type | Description + * ----- | ----------- + * DateString | Formats the date into a human-readable format. Supports the following options: `hideTime: false` - When `true` shows time. Default value is `false`. `local: false` - Displays date and time in the local time zone. Default value is `false`. When `false` the date will display in UTC. `systemLocale: false` - Displays date and time in the system locale (local time zone). Default value is `false`. + * DateFormat | Converts date fields into a human-readable format using [dojo/date/locale.format](https://dojotoolkit.org/reference-guide/1.10/dojo/date/locale/format.html) method. Supports the same options as [dojo/date/locale.format](https://dojotoolkit.org/reference-guide/1.10/dojo/date/locale/format.html). The following snippets show some usage examples: `{DATE_FIELD:DateFormat}` produces `3/8/08 4:00 PM`. `{DATE_FIELD:DateFormat(selector: 'date', fullYear: true)}` produces `4/8/2009`. + * NumberFormat | Formats numbers into various formats using the [dojo/number.format](https://dojotoolkit.org/reference-guide/1.10/dojo/number.html#format) method. Supports the same set of options as [dojo/number.format](https://dojotoolkit.org/reference-guide/1.10/dojo/number.html#format). The following snippets show examples of usage pattern examples: `{Magnitude:NumberFormat}` produces `4.23456`. `{Magnitude:NumberFormat(places:2)}` produces `4.23`. + * + * Out-of-the-box formatting functions and custom functions are supported as of version 4.1. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content) + */ content: string | any[] | Function | IPromise; + /** + * An array of objects that reference [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expressions. These expressions evaluate to either a number or a string value on a feature-by-feature basis at runtime. The values display within the view's popup as if they are field values. They can be displayed in a table using the `fieldInfos` of the popupTemplate's content or referenced within a simple string. See the object specification table below for a description of the properties that may be set in each object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#expressionInfos) + */ expressionInfos: PopupTemplateExpressionInfos[]; + /** + * An array of objects that defines how fields in the dataset or values from [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expressions participate in a popup. Each object contains properties for a single field or expression. See the object specification table below for available options to set on each field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) + */ fieldInfos: PopupTemplateFieldInfos[]; + /** + * Additional options that can be defined for the popup layer. Currently supports one property, `showNoDataRecords`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#layerOptions) + * + * @default null + */ layerOptions: PopupTemplateLayerOptions; + /** + * Indicates whether actions should replace existing [popup actions](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#actions). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#overwriteActions) + * + * @default false + */ overwriteActions: boolean; + /** + * The template for defining how to format the title used in a popup. You can format the title by specifying either a string value or a function that returns a simple string. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#title) + */ title: string | Function; - - clone(): PopupTemplate; } interface PopupTemplateConstructor { + /** + * A PopupTemplate formats and defines the content of a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) for a specific [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) or [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). A PopupTemplate allows the user to access values from feature attributes and values returned from [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expressions when a feature in the view is selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) + */ + new(properties?: PopupTemplateProperties): PopupTemplate; fromJSON(json: any): PopupTemplate; @@ -3441,325 +12856,1652 @@ declare namespace __esri { export const PopupTemplate: PopupTemplateConstructor; interface PopupTemplateProperties { - actions?: CollectionProperties>; + /** + * A [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html) objects. Each object represents an action or function that may be executed by clicking the icon or image symbolizing them in the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html). By default, every [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) has a `zoom-to` action styled with a magnifying glass icon ![popupTemplate-zoom-action](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/popuptemplate-zoom-action.png). When this icon is clicked, the view zooms in four LODs and centers on the selected feature. PopupTemplates do not have default actions. To override actions on the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) using PopupTemplate see [overwriteActions](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#overwriteActions). Actions defined in a PopupTemplate will only appear in the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) for features or layers that apply that particular PopupTemplate. The order of each action in the popup is the same order in which they appear in the actions [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html). The [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event:trigger-action) event in [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) fires each time an action in the popup is clicked. This event should be used to execute custom code for each action clicked. For example, if you would like to add a `zoom-out` action to the PopupTemplate that zooms the view out several LODs, you would define the zoom-out code in a separate function. Then you would call the custom `zoom-out` function in the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event:trigger-action) event handler. See the sample code snippet below for more details on how this works. Actions are defined with the properties listed in the [Action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html) class. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#actions) + */ + actions?: CollectionProperties; + /** + * The template for defining and formatting a popup's content. Content may be defined with one of four types of values. + * * **String** - A popup's content can be a simple text or string value referencing field values or [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expressions. Expressions must be defined in the [expressionInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#expressionInfos) property. These values are referenced via placeholders. Within the string, placeholders are denoted by `{fieldName}` or `{expression/expressionName}` which are used to specify which values from field attributes or expressions to display within certain locations in the string. When the application runs, substitution occurs and the placeholder is replaced with the actual attribute or expression value for the selected feature. The string can also include HTML markup and formatting functions. + * * **Popup elements** - You can also display content as popup elements defined as an array of Objects. These elements can be used individually or combined. The order in which they are set determines how they display within the popup. See the items below describing each element. + * * **text** - Object that provides descriptive text as content. This object must be defined using the [text popup element specification table](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#text). + * * **media** - Array of objects used to display media such as charts and/or images. This object must be defined using the [media popup element specification table](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media). + * * **fields** - Array of [fieldInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) objects. If `fieldInfos` is not set directly within the `content` property, the popup will display whatever is set in the [PopupTemplate.fieldInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) property. This must be defined using the [fields popup element specification table](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fields). + * * **attachments** - Array of attachmentInfos objects listed in the popup. This object must be defined using the [attachments popup element specification table](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#attachments). + * * **promise** - The PopupTemplate's content may also be defined with a promise that resolves to any of the above-mentioned elements. This is useful for cases when you run a task or execute a query and want to display the results in the popup. Simply pass the promise to the popupTemplate's content and ensure that it resolves to a string or other popup element. + * * **function** - Content may be defined with a JavaScript function that returns any of the above-mentioned elements. This is handy when your popup requires additional processing or functionality than what is provided with the four content types listed above. For example, let’s assume that you would like to display charts using third-party JavaScript libraries or categorize information into separate tabs. In these cases, you can use a function that returns either a string, a reference to an HTML element, a popup element, or a promise. When the feature is clicked, the feature is passed as an argument to the function and provides access to the feature’s graphic and attributes. The function then executes and returns a value to display in the popup template. It is also possible to check a specific feature attribute and determine whether to apply a function based on its value. Out-of-the-box formatting functions can be used to format date, time, and number values. The syntax for using an out-of-the-box formatting function is: `{field-name:format-function-name(option-a: value, option-b: value)}` + * + * + * The formatter functions are described below: + * + * Type | Description + * ----- | ----------- + * DateString | Formats the date into a human-readable format. Supports the following options: `hideTime: false` - When `true` shows time. Default value is `false`. `local: false` - Displays date and time in the local time zone. Default value is `false`. When `false` the date will display in UTC. `systemLocale: false` - Displays date and time in the system locale (local time zone). Default value is `false`. + * DateFormat | Converts date fields into a human-readable format using [dojo/date/locale.format](https://dojotoolkit.org/reference-guide/1.10/dojo/date/locale/format.html) method. Supports the same options as [dojo/date/locale.format](https://dojotoolkit.org/reference-guide/1.10/dojo/date/locale/format.html). The following snippets show some usage examples: `{DATE_FIELD:DateFormat}` produces `3/8/08 4:00 PM`. `{DATE_FIELD:DateFormat(selector: 'date', fullYear: true)}` produces `4/8/2009`. + * NumberFormat | Formats numbers into various formats using the [dojo/number.format](https://dojotoolkit.org/reference-guide/1.10/dojo/number.html#format) method. Supports the same set of options as [dojo/number.format](https://dojotoolkit.org/reference-guide/1.10/dojo/number.html#format). The following snippets show examples of usage pattern examples: `{Magnitude:NumberFormat}` produces `4.23456`. `{Magnitude:NumberFormat(places:2)}` produces `4.23`. + * + * Out-of-the-box formatting functions and custom functions are supported as of version 4.1. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content) + */ content?: string | any[] | Function | IPromise; + /** + * An array of objects that reference [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expressions. These expressions evaluate to either a number or a string value on a feature-by-feature basis at runtime. The values display within the view's popup as if they are field values. They can be displayed in a table using the `fieldInfos` of the popupTemplate's content or referenced within a simple string. See the object specification table below for a description of the properties that may be set in each object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#expressionInfos) + */ expressionInfos?: PopupTemplateExpressionInfos[]; + /** + * An array of objects that defines how fields in the dataset or values from [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expressions participate in a popup. Each object contains properties for a single field or expression. See the object specification table below for available options to set on each field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) + */ fieldInfos?: PopupTemplateFieldInfos[]; + /** + * Additional options that can be defined for the popup layer. Currently supports one property, `showNoDataRecords`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#layerOptions) + * + * @default null + */ layerOptions?: PopupTemplateLayerOptions; + /** + * Indicates whether actions should replace existing [popup actions](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#actions). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#overwriteActions) + * + * @default false + */ overwriteActions?: boolean; + /** + * The template for defining how to format the title used in a popup. You can format the title by specifying either a string value or a function that returns a simple string. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#title) + */ title?: string | Function; } - export interface Attachments { + /** + * Attachments are a type of popup element. Similar to text and media elements, attachments can only be set within the content. ![popuptemplate-attachments-element](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/popuptemplate-attachments-element.png) The object specification for the fields popup element is provided below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#attachments) + */ + export interface Attachments extends Object { + /** + * **Required.** The type of popup element to display. To list attachments, set this to `attachments`. The attachmentInfos are queried from the service and will list within the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#attachments) + */ type: string; } - export interface Fields { + /** + * It is possible to set the fieldInfos directly within the PopupTemplate's content. If the fieldInfos is not set within the content, it will revert to whatever may be set within the [PopupTemplate.fieldInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) property. ![popuptemplate-fields-element](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/popuptemplate-fields-element.png) The object specification for the fields popup element is provided below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fields) + */ + export interface Fields extends Object { + /** + * **Required.** The type of popup element to display. To display tabular field data, set this to `fields`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fields) + */ type: string; + /** + * Object array of [fieldInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos). If the `fieldInfos` property is not provided directly within the content, the popup will display whatever is set directly in the `PopupTemplate.fieldInfos`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fields) + */ fieldInfos: any[]; } - export interface Media { + /** + * It is possible to set media elements such as charts and/or images within the PopupTemplate's content. This content is set within the mediaInfos. You will need to reference a dijit stylesheet and reference its class within the `` HTML div. You can see this in the [Multiple popup elements sample](https://developers.arcgis.com/javascript/latest/sample-code/popup-multipleelements/index.html). ![popuptemplate-media-element](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/popuptemplate-media-element.png) The object specification for the media popup element is provided below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ + export interface Media extends Object { + /** + * **Required.** The type of popup element to display. To display charts or images, set this to `media`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ type: string; + /** + * **Required.** Object array of mediaInfos representing images or charts for display. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ mediaInfos: MediaMediaInfos[]; } - export interface PopupTemplateExpressionInfos { + + export interface PopupTemplateExpressionInfos extends Object { + /** + * The name of the expression. This is used to reference the value of the given `expression` in the popupTemplate's [content](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content) property by wrapping it in curly braces and prefacing it with `expression/` (e.g. `{expression/expressionName}`). See the code snippets below for more examples. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#expressionInfos) + */ name: string; + /** + * The title used to describe the value returned by the expression in the popup. This will display if the value is referenced in a `fieldInfos` table. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#expressionInfos) + */ title?: string; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to either a string or a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#expressionInfos) + */ expression: string; + /** + * Indicates the return type of the Arcade expression. This is an optional property. **Known Values:** string | number + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#expressionInfos) + */ returnType?: string; } - export interface PopupTemplateFieldInfos { + + export interface PopupTemplateFieldInfos extends Object { + /** + * **Required.** The field name as defined by the service or the `name` of an [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression. Arcade expression names are defined in the [expressionInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#expressionInfos) property. When referencing Arcade expressions, you must preface the name with `expression/`, such as `expression/percent-total`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) + */ fieldName: string; + /** + * An object used with numerical or date fields to provide more detail about how the value should be displayed in a popup. When formatting Number fields, you must set both the `digitSeparator` and `places` properties for the formatting to take effect. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) + */ format?: PopupTemplateFieldInfosFormat; + /** + * The field alias to display in place of the `fieldName` in the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) + */ label?: string; + /** + * For editable popups, defines the text box format. **Known Values:** rich-text | text-area | text-box + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) + */ stringFieldOption?: string; + /** + * Defines a tooltip for editable popup fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) + */ tooltip?: string; + /** + * Defines whether the field is visible in the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) + */ visible?: boolean; } - export interface PopupTemplateFieldInfosFormat { + + export interface PopupTemplateFieldInfosFormat extends Object { + /** + * Used only with Date fields. Specifies how the date should appear in a popup. **Known Values:** short-date | short-date-le | long-date | day-short-month-year | long-month-day-year | short-date-long-time | short-date-le-long-time | short-date-short-time | short-date-le-short-time | short-date-short-time-24 | short-date-le-short-time-24 | short-date-short-time-24 | short-date-le-short-time-24 | long-month-year | short-month-year | year + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) + */ dateFormat?: string; + /** + * Used only with Number fields. A value of `true` indicates the number should have a digit (or thousands) separator when the value appears in popups. A value of `false` means that no separator will be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) + */ digitSeparator?: boolean; + /** + * Used only with Number fields to specify the number of supported decimal places that should appear in popups. Any places beyond this value are rounded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#fieldInfos) + */ places?: number; } - export interface PopupTemplateLayerOptions { + + export interface PopupTemplateLayerOptions extends Object { + /** + * Applicable to [Imagery Layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html). Indicates whether records without data should display within the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#layerOptions) + */ showNoDataRecords: boolean; } - export interface Text { + /** + * An object used to define descriptive text as an element within the PopupTemplate's content. The text may reference values returned from a field attribute or an [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression. ![popuptemplate-text-element](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/popuptemplate-text-element.png) The object specification for the text popup element is provided below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#text) + */ + export interface Text extends Object { + /** + * **Required.** The type of popup element to display. For descriptive text, set this to `text`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#text) + */ type: string; + /** + * **Required.** The formatted string content to display. This may contain a field name enclosed in `{}`, such as `{FIELDNAME}`, or an [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression name, referenced as `{expression/EXPRESSIONNAME}`. Text content may also leverage HTML tags such as ``, `

`, and `
` for formatting the look and feel of the content. To use this element, set the `type` property to `text`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#text) + */ text: string; } - export interface MediaMediaInfos { + + export interface MediaMediaInfos extends Object { + /** + * Defines the media title. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ title: string; + /** + * Defines a caption for the media. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ caption: string; + /** + * **Since: 4.5** Refresh interval of the layer in minutes. Non-zero value indicates automatic layer refresh at the specified interval. Value of `0` indicates auto refresh is not enabled. If the property does not exist, it is equivalent to having a value of `0`. Only applicable when `type` is set to `image`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ refreshInterval: number; + /** + * Defines the media type. **Possible Values:** image | pie-chart | bar-chart | column-chart | line-chart + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ type: string; + /** + * Defines the value format. This depends on the media type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ value: MediaMediaInfosValue; } - export interface MediaMediaInfosValue { + + export interface MediaMediaInfosValue extends Object { + /** + * Use this for image values. It defines the sourceURL pointing to the image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ sourceURL: string; + /** + * Used for chart values. An array of strings indicating field names from the specified layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ fields: string[]; + /** + * Used for chart values. A field used to normalize data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ normalizationField: string; + /** + * Used for chart values. Defines a new dojo theme, only valid for chart types. View the [Dojox Charting Theme Preview](https://download.dojotoolkit.org/release-1.10.0/dojo-release-1.10.0/dojox/charting/tests/theme_preview.html) to see some of the theme options. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ theme: string; + /** + * Used for chart values. Defines the tooltip display field that displays when hovering over the chart. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#media) + */ tooltipField: string; } interface Portal extends Accessor, Loadable { + /** + * The access level of the organization. When public, anonymous users can access the organization. When private, access is restricted to only members of the organization. **Known Values:** public | private + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#access) + */ access: string; + /** + * When `true`, access to the organization's Portal resources must occur over SSL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#allSSL) + */ allSSL: boolean; + /** + * The authentication mode for handling authentication when the user attempts to access a secure resource. + * + * Possible Value | Description + * ---------------|------------ + * anonymous | An error will be returned when a secure resource is requested. + * auto | The user will be signed in when a secure resource is requested. + * immediate | The user will be signed in when the Portal is loaded. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#authMode) + * + * @default auto + */ authMode: string; + /** + * Array of trusted servers to send credentials to when making Cross-Origin Resource Sharing (CORS) requests to access services secured with web-tier authentication. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#authorizedCrossOriginDomains) + */ authorizedCrossOriginDomains: string[]; + /** + * The query that defines the basemaps that should be displayed in the [BasemapGallery](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html) when [useVectorBasemaps](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#useVectorBasemaps) is not true. The [fetchBasemaps()](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#fetchBasemaps) method does this automatically. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#basemapGalleryGroupQuery) + */ basemapGalleryGroupQuery: string; + /** + * The Bing key to use for web maps using Bing Maps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#bingKey) + */ bingKey: string; + /** + * Indicates whether an organization can list applications in the marketplace . + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canListApps) + */ canListApps: boolean; + /** + * Indicates whether an organization can list data services in the marketplace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canListData) + */ canListData: boolean; + /** + * Indicates whether an organization can list pre-provisioned items in the marketplace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canListPreProvisionedItems) + */ canListPreProvisionedItems: boolean; + /** + * Indicates whether an organization can provision direct purchases in the marketplace without customer request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canProvisionDirectPurchase) + */ canProvisionDirectPurchase: boolean; + /** + * When `true`, the organization's public items, groups and users are included in search queries. When `false`, no public items outside of the organization are included. However, public items which are part of the organization are included. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canSearchPublic) + */ canSearchPublic: boolean; + /** + * The Bing key can be shared to the public and is returned as part of a portal's description call (`/sharing/rest/portals/`). This requires the access of the portal to be set to public. The canShareBingPublic property is not returned publicly but only shown to users within the organization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canShareBingPublic) + * + * @default false + */ canShareBingPublic: boolean; + /** + * When `true`, members of the organization can share resources outside the organization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canSharePublic) + * + * @default false + */ canSharePublic: boolean; + /** + * Indicates whether to allow an organization with an enterprise IDP configured to be able to turn on or off the ArcGIS sign in. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canSignInArcGIS) + * + * @default false + */ canSignInArcGIS: boolean; + /** + * Indicates whether to allow an organization with an enterprise IDP configured to be able to turn on or off the enterprise sign in. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canSignInIDP) + * + * @default false + */ canSignInIDP: boolean; + /** + * The query that identifies the group containing the color sets used for rendering in the map viewer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#colorSetsGroupQuery) + */ colorSetsGroupQuery: string; + /** + * Indicates whether to allow the organization to disable commenting. When commentsEnabled is false, comments are hidden and not removed. numComments are set to zero for all items in the organization. Calls to add a comment and view comments will fail. If the organization re-enables comments, the comments display and numComments are restored. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#commentsEnabled) + * + * @default false + */ commentsEnabled: boolean; + /** + * Date the organization was created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#created) + */ created: Date; + /** + * The default locale (language and country) information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#culture) + */ culture: string; + /** + * The custom base URL for the portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#customBaseUrl) + */ customBaseUrl: string; + /** + * The default basemap to use for the portal. Used in the map viewer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#defaultBasemap) + */ defaultBasemap: Basemap; + /** + * The default extent to use for the portal. Used in the map viewer. The extent will be in the default basemap's spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#defaultExtent) + */ defaultExtent: Extent; + /** + * The default vector basemap to use for the portal. Used in the map viewer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#defaultVectorBasemap) + */ defaultVectorBasemap: Basemap; + /** + * A description of the organization/portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#description) + */ description: string; + /** + * The featured groups for the portal. Returns an array of objects that provide access to the owner and title for each featured group. Each item in this array has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#featuredGroups) + */ featuredGroups: PortalFeaturedGroups[]; + /** + * The query that defines the featured group. If null, then the most viewed items in the organization will be the featured items. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#featuredItemsGroupQuery) + */ featuredItemsGroupQuery: string; + /** + * The query that identifies the group containing features items for the gallery. Set a Group ID or, if null, then the most viewed items in your organization are displayed in the gallery. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#galleryTemplatesGroupQuery) + */ galleryTemplatesGroupQuery: string; + /** + * Helper services provided by the portal. For the detailed information about these services, see the [about utility services](https://server.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm) topic from the ArcGIS Server documentation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#helperServices) + */ helperServices: any; + /** + * The group that contains featured content to be displayed on the home page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#homePageFeaturedContent) + */ homePageFeaturedContent: string; + /** + * The number of featured items that can be displayed on the home page. The max is 100. Accepts integers only. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#homePageFeaturedContentCount) + */ homePageFeaturedContentCount: number; + /** + * The port used by the portal for HTTP communication. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#httpPort) + */ httpPort: number; + /** + * The port used by the portal for HTTPS communication. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#httpsPort) + */ httpsPort: number; + /** + * The id of the organization that owns this portal. If `null` then this is the default portal for anonymous and non-organizational users. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#id) + */ id: string; + /** + * The country code of the calling IP (ArcGIS Online only). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#ipCntryCode) + */ ipCntryCode: string; - isOrganization: boolean; + /** + * Indicates whether the portal is an organization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#isOrganization) + */ + readonly isOrganization: boolean; + /** + * Indicates if the portal is on-premises. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#isPortal) + */ isPortal: boolean; + /** + * The query that identifies the group containing editing templates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#layerTemplatesGroupQuery) + */ layerTemplatesGroupQuery: string; - loaded: boolean; + /** + * Indicates whether the portal's resources have loaded. When `true`, all the properties of the object can be accessed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#loaded) + * + * @default false + */ + readonly loaded: boolean; + /** + * The maximum validity in minutes of tokens issued for users of the organization. -1 is the default and is a special value that indicates infinite timeout or permanent tokens. For tokens granted using OAuth 2.0 authorization grant, it represents the maximum validity of refresh tokens. For access tokens, the maximum validity is the lower of two weeks or this value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#maxTokenExpirationMinutes) + */ maxTokenExpirationMinutes: number; + /** + * Date the organization was last modified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#modified) + */ modified: Date; + /** + * Name of the organization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#name) + */ name: string; + /** + * URL of the portal host. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#portalHostname) + */ portalHostname: string; + /** + * The portal mode. **Known Values:** multitenant | singletenant + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#portalMode) + */ portalMode: string; + /** + * Properties specific to the organization, for example the "contact us" link. If the organization is public, the properties are visible to the anonymous user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#portalProperties) + */ portalProperties: any; + /** + * The region for the organization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#region) + */ region: string; - restUrl: string; + /** + * The REST URL for the portal, for example "https://www.arcgis.com/sharing/rest" for ArcGIS Online and "https://www.example.com/arcgis/sharing/rest" for your in-house portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#restUrl) + */ + readonly restUrl: string; + /** + * Custom HTML for the home page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#rotatorPanels) + */ rotatorPanels: any[]; + /** + * Indicates whether the description of your organization displays on the home page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#showHomePageDescription) + */ showHomePageDescription: boolean; + /** + * Indicates whether hosted services are supported. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#supportsHostedServices) + * + * @default false + */ supportsHostedServices: boolean; + /** + * The query that defines the symbols sets. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#symbolSetsGroupQuery) + */ symbolSetsGroupQuery: string; + /** + * The query that defines the collection of templates that will appear in the template gallery. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#templatesGroupQuery) + */ templatesGroupQuery: string; - thumbnailUrl: string; + /** + * The URL to the thumbnail of the organization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#thumbnailUrl) + */ + readonly thumbnailUrl: string; + /** + * Sets the units of measure for the organization's users. The user default is derived from the organization's [region](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#region). **Known Values:** english | metric + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#units) + */ units: string; + /** + * The URL to the portal instance. Setting the location of the portal instance via [esriConfig.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl) should be used in favor of setting it directly on this property. If using an on-premise portal, the syntax should look similar to: `https://www.example.com/arcgis` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#url) + * + * @default {@link module:esri/config#portalUrl esriConfig.portalUrl} + */ url: string; + /** + * The prefix selected by the organization's administrator to be used with the customBaseURL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#urlKey) + */ urlKey: string; + /** + * Information representing a registered user of the portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#user) + */ user: PortalUser; + /** + * When `true`, only simple where clauses that are compliant with SQL92 can be used when querying layers and tables. The recommended security setting is true. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#useStandardizedQuery) + */ useStandardizedQuery: boolean; + /** + * When `true`, the organization has opted in to use the vector tile basemaps, and (a) [vectorBasemapGalleryGroupQuery](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#vectorBasemapGalleryGroupQuery) should be used instead of [basemapGalleryGroupQuery](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#basemapGalleryGroupQuery), while (b) [defaultVectorBasemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#defaultVectorBasemap) should be used instead of [defaultBasemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#defaultBasemap). The [fetchBasemaps()](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#fetchBasemaps) method automatically uses vectorBasemapGalleryGroupQuery. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#useVectorBasemaps) + */ useVectorBasemaps: boolean; + /** + * The query that defines the vector tiles basemaps that should be displayed in the [BasemapGallery](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html) when [useVectorBasemaps](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#useVectorBasemaps) is true. The [fetchBasemaps()](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#fetchBasemaps) method does this automatically. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#vectorBasemapGalleryGroupQuery) + */ vectorBasemapGalleryGroupQuery: string; + /** + * Fetches the [basemaps](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) that are displayed in the [BasemapGallery](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html). When [useVectorBasemaps](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#useVectorBasemaps) is `true`, the basemaps will be based on [vectorBasemapGalleryGroupQuery](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#vectorBasemapGalleryGroupQuery), and otherwise on [basemapGalleryGroupQuery](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#basemapGalleryGroupQuery). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#fetchBasemaps) + * + * @param basemapGalleryGroupQuery When provided, this argument is used to fetch basemaps based on input query parameters. + * + */ fetchBasemaps(basemapGalleryGroupQuery?: string): IPromise; + /** + * Fetches the featured groups in the Portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#fetchFeaturedGroups) + * + * + */ fetchFeaturedGroups(): IPromise; - queryGroups(queryParams: PortalQueryParams): IPromise; - queryItems(queryParams: PortalQueryParams): IPromise; - queryUsers(queryParams: PortalQueryParams): IPromise; + /** + * Executes a query against the Portal to return an array of [PortalGroup](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html) objects that match the input query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#queryGroups) + * + * @param queryParams The input query parameters defined in [PortalQueryParams](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html). + * + */ + queryGroups(queryParams: PortalQueryParams | PortalQueryParamsProperties): IPromise; + /** + * Executes a query against the Portal to return an array of [PortalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html) objects that match the input query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#queryItems) + * + * @param queryParams The input query parameters defined in [PortalQueryParams](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html). + * + */ + queryItems(queryParams: PortalQueryParams | PortalQueryParamsProperties): IPromise; + /** + * Executes a query against the Portal to return an array of [PortalUser](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html) objects that match the input query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#queryUsers) + * + * @param queryParams The input query parameters defined in [PortalQueryParams](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html). + * + */ + queryUsers(queryParams: PortalQueryParams | PortalQueryParamsProperties): IPromise; } interface PortalConstructor { + /** + * The Portal class is part of the [ArcGIS Portal API](http://server.arcgis.com/en/portal/) which provides a way to build applications that work with content from [ArcGIS Online](http://www.arcgis.com/home/) or an [ArcGIS Portal API](http://server.arcgis.com/en/portal/). [ArcGIS Portal API](http://server.arcgis.com/en/portal/) is software from Esri that customers can deploy either on-premises or in the cloud. [ArcGIS Online](http://www.arcgis.com/home/) is Esri's Software as a Service offering that represents GIS as a Service and is implemented using the same technology as ArcGIS Portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html) + */ + new(properties?: PortalProperties): Portal; + /** + * Returns a cached default Portal instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#getDefault) + * + * + */ getDefault(): Portal; } export const Portal: PortalConstructor; interface PortalProperties extends LoadableProperties { + /** + * The access level of the organization. When public, anonymous users can access the organization. When private, access is restricted to only members of the organization. **Known Values:** public | private + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#access) + */ access?: string; + /** + * When `true`, access to the organization's Portal resources must occur over SSL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#allSSL) + */ allSSL?: boolean; + /** + * The authentication mode for handling authentication when the user attempts to access a secure resource. + * + * Possible Value | Description + * ---------------|------------ + * anonymous | An error will be returned when a secure resource is requested. + * auto | The user will be signed in when a secure resource is requested. + * immediate | The user will be signed in when the Portal is loaded. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#authMode) + * + * @default auto + */ authMode?: string; + /** + * Array of trusted servers to send credentials to when making Cross-Origin Resource Sharing (CORS) requests to access services secured with web-tier authentication. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#authorizedCrossOriginDomains) + */ authorizedCrossOriginDomains?: string[]; + /** + * The query that defines the basemaps that should be displayed in the [BasemapGallery](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html) when [useVectorBasemaps](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#useVectorBasemaps) is not true. The [fetchBasemaps()](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#fetchBasemaps) method does this automatically. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#basemapGalleryGroupQuery) + */ basemapGalleryGroupQuery?: string; + /** + * The Bing key to use for web maps using Bing Maps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#bingKey) + */ bingKey?: string; + /** + * Indicates whether an organization can list applications in the marketplace . + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canListApps) + */ canListApps?: boolean; + /** + * Indicates whether an organization can list data services in the marketplace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canListData) + */ canListData?: boolean; + /** + * Indicates whether an organization can list pre-provisioned items in the marketplace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canListPreProvisionedItems) + */ canListPreProvisionedItems?: boolean; + /** + * Indicates whether an organization can provision direct purchases in the marketplace without customer request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canProvisionDirectPurchase) + */ canProvisionDirectPurchase?: boolean; + /** + * When `true`, the organization's public items, groups and users are included in search queries. When `false`, no public items outside of the organization are included. However, public items which are part of the organization are included. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canSearchPublic) + */ canSearchPublic?: boolean; + /** + * The Bing key can be shared to the public and is returned as part of a portal's description call (`/sharing/rest/portals/`). This requires the access of the portal to be set to public. The canShareBingPublic property is not returned publicly but only shown to users within the organization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canShareBingPublic) + * + * @default false + */ canShareBingPublic?: boolean; + /** + * When `true`, members of the organization can share resources outside the organization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canSharePublic) + * + * @default false + */ canSharePublic?: boolean; + /** + * Indicates whether to allow an organization with an enterprise IDP configured to be able to turn on or off the ArcGIS sign in. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canSignInArcGIS) + * + * @default false + */ canSignInArcGIS?: boolean; + /** + * Indicates whether to allow an organization with an enterprise IDP configured to be able to turn on or off the enterprise sign in. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#canSignInIDP) + * + * @default false + */ canSignInIDP?: boolean; + /** + * The query that identifies the group containing the color sets used for rendering in the map viewer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#colorSetsGroupQuery) + */ colorSetsGroupQuery?: string; + /** + * Indicates whether to allow the organization to disable commenting. When commentsEnabled is false, comments are hidden and not removed. numComments are set to zero for all items in the organization. Calls to add a comment and view comments will fail. If the organization re-enables comments, the comments display and numComments are restored. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#commentsEnabled) + * + * @default false + */ commentsEnabled?: boolean; + /** + * Date the organization was created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#created) + */ created?: DateProperties; + /** + * The default locale (language and country) information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#culture) + */ culture?: string; + /** + * The custom base URL for the portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#customBaseUrl) + */ customBaseUrl?: string; + /** + * The default basemap to use for the portal. Used in the map viewer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#defaultBasemap) + */ defaultBasemap?: BasemapProperties; + /** + * The default extent to use for the portal. Used in the map viewer. The extent will be in the default basemap's spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#defaultExtent) + */ defaultExtent?: ExtentProperties; + /** + * The default vector basemap to use for the portal. Used in the map viewer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#defaultVectorBasemap) + */ defaultVectorBasemap?: BasemapProperties; + /** + * A description of the organization/portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#description) + */ description?: string; + /** + * The featured groups for the portal. Returns an array of objects that provide access to the owner and title for each featured group. Each item in this array has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#featuredGroups) + */ featuredGroups?: PortalFeaturedGroups[]; + /** + * The query that defines the featured group. If null, then the most viewed items in the organization will be the featured items. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#featuredItemsGroupQuery) + */ featuredItemsGroupQuery?: string; + /** + * The query that identifies the group containing features items for the gallery. Set a Group ID or, if null, then the most viewed items in your organization are displayed in the gallery. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#galleryTemplatesGroupQuery) + */ galleryTemplatesGroupQuery?: string; + /** + * Helper services provided by the portal. For the detailed information about these services, see the [about utility services](https://server.arcgis.com/en/portal/latest/administer/windows/about-utility-services.htm) topic from the ArcGIS Server documentation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#helperServices) + */ helperServices?: any; + /** + * The group that contains featured content to be displayed on the home page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#homePageFeaturedContent) + */ homePageFeaturedContent?: string; + /** + * The number of featured items that can be displayed on the home page. The max is 100. Accepts integers only. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#homePageFeaturedContentCount) + */ homePageFeaturedContentCount?: number; + /** + * The port used by the portal for HTTP communication. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#httpPort) + */ httpPort?: number; + /** + * The port used by the portal for HTTPS communication. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#httpsPort) + */ httpsPort?: number; + /** + * The id of the organization that owns this portal. If `null` then this is the default portal for anonymous and non-organizational users. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#id) + */ id?: string; + /** + * The country code of the calling IP (ArcGIS Online only). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#ipCntryCode) + */ ipCntryCode?: string; - isOrganization?: boolean; + /** + * Indicates if the portal is on-premises. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#isPortal) + */ isPortal?: boolean; + /** + * The query that identifies the group containing editing templates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#layerTemplatesGroupQuery) + */ layerTemplatesGroupQuery?: string; - loaded?: boolean; + /** + * The maximum validity in minutes of tokens issued for users of the organization. -1 is the default and is a special value that indicates infinite timeout or permanent tokens. For tokens granted using OAuth 2.0 authorization grant, it represents the maximum validity of refresh tokens. For access tokens, the maximum validity is the lower of two weeks or this value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#maxTokenExpirationMinutes) + */ maxTokenExpirationMinutes?: number; + /** + * Date the organization was last modified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#modified) + */ modified?: DateProperties; + /** + * Name of the organization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#name) + */ name?: string; + /** + * URL of the portal host. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#portalHostname) + */ portalHostname?: string; + /** + * The portal mode. **Known Values:** multitenant | singletenant + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#portalMode) + */ portalMode?: string; + /** + * Properties specific to the organization, for example the "contact us" link. If the organization is public, the properties are visible to the anonymous user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#portalProperties) + */ portalProperties?: any; + /** + * The region for the organization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#region) + */ region?: string; - restUrl?: string; + /** + * Custom HTML for the home page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#rotatorPanels) + */ rotatorPanels?: any[]; + /** + * Indicates whether the description of your organization displays on the home page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#showHomePageDescription) + */ showHomePageDescription?: boolean; + /** + * Indicates whether hosted services are supported. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#supportsHostedServices) + * + * @default false + */ supportsHostedServices?: boolean; + /** + * The query that defines the symbols sets. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#symbolSetsGroupQuery) + */ symbolSetsGroupQuery?: string; + /** + * The query that defines the collection of templates that will appear in the template gallery. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#templatesGroupQuery) + */ templatesGroupQuery?: string; - thumbnailUrl?: string; + /** + * Sets the units of measure for the organization's users. The user default is derived from the organization's [region](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#region). **Known Values:** english | metric + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#units) + */ units?: string; + /** + * The URL to the portal instance. Setting the location of the portal instance via [esriConfig.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl) should be used in favor of setting it directly on this property. If using an on-premise portal, the syntax should look similar to: `https://www.example.com/arcgis` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#url) + * + * @default {@link module:esri/config#portalUrl esriConfig.portalUrl} + */ url?: string; + /** + * The prefix selected by the organization's administrator to be used with the customBaseURL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#urlKey) + */ urlKey?: string; + /** + * Information representing a registered user of the portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#user) + */ user?: PortalUserProperties; + /** + * When `true`, only simple where clauses that are compliant with SQL92 can be used when querying layers and tables. The recommended security setting is true. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#useStandardizedQuery) + */ useStandardizedQuery?: boolean; + /** + * When `true`, the organization has opted in to use the vector tile basemaps, and (a) [vectorBasemapGalleryGroupQuery](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#vectorBasemapGalleryGroupQuery) should be used instead of [basemapGalleryGroupQuery](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#basemapGalleryGroupQuery), while (b) [defaultVectorBasemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#defaultVectorBasemap) should be used instead of [defaultBasemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#defaultBasemap). The [fetchBasemaps()](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#fetchBasemaps) method automatically uses vectorBasemapGalleryGroupQuery. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#useVectorBasemaps) + */ useVectorBasemaps?: boolean; + /** + * The query that defines the vector tiles basemaps that should be displayed in the [BasemapGallery](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html) when [useVectorBasemaps](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#useVectorBasemaps) is true. The [fetchBasemaps()](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#fetchBasemaps) method does this automatically. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#vectorBasemapGalleryGroupQuery) + */ vectorBasemapGalleryGroupQuery?: string; } - export interface PortalFeaturedGroups { + + export interface PortalFeaturedGroups extends Object { + /** + * Name of the group owner. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#featuredGroups) + */ owner: string; + /** + * Group title. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html#featuredGroups) + */ title: string; } interface PortalFolder extends Accessor { + /** + * The date the folder was created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalFolder.html#created) + */ created: Date; + /** + * The unique id of the folder. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalFolder.html#id) + */ id: string; + /** + * The portal associated with the folder. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalFolder.html#portal) + */ portal: Portal; + /** + * The title of the folder. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalFolder.html#title) + */ title: string; - url: string; + /** + * The URL to the folder. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalFolder.html#url) + */ + readonly url: string; } interface PortalFolderConstructor { + + new(properties?: PortalFolderProperties): PortalFolder; } export const PortalFolder: PortalFolderConstructor; interface PortalFolderProperties { + /** + * The date the folder was created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalFolder.html#created) + */ created?: DateProperties; + /** + * The unique id of the folder. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalFolder.html#id) + */ id?: string; + /** + * The portal associated with the folder. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalFolder.html#portal) + */ portal?: PortalProperties; + /** + * The title of the folder. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalFolder.html#title) + */ title?: string; - url?: string; } interface PortalGroup extends Accessor { + /** + * The access privileges on the group which determines who can see and access the group. **Known Values:** private | org | public + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#access) + */ access: string; + /** + * The date the group was created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#created) + */ created: Date; + /** + * A detailed description of the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#description) + */ description: string; + /** + * The unique id for the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#id) + */ id: string; + /** + * If set to `true`, then users will not be able to apply to join the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#isInvitationOnly) + * + * @default false + */ isInvitationOnly: boolean; + /** + * The date the group was last modified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#modified) + */ modified: Date; + /** + * The username of the group's owner. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#owner) + */ owner: string; + /** + * The portal associated with the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#portal) + */ portal: Portal; + /** + * A short summary that describes the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#snippet) + */ snippet: string; + /** + * User defined tags that describe the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#tags) + */ tags: string[]; - thumbnailUrl: string; + /** + * The URL to the thumbnail used for the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#thumbnailUrl) + */ + readonly thumbnailUrl: string; + /** + * The title of the group. This is the name that is displayed to users. It is also used to refer to the group. Every group must have a title and it must be unique. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#title) + */ title: string; - url: string; + /** + * The URL to the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#url) + */ + readonly url: string; + /** + * Fetches the current members of the group. This method is only available to members or administrators of the group. View the ArcGIS Portal API REST documentation for the [Group Users](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Group_Users/02r30000006p000000/) for more details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#fetchMembers) + * + * + */ fetchMembers(): IPromise; + /** + * Get the URL to the thumbnail image for the group. Available width sizes: 150, 300 and 600. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#getThumbnailUrl) + * + * @param width The desired image width. + * + */ getThumbnailUrl(width?: number): string; - queryItems(queryParams?: PortalQueryParams): IPromise; + /** + * Executes a query against the group to return an array of [PortalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html) objects that match the input query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#queryItems) + * + * @param queryParams The input query parameters defined in [PortalQueryParams](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html). + * + */ + queryItems(queryParams?: PortalQueryParams | PortalQueryParamsProperties): IPromise; } interface PortalGroupConstructor { + + new(properties?: PortalGroupProperties): PortalGroup; } export const PortalGroup: PortalGroupConstructor; interface PortalGroupProperties { + /** + * The access privileges on the group which determines who can see and access the group. **Known Values:** private | org | public + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#access) + */ access?: string; + /** + * The date the group was created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#created) + */ created?: DateProperties; + /** + * A detailed description of the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#description) + */ description?: string; + /** + * The unique id for the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#id) + */ id?: string; + /** + * If set to `true`, then users will not be able to apply to join the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#isInvitationOnly) + * + * @default false + */ isInvitationOnly?: boolean; + /** + * The date the group was last modified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#modified) + */ modified?: DateProperties; + /** + * The username of the group's owner. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#owner) + */ owner?: string; + /** + * The portal associated with the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#portal) + */ portal?: PortalProperties; + /** + * A short summary that describes the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#snippet) + */ snippet?: string; + /** + * User defined tags that describe the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#tags) + */ tags?: string[]; - thumbnailUrl?: string; + /** + * The title of the group. This is the name that is displayed to users. It is also used to refer to the group. Every group must have a title and it must be unique. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalGroup.html#title) + */ title?: string; - url?: string; } interface PortalItem extends Accessor, Loadable, JSONSupport { + /** + * Indicates the level of access to this item: `private`, `shared`, `org`, or `public`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#access) + */ access: string; + /** + * Information on the source of the item and its copyright status. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#accessInformation) + */ accessInformation: string; + /** + * Average rating. Uses a weighted average called "Bayesian average." + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#avgRating) + */ avgRating: number; + /** + * The date the item was created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#created) + */ created: Date; + /** + * The item's locale information (language and country). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#culture) + */ culture: string; + /** + * The detailed description of the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#description) + */ description: string; + /** + * The geographic extent, or bounding rectangle, of the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#extent) + */ extent: Extent; + /** + * The unique id for the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#id) + */ id: string; - isLayer: boolean; - itemControl: string; - itemUrl: string; + /** + * Indicates whether a layer can be created from this item using [Layer.fromPortalItem()](esri-layers-Layer.html#fromPortalItem). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#isLayer) + */ + readonly isLayer: boolean; + /** + * Indicates whether an item can be updated and deleted. + * + * Possible Value | Description + * ---------------|------------ + * admin | The item can be updated or deleted. + * update | The item can be updated, but not deleted. + * null | The item cannot be updated nor deleted. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#itemControl) + */ + readonly itemControl: string; + /** + * The URL to the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#itemUrl) + */ + readonly itemUrl: string; + /** + * Information on license or restrictions related to the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#licenseInfo) + */ licenseInfo: string; - loaded: boolean; + /** + * Indicates whether the item's resources have loaded from the portal. When `true`, all the properties of the object can be accessed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#loaded) + * + * @default false + */ + readonly loaded: boolean; + /** + * The date the item was last modified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#modified) + */ modified: Date; + /** + * The name of the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#name) + */ name: string; + /** + * Number of comments on the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#numComments) + */ numComments: number; + /** + * Number of ratings on the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#numRatings) + */ numRatings: number; + /** + * Number of views on the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#numViews) + */ numViews: number; + /** + * The username of the user who owns this item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#owner) + */ owner: string; + /** + * The portal that contains the item. Defaults to the value in [config.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl) (e.g. https://www.arcgis.com). Suggested to use [config.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl) instead of this property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#portal) + */ portal: Portal; + /** + * The size of the item (in bytes). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#size) + */ size: number; + /** + * A summary description of the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#snippet) + */ snippet: string; + /** + * User defined tags that describe the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#tags) + */ tags: string[]; - thumbnailUrl: string; + /** + * The URL to the thumbnail used for the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#thumbnailUrl) + */ + readonly thumbnailUrl: string; + /** + * The title for the item. This is the name that is displayed to users and used to refer to the item. Every item must have a title. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#title) + */ title: string; + /** + * The GIS content type of this item. Example types include Web Map, Map Service, Shapefile, and Web Mapping Application. See the [ArcGIS REST API Items and Items Types Reference](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Items_and_item_types/02r3000000ms000000/) to get an understanding of the item type hierarchy. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#type) + */ type: string; + /** + * Type keywords that describe the type of content of this item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#typeKeywords) + */ typeKeywords: string[]; + /** + * The service URL of this item. Only certain layer item types such as "Feature Service", "Map Service", "Image Service", "Scene Service", "WMS" and "KML" have service URLs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#url) + */ url: string; + /** + * Adds a rating to an accessible item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#addRating) + * + * @param rating Rating to set for the item. Rating must be a number between 1.0 and 5.0. + * + */ addRating(rating: number | PortalRating): IPromise; + /** + * Deletes a rating for the specified item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#deleteRating) + * + * + */ deleteRating(): IPromise; + /** + * Requests a PortalItem in the format specified in `responseType`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#fetchData) + * + * @param responseType The format of the response. **Known Values:** json | xml | text | blob | array-buffer | document + * + */ fetchData(responseType?: string): IPromise; + /** + * Returns the rating (if any) given to the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#fetchRating) + * + * + */ fetchRating(): IPromise; + /** + * Gets all the related items of a certain relationship type for the portal item. An optional direction can be specified if the direction of the relationship is ambiguous. Otherwise, the service will try to infer it. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#fetchRelatedItems) + * + * @param params See the object specifications table below for the parameters that may be passed as properties in this object. + * @param params.relationshipType The type of relationship between the two items. See [Relationship types](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000mm000000) for a complete listing of types. + * @param params.direction The direction of the relationship. Can either be `forward` (from origin to destination) or `reverse` (from destination to origin). **Possible Values:** forward | reverse + * + */ fetchRelatedItems(params: PortalItemFetchRelatedItemsParams): IPromise; + /** + * Get the URL to the thumbnail image for the item. Available width sizes: 200, 400, 800 and 2400. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#getThumbnailUrl) + * + * @param width The desired image width. + * + */ getThumbnailUrl(width?: number): string; + /** + * Updates the item's properties to the portal, and optionally its data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#update) + * + * @param params See the object specifications table below for the parameters that may be passed as properties in this object. + * @param params.data **Optional**. The component used to stream the data represented by the item to the client. + * + */ update(params?: PortalItemUpdateParams): IPromise; + /** + * Updates the item's thumbnail on the portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#updateThumbnail) + * + * @param params See the object specification table below for the parameters that may be passed as properties in this object. + * @param params.thumbnail A URL, Data URI, Blob, or File. The accepted formats are `GIF`, `JPG`, and `PNG`. + * + */ updateThumbnail(params: PortalItemUpdateThumbnailParams): IPromise; } interface PortalItemConstructor { + + new(properties?: PortalItemProperties): PortalItem; fromJSON(json: any): PortalItem; @@ -3768,198 +14510,896 @@ declare namespace __esri { export const PortalItem: PortalItemConstructor; interface PortalItemProperties extends LoadableProperties { + /** + * Indicates the level of access to this item: `private`, `shared`, `org`, or `public`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#access) + */ access?: string; + /** + * Information on the source of the item and its copyright status. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#accessInformation) + */ accessInformation?: string; + /** + * Average rating. Uses a weighted average called "Bayesian average." + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#avgRating) + */ avgRating?: number; + /** + * The date the item was created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#created) + */ created?: DateProperties; + /** + * The item's locale information (language and country). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#culture) + */ culture?: string; + /** + * The detailed description of the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#description) + */ description?: string; + /** + * The geographic extent, or bounding rectangle, of the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#extent) + */ extent?: ExtentProperties; + /** + * The unique id for the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#id) + */ id?: string; - isLayer?: boolean; - itemControl?: string; - itemUrl?: string; + /** + * Information on license or restrictions related to the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#licenseInfo) + */ licenseInfo?: string; - loaded?: boolean; + /** + * The date the item was last modified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#modified) + */ modified?: DateProperties; + /** + * The name of the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#name) + */ name?: string; + /** + * Number of comments on the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#numComments) + */ numComments?: number; + /** + * Number of ratings on the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#numRatings) + */ numRatings?: number; + /** + * Number of views on the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#numViews) + */ numViews?: number; + /** + * The username of the user who owns this item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#owner) + */ owner?: string; + /** + * The portal that contains the item. Defaults to the value in [config.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl) (e.g. https://www.arcgis.com). Suggested to use [config.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl) instead of this property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#portal) + */ portal?: PortalProperties; + /** + * The size of the item (in bytes). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#size) + */ size?: number; + /** + * A summary description of the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#snippet) + */ snippet?: string; + /** + * User defined tags that describe the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#tags) + */ tags?: string[]; - thumbnailUrl?: string; + /** + * The title for the item. This is the name that is displayed to users and used to refer to the item. Every item must have a title. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#title) + */ title?: string; + /** + * The GIS content type of this item. Example types include Web Map, Map Service, Shapefile, and Web Mapping Application. See the [ArcGIS REST API Items and Items Types Reference](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Items_and_item_types/02r3000000ms000000/) to get an understanding of the item type hierarchy. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#type) + */ type?: string; + /** + * Type keywords that describe the type of content of this item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#typeKeywords) + */ typeKeywords?: string[]; + /** + * The service URL of this item. Only certain layer item types such as "Feature Service", "Map Service", "Image Service", "Scene Service", "WMS" and "KML" have service URLs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#url) + */ url?: string; } - export interface PortalItemFetchRelatedItemsParams { + + export interface PortalItemFetchRelatedItemsParams extends Object { + /** + * The type of relationship between the two items. See [Relationship types](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000mm000000) for a complete listing of types. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#fetchRelatedItems) + */ relationshipType: string; + /** + * The direction of the relationship. Can either be `forward` (from origin to destination) or `reverse` (from destination to origin). **Possible Values:** forward | reverse + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#fetchRelatedItems) + */ direction?: string; } - export interface PortalItemUpdateParams { + + export interface PortalItemUpdateParams extends Object { + /** + * **Optional**. The component used to stream the data represented by the item to the client. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#update) + */ data: string | any; } - export interface PortalItemUpdateThumbnailParams { + + export interface PortalItemUpdateThumbnailParams extends Object { + /** + * A URL, Data URI, Blob, or File. The accepted formats are `GIF`, `JPG`, and `PNG`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#updateThumbnail) + */ thumbnail: Blob | string; } interface PortalQueryParams extends Accessor { + /** + * Only relevant when querying for [PortalItems](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html). When specified, restricts the results of the query to the extent defined here. The [spatial reference](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#spatialReference) of the given extent must be WGS84 (wkid 4326) or Web Mercator (wkid 3857). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#extent) + */ extent: Extent; + /** + * The maximum number of results to be included in the [result](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryResult.html#results) set response. The maximum value allowed is `100`. The [start](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#start) property combined with the `num` property can be used to paginate the search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#num) + * + * @default 10 + */ num: number; + /** + * The query string used for the search. View the [ArcGIS REST API Search Reference](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000mn000000) for details on constructing a valid query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#query) + */ query: string; + /** + * A comma-delimited list of fields to sort. Field names may vary depending on what is being queried. For example, the fields allowed for a user query are much more limited than if performing a basic search query for portal items. A list of possible field names is listed below. These names correspond to either item (search), group, and/or user queries. + * + * Field name | Query functionality + * ---------------|------------ + * title | search, group + * uploaded | search + * modified | search + * username | user + * created | user, group + * type | search + * owner | search, group + * avg-rating | search + * num-ratings | search + * num-comments | search + * num-views | search + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#sortField) + */ sortField: string; + /** + * The order in which to sort the results. + * + * Possible Value | Description + * ---------------|------------ + * asc | Sort the results in ascending order. + * desc | Sort the results in descending order. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#sortOrder) + * + * @default asc + */ sortOrder: string; + /** + * The index of the first entry in the result set response. The index is 1-based. The [start](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#start) property, along with the [num](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#num) property can be used to paginate the search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#start) + * + * @default 1 + */ start: number; + /** + * Creates a deep clone of the instance of PortalQueryParams that calls this method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#clone) + * + * + */ clone(): PortalQueryParams; } interface PortalQueryParamsConstructor { + + new(properties?: PortalQueryParamsProperties): PortalQueryParams; } export const PortalQueryParams: PortalQueryParamsConstructor; interface PortalQueryParamsProperties { + /** + * Only relevant when querying for [PortalItems](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html). When specified, restricts the results of the query to the extent defined here. The [spatial reference](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#spatialReference) of the given extent must be WGS84 (wkid 4326) or Web Mercator (wkid 3857). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#extent) + */ extent?: ExtentProperties; + /** + * The maximum number of results to be included in the [result](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryResult.html#results) set response. The maximum value allowed is `100`. The [start](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#start) property combined with the `num` property can be used to paginate the search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#num) + * + * @default 10 + */ num?: number; + /** + * The query string used for the search. View the [ArcGIS REST API Search Reference](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000mn000000) for details on constructing a valid query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#query) + */ query?: string; + /** + * A comma-delimited list of fields to sort. Field names may vary depending on what is being queried. For example, the fields allowed for a user query are much more limited than if performing a basic search query for portal items. A list of possible field names is listed below. These names correspond to either item (search), group, and/or user queries. + * + * Field name | Query functionality + * ---------------|------------ + * title | search, group + * uploaded | search + * modified | search + * username | user + * created | user, group + * type | search + * owner | search, group + * avg-rating | search + * num-ratings | search + * num-comments | search + * num-views | search + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#sortField) + */ sortField?: string; + /** + * The order in which to sort the results. + * + * Possible Value | Description + * ---------------|------------ + * asc | Sort the results in ascending order. + * desc | Sort the results in descending order. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#sortOrder) + * + * @default asc + */ sortOrder?: string; + /** + * The index of the first entry in the result set response. The index is 1-based. The [start](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#start) property, along with the [num](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#num) property can be used to paginate the search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html#start) + * + * @default 1 + */ start?: number; } interface PortalQueryResult extends Accessor { + /** + * The query parameters for the next set of results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryResult.html#nextQueryParams) + */ nextQueryParams: PortalQueryParams; + /** + * The query parameters for the first set of results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryResult.html#queryParams) + */ queryParams: PortalQueryParams; + /** + * An array of result item objects. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryResult.html#results) + */ results: any[]; + /** + * The total number of results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryResult.html#total) + */ total: number; } interface PortalQueryResultConstructor { + + new(properties?: PortalQueryResultProperties): PortalQueryResult; } export const PortalQueryResult: PortalQueryResultConstructor; interface PortalQueryResultProperties { + /** + * The query parameters for the next set of results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryResult.html#nextQueryParams) + */ nextQueryParams?: PortalQueryParamsProperties; + /** + * The query parameters for the first set of results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryResult.html#queryParams) + */ queryParams?: PortalQueryParamsProperties; + /** + * An array of result item objects. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryResult.html#results) + */ results?: any[]; + /** + * The total number of results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryResult.html#total) + */ total?: number; } interface PortalRating extends Accessor { + /** + * Date the rating was added to the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalRating.html#created) + */ created: Date; + /** + * A rating between 1.0 and 5.0 for the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalRating.html#rating) + */ rating: number; } interface PortalRatingConstructor { + + new(properties?: PortalRatingProperties): PortalRating; } export const PortalRating: PortalRatingConstructor; interface PortalRatingProperties { + /** + * Date the rating was added to the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalRating.html#created) + */ created?: DateProperties; + /** + * A rating between 1.0 and 5.0 for the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalRating.html#rating) + */ rating?: number; } interface PortalUser extends Accessor { + /** + * Indicates the level of access of the user. If private, the user descriptive information will not be available to others nor will the username be searchable. **Known Values:** private | org | public + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#access) + */ access: string; + /** + * The date the user was created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#created) + */ created: Date; + /** + * The culture information for the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#culture) + */ culture: string; + /** + * A description of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#description) + */ description: string; + /** + * The user's e-mail address. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#email) + */ email: string; + /** + * The user's full name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#fullName) + */ fullName: string; + /** + * The date the user was last modified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#modified) + */ modified: Date; + /** + * The ID of the organization the user belongs to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#orgId) + */ orgId: string; + /** + * The portal associated with the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#portal) + */ portal: Portal; + /** + * The user's preferred view for content, either web or GIS. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#preferredView) + */ preferredView: string; + /** + * The user preferred region, used to set the featured maps on the home page, content in the gallery, and the default extent of new maps in the Viewer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#region) + */ region: string; + /** + * Defines the user's role in the organization. See [roleId](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#roleId) for more details about when user has a custom role. **Known Values:** org_admin | org_publisher | org_user + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#role) + */ role: string; + /** + * The ID of the user's role. Only set if the user is assigned a custom role. When present, the [role](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#role) will indicate the "base" role of the custom role based on the privileges the custom role contains. For example, if the custom role contains some publisher privileges, the [role](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#role) will be set to `org_publisher`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#roleId) + */ roleId: string; - thumbnailUrl: string; + /** + * The URL to the thumbnail image for the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#thumbnailUrl) + */ + readonly thumbnailUrl: string; + /** + * The user's personal units of measure setting. **Known Values:** english | metric + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#units) + */ units: string; - userContentUrl: string; + /** + * The URL for the user's content. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#userContentUrl) + */ + readonly userContentUrl: string; + /** + * The username of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#username) + */ username: string; + /** + * Adds an item to the user's portal content. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#addItem) + * + * @param params See the object specifications table below for the parameters that may be passed as properties in this object. + * @param params.item The item to add to the user's content. + * @param params.data The component used to stream the data represented by the item to the client. + * @param params.folder The portal folder in which to store the item. + * + */ addItem(params: PortalUserAddItemParams): IPromise; + /** + * Deletes an item from the user's portal content. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#deleteItem) + * + * @param item The portal item to remove. + * + */ deleteItem(item: PortalItem): IPromise; + /** + * Fetches all of the user's folders used to organize portal content. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#fetchFolders) + * + * + */ fetchFolders(): IPromise; + /** + * Fetches all the groups that the portal user has permission to access. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#fetchGroups) + * + * + */ fetchGroups(): IPromise; - fetchItems(params: PortalUserFetchItemsParams): IPromise; + /** + * Retrieves all the items in the specified folder. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#fetchItems) + * + * @param params See the object specifications table below for the parameters that may be passed as properties in this object. + * @param params.folder The folder to retrieve items from. + * @param params.num The maximum number of results to be included in the result set response. The maximum value allowed is 100. The start property combined with the num property can be used to paginate the search results. + * @param params.start The index of the first entry in the result set response. The index is 1-based. + * + */ + fetchItems(params?: PortalUserFetchItemsParams): IPromise; + /** + * Get the URL to the thumbnail image for the user. Available width sizes: 150, 300 and 600. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#getThumbnailUrl) + * + * @param width The desired image width. + * + */ getThumbnailUrl(width?: number): string; + /** + * Executes a query against the user's favorite group to return an array of [PortalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html) objects that match the input query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#queryFavorites) + * + * @param queryParams The input query parameters defined in [PortalQueryParams](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalQueryParams.html). This object may be [autocast](https://developers.arcgis.com/javascript/latest/guide/autocasting/). + * + */ queryFavorites(queryParams?: PortalQueryParams): IPromise; } interface PortalUserConstructor { + + new(properties?: PortalUserProperties): PortalUser; } export const PortalUser: PortalUserConstructor; interface PortalUserProperties { + /** + * Indicates the level of access of the user. If private, the user descriptive information will not be available to others nor will the username be searchable. **Known Values:** private | org | public + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#access) + */ access?: string; + /** + * The date the user was created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#created) + */ created?: DateProperties; + /** + * The culture information for the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#culture) + */ culture?: string; + /** + * A description of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#description) + */ description?: string; + /** + * The user's e-mail address. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#email) + */ email?: string; + /** + * The user's full name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#fullName) + */ fullName?: string; + /** + * The date the user was last modified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#modified) + */ modified?: DateProperties; + /** + * The ID of the organization the user belongs to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#orgId) + */ orgId?: string; + /** + * The portal associated with the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#portal) + */ portal?: PortalProperties; + /** + * The user's preferred view for content, either web or GIS. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#preferredView) + */ preferredView?: string; + /** + * The user preferred region, used to set the featured maps on the home page, content in the gallery, and the default extent of new maps in the Viewer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#region) + */ region?: string; + /** + * Defines the user's role in the organization. See [roleId](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#roleId) for more details about when user has a custom role. **Known Values:** org_admin | org_publisher | org_user + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#role) + */ role?: string; + /** + * The ID of the user's role. Only set if the user is assigned a custom role. When present, the [role](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#role) will indicate the "base" role of the custom role based on the privileges the custom role contains. For example, if the custom role contains some publisher privileges, the [role](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#role) will be set to `org_publisher`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#roleId) + */ roleId?: string; - thumbnailUrl?: string; + /** + * The user's personal units of measure setting. **Known Values:** english | metric + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#units) + */ units?: string; - userContentUrl?: string; + /** + * The username of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#username) + */ username?: string; } - export interface PortalUserAddItemParams { + + export interface PortalUserAddItemParams extends Object { + /** + * The item to add to the user's content. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#addItem) + */ item: PortalItem; + /** + * The component used to stream the data represented by the item to the client. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#addItem) + */ data?: string | any; + /** + * The portal folder in which to store the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#addItem) + */ folder?: PortalFolder; } - export interface PortalUserFetchItemsParams { - folder: PortalFolder; - num: number; - start: number; + + export interface PortalUserFetchItemsParams extends Object { + /** + * The folder to retrieve items from. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#fetchItems) + */ + folder?: PortalFolder; + /** + * The maximum number of results to be included in the result set response. The maximum value allowed is 100. The start property combined with the num property can be used to paginate the search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#fetchItems) + * + * @default 10 + */ + num?: number; + /** + * The index of the first entry in the result set response. The index is 1-based. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#fetchItems) + * + * @default 1 + */ + start?: number; } interface ClassBreaksRenderer extends Renderer, VisualVariablesMixin { + /** + * When symbolizing polygon features with graduated symbols, set a [FillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol.html) on this property to visualize the boundaries of each feature. Use a [FillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol.html) of varying sizes in the [classBreakInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classBreakInfos) to indicate the quantity. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#backgroundFillSymbol) + */ backgroundFillSymbol: FillSymbol; + /** + * Each element in the array is an object that provides information about a class break associated with the renderer. Each object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classBreakInfos) + */ classBreakInfos: ClassBreaksRendererClassBreakInfos[]; + /** + * The classification method used to generate class breaks if the renderer was generated with either of the two following methods: + * * [colorRendererCreator.createClassBreaksRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + * * [sizeRendererCreator.createClassBreaksRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + * + * + * **Known Values:** equal-interval | natural-breaks | quantile | standard-deviation + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classificationMethod) + */ + classificationMethod: string; + /** + * The default symbol assigned to features with a value not matched to a given break. If `null`, unmatched features will not be assigned a symbol. + * > **Known Limitations** SceneLayers with a `mesh` [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#geometryType) will display unmatching features with a generic symbol even if the `defaultSymbol` is `null`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#defaultSymbol) + */ defaultSymbol: Symbol; + /** + * The name of the attribute field the renderer uses to render data. A function may also be used to return a numeric value if the data does not already explicitly exist in a field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#field) + */ field: string | Function; + /** + * If `true`, graphics with attribute values equal to the max value of a class will be included in that class. Set this property to `false` if the desired behavior is to make a class include values less than, but not equal to the max value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#isMaxInclusive) + * + * @default true + */ isMaxInclusive: boolean; + /** + * An object providing options for displaying the renderer in the Legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#legendOptions) + */ legendOptions: ClassBreaksRendererLegendOptions; + /** + * When [normalizationType](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationType) is `field`, this property contains the attribute field name used for normalization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationField) + */ normalizationField: string; + /** + * When [normalizationType](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationType) is `percent-of-total`, this property contains the total of all data values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationTotal) + */ normalizationTotal: number; + /** + * Indicates how the data is normalized. If this property is defined, then the class breaks contain a normalized min/max value instead of the value in the given [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#field). The data value obtained from the field is normalized in one of the following ways before it is compared with the class breaks. See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------ + * field | Divides the data value using the attribute value of the field specified in the [normalizationField](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationField) property. This value is set by default if the [normalizationField](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationField) is provided. + * log | Computes the base 10 logarithm of the data value. This can be a useful approach for some data distributions because it reduces the influence of very large data values. + * percent-of-total | Divides the data value by the sum of all data values then multiplies by 100. Use [normalizationTotal](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationTotal) to define the total value by which to normalize. This value is set by default if the [normalizationTotal](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationTotal) is provided. + * + * With the exception of `log` normalization, data normalization creates a ratio by dividing two values. When comparing attribute values between features, normalization minimizes the effect of varying map areas and the number of observations. For example, dividing the 18 to 30 year old population by the area of a polygon feature yields a density value that can be compared evenly with other features, regardless of their size. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationType) + */ normalizationType: string; - type: string; + /** + * The type of renderer. For ClassBreaksRenderer this value is always `class-breaks`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#type) + */ + readonly type: "class-breaks"; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. This property is typically used as an alternative to [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#field) for data-driven visualizations. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#valueExpression) + */ valueExpression: string; + /** + * The title identifying and describing the associated [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression as defined in the [valueExpression](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#valueExpression) property. This is displayed as the title of the corresponding renderer in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) in the absence of a provided `title` in the [legendOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#legendOptions) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#valueExpressionTitle) + */ valueExpressionTitle: string; + /** + * Adds a class break to the renderer. You can provide the minimum, maximum and symbol values as individual arguments or by using the info object. The range of the break is greater than or equal to the minimum value and less than the maximum value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#addClassBreakInfo) + * + * @param min The minimum value to use in the break. This can be a number or an info object as defined in [classBreakInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classBreakInfos). + * @param max The maximum value to use in the break. + * @param symbol Symbol to use for the break. + * + */ addClassBreakInfo(min: number | any, max: number, symbol: Symbol): void; + /** + * Creates a deep clone of the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#clone) + * + * + */ clone(): ClassBreaksRenderer; + /** + * Returns the [classBreakInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classBreakInfos) information (as defined by the renderer) associated with the given graphic. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#getClassBreakInfo) + * + * @param graphic The graphic whose rendering information will be returned. + * + */ getClassBreakInfo(graphic: Graphic): any; + /** + * Removes a break from the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#removeClassBreakInfo) + * + * @param min Minimum value in the break to remove + * @param max Maximum value in the break to remove. + * + */ removeClassBreakInfo(min: number, max: number): void; } interface ClassBreaksRendererConstructor { + /** + * ClassBreaksRenderer defines the symbol of each feature in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) based on the value of a numeric attribute. Symbols are assigned based on classes or ranges of data. Each feature is assigned a symbol based on the class break in which the value of the attribute falls. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html) + */ + new(properties?: ClassBreaksRendererProperties): ClassBreaksRenderer; fromJSON(json: any): ClassBreaksRenderer; @@ -3968,41 +15408,185 @@ declare namespace __esri { export const ClassBreaksRenderer: ClassBreaksRendererConstructor; interface ClassBreaksRendererProperties extends RendererProperties, VisualVariablesMixinProperties { + /** + * When symbolizing polygon features with graduated symbols, set a [FillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol.html) on this property to visualize the boundaries of each feature. Use a [FillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol.html) of varying sizes in the [classBreakInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classBreakInfos) to indicate the quantity. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#backgroundFillSymbol) + */ backgroundFillSymbol?: FillSymbolProperties; + /** + * Each element in the array is an object that provides information about a class break associated with the renderer. Each object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classBreakInfos) + */ classBreakInfos?: ClassBreaksRendererClassBreakInfos[]; + /** + * The classification method used to generate class breaks if the renderer was generated with either of the two following methods: + * * [colorRendererCreator.createClassBreaksRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + * * [sizeRendererCreator.createClassBreaksRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + * + * + * **Known Values:** equal-interval | natural-breaks | quantile | standard-deviation + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classificationMethod) + */ + classificationMethod?: string; + /** + * The default symbol assigned to features with a value not matched to a given break. If `null`, unmatched features will not be assigned a symbol. + * > **Known Limitations** SceneLayers with a `mesh` [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#geometryType) will display unmatching features with a generic symbol even if the `defaultSymbol` is `null`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#defaultSymbol) + */ defaultSymbol?: SymbolProperties; + /** + * The name of the attribute field the renderer uses to render data. A function may also be used to return a numeric value if the data does not already explicitly exist in a field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#field) + */ field?: string | Function; + /** + * If `true`, graphics with attribute values equal to the max value of a class will be included in that class. Set this property to `false` if the desired behavior is to make a class include values less than, but not equal to the max value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#isMaxInclusive) + * + * @default true + */ isMaxInclusive?: boolean; + /** + * An object providing options for displaying the renderer in the Legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#legendOptions) + */ legendOptions?: ClassBreaksRendererLegendOptions; + /** + * When [normalizationType](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationType) is `field`, this property contains the attribute field name used for normalization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationField) + */ normalizationField?: string; + /** + * When [normalizationType](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationType) is `percent-of-total`, this property contains the total of all data values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationTotal) + */ normalizationTotal?: number; + /** + * Indicates how the data is normalized. If this property is defined, then the class breaks contain a normalized min/max value instead of the value in the given [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#field). The data value obtained from the field is normalized in one of the following ways before it is compared with the class breaks. See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------ + * field | Divides the data value using the attribute value of the field specified in the [normalizationField](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationField) property. This value is set by default if the [normalizationField](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationField) is provided. + * log | Computes the base 10 logarithm of the data value. This can be a useful approach for some data distributions because it reduces the influence of very large data values. + * percent-of-total | Divides the data value by the sum of all data values then multiplies by 100. Use [normalizationTotal](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationTotal) to define the total value by which to normalize. This value is set by default if the [normalizationTotal](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationTotal) is provided. + * + * With the exception of `log` normalization, data normalization creates a ratio by dividing two values. When comparing attribute values between features, normalization minimizes the effect of varying map areas and the number of observations. For example, dividing the 18 to 30 year old population by the area of a polygon feature yields a density value that can be compared evenly with other features, regardless of their size. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#normalizationType) + */ normalizationType?: string; - type?: string; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. This property is typically used as an alternative to [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#field) for data-driven visualizations. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#valueExpression) + */ valueExpression?: string; + /** + * The title identifying and describing the associated [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression as defined in the [valueExpression](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#valueExpression) property. This is displayed as the title of the corresponding renderer in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) in the absence of a provided `title` in the [legendOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#legendOptions) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#valueExpressionTitle) + */ valueExpressionTitle?: string; } - export interface ClassBreaksRendererClassBreakInfos { + + export interface ClassBreaksRendererClassBreakInfos extends Object { + /** + * The minimum value of the break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classBreakInfos) + */ minValue: number; + /** + * The maximum value of the break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classBreakInfos) + */ maxValue: number; + /** + * The symbol used to style features whose values are between the `minValue` and `maxValue` of the break. This value may be autocast by specifying the symbol `type`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classBreakInfos) + */ symbol: Symbol; + /** + * The label used to describe features in the break in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#classBreakInfos) + */ label?: string; } - export interface ClassBreaksRendererLegendOptions { + + export interface ClassBreaksRendererLegendOptions extends Object { + /** + * Describes the variable driving the visualization. This is displayed as the title of the corresponding renderer in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) and takes precedence over a [field alias](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#alias) or [valueExpressionTitle](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#valueExpressionTitle). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html#legendOptions) + */ title: string; } interface PointCloudClassBreaksRenderer extends PointCloudRenderer { + /** + * Each element in the array is an object that provides information about a class break associated with the renderer. Each object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#colorClassBreakInfos) + */ colorClassBreakInfos: PointCloudClassBreaksRendererColorClassBreakInfos[]; + /** + * The name of the field that is used to drive the color visualization for the renderer. The value of this field determines which class break each point is assigned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#field) + */ field: string; + /** + * A transform that is applied to the field value before evaluating the renderer. **Possible Values:** none | low-four-bit | high-four-bit | absolute-value | modulo-ten + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#fieldTransformType) + * + * @default null + */ fieldTransformType: string; - type: string; + /** + * An object providing options for displaying the renderer in the Legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#legendOptions) + */ + legendOptions: PointCloudClassBreaksRendererLegendOptions; + /** + * The type of renderer. For PointCloudClassBreaksRenderer this value is always `point-cloud-class-breaks`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#type) + */ + readonly type: "point-cloud-class-breaks"; + /** + * Creates a deep clone of the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#clone) + * + * + */ clone(): PointCloudClassBreaksRenderer; } interface PointCloudClassBreaksRendererConstructor { + /** + * This class defines the color of each point in a [PointCloudLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html) based on the value of a numeric attribute. Colors are assigned based on classes or ranges of data. Each point is assigned a symbol based on the class break in which the value of the attribute falls. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html) + */ + new(properties?: PointCloudClassBreaksRendererProperties): PointCloudClassBreaksRenderer; fromJSON(json: any): PointCloudClassBreaksRenderer; @@ -4011,28 +15595,107 @@ declare namespace __esri { export const PointCloudClassBreaksRenderer: PointCloudClassBreaksRendererConstructor; interface PointCloudClassBreaksRendererProperties extends PointCloudRendererProperties { + /** + * Each element in the array is an object that provides information about a class break associated with the renderer. Each object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#colorClassBreakInfos) + */ colorClassBreakInfos?: PointCloudClassBreaksRendererColorClassBreakInfos[]; + /** + * The name of the field that is used to drive the color visualization for the renderer. The value of this field determines which class break each point is assigned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#field) + */ field?: string; + /** + * A transform that is applied to the field value before evaluating the renderer. **Possible Values:** none | low-four-bit | high-four-bit | absolute-value | modulo-ten + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#fieldTransformType) + * + * @default null + */ fieldTransformType?: string; - type?: string; + /** + * An object providing options for displaying the renderer in the Legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#legendOptions) + */ + legendOptions?: PointCloudClassBreaksRendererLegendOptions; } - export interface PointCloudClassBreaksRendererColorClassBreakInfos { + + export interface PointCloudClassBreaksRendererColorClassBreakInfos extends Object { + /** + * The minimum value of the break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#colorClassBreakInfos) + */ minValue: number; + /** + * The maximum value of the break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#colorClassBreakInfos) + */ maxValue: number; + /** + * The color used to colorize the points where values are between the `minValue` and `maxValue` of the break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#colorClassBreakInfos) + */ color: Color; + /** + * The label used to describe point in the break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#colorClassBreakInfos) + */ label?: string; } + + export interface PointCloudClassBreaksRendererLegendOptions extends Object { + /** + * Describes the variable driving the visualization. This is displayed as the title of the corresponding renderer in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) and takes precedence over a [field alias](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#alias). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudClassBreaksRenderer.html#legendOptions) + */ + title?: string; + } + interface PointCloudRenderer extends Accessor, JSONSupport { + /** + * Reduces the brightness of the point's color, based on the value of another field, usually `intensity`. High values leave the color unchanged, while low values darken the color of the point. This helps to display the scanned surface in a more realistic way. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#colorModulation) + */ colorModulation: PointCloudRendererColorModulation; + /** + * Specifies how the size of the points in the point cloud is computed for rendering. The splat algorithm automatically computes a size based on the density, which varies with the Level of Detail that is currently displayed. The fixed size algorithm displays all points with the same size, either in screen space or real world units. When `pointSizeAlgorithm` is not set, the default is `splat`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#pointSizeAlgorithm) + */ pointSizeAlgorithm: PointCloudRendererPointSizeAlgorithm; + /** + * The number of points to draw per display inch. This property determines the level of detail in the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#pointsPerInch) + * + * @default 10 + */ pointsPerInch: number; + /** + * Creates a deep clone of the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#clone) + * + * + */ clone(): PointCloudRenderer; } interface PointCloudRendererConstructor { + + new(properties?: PointCloudRendererProperties): PointCloudRenderer; fromJSON(json: any): PointCloudRenderer; @@ -4041,33 +15704,121 @@ declare namespace __esri { export const PointCloudRenderer: PointCloudRendererConstructor; interface PointCloudRendererProperties { + /** + * Reduces the brightness of the point's color, based on the value of another field, usually `intensity`. High values leave the color unchanged, while low values darken the color of the point. This helps to display the scanned surface in a more realistic way. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#colorModulation) + */ colorModulation?: PointCloudRendererColorModulation; + /** + * Specifies how the size of the points in the point cloud is computed for rendering. The splat algorithm automatically computes a size based on the density, which varies with the Level of Detail that is currently displayed. The fixed size algorithm displays all points with the same size, either in screen space or real world units. When `pointSizeAlgorithm` is not set, the default is `splat`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#pointSizeAlgorithm) + */ pointSizeAlgorithm?: PointCloudRendererPointSizeAlgorithm; + /** + * The number of points to draw per display inch. This property determines the level of detail in the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#pointsPerInch) + * + * @default 10 + */ pointsPerInch?: number; } - export interface PointCloudRendererColorModulation { + + export interface PointCloudRendererColorModulation extends Object { + /** + * Field to use for the color modulation. Commonly modulation is used with the `intensity` field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#colorModulation) + */ field: string; + /** + * Field value at which the point color becomes darkest. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#colorModulation) + * + * @default 0 + */ minValue?: number; + /** + * Field value at which the point color will be left unchanged. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#colorModulation) + * + * @default 255 + */ maxValue?: number; } - export interface PointCloudRendererPointSizeAlgorithm { + + export interface PointCloudRendererPointSizeAlgorithm extends Object { + /** + * `fixed-size` or `splat`. Choosing `fixed-size` implies setting `size` and `useRealWorldSymbolSizes`. If `splat` is chosen then `scaleFactor` should be set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#pointSizeAlgorithm) + */ type: string; + /** + * Specifies whether `size` is in real world units or screen-space units. Applies to `fixed-size` only. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#pointSizeAlgorithm) + */ useRealWorldSymbolSizes?: boolean; + /** + * Point size in meters (`useRealWorldSymbolSizes = true`) or points. Applies to `fixed-size` only. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#pointSizeAlgorithm) + */ size?: number; + /** + * Specifies the scale factor that is applied to the size estimated by the density. Applies to `splat` only. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#pointSizeAlgorithm) + * + * @default 1 + */ scaleFactor?: number; + /** + * Minimum screen space size in points. Applies to `splat` only. **Deprecated since version 4.5** + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRenderer.html#pointSizeAlgorithm) + */ minSize?: number; } interface PointCloudRGBRenderer extends PointCloudRenderer { + /** + * The name of the field containing RGB values used to drive the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRGBRenderer.html#field) + */ field: string; - type: string; + /** + * The type of Renderer. For PointCloudRGBRenderer this value is always `point-cloud-rgb`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRGBRenderer.html#type) + */ + readonly type: "point-cloud-rgb"; + /** + * Creates a deep clone of the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRGBRenderer.html#clone) + * + * + */ clone(): PointCloudRGBRenderer; } interface PointCloudRGBRendererConstructor { + /** + * PointCloudRGBRenderer defines the color of each point in a [PointCloudLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html) based on the value of a color attribute. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRGBRenderer.html) + */ + new(properties?: PointCloudRGBRendererProperties): PointCloudRGBRenderer; fromJSON(json: any): PointCloudRGBRenderer; @@ -4076,20 +15827,65 @@ declare namespace __esri { export const PointCloudRGBRenderer: PointCloudRGBRendererConstructor; interface PointCloudRGBRendererProperties extends PointCloudRendererProperties { + /** + * The name of the field containing RGB values used to drive the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRGBRenderer.html#field) + */ field?: string; - type?: string; } interface PointCloudStretchRenderer extends PointCloudRenderer { + /** + * The name of the number field whose values are used to drive the continuous color visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#field) + */ field: string; + /** + * A transform that is applied to the field value before evaluating the renderer. **Possible Values:** none | low-four-bit | high-four-bit | absolute-value | modulo-ten + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#fieldTransformType) + * + * @default null + */ fieldTransformType: string; + /** + * An object providing options for displaying the renderer in the Legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#legendOptions) + */ + legendOptions: PointCloudStretchRendererLegendOptions; + /** + * An array of color value pairs. Points with values between the specified stops are colorized with linearly interpolated colors. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#stops) + */ stops: PointCloudStretchRendererStops[]; - type: string; + /** + * The type of Renderer. For PointCloudStretchRenderer this value is always `point-cloud-stretch`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#type) + */ + readonly type: "point-cloud-stretch"; + /** + * Creates a deep clone of the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#clone) + * + * + */ clone(): PointCloudStretchRenderer; } interface PointCloudStretchRendererConstructor { + /** + * PointCloudStretchRenderer defines the color of each point in a [PointCloudLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html) based on the value of a numeric attribute. It allows you to easily map continuous color ramps to minimum and maximum data values of one of the layer's numeric attribute fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html) + */ + new(properties?: PointCloudStretchRendererProperties): PointCloudStretchRenderer; fromJSON(json: any): PointCloudStretchRenderer; @@ -4098,28 +15894,117 @@ declare namespace __esri { export const PointCloudStretchRenderer: PointCloudStretchRendererConstructor; interface PointCloudStretchRendererProperties extends PointCloudRendererProperties { + /** + * The name of the number field whose values are used to drive the continuous color visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#field) + */ field?: string; + /** + * A transform that is applied to the field value before evaluating the renderer. **Possible Values:** none | low-four-bit | high-four-bit | absolute-value | modulo-ten + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#fieldTransformType) + * + * @default null + */ fieldTransformType?: string; + /** + * An object providing options for displaying the renderer in the Legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#legendOptions) + */ + legendOptions?: PointCloudStretchRendererLegendOptions; + /** + * An array of color value pairs. Points with values between the specified stops are colorized with linearly interpolated colors. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#stops) + */ stops?: PointCloudStretchRendererStops[]; - type?: string; } - export interface PointCloudStretchRendererStops { + + export interface PointCloudStretchRendererLegendOptions extends Object { + /** + * Describes the variable driving the visualization. This is displayed as the title of the corresponding renderer in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) and takes precedence over a [field alias](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#alias). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#legendOptions) + */ + title?: string; + } + + + export interface PointCloudStretchRendererStops extends Object { + /** + * The value for this stop. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#stops) + */ value: number; + /** + * The label for this stop. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#stops) + */ label?: string; + /** + * The color value for this stop. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html#stops) + */ color: Color; } interface PointCloudUniqueValueRenderer extends PointCloudRenderer { + /** + * Each element in the array is an object that matches a unique value with a specific color. Features with equal values to those specified here will be assigned the associated color. For example, you may choose to visualize points representing low vegetation with a green color and points representing power lines with a gray color. Each object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#colorUniqueValueInfos) + */ colorUniqueValueInfos: PointCloudUniqueValueRendererColorUniqueValueInfos[]; + /** + * The name of the field whose values are used to drive the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#field) + */ field: string; + /** + * A transform that is applied to the field value before evaluating the renderer. **Possible Values:** none | low-four-bit | high-four-bit | absolute-value | modulo-ten + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#fieldTransformType) + * + * @default null + */ fieldTransformType: string; - type: string; + /** + * An object providing options for displaying the renderer in the Legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#legendOptions) + */ + legendOptions: PointCloudUniqueValueRendererLegendOptions; + /** + * The type of Renderer. For PointCloudUniqueValueRenderer this value is always `point-cloud-unique-value`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#type) + */ + readonly type: "point-cloud-unique-value"; + /** + * Creates a deep clone of the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#clone) + * + * + */ clone(): PointCloudUniqueValueRenderer; } interface PointCloudUniqueValueRendererConstructor { + /** + * PointCloudUniqueValueRenderer allows you to colorize points in a [PointCloudLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html) based on an attribute value. This is done by assigning unique colors to represent points with equal attribute values. This renderer is used to visualize points of the same type, not interpolate colors along a continuous ramp mapped to numbers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html) + */ + new(properties?: PointCloudUniqueValueRendererProperties): PointCloudUniqueValueRenderer; fromJSON(json: any): PointCloudUniqueValueRenderer; @@ -4128,23 +16013,82 @@ declare namespace __esri { export const PointCloudUniqueValueRenderer: PointCloudUniqueValueRendererConstructor; interface PointCloudUniqueValueRendererProperties extends PointCloudRendererProperties { + /** + * Each element in the array is an object that matches a unique value with a specific color. Features with equal values to those specified here will be assigned the associated color. For example, you may choose to visualize points representing low vegetation with a green color and points representing power lines with a gray color. Each object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#colorUniqueValueInfos) + */ colorUniqueValueInfos?: PointCloudUniqueValueRendererColorUniqueValueInfos[]; + /** + * The name of the field whose values are used to drive the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#field) + */ field?: string; + /** + * A transform that is applied to the field value before evaluating the renderer. **Possible Values:** none | low-four-bit | high-four-bit | absolute-value | modulo-ten + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#fieldTransformType) + * + * @default null + */ fieldTransformType?: string; - type?: string; + /** + * An object providing options for displaying the renderer in the Legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#legendOptions) + */ + legendOptions?: PointCloudUniqueValueRendererLegendOptions; } - export interface PointCloudUniqueValueRendererColorUniqueValueInfos { - values: number[]; + + export interface PointCloudUniqueValueRendererColorUniqueValueInfos extends Object { + /** + * A unique combination of values that will be represented with the given `color`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#colorUniqueValueInfos) + */ + values: string[]; + /** + * The color used to represent points whose value matches `values`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#colorUniqueValueInfos) + */ color: Color; + /** + * Label used to describe points matched to the unique value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#colorUniqueValueInfos) + */ label?: string; } + + export interface PointCloudUniqueValueRendererLegendOptions extends Object { + /** + * Describes the variable driving the visualization. This is displayed as the title of the corresponding renderer in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) and takes precedence over a [field alias](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#alias). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html#legendOptions) + */ + title?: string; + } + interface Renderer extends Accessor, JSONSupport { + /** + * Authoring metadata only included in renderers generated from one of the Smart Mapping creator methods, such as [sizeRendererCreator.createContinuousRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) or [colorRendererCreator.createContinuousRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer). This includes information from UI elements such as sliders and selected classification methods and themes. This allows the authoring clients to save specific overridable settings so that next time it is accessed via the UI, their selections can be remembered. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#authoringInfo) + */ authoringInfo: AuthoringInfo; } interface RendererConstructor { + /** + * Renderers define how to visually represent each feature in one of the following layer types: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) + */ + new(properties?: RendererProperties): Renderer; fromJSON(json: any): Renderer; @@ -4153,118 +16097,795 @@ declare namespace __esri { export const Renderer: RendererConstructor; interface RendererProperties { - authoringInfo?: AuthoringInfo; + /** + * Authoring metadata only included in renderers generated from one of the Smart Mapping creator methods, such as [sizeRendererCreator.createContinuousRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) or [colorRendererCreator.createContinuousRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer). This includes information from UI elements such as sliders and selected classification methods and themes. This allows the authoring clients to save specific overridable settings so that next time it is accessed via the UI, their selections can be remembered. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#authoringInfo) + */ + authoringInfo?: AuthoringInfoProperties; } - export interface AuthoringInfo { + /** + * Defines a [size visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable) with minimum and maximum bounds. When an object with this specification is applied to the [visualVariables](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#visualVariables) property of a renderer, then feature sizes are bounded by min and max data values. Features with values greater than the provided max value are assigned the specified maximum size. Likewise, features with values less than the provied min value are assigned the specified minimum size. Features with values between the min and the max are assigned a corresponding size that is linearly interpolated between the provided min and max size values. The object specification for this object is provided below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + export interface BoundedMinMax extends Object { + /** + * The size used to render a feature containing the maximum data value. + * * When setting a number, sizes are expressed in points for all 2D symbols and 3D flat symbol layers; size is expressed in meters for all 3D volumetric symbols. + * * String values are only supported for 2D symbols and 3D flat symbol layers. Strings may specify size in either points or pixels (e.g. `minSize: "16pt"`, `minSize: "12px"`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + maxSize: string | number; + /** + * Value must be `size`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ type: string; - fields: string[]; - classificationMethod: string; - standardDeviationInterval: number; - visualVariables: AuthoringInfoVisualVariables[]; + /** + * The name of the numeric attribute field used to normalize the data in `field`. If this field is used, then the values in `maxDataValue` and `minDataValue` should be normalized as percentages or ratios. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + normalizationField?: string; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. This takes precedence over `field`. Therefore, this property is typically used as an alternative to `field` in visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + valueExpression?: string; + /** + * The title identifying and describing the associated [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression as defined in the `valueExpression` property. This is displayed as the title of the corresponding size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) in the absence of a provided `title` in the `legendOptions` property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + valueExpressionTitle?: string; + /** + * The maximum data value used in the size ramp. Features with this value or higher will be rendered at the size defined in `maxSize`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + maxDataValue: number; + /** + * Indicates the source of the data values used to determine the size of each feature. + * + * Value Type | Description + * ------|----------- + * String | The name of the numeric attribute field that contains the data values used to determine the size of each feature. + * Function | A function that iterates through each [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html), which includes the feature's attributes, and returns the value used to determine the size of the given feature. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + field?: string | Function; + /** + * The minimum data value used in the size ramp. Features with this value or lower will be rendered at the size defined in `minSize`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + minDataValue: number; + /** + * The size used to render a feature containing the minimum data value. + * * When setting a number, sizes are expressed in points for all 2D symbols and 3D flat symbol layers; size is expressed in meters for all 3D volumetric symbols. + * * String values are only supported for 2D symbols and 3D flat symbol layers. Strings may specify size in either points or pixels (e.g. `minSize: "16pt"`, `minSize: "12px"`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + minSize: string | number; + /** + * An object providing options for displaying the size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + legendOptions?: BoundedMinMaxLegendOptions; + /** + * Only applicable when working in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Defines the axis the size visual variable should be applied to when rendering features with an [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html). See the [local scene sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-local/index.html) for an example of this. + * + * Possible Value | Description + * ----------------|----------- + * width | The diameter of the symbol from east to west. + * depth | The diameter of the symbol from north to south. + * height | The height of the symbol. + * width-and-depth | Applies the size visual variable to both width and depth axes. + * all | Applies the size visual variable to all axes. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + axis?: string; + /** + * When setting a size visual variable on a renderer using an [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), this property indicates whether to apply the value defined by the [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#height), [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#width), or [depth](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#depth) properties to the corresponding axis of this visual variable instead of proportionally scaling this axis' value after other axes. [View an example](https://developers.arcgis.com/javascript/latest/sample-code/visualization-multivariate-3d/index.html) of this. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + useSymbolValue?: boolean; } - export interface ColorVisualVariable { + /** + * The **color** visual variable defines how a continuous color ramp is applied to features based on the values of a numeric attribute field. The minimum and maximum values of the data should be indicated along with their respective color values. You must specify `stops` to construct the color ramp, and either `field` or `valueExpression` to define the driving value. [![renderer-vv-color](https://developers.arcgis.com/javascript/latest/assets/img/samples/7-vv-color.png)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-vv-color/index.html) The object specification for color is provided below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ + export interface ColorVisualVariable extends Object { + /** + * **Required.** Value must be `color`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ type: string; + /** + * Indicates the source of the data values used to determine the color of each feature. + * + * Value Type | Description + * ------|----------- + * String | The name of the numeric attribute field that contains the data values used to determine the color of each feature. + * Function | A function that iterates through each [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) including a feature's attributes and returns the value used to determine the color of the given feature. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ field: string | Function; + /** + * Name of the numeric attribute field by which to normalize the data. If this field is used, then the values in `stops` should be normalized as percentages or ratios. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ normalizationField: string; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. This takes precedence over `field`. Therefore, this property is typically used as an alternative to `field` in visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ valueExpression: string; + /** + * The title identifying and describing the associated [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression as defined in the `valueExpression` property. This is displayed as the title of the corresponding color ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) in the absence of a provided `title` in the `legendOptions` property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ valueExpressionTitle: string; + /** + * An object providing options for displaying the color ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ legendOptions: ColorVisualVariableLegendOptions; + /** + * An array of objects that defines the color ramp in a sequence of stops. At least two stops are required. Features with values between the given stops will be assigned colors along the ramp proportional to the minimum and maximum values used. The stops must be listed in ascending order based on the value of the `value` property in each stop. Each stop object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ stops: ColorVisualVariableStops[]; } - export interface OpacityVisualVariable { + /** + * The **opacity** visual variable defines the opacity of each feature's symbol based on a numeric attribute field value. The minimum and maximum values of the data should be indicated along with their respective opacity values. The specification for this object is provided below. You must specify `stops` to construct the opacity ramp, and either `field` or `valueExpression` to define the driving value. [![renderer-vv-opacity](https://developers.arcgis.com/javascript/latest/assets/img/samples/12-vv-transparency.png)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-vv-opacity/index.html) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ + export interface OpacityVisualVariable extends Object { + /** + * **Required.** Value must be `opacity`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ type: string; + /** + * Indicates the source of the data values used to determine the opacity of each feature. + * + * Value Type | Description + * ------|----------- + * String | The name of the numeric attribute field that contains the data values used to determine the opacity of each feature. + * Function | A function that iterates through each [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) including the attributes of the feature and returns the value used to determine the opacity of the given feature. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ field: string | Function; + /** + * Name of the attribute field by which to normalize the data. If this field is used, then the values in `stops` should be normalized as percentages or ratios. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ normalizationField: string; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. This takes precedence over `field`. Therefore, this property is typically used as an alternative to `field` in visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ valueExpression: string; + /** + * The title identifying and describing the associated [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression as defined in the `valueExpression` property. This is displayed as the title of the corresponding opacity ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) in the absence of a provided `title` in the `legendOptions` property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ valueExpressionTitle: string; + /** + * An object providing options for displaying the opacity ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ legendOptions: OpacityVisualVariableLegendOptions; + /** + * An array of objects that defines the thematic opacity ramp in a sequence of stops. At least two stops are required. The stops must be listed in ascending order based on the value of the `value` property in each stop. Each stop object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ stops: OpacityVisualVariableStops[]; } - export interface RotationVisualVariable { + /** + * Defines a [size visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable) where data values are interpreted as real-world sizes based on a given unit. Features are then sized according to the real-world measurements, not thematic values and screen units. [![renderer-vv-rw](https://developers.arcgis.com/javascript/latest/assets/img/samples/2-extrude-height.png)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-buildings-3d/index.html) The object specification for this object is provided below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ + export interface RealWorldSize extends Object { + /** + * Value must be `size`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ type: string; - field: string | Function; - valueExpression: string; - axis: string; - rotationType: string; - } - - export interface SizeVisualVariable { - maxDataValue: number; - type: string; - normalizationField: string; - valueExpression: string; - valueExpressionTitle: string; - legendOptions: SizeVisualVariableLegendOptions; - axis: string; - expression: string; - field: string | Function; - minDataValue: number; - maxSize: string | number | SizeVisualVariable; - minSize: string | number | SizeVisualVariable; - stops: SizeVisualVariableStops[]; + /** + * Indicates the source of the data values used to determine the size of each feature. + * + * Value Type | Description + * ------|----------- + * String | The name of the numeric attribute field that contains the data values used to determine the size of each feature. + * Function | A function that iterates through each [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html), which includes the feature's attributes, and returns the value used to determine the size of the given feature. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ + field?: string | Function; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. This takes precedence over `field`. Therefore, this property is typically used as an alternative to `field` in visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ + valueExpression?: string; + /** + * The title identifying and describing the associated [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression as defined in the `valueExpression` property. This is displayed as the title of the corresponding size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) in the absence of a provided `title` in the `legendOptions` property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ + valueExpressionTitle?: string; + /** + * Indicates the unit of measurement used to interpret the value returned by `field` or `valueExpression`. For 3D volumetric symbols the default is `meters`. This property should not be used if the data value represents a thematic quantity (e.g. traffic count, census data, etc.). **Possible Values:** unknown | inches | feet | yards | miles | nautical-miles | millimeters | centimeters | decimeters | meters | kilometers | decimal-degrees + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ valueUnit: string; + /** + * Specifies how to apply the data value when mapping real-world sizes. See table below for supported values. + * + * Value | Description + * ------|----------- + * radius | The point data value represents the radius of a circular feature. + * diameter | The point data value represents the diameter of a circular feature. + * area | The point data value represents the area of a feature. + * width | The polyline data value represents the width of a line. + * distance | The polyline data value represents the distance from the center line (one half of the width). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ valueRepresentation: string; - useSymbolValue: boolean; + /** + * An object providing options for displaying the size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ + legendOptions?: RealWorldSizeLegendOptions; + /** + * Only applicable when working in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Defines the axis the size visual variable should be applied to when rendering features with an [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html). See the [local scene sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-local/index.html) for an example of this. + * + * Possible Value | Description + * ----------------|----------- + * width | The diameter of the symbol from east to west. + * depth | The diameter of the symbol from north to south. + * height | The height of the symbol. + * width-and-depth | Applies the size visual variable to both width and depth axes. + * all | Applies the size visual variable to all axes. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ + axis?: string; + /** + * When setting a size visual variable on a renderer using an [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), this property indicates whether to apply the value defined by the [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#height), [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#width), or [depth](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#depth) properties to the corresponding axis of this visual variable instead of proportionally scaling this axis' value after other axes. [View an example](https://developers.arcgis.com/javascript/latest/sample-code/visualization-multivariate-3d/index.html) of this. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ + useSymbolValue?: boolean; } - export interface AuthoringInfoVisualVariables { + /** + * The **rotation** visual variable defines how features rendered with [marker symbols](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html) or [text symbols](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html) in a MapView or [3D object symbol layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html) in a SceneView are rotated. The rotation value is determined by mapping the values to data in a field, or by other arithmetic means with a function. This object may be used to depict variables such as wind direction, vehicle heading, etc. [![renderer-vv-rotation](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/renderer-vv-rotation.png)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-vv-rotation/index.html) + * > **Known Limitations** In a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) rotation visual variables are not supported with [marker symbols](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html), [text symbols](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html), [3D icon symbol layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html) and [3D text symbol layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RotationVisualVariable) + */ + export interface RotationVisualVariable extends Object { + /** + * **Required.** Value must be `rotation`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RotationVisualVariable) + */ type: string; - field: string; - minSliderValue: number; - maxSliderValue: number; - theme: string; - style: string; - units: string; - startTime: string | number; - endTime: string | number; + /** + * Indicates the source of the rotation angle of each feature. + * + * Value Type | Description + * ------|----------- + * String | The name of the numeric attribute field that contains the rotation angle of each feature. + * Function | A function that iterates through each [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html), which includes the feature's attributes, and returns the rotation angle of the given feature. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RotationVisualVariable) + */ + field: string | Function; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. This takes precedence over `field`. Therefore, this property is typically used as an alternative to `field` in visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RotationVisualVariable) + */ + valueExpression: string; + /** + * Only applicable when working in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Defines the axis the rotation visual variable should be applied to when rendering features with an [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html). If the symbol resource is aligned such that its forward facing side points in the direction of the y-axis (the y-axis always points North in WGS84 or WebMercator coordinates), its upwards facing side is pointing in the direction of the z-axis, and its right-hand side points in the direction of the x-axis (the x-axis always points East in WGS84 or WebMercator coordinates), then the following rotation axis will rotate the symbol as indicated by their name. + * + * Possible Value | Description + * ----------------|----------- + * heading | The rotation of the symbol in the horizontal plane (i.e., around the z axis). + * tilt | The rotation of the symbol in the longitudinal vertical plane (i.e., around the x axis). + * roll | The rotation of the symbol in the lateral vertical plane (i.e., around the y axis). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RotationVisualVariable) + */ + axis?: string; + /** + * Defines the origin and direction of rotation depending on how the angle of rotation was measured. See the table below for a list of possible values. This property only applies to rotations around the `heading` axis. + * + * Value | Description + * ------|------------ + * geographic | Rotates the symbol from the north in a clockwise direction. + * arithmetic | Rotates the symbol from the east in a counter-clockwise direction. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RotationVisualVariable) + */ + rotationType?: string; } - export interface ColorVisualVariableLegendOptions { + /** + * **Only applicable to [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html)**. Defines icon sizes in a [size visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable) based on minimum and maximum bounds similar to the [BoundedMinMax](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) case. However, this specification allows the developer to specify various min and max sizes based on the [MapView.scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale). Features with values greater than the provided max value are assigned the specified maximum size for the given view scale. Likewise, features with values less than the provied min value are assigned the specified minumum size for the given view scale. Features with values between the min and the max are assigned a corresponding size that is linearly interpolated between the provided min and max size values for the given scale value. The object specification for this object is provided below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + export interface ScaleDependentIcons extends Object { + /** + * Value must be `size`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + type: string; + /** + * Indicates the source of the data values used to determine the size of each feature. + * + * Value Type | Description + * ------|----------- + * String | The name of the numeric attribute field that contains the data values used to determine the size of each feature. + * Function | A function that iterates through each [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html), which includes the feature's attributes, and returns the value used to determine the size of the given feature. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + field?: string | Function; + /** + * The name of the numeric attribute field used to normalize the data in `field`. If this field is used, then the values in `maxDataValue` and `minDataValue` should be normalized as percentages or ratios. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + normalizationField?: string; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. This takes precedence over `field`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + valueExpression?: string; + /** + * The title identifying and describing the associated [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression as defined in the `valueExpression` property. This is displayed as the title of the corresponding size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) in the absence of a provided `title` in the `legendOptions` property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + valueExpressionTitle?: string; + /** + * The maximum data value used in the size ramp. Features with this value or higher will be rendered at the size defined in `maxSize`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + maxDataValue: number; + /** + * An object defining the size of features whose data value (defined in `field` or `valueExpression`) is greater than or equal to the `maxDataValue` for the given view scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + maxSize: ScaleDependentStops; + /** + * The minimum data value used in the size ramp. Features with this value or lower will be rendered at the size defined in `minSize`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + minDataValue: number; + /** + * An object defining the size of features whose data value (defined in `field` or `valueExpression`) is less than or equal to the `minDataValue` for the given view scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + minSize: ScaleDependentStops; + /** + * An object providing options for displaying the size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + legendOptions?: ScaleDependentIconsLegendOptions; + } + + /** + * **Only applicable to [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html)**. Defines feature sizes and outline widths in a [size visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable) based on the [MapView.scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale). It also provides the specification of the `minSize` and `maxSize` properties in a [ScaleDependentIcons](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) size visual variable. The object specification for this object is provided below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentStops) + */ + export interface ScaleDependentStops extends Object { + /** + * Value must be `size`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentStops) + */ + type: string; + /** + * This value must be `$view.scale`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentStops) + */ + valueExpression: string; + /** + * **Deprecated since version 4.2. Use `valueExpression` instead**. The only supported expression is `view.scale`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentStops) + */ + expression?: string; + /** + * This value must be `outline` when scaling polygon outline widths based on the view scale. If scale-dependent icons are desired, then this property should be ignored. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentStops) + */ + target?: string; + /** + * An array of objects that define the size of the icon (or alternatively the width of the polygon outline) at the given scale `value`. At least two stops are required. The stops must be listed in ascending order based on the value of the `value` property in each stop. Each stop object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentStops) + */ + stops: ScaleDependentStopsStops[]; + } + + /** + * The **size** visual variable defines the size of individual features in a layer based on a numeric (often thematic) value. This value comes from one of the following: + * * An attribute `field` + * * The value of an attribute `field` divided by a `normalizationField` + * * A value returned from an [Arcade expression](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) specified in `valueExpression`. + * + * + * Size is defined in the form of a continuous ramp, which may be applied to renderers in either a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Symbol size may be applied either thematically, or literally using real-world units. See the following object specification tables for details about each potential use of a size visual variable: + * * **[BoundedMinMax](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax)** - Feature sizes are bounded by min and max data values. + * * **[ThematicStops](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops)** - Defines two or more stops at which feature sizes are mapped to data values. + * * **[ScaleDependentIcons](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons)** - Icons sizes are bounded by min and max data values, but the min and max sizes (and interpolated sizes) change based on the scale of the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * * **[ScaleDependentStops](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentStops)** - Defines the width of polygon outlines at various view scales. + * * **[RealWorldSize](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize)** - Feature sizes are determined based on real-world measurements and units, not thematic values and screen units. + * + * + * [![renderer-unique-vv](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/renderer-unique-vv.png)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-multivariate-2d/index.html) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable) + */ + export interface SizeVisualVariable extends Object { + } + + /** + * Defines two or more stops at which feature sizes are mapped to data values in a [size visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable). Setting two stops will have the same effect as creating a [BoundedMinMax](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) size visual variable. Adding additional stops allows you to map specific sizes with data values. Sizes are interpolated linearly between stop values. The object specification for this object is provided below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + export interface ThematicStops extends Object { + /** + * Value must be `size`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + type: string; + /** + * Indicates the source of the data values used to determine the size of each feature. + * + * Value Type | Description + * ------|----------- + * String | The name of the numeric attribute field that contains the data values used to determine the size of each feature. + * Function | A function that iterates through each [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html), which includes the feature's attributes, and returns the value used to determine the size of the given feature. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + field?: string | Function; + /** + * The name of the numeric attribute field used to normalize the data in `field`. If this field is used, then the values in `stops` should be normalized as percentages or ratios. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + normalizationField?: string; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. The values returned from this expression are the data used to drive the visualization. This takes precedence over `field`. Therefore, this property is typically used as an alternative to `field` in visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + valueExpression?: string; + /** + * The title identifying and describing the associated [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression as defined in the `valueExpression` property. This is displayed as the title of the corresponding size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) in the absence of a provided `title` in the `legendOptions` property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + valueExpressionTitle?: string; + /** + * An array of objects that defines the thematic size ramp in a sequence of data or expression stops. At least two stops are required. The stops must be listed in ascending order based on the value of the `value` property in each stop. Each stop object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + stops: ThematicStopsStops[]; + /** + * An object providing options for displaying the size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + legendOptions?: ThematicStopsLegendOptions; + /** + * Only applicable when working in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Defines the axis the size visual variable should be applied to when rendering features with an [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html). See the [local scene sample](https://developers.arcgis.com/javascript/latest/sample-code/scene-local/index.html) for an example of this. + * + * Possible Value | Description + * ----------------|----------- + * width | The diameter of the symbol from east to west. + * depth | The diameter of the symbol from north to south. + * height | The height of the symbol. + * width-and-depth | Applies the size visual variable to both width and depth axes. + * all | Applies the size visual variable to all axes. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + axis?: string; + /** + * When setting a size visual variable on a renderer using an [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), this property indicates whether to apply the value defined by the [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#height), [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#width), or [depth](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#depth) properties to the corresponding axis of this visual variable instead of proportionally scaling this axis' value after other axes. [View an example](https://developers.arcgis.com/javascript/latest/sample-code/visualization-multivariate-3d/index.html) of this. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + useSymbolValue?: boolean; + } + + + export interface BoundedMinMaxLegendOptions extends Object { + /** + * The title describing the visualization of the size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). This takes precedence over a field alias or `valueExpressionTitle`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + title?: string; + /** + * Indicates whether to show the size ramp in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#BoundedMinMax) + */ + showLegend?: boolean; + } + + + export interface ColorVisualVariableLegendOptions extends Object { + /** + * The title describing the visualization of the color ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). This takes precedence over a field alias or `valueExpressionTitle`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ title: string; + /** + * Indicates whether to show the color ramp in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ showLegend: boolean; } - export interface ColorVisualVariableStops { + + export interface ColorVisualVariableStops extends Object { + /** + * **Required**. Specifies the data value to map with the given `color`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ value: number; + /** + * **Required**. The [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) used to render features with the given `value`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ color: Color; + /** + * A string value used to label the stop in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) + */ label: string; } - export interface OpacityVisualVariableLegendOptions { + + export interface OpacityVisualVariableLegendOptions extends Object { + /** + * The title describing the visualization of the opacity ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). This takes precedence over a field alias or `valueExpressionTitle`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ title: string; + /** + * Indicates whether to show the opacity ramp in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ showLegend: boolean; } - export interface OpacityVisualVariableStops { + + export interface OpacityVisualVariableStops extends Object { + /** + * **Required**. Specifies the data value to map with the given `opacity`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ value: number; + /** + * **Required**. The opacity value used to render features containing the specified `value`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ opacity: number; + /** + * A string value used to label the stop in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) + */ label: string; } - export interface SizeVisualVariableLegendOptions { - title: string; - showLegend: boolean; + + export interface RealWorldSizeLegendOptions extends Object { + /** + * The title describing the visualization of the size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). This takes precedence over a field alias or `valueExpressionTitle`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ + title?: string; + /** + * Indicates whether to show the size ramp in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RealWorldSize) + */ + showLegend?: boolean; } - export interface SizeVisualVariableStops { + + export interface ScaleDependentIconsLegendOptions extends Object { + /** + * The title describing the visualization of the size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). This takes precedence over a field alias or `valueExpressionTitle`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + title?: string; + /** + * Indicates whether to show the size ramp in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentIcons) + */ + showLegend?: boolean; + } + + + export interface ScaleDependentStopsStops extends Object { + /** + * Specifies the scale value to map with the given `size`. When the [MapView.scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale) equals the given number then icons (or outlines) will be rendered with the given size. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentStops) + */ value: number; - size: string | number | any; - label: string; + /** + * The size at which to render features at the specified scale `value`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ScaleDependentStops) + */ + size: string | number; + } + + + export interface ThematicStopsLegendOptions extends Object { + /** + * The title describing the visualization of the size ramp in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). This takes precedence over a field alias or `valueExpressionTitle`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + title?: string; + /** + * Indicates whether to show the size ramp in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + showLegend?: boolean; + } + + + export interface ThematicStopsStops extends Object { + /** + * Specifies the data or expression value to map with the given `size`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + value: number; + /** + * The size at which to render features containing the specified `value`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + size: number | string; + /** + * A string value used to label the stop in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ThematicStops) + */ + label?: string; } interface SimpleRenderer extends Renderer, VisualVariablesMixin { + /** + * The label for the renderer. This describes what features with the given [symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#symbol) represent in the real world. This will display next to the layer's [symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#symbol) inside the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widget. This text is not displayed in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) when [visualVariables](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#visualVariables) are used. When the renderer contains [visualVariables](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#visualVariables), you should set the `title` property in `legendOptions` on each visual variable to describe the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#label) + */ label: string; + /** + * The symbol used by the renderer to visualize all features in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#symbol) + */ symbol: Symbol; - type: string; + /** + * The type of renderer. For SimpleRenderer this value is always `simple`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#type) + */ + readonly type: "simple"; + /** + * Creates a deep clone of the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#clone) + * + * + */ clone(): SimpleRenderer; } interface SimpleRendererConstructor { + /** + * SimpleRenderer renders all features in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) with one [Symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol.html). This renderer may be used to simply visualize the location of geographic features. For example, layers representing political boundaries, cities, buildings, rivers, etc. that are typically used for providing geographic context in an application may be defined with a single symbol per layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html) + */ + new(properties?: SimpleRendererProperties): SimpleRenderer; fromJSON(json: any): SimpleRenderer; @@ -4273,358 +16894,2515 @@ declare namespace __esri { export const SimpleRenderer: SimpleRendererConstructor; interface SimpleRendererProperties extends RendererProperties, VisualVariablesMixinProperties { + /** + * The label for the renderer. This describes what features with the given [symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#symbol) represent in the real world. This will display next to the layer's [symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#symbol) inside the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) widget. This text is not displayed in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) when [visualVariables](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#visualVariables) are used. When the renderer contains [visualVariables](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#visualVariables), you should set the `title` property in `legendOptions` on each visual variable to describe the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#label) + */ label?: string; + /** + * The symbol used by the renderer to visualize all features in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html#symbol) + */ symbol?: SymbolProperties; - type?: string; } + /** + * This object contains helper methods for generating data-driven visualizations with continuous color or class breaks based on a field value or expression from features in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). The methods in this module generate renderer or visual variable objects that may be applied directly to a supported layer. The renderers specify how features should be visualized based on data values and colors optimized based on the indicated basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html) + */ interface color { + /** + * Generates a [ClassBreaksRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html) that may be applied directly to the layer used to call this method. The resulting renderer defines the symbol color of each feature based on the value of the given `field` value. A default color scheme is determined based on the given `basemap`. Depending on the `classificationMethod`, class breaks (or data ranges) are generated based on the statistics of the data. Each feature is assigned a color based on the class break in which the value of the `field` falls. In most cases you will provide a `layer`, `basemap`, `field`, and `classificationMethod` to generate this renderer. This is a scenario in which the statistics of the data aren't well known and the user doesn't know what colors to use in the visualization. The other options are provided for convenience for more involved custom visualization authoring applications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + * + * @param params Input parameters for generating a classed color visualization based on data returned from a given field or expression. See the table below for details of each parameter. + * @param params.layer The layer for which the visualization is generated. + * @param params.field The name of the field whose data will be queried for statistics and classified. + * @param params.normalizationField The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * @param params.normalizationType With the exception of `log` normalization, data normalization creates a ratio by dividing two values. When comparing attribute values between features, normalization minimizes the effect of varying map areas and the number of observations. For example, dividing the 18 to 30 year old population by the area of a polygon feature yields a density value that can be compared evenly with other features, regardless of their size. + * Indicates how the data is normalized. The data value obtained from the `field` is normalized in one of the following ways before it is compared with the class breaks. See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------ + * field | Divides the `field` value by the value of `normalizationField`. This value is set by default if the `normalizationField` is provided. + * log | Computes the base 10 logarithm of the data value. This can be a useful approach for some data distributions because it reduces the influence of very large data values. + * percent-of-total | Divides the data value by the sum of all data values then multiplies by 100. Use `normalizationTotal` to define the total value by which to normalize. This value is set by default if the `normalizationTotal` is provided. + * + * @param params.normalizationTotal When `normalizationType` is `percent-of-total`, this property contains the total of all data values. + * @param params.basemap The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * @param params.classificationMethod + * The classification method used for generating breaks. See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------ + * equal-interval | Divides the range of attribute values into equal-sized subranges. For example, if you specify three classes for a field whose values range from 0 to 300, this method will create three classes with ranges of 0–100, 101–200, and 201–300. Equal interval is best applied to familiar data ranges, such as percentages and temperature. This method emphasizes the amount of an attribute value relative to other values. For example, it could show if a store is part of the group of stores that make up the top one-third of all sales. + * natural-breaks | Groups similar values that maximize the differences between classes. Features are divided into classes whose boundaries are set where there are relatively big differences in the data values. Natural breaks are data-specific classifications and not useful for comparing multiple maps built from different underlying information. + * quantile | Assigns the same number of data values to each class. This is well suited to linearly distributed data. Because features are grouped in equal numbers in each class, the resulting map can often be misleading. Similar features can potentially be placed in adjacent classes, or features with widely different values can be put in the same class. You can minimize this distortion by increasing the number of classes. + * standard-deviation | Creates class breaks with equal value ranges that are a proportion of the standard deviation. This is usually done at intervals of one, one-half, one-third, or one-fourth standard deviations from the mean. + * @param params.standardDeviationInterval If a `standard-deviation` classification method is used, then this indicates the interval by which to generate class breaks. **Possible Values:** 1 | 0.5 | 0.33 | 0.25 + * @param params.numClasses The number of class breaks to generate. This is ignored if a `standard-deviation` classification method is specified. + * @param params.colorScheme In authoring apps, the user may select a pre-defined color scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * @param params.legendOptions Provides options for setting a title to describe a field instead of using the field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * @param params.minValue A minimum value set by the user. Use this in conjunction with `maxValue` to generate class breaks between lower and upper bounds. This will be the lower bound of the lowest class break. + * @param params.maxValue A maximum value set by the user. Use this in conjunction with `minValue` to generate class breaks between lower and upper bounds. This will be the upper bound of the highest class break. + * @param params.defaultSymbolEnabled Enables the `defaultSymbol` on the renderer and assigns it to features with no value and features that do not fall within the configured data range. + * @param params.view The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric"`, but isn't required for layers with a `mesh` geometry type. + * @param params.symbolType + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. This parameter does not need to be specified for layers with a `mesh` geometry type. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). A SceneView instance must be provided to the `view` parameter if this option is used. | + * @param params.colorMixMode + * **This option only applies to generating renderers for mesh SceneLayers**. Specifies how the symbol's color is applied to the geometry color/texture. See the documentation in [FillSymbol3DLayer.material](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#material) for more context. See the table below for possible values. + * + * Value | Description + * ------|------------ + * tint | Applies the symbol `color` to the desaturated geometry/texture color. + * replace | Removes the geometry/texture color and applies the symbol `color`. + * multiply | Multiplies geometry/texture color value with the symbol `color` value. The result is a darker color. Multiplying with white keeps the geometry color the same. + * + */ + createClassBreaksRenderer(params: colorCreateClassBreaksRendererParams): IPromise; + /** + * Generates a [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) that may be applied directly to the layer used to call this method. The renderer contains a continuous color visual variable that maps optimal colors based on the indicated basemap to specific stop values based on queried statistics from the indicated field or expression. In most cases you will provide a `layer`, `basemap`, `field`, and `theme` to generate this renderer. This is a scenario in which the statistics of the data aren't well known and the user doesn't know what colors to use in the visualization. The other options are provided for convenience for more involved custom visualization authoring applications. For example, if you already generated statistics in another operation, you can pass the statistics object to the `statistics` parameter to avoid making an extra call to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + * + * @param params Input parameters for generating a continuous color visualization based on data returned from a given field or expression. See the table below for details of each parameter. + * @param params.layer The layer for which the visualization is generated. + * @param params.field The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * @param params.normalizationField The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * @param params.basemap The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * @param params.theme + * Determines which values will be emphasized in the continuous ramp and the map. Valid values are listed below. + * + * | Value | Description | Example | + * | ----- | ----------- | ------- | + * | high-to-low | High values are emphasized with strong colors. | ![high-to-low](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-high-to-low.png) | + * | above-and-below | Values centered around a given point (e.g. the average) are visualized with weak colors while other values are emphasized with strong colors. | ![above-and-below](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-above-and-below.png) | + * | centered-on | Values centered around a given point (e.g. the average) are emphasized with strong colors while other values are visualized with weak colors. | ![centered-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-centered-on.png) | + * | extremes | High and low values are emphasized with strong colors. All others are visualized with weak colors. | ![extremes](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-extremes.png) | + * @param params.colorScheme In authoring apps, the user may select a pre-defined color scheme. Pass the scheme object to this property to avoid getting one based on a `theme` and the `basemap`. + * @param params.legendOptions Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * @param params.statistics A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * @param params.minValue A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned color visual variable. + * @param params.maxValue A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned color visual variable. + * @param params.defaultSymbolEnabled Enables the `defaultSymbol` on the renderer and assigns it to features with no value and features that do not fall within the configured data range. + * @param params.view The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric"`, but isn't required for layers with a `mesh` geometry type. + * @param params.symbolType + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. This parameter does not need to be specified for layers with a `mesh` geometry type. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). A SceneView instance must be provided to the `view` parameter if this option is used. | + * @param params.colorMixMode + * **This option only applies to generating renderers for mesh SceneLayers**. Specifies how the symbol's color is applied to the geometry color/texture. See the documentation in [FillSymbol3DLayer.material](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#material) for more context. See the table below for possible values. + * + * Value | Description + * ------|------------ + * tint | Applies the symbol `color` to the desaturated geometry/texture color. + * replace | Removes the geometry/texture color and applies the symbol `color`. + * multiply | Multiplies geometry/texture color value with the symbol `color` value. The result is a darker color. Multiplying with white keeps the geometry color the same. + * + */ createContinuousRenderer(params: colorCreateContinuousRendererParams): IPromise; + /** + * Generates a [PointCloudStretchRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudStretchRenderer.html) with a color scheme best-suited for the given basemap based on statistics returned from a given field of a [PointCloudLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html). All that's required is a layer instance, field name, and basemap ID. You can optionally set the size and density of the points to suit the needs of the desired visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCContinuousRenderer) + * + * @param params Input parameters for generating a renderer based on the given field of the input layer. See the table below for details of each parameter. + * @param params.layer The layer for which the visualization is generated. + * @param params.field The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. The only field names used for this renderer type are `elevation` and `intensity`. + * @param params.basemap The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * @param params.size The size of each point expressed as a percentage. This value will determine point sizes scaled based on the given `density` of points. When the value is `100%`, the size of each point is set so that it minimizes the number of gaps between neighboring points. Any value above `100%` will allow for points to overlap neighboring points scaled to the given value. Values below `100%` scale point sizes smaller so there appear to be more gaps between points. + * @param params.density The number of points per inch in the view. + * @param params.colorScheme In authoring apps, the user may select a pre-defined color scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * @param params.statistics A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the stats object here to avoid making a second statistics query to the server. + * + */ createPCContinuousRenderer(params: colorCreatePCContinuousRendererParams): IPromise; + /** + * Generates a [PointCloudRGBRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRGBRenderer.html) based on the `RGB` field of a given [PointCloudLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html). This method simplifies the experience of creating a [PointCloudRGBRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudRGBRenderer.html) manually. All that's required is a layer instance. You can optionally set the size and density of the points to suit the needs of the desired visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCTrueColorRenderer) + * + * @param params Input parameters for generating a true color visualization based on the `RGB` field of the input layer. See the table below for details of each parameter. + * @param params.layer The layer for which the visualization is generated. + * @param params.size The size of each point expressed as a percentage. This value will determine point sizes scaled based on the given `density` of points. When the value is `100%`, the size of each point is set so that it minimizes the number of gaps between neighboring points. Any value above `100%` will allow for points to overlap neighboring points scaled to the given value. Values below `100%` scale point sizes smaller so there appear to be more gaps between points. + * @param params.density The number of points per inch in the view. + * + */ createPCTrueColorRenderer(params: colorCreatePCTrueColorRendererParams): IPromise; + /** + * This method generates a color visual variable with default stops that are optimally chosen based on the statistics queried for the indicated field or expression and colors based on the input basemap. There are two different ways this method may be called. The most common case is by providing a `layer`, `basemap`, `field`, and `theme`. This is the scenario where the statistics of the data aren't well known and the user doesn't know what colors to use. The other options are provided for convenience for more involved custom visualization authoring applications. For example, if you already generated statistics in another operation, you can pass the object in the `statistics` parameter to avoid making an extra call to the server. You can also provide a `colorScheme` if you don't want one picked for you. In this case the `basemap` and `theme` options would be ignored. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + * + * @param params Input parameters for generating a color visual variable based on data returned from a given field or expression. See the table below for details of each parameter. + * @param params.layer The layer for which the visual variable is generated. + * @param params.field The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * @param params.normalizationField The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * @param params.basemap The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * @param params.theme + * Determines which values will be emphasized in the continuous ramp and the map. Valid values are listed below. + * + * | Value | Description | Example | + * | ----- | ----------- | ------- | + * | high-to-low | High values are emphasized with strong colors. | ![high-to-low](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-high-to-low.png) | + * | above-and-below | Values centered around a given point (e.g. the average) are visualized with weak colors while other values are emphasized with strong colors. | ![above-and-below](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-above-and-below.png) | + * | centered-on | Values centered around a given point (e.g. the average) are emphasized with strong colors while other values are visualized with weak colors. | ![centered-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-centered-on.png) | + * | extremes | High and low values are emphasized with strong colors. All others are visualized with weak colors. | ![extremes](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-extremes.png) | + * @param params.colorScheme In authoring apps, the user may select a pre-defined color scheme. Pass the scheme object to this property to avoid getting one based on a `theme` and the `basemap`. + * @param params.legendOptions Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * @param params.statistics A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * @param params.minValue A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned color visual variable. + * @param params.maxValue A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned color visual variable. + * @param params.view The SceneView instance in which the visualization will be rendered. This property is only applicable to generating visualizations with 3D symbols, except for layers with a `mesh` geometry type. + * @param params.worldScale Indicates if the size units of the symbols will be in meters. This should be `true` when generating visualizations with 3D volumetric symbology, except for layers with a `mesh` geometry type. A `view` must be provided if this property is set to `true`. + * + */ createVisualVariable(params: colorCreateVisualVariableParams): IPromise; } export const color: color; - export interface colorCreateContinuousRendererParams { + /** + * The result object of the [createClassBreaksRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ClassBreaksRendererResult) + */ + export interface ClassBreaksRendererResult extends Object { + /** + * The renderer object configured to best match the given basemap and the spread of the data. Set this on a layer's `renderer` property to update its visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ClassBreaksRendererResult) + */ + renderer: ClassBreaksRenderer; + /** + * This object describes class breaks generated from data in a layer for a given field with a specified classification method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ClassBreaksRendererResult) + */ + classBreaksResult: ClassBreaksResult; + /** + * The color scheme used for the class breaks. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ClassBreaksRendererResult) + */ + colorScheme: ColorScheme; + /** + * Indicates whether default values are used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ClassBreaksRendererResult) + */ + defaultValuesUsed: boolean; + /** + * The ID of the basemap used to determine the optimal fill color of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ClassBreaksRendererResult) + */ + basemapId: string; + } + + + export interface colorCreateClassBreaksRendererParams extends Object { + /** + * The layer for which the visualization is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + */ layer: FeatureLayer | SceneLayer; + /** + * The name of the field whose data will be queried for statistics and classified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + */ field: string; + /** + * The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + */ normalizationField?: string; + /** + * Indicates how the data is normalized. The data value obtained from the `field` is normalized in one of the following ways before it is compared with the class breaks. See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------ + * field | Divides the `field` value by the value of `normalizationField`. This value is set by default if the `normalizationField` is provided. + * log | Computes the base 10 logarithm of the data value. This can be a useful approach for some data distributions because it reduces the influence of very large data values. + * percent-of-total | Divides the data value by the sum of all data values then multiplies by 100. Use `normalizationTotal` to define the total value by which to normalize. This value is set by default if the `normalizationTotal` is provided. + * + * With the exception of `log` normalization, data normalization creates a ratio by dividing two values. When comparing attribute values between features, normalization minimizes the effect of varying map areas and the number of observations. For example, dividing the 18 to 30 year old population by the area of a polygon feature yields a density value that can be compared evenly with other features, regardless of their size. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + */ + normalizationType?: string; + /** + * When `normalizationType` is `percent-of-total`, this property contains the total of all data values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + */ + normalizationTotal?: number; + /** + * The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + * + * @default gray + */ basemap?: string | Basemap; - theme?: string; + /** + * The classification method used for generating breaks. See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------ + * equal-interval | Divides the range of attribute values into equal-sized subranges. For example, if you specify three classes for a field whose values range from 0 to 300, this method will create three classes with ranges of 0–100, 101–200, and 201–300. Equal interval is best applied to familiar data ranges, such as percentages and temperature. This method emphasizes the amount of an attribute value relative to other values. For example, it could show if a store is part of the group of stores that make up the top one-third of all sales. + * natural-breaks | Groups similar values that maximize the differences between classes. Features are divided into classes whose boundaries are set where there are relatively big differences in the data values. Natural breaks are data-specific classifications and not useful for comparing multiple maps built from different underlying information. + * quantile | Assigns the same number of data values to each class. This is well suited to linearly distributed data. Because features are grouped in equal numbers in each class, the resulting map can often be misleading. Similar features can potentially be placed in adjacent classes, or features with widely different values can be put in the same class. You can minimize this distortion by increasing the number of classes. + * standard-deviation | Creates class breaks with equal value ranges that are a proportion of the standard deviation. This is usually done at intervals of one, one-half, one-third, or one-fourth standard deviations from the mean. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + * + * @default equal-interval + */ + classificationMethod?: string; + /** + * If a `standard-deviation` classification method is used, then this indicates the interval by which to generate class breaks. **Possible Values:** 1 | 0.5 | 0.33 | 0.25 + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + * + * @default 1 + */ + standardDeviationInterval?: number; + /** + * The number of class breaks to generate. This is ignored if a `standard-deviation` classification method is specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + * + * @default 5 + */ + numClasses?: number; + /** + * In authoring apps, the user may select a pre-defined color scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + */ colorScheme?: ColorScheme; - legendOptions?: colorCreateContinuousRendererParamsLegendOptions; - statistics?: SummaryStatisticsResult; + /** + * Provides options for setting a title to describe a field instead of using the field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + */ + legendOptions?: colorCreateClassBreaksRendererParamsLegendOptions; + /** + * A minimum value set by the user. Use this in conjunction with `maxValue` to generate class breaks between lower and upper bounds. This will be the lower bound of the lowest class break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + */ minValue?: number; + /** + * A maximum value set by the user. Use this in conjunction with `minValue` to generate class breaks between lower and upper bounds. This will be the upper bound of the highest class break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + */ maxValue?: number; + /** + * Enables the `defaultSymbol` on the renderer and assigns it to features with no value and features that do not fall within the configured data range. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + * + * @default true + */ defaultSymbolEnabled?: boolean; + /** + * The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric"`, but isn't required for layers with a `mesh` geometry type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + */ view?: SceneView; + /** + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. This parameter does not need to be specified for layers with a `mesh` geometry type. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). A SceneView instance must be provided to the `view` parameter if this option is used. | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + * + * @default 2d + */ symbolType?: string; + /** + * **This option only applies to generating renderers for mesh SceneLayers**. Specifies how the symbol's color is applied to the geometry color/texture. See the documentation in [FillSymbol3DLayer.material](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#material) for more context. See the table below for possible values. + * + * Value | Description + * ------|------------ + * tint | Applies the symbol `color` to the desaturated geometry/texture color. + * replace | Removes the geometry/texture color and applies the symbol `color`. + * multiply | Multiplies geometry/texture color value with the symbol `color` value. The result is a darker color. Multiplying with white keeps the geometry color the same. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + * + * @default replace + */ colorMixMode?: string; } - export interface colorCreateContinuousRendererParamsLegendOptions { - title: string; + + export interface colorCreateClassBreaksRendererParamsLegendOptions extends Object { + /** + * The title used to represent the given field or expression in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer) + */ + title?: string; } - export interface colorCreatePCContinuousRendererParams { - layer: PointCloudLayer; - field: string; - basemap?: string | Basemap; - size?: string; - density?: number; - colorScheme?: ColorScheme; - statistics?: SummaryStatisticsResult; - } - export interface colorCreatePCTrueColorRendererParams { - layer: PointCloudLayer; - size?: string; - density?: number; - } - - export interface colorCreateVisualVariableParams { + export interface colorCreateContinuousRendererParams extends Object { + /** + * The layer for which the visualization is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ layer: FeatureLayer | SceneLayer; + /** + * The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ field: string; + /** + * The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ normalizationField?: string; + /** + * The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + * + * @default gray + */ basemap?: string | Basemap; + /** + * Determines which values will be emphasized in the continuous ramp and the map. Valid values are listed below. + * + * | Value | Description | Example | + * | ----- | ----------- | ------- | + * | high-to-low | High values are emphasized with strong colors. | ![high-to-low](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-high-to-low.png) | + * | above-and-below | Values centered around a given point (e.g. the average) are visualized with weak colors while other values are emphasized with strong colors. | ![above-and-below](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-above-and-below.png) | + * | centered-on | Values centered around a given point (e.g. the average) are emphasized with strong colors while other values are visualized with weak colors. | ![centered-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-centered-on.png) | + * | extremes | High and low values are emphasized with strong colors. All others are visualized with weak colors. | ![extremes](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-extremes.png) | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ theme?: string; + /** + * In authoring apps, the user may select a pre-defined color scheme. Pass the scheme object to this property to avoid getting one based on a `theme` and the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ colorScheme?: ColorScheme; - legendOptions?: colorCreateVisualVariableParamsLegendOptions; + /** + * Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ + legendOptions?: colorCreateContinuousRendererParamsLegendOptions; + /** + * A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ statistics?: SummaryStatisticsResult; + /** + * A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned color visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ minValue?: number; + /** + * A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned color visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ maxValue?: number; + /** + * Enables the `defaultSymbol` on the renderer and assigns it to features with no value and features that do not fall within the configured data range. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + * + * @default true + */ + defaultSymbolEnabled?: boolean; + /** + * The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric"`, but isn't required for layers with a `mesh` geometry type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ view?: SceneView; + /** + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. This parameter does not need to be specified for layers with a `mesh` geometry type. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). A SceneView instance must be provided to the `view` parameter if this option is used. | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + * + * @default 2d + */ + symbolType?: string; + /** + * **This option only applies to generating renderers for mesh SceneLayers**. Specifies how the symbol's color is applied to the geometry color/texture. See the documentation in [FillSymbol3DLayer.material](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#material) for more context. See the table below for possible values. + * + * Value | Description + * ------|------------ + * tint | Applies the symbol `color` to the desaturated geometry/texture color. + * replace | Removes the geometry/texture color and applies the symbol `color`. + * multiply | Multiplies geometry/texture color value with the symbol `color` value. The result is a darker color. Multiplying with white keeps the geometry color the same. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + * + * @default replace + */ + colorMixMode?: string; + } + + + export interface colorCreateContinuousRendererParamsLegendOptions extends Object { + /** + * The title used to represent the given field or expression in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ + title?: string; + /** + * Indicates whether to describe the renderer in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) + */ + showLegend?: boolean; + } + + + export interface colorCreatePCContinuousRendererParams extends Object { + /** + * The layer for which the visualization is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCContinuousRenderer) + */ + layer: PointCloudLayer; + /** + * The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. The only field names used for this renderer type are `elevation` and `intensity`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCContinuousRenderer) + */ + field: string; + /** + * The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCContinuousRenderer) + * + * @default gray + */ + basemap?: string | Basemap; + /** + * The size of each point expressed as a percentage. This value will determine point sizes scaled based on the given `density` of points. When the value is `100%`, the size of each point is set so that it minimizes the number of gaps between neighboring points. Any value above `100%` will allow for points to overlap neighboring points scaled to the given value. Values below `100%` scale point sizes smaller so there appear to be more gaps between points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCContinuousRenderer) + * + * @default 100% + */ + size?: string; + /** + * The number of points per inch in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCContinuousRenderer) + * + * @default 25 + */ + density?: number; + /** + * In authoring apps, the user may select a pre-defined color scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCContinuousRenderer) + */ + colorScheme?: ColorScheme; + /** + * A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the stats object here to avoid making a second statistics query to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCContinuousRenderer) + */ + statistics?: SummaryStatisticsResult; + } + + + export interface colorCreatePCTrueColorRendererParams extends Object { + /** + * The layer for which the visualization is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCTrueColorRenderer) + */ + layer: PointCloudLayer; + /** + * The size of each point expressed as a percentage. This value will determine point sizes scaled based on the given `density` of points. When the value is `100%`, the size of each point is set so that it minimizes the number of gaps between neighboring points. Any value above `100%` will allow for points to overlap neighboring points scaled to the given value. Values below `100%` scale point sizes smaller so there appear to be more gaps between points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCTrueColorRenderer) + * + * @default 100% + */ + size?: string; + /** + * The number of points per inch in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCTrueColorRenderer) + * + * @default 25 + */ + density?: number; + } + + + export interface colorCreateVisualVariableParams extends Object { + /** + * The layer for which the visual variable is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + layer: FeatureLayer | SceneLayer; + /** + * The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + field: string; + /** + * The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + normalizationField?: string; + /** + * The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + * + * @default gray + */ + basemap?: string | Basemap; + /** + * Determines which values will be emphasized in the continuous ramp and the map. Valid values are listed below. + * + * | Value | Description | Example | + * | ----- | ----------- | ------- | + * | high-to-low | High values are emphasized with strong colors. | ![high-to-low](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-high-to-low.png) | + * | above-and-below | Values centered around a given point (e.g. the average) are visualized with weak colors while other values are emphasized with strong colors. | ![above-and-below](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-above-and-below.png) | + * | centered-on | Values centered around a given point (e.g. the average) are emphasized with strong colors while other values are visualized with weak colors. | ![centered-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-centered-on.png) | + * | extremes | High and low values are emphasized with strong colors. All others are visualized with weak colors. | ![extremes](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-extremes.png) | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + theme?: string; + /** + * In authoring apps, the user may select a pre-defined color scheme. Pass the scheme object to this property to avoid getting one based on a `theme` and the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + colorScheme?: ColorScheme; + /** + * Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + legendOptions?: colorCreateVisualVariableParamsLegendOptions; + /** + * A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + statistics?: SummaryStatisticsResult; + /** + * A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned color visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + minValue?: number; + /** + * A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned color visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + maxValue?: number; + /** + * The SceneView instance in which the visualization will be rendered. This property is only applicable to generating visualizations with 3D symbols, except for layers with a `mesh` geometry type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + view?: SceneView; + /** + * Indicates if the size units of the symbols will be in meters. This should be `true` when generating visualizations with 3D volumetric symbology, except for layers with a `mesh` geometry type. A `view` must be provided if this property is set to `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ worldScale?: boolean; } - export interface colorCreateVisualVariableParamsLegendOptions { - title: string; + + export interface colorCreateVisualVariableParamsLegendOptions extends Object { + /** + * The title used to represent the given field or expression in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + title?: string; + /** + * Indicates whether to describe the renderer in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) + */ + showLegend?: boolean; } - export interface ContinuousRendererResult { + /** + * The result object of the [createContinuousRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createContinuousRenderer) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ContinuousRendererResult) + */ + export interface ContinuousRendererResult extends Object { + /** + * The renderer object configured to best match the given basemap and the spread of the data. Set this on a layer's `renderer` property to update its visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ContinuousRendererResult) + */ renderer: ClassBreaksRenderer; + /** + * A color visual variable configured based on the statistics of the data and the given basemap and scheme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ContinuousRendererResult) + */ visualVariable: ColorVisualVariable; + /** + * The color scheme used by the visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ContinuousRendererResult) + */ colorScheme: ColorScheme; + /** + * Indicates whether default values are used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ContinuousRendererResult) + */ defaultValuesUsed: boolean; + /** + * Basic statistics returned from a query to the service for data from the given field name or expression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ContinuousRendererResult) + */ statistics: SummaryStatisticsResult; + /** + * The ID of the basemap used to determine the optimal fill color of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#ContinuousRendererResult) + */ basemapId: string; } - export interface PCContinuousRendererResult { + /** + * The result object of the [createPCContinuousRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCContinuousRenderer) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#PCContinuousRendererResult) + */ + export interface PCContinuousRendererResult extends Object { + /** + * The renderer object configured to best match the given basemap and the spread of the data. Set this object on the input layer's `renderer` property to update its visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#PCContinuousRendererResult) + */ renderer: PointCloudStretchRenderer; + /** + * The color scheme used by the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#PCContinuousRendererResult) + */ colorScheme: ColorScheme; + /** + * Indicates whether default values are used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#PCContinuousRendererResult) + */ defaultValuesUsed: boolean; + /** + * Basic statistics returned from a query to the service for data from the given field name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#PCContinuousRendererResult) + */ statistics: SummaryStatisticsResult; + /** + * The ID of the basemap used to determine the optimal color scheme for the output renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#PCContinuousRendererResult) + */ basemapId: string; } - export interface PCTrueColorRendererResult { + /** + * The result object of the [createPCTrueColorRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createPCTrueColorRenderer) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#PCTrueColorRendererResult) + */ + export interface PCTrueColorRendererResult extends Object { + /** + * The renderer object configured to represent the true color of each point in the point cloud. This gives the PointCloudLayer a realistic visualization of how it looks in the real world. Set this object on the input layer's `renderer` property to update its visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#PCTrueColorRendererResult) + */ renderer: PointCloudRGBRenderer; } - export interface VisualVariableResult { + /** + * The result object of the [createVisualVariable()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createVisualVariable) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#VisualVariableResult) + */ + export interface VisualVariableResult extends Object { + /** + * A color visual variable configured based on the statistics of the data and the given basemap and scheme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#VisualVariableResult) + */ visualVariable: ColorVisualVariable; + /** + * The color scheme used by the visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#VisualVariableResult) + */ colorScheme: ColorScheme; + /** + * Basic statistics returned from a query to the service for the given field or expression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#VisualVariableResult) + */ statistics: SummaryStatisticsResult; + /** + * Indicates whether default values are used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#VisualVariableResult) + */ defaultValuesUsed: boolean; + /** + * The ID of the basemap used to determine the optimal fill color of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#VisualVariableResult) + */ basemapId: string; + /** + * Authoring information related to the creation of the visual variable. This includes information related to UI inputs from sliders and selected themes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#VisualVariableResult) + */ authoringInfo: AuthoringInfo; } + /** + * This object contains helper methods for generating location-only visualizations (not data-driven) in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). The [createRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#createRenderer) method generates a [SimpleRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-SimpleRenderer.html) object that may be applied directly to the layer. This renderer contains a single symbol with a color optimally selected based on the indicated basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html) + */ interface location { + /** + * Generates a [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) that may be applied directly to a supported [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). The renderer contains a single symbol with a color optimally chosen based on the indicated basemap. In most cases you will provide a `layer` and `basemap` to generate this renderer. If working in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html), then the `view` and `symbolType` options should be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#createRenderer) + * + * @param params Input parameters for generating a location-based visualization. See the table below for details of each parameter. + * @param params.layer The layer for which the visualization is generated. + * @param params.basemap The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * @param params.locationScheme In authoring apps, the user may select a pre-defined location scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * @param params.view The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric"`, except for layers with a `mesh` geometryType. + * @param params.symbolType + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. This parameter does not need to be specified for layers with a `mesh` geometry type. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). A SceneView instance must be provided to the `view` parameter if this option is used. | + * @param params.colorMixMode + * **This option only applies to generating renderers for mesh SceneLayers**. Specifies how the symbol's color is applied to the geometry color/texture. See the documentation in [FillSymbol3DLayer.material](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#material) for more context. See the table below for possible values. + * + * Value | Description + * ------|------------ + * tint | Applies the symbol `color` to the desaturated geometry/texture color. + * replace | Removes the geometry/texture color and applies the symbol `color`. + * multiply | Multiplies geometry/texture color value with the symbol `color` value. The result is a darker color. Multiplying with white keeps the geometry color the same. + * + */ createRenderer(params: locationCreateRendererParams): IPromise; } export const location: location; - export interface locationCreateRendererParams { + + export interface locationCreateRendererParams extends Object { + /** + * The layer for which the visualization is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#createRenderer) + */ layer: FeatureLayer | SceneLayer; + /** + * The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#createRenderer) + * + * @default gray + */ basemap?: string | Basemap; + /** + * In authoring apps, the user may select a pre-defined location scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#createRenderer) + */ locationScheme?: PointLocationScheme | PolylineLocationScheme | PolygonLocationScheme; + /** + * The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric"`, except for layers with a `mesh` geometryType. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#createRenderer) + */ view?: SceneView; + /** + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. This parameter does not need to be specified for layers with a `mesh` geometry type. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). A SceneView instance must be provided to the `view` parameter if this option is used. | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#createRenderer) + * + * @default 2d + */ symbolType?: string; + /** + * **This option only applies to generating renderers for mesh SceneLayers**. Specifies how the symbol's color is applied to the geometry color/texture. See the documentation in [FillSymbol3DLayer.material](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#material) for more context. See the table below for possible values. + * + * Value | Description + * ------|------------ + * tint | Applies the symbol `color` to the desaturated geometry/texture color. + * replace | Removes the geometry/texture color and applies the symbol `color`. + * multiply | Multiplies geometry/texture color value with the symbol `color` value. The result is a darker color. Multiplying with white keeps the geometry color the same. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#createRenderer) + * + * @default replace + */ colorMixMode?: string; } - export interface RendererResult { + /** + * The result object of the [createRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#createRenderer) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#RendererResult) + */ + export interface RendererResult extends Object { + /** + * A simple renderer configured with a single color best suited to match the given basemap. Set this to a layer's `renderer` property to update its visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#RendererResult) + */ renderer: SimpleRenderer; + /** + * The location scheme used by the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#RendererResult) + */ locationScheme: PointLocationScheme | PolylineLocationScheme | PolygonLocationScheme; + /** + * The ID of the basemap used to determine the optimal fill color of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-location.html#RendererResult) + */ basemapId: string; } + /** + * This object contains a helper method for generating data-driven visualizations with continuous opacity based on data returned from a field value or expression in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html) + */ + interface opacity { + /** + * This method generates an opacity visual variable with default alpha values optimally mapped to data values based on the statistics queried for the indicated field or expression. There are several ways this method may be called. The most common case is by providing a `layer` and a `field`. This is the scenario where the statistics of the data aren't well known and the user doesn't know the which alpha values to map to data values. The other options are provided for convenience for more involved custom visualization authoring applications. For example, if you already generated statistics in another operation, you can pass the stats in the `statistics` parameter to avoid making an extra call to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#createVisualVariable) + * + * @param params Input parameters for generating an opacity visual variable based on data returned from a given field or expression. See the table below for details of each parameter. + * @param params.layer The layer for which the visual variable is generated. + * @param params.field The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * @param params.normalizationField The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * @param params.legendOptions Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * @param params.statistics A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * @param params.minValue A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned visual variable. + * @param params.maxValue A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned visual variable. + * + */ + createVisualVariable(params: opacityCreateVisualVariableParams): IPromise; + } + + export const opacity: opacity; + + + export interface opacityCreateVisualVariableParams extends Object { + /** + * The layer for which the visual variable is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#createVisualVariable) + */ + layer: FeatureLayer | SceneLayer; + /** + * The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#createVisualVariable) + */ + field: string; + /** + * The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#createVisualVariable) + */ + normalizationField?: string; + /** + * Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#createVisualVariable) + */ + legendOptions?: opacityCreateVisualVariableParamsLegendOptions; + /** + * A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#createVisualVariable) + */ + statistics?: SummaryStatisticsResult; + /** + * A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#createVisualVariable) + */ + minValue?: number; + /** + * A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#createVisualVariable) + */ + maxValue?: number; + } + + + export interface opacityCreateVisualVariableParamsLegendOptions extends Object { + /** + * The title used to represent the given field or expression in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#createVisualVariable) + */ + title?: string; + } + + /** + * The result object of the [createVisualVariable()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#createVisualVariable) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#VisualVariableResult) + */ + export interface opacityVisualVariableResult extends Object { + /** + * An opacity visual variable configured based on the statistics of the data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#VisualVariableResult) + */ + visualVariable: OpacityVisualVariable; + /** + * Basic statistics returned from a query to the service for the given field or expression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#VisualVariableResult) + */ + statistics: SummaryStatisticsResult; + /** + * Indicates whether default values are used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#VisualVariableResult) + */ + defaultValuesUsed: boolean; + /** + * Authoring information related to the creation of the visual variable. This includes information related to UI inputs from sliders and selected themes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-opacity.html#VisualVariableResult) + */ + authoringInfo: AuthoringInfo; + } + + /** + * This object contains helper methods for generating data-driven visualizations with continuous size or class breaks based on a field value or expression from features in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). The methods in this module generate renderer or visual variable objects that may be applied directly to a supported layer. The renderers specify how features should be visualized based on data values and sizes optimized based on the indicated basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html) + */ interface size { + /** + * Generates a [ClassBreaksRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-ClassBreaksRenderer.html) that may be applied directly to the layer used to call this method. The resulting renderer defines the symbol size of each feature based on the value of the given `field` value. A default size scheme is determined based on the given `basemap`. Depending on the `classificationMethod`, class breaks (or data ranges) are generated based on the statistics of the data. Each feature is assigned a color based on the class break in which the value of the `field` falls. In most cases you will provide a `layer`, `basemap`, `field`, and `classificationMethod` to generate this renderer. This is a scenario in which the statistics of the data aren't well known and the user doesn't know what sizes to use in the visualization. The other options are provided for convenience for more involved custom visualization authoring applications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + * + * @param params Input parameters for generating a classed size visualization based on data returned from a given field or expression. See the table below for details of each parameter. + * @param params.layer The layer for which the visualization is generated. + * @param params.basemap The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * @param params.field The name of the field whose data will be queried for statistics and classified. + * @param params.normalizationField The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * @param params.normalizationType With the exception of `log` normalization, data normalization creates a ratio by dividing two values. When comparing attribute values between features, normalization minimizes the effect of varying map areas and the number of observations. For example, dividing the 18 to 30 year old population by the area of a polygon feature yields a density value that can be compared evenly with other features, regardless of their size. + * Indicates how the data is normalized. The data value obtained from the `field` is normalized in one of the following ways before it is compared with the class breaks. See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------ + * field | Divides the `field` value by the value of `normalizationField`. This value is set by default if the `normalizationField` is provided. + * log | Computes the base 10 logarithm of the data value. This can be a useful approach for some data distributions because it reduces the influence of very large data values. + * percent-of-total | Divides the data value by the sum of all data values then multiplies by 100. Use `normalizationTotal` to define the total value by which to normalize. This value is set by default if the `normalizationTotal` is provided. + * + * @param params.normalizationTotal When `normalizationType` is `percent-of-total`, this property contains the total of all data values. + * @param params.classificationMethod + * The classification method used for generating breaks. See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------ + * equal-interval | Divides the range of attribute values into equal-sized subranges. For example, if you specify three classes for a field whose values range from 0 to 300, this method will create three classes with ranges of 0–100, 101–200, and 201–300. Equal interval is best applied to familiar data ranges, such as percentages and temperature. This method emphasizes the amount of an attribute value relative to other values. For example, it could show if a store is part of the group of stores that make up the top one-third of all sales. + * natural-breaks | Groups similar values that maximize the differences between classes. Features are divided into classes whose boundaries are set where there are relatively big differences in the data values. Natural breaks are data-specific classifications and not useful for comparing multiple maps built from different underlying information. + * quantile | Assigns the same number of data values to each class. This is well suited to linearly distributed data. Because features are grouped in equal numbers in each class, the resulting map can often be misleading. Similar features can potentially be placed in adjacent classes, or features with widely different values can be put in the same class. You can minimize this distortion by increasing the number of classes. + * standard-deviation | Creates class breaks with equal value ranges that are a proportion of the standard deviation. This is usually done at intervals of one, one-half, one-third, or one-fourth standard deviations from the mean. + * @param params.standardDeviationInterval If a `standard-deviation` classification method is used, then this indicates the interval by which to generate class breaks. **Possible Values:** 1 | 0.5 | 0.33 | 0.25 + * @param params.numClasses The number of class breaks to generate. This is ignored if a `standard-deviation` classification method is specified. + * @param params.sizeScheme In authoring apps, the user may select a pre-defined size scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * @param params.legendOptions Provides options for setting a title to describe a field instead of using the field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * @param params.minValue A minimum value set by the user. Use this in conjunction with `maxValue` to generate class breaks between lower and upper bounds. This will be the lower bound of the lowest class break. + * @param params.maxValue A maximum value set by the user. Use this in conjunction with `minValue` to generate class breaks between lower and upper bounds. This will be the upper bound of the highest class break. + * @param params.defaultSymbolEnabled Enables the `defaultSymbol` on the renderer and assigns it to features with no value and features that do not fall within the configured data range. + * @param params.view The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric" or "3d-volumetric-uniform"`. + * @param params.symbolType + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and only the symbol's height should be variable, for example with cylinders. A SceneView instance must be provided to the `view` parameter if this option is used. | + * | 3d-volumetric-uniform | Generates a visualization using uniformly sized 3D symbols with volumetric symbol layers. Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and the symbol should be sized uniformly, for example with spheres. A SceneView instance must be provided to the `view` parameter if this option is used. | + * + */ + createClassBreaksRenderer(params: sizeCreateClassBreaksRendererParams): IPromise; + /** + * Generates a [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) that may be applied directly to the layer used to call this method. The renderer contains a continuous size visual variable that maps marker sizes to specific stop values based on queried statistics from the indicated field or expression. In most cases you will provide a `layer`, `basemap`, and `field` to generate this renderer. This is a scenario in which the statistics of the data aren't well known and the user doesn't know what colors to use in the visualization. The other options are provided for convenience for more involved custom visualization authoring applications. For example, if you already generated statistics in another operation, you can pass the statistics object to the `statistics` parameter to avoid making an extra call to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + * + * @param params Input parameters for generating size visual variables based on data returned from a given field or expression. See the table below for details of each parameter. + * @param params.layer The layer for which the renderer is generated. + * @param params.field The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * @param params.normalizationField The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * @param params.basemap The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * @param params.sizeScheme In authoring apps, the user may select a pre-defined size scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * @param params.legendOptions Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * @param params.statistics A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * @param params.minValue A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned size visual variable. + * @param params.maxValue A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned size visual variable. + * @param params.defaultSymbolEnabled Enables the `defaultSymbol` on the renderer and assigns it to features with no value and features that do not fall within the configured data range. + * @param params.view The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric" or "3d-volumetric-uniform"`. + * @param params.symbolType + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and only the symbol's height should be variable, for example with cylinders. A SceneView instance must be provided to the `view` parameter if this option is used. | + * | 3d-volumetric-uniform | Generates a visualization using uniformly sized 3D symbols with volumetric symbol layers. Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and the symbol should be sized uniformly, for example with spheres. A SceneView instance must be provided to the `view` parameter if this option is used. | + * + */ createContinuousRenderer(params: sizeCreateContinuousRendererParams): IPromise; + /** + * This method generates an array of size visual variables with default stops that are optimally chosen based on the statistics queried for the indicated field or expression and mapped to appropriate sizes. There are two different ways this method may be called. The most common case is by providing a `layer`, `basemap`, and `field`. This is the scenario where the statistics of the data aren't well known and the user doesn't know what colors to use. The other options are provided for convenience for more involved custom visualization authoring applications. For example, if you already generated statistics in another operation, you can pass the object in the `statistics` parameter to avoid making an extra call to the server. You can also provide a `colorScheme` if you don't want one picked for you. In this case the `basemap` and `theme` options would be ignored. The resulting array of visual variables will contain exactly one size visual variable unless the `axis` parameter is set to "height". + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + * + * @param params Input parameters for generating size visual variables based on data returned from a given field or expression. See the table below for details of each parameter. + * @param params.layer The layer for which the visual variables are generated. + * @param params.field The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * @param params.normalizationField The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * @param params.basemap The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * @param params.sizeScheme In authoring apps, the user may select a pre-defined size scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * @param params.legendOptions Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * @param params.statistics A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * @param params.minValue A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned size visual variable. + * @param params.maxValue A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned size visual variable. + * @param params.view The SceneView instance in which the visualization will be rendered. This property is only applicable to generating visualizations with 3D symbols. + * @param params.worldScale Indicates if the size units of the symbols will be in meters. This should be `true` when generating visualizations with 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * @param params.axis When set to `all`, a single size variable that scales uniformly in all dimensions is generated. When set to `height`, the result contains two size visual variables: the first one sizes the height according to the field statistics, while the second defines a constant size for width and depth. **Possible Values:** all | height + * + */ createVisualVariables(params: sizeCreateVisualVariablesParams): IPromise; } export const size: size; - export interface sizeContinuousRendererResult { + /** + * The result object of the [createClassBreaksRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ClassBreaksRendererResult) + */ + export interface sizeClassBreaksRendererResult extends Object { + /** + * The renderer object configured to best match the given basemap and the spread of the data. Set this on a layer's `renderer` property to update its visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ClassBreaksRendererResult) + */ renderer: ClassBreaksRenderer; - visualVariables: SizeVisualVariable[]; + /** + * This object describes class breaks generated from data in a layer for a given field with a specified classification method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ClassBreaksRendererResult) + */ + classBreaksResult: ClassBreaksResult; + /** + * The size scheme used by the visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ClassBreaksRendererResult) + */ sizeScheme: PointSizeScheme | PolylineSizeScheme | PolygonSizeScheme; + /** + * Indicates whether default values are used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ClassBreaksRendererResult) + */ defaultValuesUsed: boolean; - statistics: SummaryStatisticsResult; + /** + * The ID of the basemap used to determine the optimal fill color of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ClassBreaksRendererResult) + */ basemapId: string; } - export interface sizeCreateContinuousRendererParams { + /** + * The result object of the [createContinuousRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ContinuousRendererResult) + */ + export interface sizeContinuousRendererResult extends Object { + /** + * The renderer object configured to best match the given basemap and the spread of the data. Set this on a layer's `renderer` property to update its visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ContinuousRendererResult) + */ + renderer: ClassBreaksRenderer; + /** + * Size visual variables configured based on the statistics of the data and the given basemap and scheme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ContinuousRendererResult) + */ + visualVariables: SizeVisualVariable[]; + /** + * The size scheme used by the visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ContinuousRendererResult) + */ + sizeScheme: PointSizeScheme | PolylineSizeScheme | PolygonSizeScheme; + /** + * Indicates whether default values are used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ContinuousRendererResult) + */ + defaultValuesUsed: boolean; + /** + * Basic statistics returned from a query to the service for data from the given field name or expression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ContinuousRendererResult) + */ + statistics: SummaryStatisticsResult; + /** + * The ID of the basemap used to determine the optimal fill color of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#ContinuousRendererResult) + */ + basemapId: string; + } + + + export interface sizeCreateClassBreaksRendererParams extends Object { + /** + * The layer for which the visualization is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + */ layer: FeatureLayer | SceneLayer; - field: string; - normalizationField?: string; + /** + * The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + * + * @default gray + */ basemap?: string | Basemap; + /** + * The name of the field whose data will be queried for statistics and classified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + */ + field: string; + /** + * The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + */ + normalizationField?: string; + /** + * Indicates how the data is normalized. The data value obtained from the `field` is normalized in one of the following ways before it is compared with the class breaks. See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------ + * field | Divides the `field` value by the value of `normalizationField`. This value is set by default if the `normalizationField` is provided. + * log | Computes the base 10 logarithm of the data value. This can be a useful approach for some data distributions because it reduces the influence of very large data values. + * percent-of-total | Divides the data value by the sum of all data values then multiplies by 100. Use `normalizationTotal` to define the total value by which to normalize. This value is set by default if the `normalizationTotal` is provided. + * + * With the exception of `log` normalization, data normalization creates a ratio by dividing two values. When comparing attribute values between features, normalization minimizes the effect of varying map areas and the number of observations. For example, dividing the 18 to 30 year old population by the area of a polygon feature yields a density value that can be compared evenly with other features, regardless of their size. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + */ + normalizationType?: string; + /** + * When `normalizationType` is `percent-of-total`, this property contains the total of all data values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + */ + normalizationTotal?: number; + /** + * The classification method used for generating breaks. See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------ + * equal-interval | Divides the range of attribute values into equal-sized subranges. For example, if you specify three classes for a field whose values range from 0 to 300, this method will create three classes with ranges of 0–100, 101–200, and 201–300. Equal interval is best applied to familiar data ranges, such as percentages and temperature. This method emphasizes the amount of an attribute value relative to other values. For example, it could show if a store is part of the group of stores that make up the top one-third of all sales. + * natural-breaks | Groups similar values that maximize the differences between classes. Features are divided into classes whose boundaries are set where there are relatively big differences in the data values. Natural breaks are data-specific classifications and not useful for comparing multiple maps built from different underlying information. + * quantile | Assigns the same number of data values to each class. This is well suited to linearly distributed data. Because features are grouped in equal numbers in each class, the resulting map can often be misleading. Similar features can potentially be placed in adjacent classes, or features with widely different values can be put in the same class. You can minimize this distortion by increasing the number of classes. + * standard-deviation | Creates class breaks with equal value ranges that are a proportion of the standard deviation. This is usually done at intervals of one, one-half, one-third, or one-fourth standard deviations from the mean. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + * + * @default equal-interval + */ + classificationMethod?: string; + /** + * If a `standard-deviation` classification method is used, then this indicates the interval by which to generate class breaks. **Possible Values:** 1 | 0.5 | 0.33 | 0.25 + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + * + * @default 1 + */ + standardDeviationInterval?: number; + /** + * The number of class breaks to generate. This is ignored if a `standard-deviation` classification method is specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + * + * @default 5 + */ + numClasses?: number; + /** + * In authoring apps, the user may select a pre-defined size scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + */ sizeScheme?: PointSizeScheme | PolylineSizeScheme | PolygonSizeScheme; - legendOptions?: sizeCreateContinuousRendererParamsLegendOptions; - statistics?: SummaryStatisticsResult; + /** + * Provides options for setting a title to describe a field instead of using the field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + */ + legendOptions?: sizeCreateClassBreaksRendererParamsLegendOptions; + /** + * A minimum value set by the user. Use this in conjunction with `maxValue` to generate class breaks between lower and upper bounds. This will be the lower bound of the lowest class break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + */ minValue?: number; + /** + * A maximum value set by the user. Use this in conjunction with `minValue` to generate class breaks between lower and upper bounds. This will be the upper bound of the highest class break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + */ maxValue?: number; + /** + * Enables the `defaultSymbol` on the renderer and assigns it to features with no value and features that do not fall within the configured data range. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + * + * @default true + */ defaultSymbolEnabled?: boolean; + /** + * The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric" or "3d-volumetric-uniform"`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + */ view?: SceneView; + /** + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and only the symbol's height should be variable, for example with cylinders. A SceneView instance must be provided to the `view` parameter if this option is used. | + * | 3d-volumetric-uniform | Generates a visualization using uniformly sized 3D symbols with volumetric symbol layers. Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and the symbol should be sized uniformly, for example with spheres. A SceneView instance must be provided to the `view` parameter if this option is used. | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + * + * @default 2d + */ symbolType?: string; } - export interface sizeCreateContinuousRendererParamsLegendOptions { - title: string; + + export interface sizeCreateClassBreaksRendererParamsLegendOptions extends Object { + /** + * The title used to represent the given field or expression in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createClassBreaksRenderer) + */ + title?: string; } - export interface sizeCreateVisualVariablesParams { + + export interface sizeCreateContinuousRendererParams extends Object { + /** + * The layer for which the renderer is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + */ layer: FeatureLayer | SceneLayer; + /** + * The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + */ field: string; + /** + * The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + */ normalizationField?: string; + /** + * The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + * + * @default gray + */ basemap?: string | Basemap; + /** + * In authoring apps, the user may select a pre-defined size scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + */ sizeScheme?: PointSizeScheme | PolylineSizeScheme | PolygonSizeScheme; - legendOptions?: sizeCreateVisualVariablesParamsLegendOptions; + /** + * Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + */ + legendOptions?: sizeCreateContinuousRendererParamsLegendOptions; + /** + * A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + */ statistics?: SummaryStatisticsResult; + /** + * A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned size visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + */ minValue?: number; + /** + * A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned size visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + */ maxValue?: number; + /** + * Enables the `defaultSymbol` on the renderer and assigns it to features with no value and features that do not fall within the configured data range. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + * + * @default true + */ + defaultSymbolEnabled?: boolean; + /** + * The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric" or "3d-volumetric-uniform"`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + */ view?: SceneView; + /** + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and only the symbol's height should be variable, for example with cylinders. A SceneView instance must be provided to the `view` parameter if this option is used. | + * | 3d-volumetric-uniform | Generates a visualization using uniformly sized 3D symbols with volumetric symbol layers. Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and the symbol should be sized uniformly, for example with spheres. A SceneView instance must be provided to the `view` parameter if this option is used. | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + * + * @default 2d + */ + symbolType?: string; + } + + + export interface sizeCreateContinuousRendererParamsLegendOptions extends Object { + /** + * The title used to represent the given field or expression in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + */ + title?: string; + /** + * Indicates whether to describe the renderer in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createContinuousRenderer) + */ + showLegend?: boolean; + } + + + export interface sizeCreateVisualVariablesParams extends Object { + /** + * The layer for which the visual variables are generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ + layer: FeatureLayer | SceneLayer; + /** + * The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ + field: string; + /** + * The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ + normalizationField?: string; + /** + * The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + * + * @default gray + */ + basemap?: string | Basemap; + /** + * In authoring apps, the user may select a pre-defined size scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ + sizeScheme?: PointSizeScheme | PolylineSizeScheme | PolygonSizeScheme; + /** + * Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ + legendOptions?: sizeCreateVisualVariablesParamsLegendOptions; + /** + * A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ + statistics?: SummaryStatisticsResult; + /** + * A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned size visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ + minValue?: number; + /** + * A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned size visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ + maxValue?: number; + /** + * The SceneView instance in which the visualization will be rendered. This property is only applicable to generating visualizations with 3D symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ + view?: SceneView; + /** + * Indicates if the size units of the symbols will be in meters. This should be `true` when generating visualizations with 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ worldScale?: boolean; + /** + * When set to `all`, a single size variable that scales uniformly in all dimensions is generated. When set to `height`, the result contains two size visual variables: the first one sizes the height according to the field statistics, while the second defines a constant size for width and depth. **Possible Values:** all | height + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + * + * @default all + */ axis?: boolean; } - export interface sizeCreateVisualVariablesParamsLegendOptions { - title: string; + + export interface sizeCreateVisualVariablesParamsLegendOptions extends Object { + /** + * The title used to represent the given field or expression in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ + title?: string; + /** + * Indicates whether to describe the renderer in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) + */ + showLegend?: boolean; } - export interface sizeVisualVariableResult { + /** + * The result object of the [createVisualVariables()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#createVisualVariables) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#VisualVariableResult) + */ + export interface sizeVisualVariableResult extends Object { + /** + * An array of size visual variables configured based on the statistics of the data and the view scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#VisualVariableResult) + */ visualVariables: SizeVisualVariable[]; + /** + * The size scheme used by the main visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#VisualVariableResult) + */ sizeScheme: PointSizeScheme | PolylineSizeScheme | PolygonSizeScheme; + /** + * Indicates whether default values were used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#VisualVariableResult) + */ defaultValuesUsed: boolean; + /** + * Basic statistics returned from a query to the service for the given field or expression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#VisualVariableResult) + */ statistics: SummaryStatisticsResult; + /** + * The ID of the basemap used to determine the optimal fill color of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#VisualVariableResult) + */ basemapId: string; + /** + * Authoring information related to the creation of the visual variable. This includes information related to UI inputs from sliders and selected themes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-size.html#VisualVariableResult) + */ authoringInfo: AuthoringInfo; } + /** + * This object contains helper methods for generating data-driven visualizations with unique types (or categories) based on a field value from features in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). The [createRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) method generates a [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) object that may be applied directly to the layer used to generate it. This renderer contains unique values with colors best suited to the given basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html) + */ interface type { + /** + * Generates a [PointCloudUniqueValueRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PointCloudUniqueValueRenderer.html) based on a given field of a [PointCloudLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html). This renderer visualizes points of the same type, usually from the `CLASS_CODE` field or an equivalent field that stores information related to the classification of the data (e.g. low vegetation, high vegetation, ground, etc.). The generated renderer visualizes each point with a standard predefined color matching the class code of the point. All that's required is a layer instance and field name. You can optionally set the size and density of the points to suit the needs of the desired visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createPCClassRenderer) + * + * @param params Input parameters for generating a renderer based on the given field of the input layer. See the table below for details of each parameter. + * @param params.layer The layer for which the visualization is generated. + * @param params.field The name of the field containing classification data for the given layer. A common field name used for this renderer type is `CLASS_CODE`, though other fields can be used. + * @param params.size The size of each point expressed as a percentage. This value will determine point sizes scaled based on the given `density` of points. When the value is `100%`, the size of each point is set so that it minimizes the number of gaps between neighboring points. Any value above `100%` will allow for points to overlap neighboring points scaled to the given value. Values below `100%` scale point sizes smaller so there appear to be more gaps between points. + * @param params.density The number of points per inch in the view. + * @param params.typeScheme In authoring apps, the user may select a pre-defined type scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * @param params.statistics A statistics object generated from the [uniqueValues](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * + */ createPCClassRenderer(params: typeCreatePCClassRendererParams): IPromise; + /** + * Generates a [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) that may be applied directly to a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) that supports renderers. The renderer contains unique symbols representing a string or a numeric value returned from the indicated field. In most cases you will provide a `layer`, `basemap`, and `field` to generate this renderer. This is a scenario in which the values of the field aren't well known and the user doesn't know which colors to use in the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + * + * @param params Input parameters for generating symbols to represent unique types based on data returned from a given field. See the table below for details of each parameter. + * @param params.layer The layer for which the renderer is generated. + * @param params.field The name of the field from which to extract unique values that will be used for the basis of the data-driven visualization. + * @param params.basemap The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * @param params.numTypes The number of types (or categories) displayed by the renderer. Use `-1` to display all returned types. + * @param params.sortBy + * Indicates how values should be sorted in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). See the table below for information about values that may be passed to this parameter. + * + * Possible Value | Description + * ---------------|------------ + * count | Unique values/types will be sorted from highest to lowest based on the count of features that fall in each category. + * value | Unique values/types will be sorted in alphabetical order. + * + * **Known Values:** count | value + * @param params.typeScheme In authoring apps, the user may select a pre-defined type scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * @param params.legendOptions Provides options for setting a title to a field that will override the field alias defined in the service. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * @param params.defaultSymbolEnabled Enables the `defaultSymbol` on the renderer and assigns it to features with no value. + * @param params.view The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric" or "3d-volumetric-uniform"`, except for layers with a `mesh` geometry type. + * @param params.symbolType + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. This parameter can be ignored for layers with a `mesh` geometry type. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and only the symbol's height should be variable, for example with cylinders. A SceneView instance must be provided to the `view` parameter if this option is used. | + * | 3d-volumetric-uniform | Generates a visualization using uniformly-sized 3D symbols with volumetric symbol layers. Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and the symbol should be sized uniformly, for example with spheres. A SceneView instance must be provided to the `view` parameter if this option is used. | + * @param params.statistics A statistics object generated from the [uniqueValues](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * @param params.colorMixMode + * **This option only applies to generating renderers for mesh SceneLayers**. Specifies how the symbol's color is applied to the geometry color/texture. See the documentation in [FillSymbol3DLayer.material](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#material) for more context. See the table below for possible values. + * + * Value | Description + * ------|------------ + * tint | Applies the symbol `color` to the desaturated geometry/texture color. + * replace | Removes the geometry/texture color and applies the symbol `color`. + * multiply | Multiplies geometry/texture color value with the symbol `color` value. The result is a darker color. Multiplying with white keeps the geometry color the same. + * + */ createRenderer(params: typeCreateRendererParams): IPromise; } export const type: type; - export interface PCClassRendererResult { + /** + * The result object of the [createPCClassRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createPCClassRenderer) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#PCClassRendererResult) + */ + export interface PCClassRendererResult extends Object { + /** + * The renderer object configured to represent the class codes in the point cloud. Set this object on the input layer's `renderer` property to update its visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#PCClassRendererResult) + */ renderer: PointCloudUniqueValueRenderer; } - export interface typeRendererResult { + /** + * The result object of the [createRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#RendererResult) + */ + export interface typeRendererResult extends Object { + /** + * The renderer object configured to best match the given basemap. Set this on a layer's `renderer` property to update its visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#RendererResult) + */ renderer: UniqueValueRenderer; + /** + * An array of objects describing the value, symbol, and count of each unique type or category represented in the renderer. See the table below describing each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#RendererResult) + */ uniqueValueInfos: RendererResultUniqueValueInfos[]; + /** + * An array of objects describing the values or categories excluded from consideration in visualizing data from the given field. The specification of each object matches that of the objects specified in the `uniqueValueInfos` property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#RendererResult) + */ excludedUniqueValueInfos: any[]; + /** + * The scheme used to represent each category within the `uniqueValueInfos`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#RendererResult) + */ typeScheme: PointTypeScheme | PolylineTypeScheme | PolygonTypeScheme | MeshTypeScheme; + /** + * The ID of the basemap used to determine the optimal color scheme to represent the categorical variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#RendererResult) + */ basemapId: string; } - export interface typeCreatePCClassRendererParams { + + export interface typeCreatePCClassRendererParams extends Object { + /** + * The layer for which the visualization is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createPCClassRenderer) + */ layer: PointCloudLayer; + /** + * The name of the field containing classification data for the given layer. A common field name used for this renderer type is `CLASS_CODE`, though other fields can be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createPCClassRenderer) + */ field: string; + /** + * The size of each point expressed as a percentage. This value will determine point sizes scaled based on the given `density` of points. When the value is `100%`, the size of each point is set so that it minimizes the number of gaps between neighboring points. Any value above `100%` will allow for points to overlap neighboring points scaled to the given value. Values below `100%` scale point sizes smaller so there appear to be more gaps between points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createPCClassRenderer) + * + * @default 100% + */ size?: string; + /** + * The number of points per inch in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createPCClassRenderer) + * + * @default 25 + */ density?: number; + /** + * In authoring apps, the user may select a pre-defined type scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createPCClassRenderer) + */ typeScheme?: PointTypeScheme; + /** + * A statistics object generated from the [uniqueValues](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createPCClassRenderer) + */ statistics?: UniqueValuesResult; } - export interface typeCreateRendererParams { + + export interface typeCreateRendererParams extends Object { + /** + * The layer for which the renderer is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + */ layer: FeatureLayer | SceneLayer; + /** + * The name of the field from which to extract unique values that will be used for the basis of the data-driven visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + */ field: string; + /** + * The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + * + * @default gray + */ basemap?: string | Basemap; + /** + * The number of types (or categories) displayed by the renderer. Use `-1` to display all returned types. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + * + * @default 10 + */ numTypes?: number; + /** + * Indicates how values should be sorted in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). See the table below for information about values that may be passed to this parameter. + * + * Possible Value | Description + * ---------------|------------ + * count | Unique values/types will be sorted from highest to lowest based on the count of features that fall in each category. + * value | Unique values/types will be sorted in alphabetical order. + * + * **Known Values:** count | value + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + * + * @default count + */ sortBy?: string; + /** + * In authoring apps, the user may select a pre-defined type scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + */ typeScheme?: PointTypeScheme | PolylineTypeScheme | PolygonTypeScheme | MeshTypeScheme; + /** + * Provides options for setting a title to a field that will override the field alias defined in the service. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + */ legendOptions?: typeCreateRendererParamsLegendOptions; + /** + * Enables the `defaultSymbol` on the renderer and assigns it to features with no value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + */ defaultSymbolEnabled?: boolean; + /** + * The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric" or "3d-volumetric-uniform"`, except for layers with a `mesh` geometry type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + */ view?: SceneView; + /** + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. This parameter can be ignored for layers with a `mesh` geometry type. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and only the symbol's height should be variable, for example with cylinders. A SceneView instance must be provided to the `view` parameter if this option is used. | + * | 3d-volumetric-uniform | Generates a visualization using uniformly-sized 3D symbols with volumetric symbol layers. Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and the symbol should be sized uniformly, for example with spheres. A SceneView instance must be provided to the `view` parameter if this option is used. | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + * + * @default 2d + */ symbolType?: string; + /** + * A statistics object generated from the [uniqueValues](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + */ statistics?: UniqueValuesResult; + /** + * **This option only applies to generating renderers for mesh SceneLayers**. Specifies how the symbol's color is applied to the geometry color/texture. See the documentation in [FillSymbol3DLayer.material](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#material) for more context. See the table below for possible values. + * + * Value | Description + * ------|------------ + * tint | Applies the symbol `color` to the desaturated geometry/texture color. + * replace | Removes the geometry/texture color and applies the symbol `color`. + * multiply | Multiplies geometry/texture color value with the symbol `color` value. The result is a darker color. Multiplying with white keeps the geometry color the same. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + * + * @default replace + */ colorMixMode?: string; } - export interface typeCreateRendererParamsLegendOptions { + + export interface typeCreateRendererParamsLegendOptions extends Object { + /** + * The title used to represent the given field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#createRenderer) + */ title: string; } - export interface RendererResultUniqueValueInfos { + + export interface RendererResultUniqueValueInfos extends Object { + /** + * A unique value representing a type or category of features in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#RendererResult) + */ value: string | number; + /** + * The number of features assigned the given `value` (or belonging to the given category). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#RendererResult) + */ count: number; + /** + * The label describing the value or category in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#RendererResult) + */ label: string; + /** + * The symbol used to represent features belonging to the given category. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-type.html#RendererResult) + */ symbol: Symbol; } + /** + * This object contains helper methods for generating data-driven univariate visualizations using both continuous color and continuous size based on a field value or expression from features in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). The [createContinuousRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) method generates a [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) object that may be applied directly to a supported layer. This renderer contains a continuous color and size ramp with optimal colors based on the indicated basemap and mapped to specific break values based on the statistics of the indicated field or expression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html) + */ interface univariateColorSize { + /** + * Generates a [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) that may be applied directly to a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). The renderer contains continuous color and size visual variables that map symbols with optimal colors and sizes based on the indicated basemap to specific stop values based on queried statistics from the indicated field or expression. In most cases you will provide a `layer`, `basemap`, `field`, and `theme` to generate this renderer. This is a scenario in which the statistics of the data aren't well known and the user doesn't know what colors and sizes to use in the visualization. The other options are provided for convenience for more involved custom visualization authoring applications. For example, if you already generated statistics in another operation, you can pass the statistics object to the `statistics` parameter to avoid making an extra call to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + * + * @param params See the table below for details of each parameter that may be passed to this method. + * @param params.layer The layer for which the visual variable is generated. + * @param params.basemap The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * @param params.field The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * @param params.normalizationField The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * @param params.statistics A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * @param params.minValue A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned visual variables. + * @param params.maxValue A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned visual variables. + * @param params.defaultSymbolEnabled Enables the `defaultSymbol` on the renderer and assigns it to features with no value and features that do not fall within the configured data range. + * @param params.colorOptions Options for configuring the color portion of the visualization. + * @param params.sizeOptions Options for configuring the size portion of the visualization. + * @param params.view The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric" or "3d-volumetric-uniform"`. + * @param params.symbolType + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and only the symbol's height should be variable, for example with cylinders. A SceneView instance must be provided to the `view` parameter if this option is used. | + * | 3d-volumetric-uniform | Generates a visualization using uniformly sized 3D symbols with volumetric symbol layers. Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and the symbol should be sizes uniformly, for example with spheres. A SceneView instance must be provided to the `view` parameter if this option is used. | + * + */ createContinuousRenderer(params: univariateColorSizeCreateContinuousRendererParams): IPromise; + /** + * This method generates color and size visual variables, both based on the same given field or expression. These visual variables are generated with default stops that are optimally chosen based on the statistics queried for the indicated field or expression and colors based on the input basemap. There are two different ways this method may be called. The most common case is by providing a `layer`, `basemap`, and `field`. This is the scenario where the statistics of the data aren't well known and the user doesn't know what colors to use. The other options are provided for convenience for more involved custom visualization authoring applications. For example, if you already generated statistics in another operation, you can pass the object in the `statistics` parameter to avoid making an extra call to the server. You can also provide a `colorScheme` and/or a `sizeScheme` if you don't want one picked for you. In this case the `basemap` and `theme` options would be ignored. The resulting array of visual variables will contain one color visual variable, and one or two size visual variables depending on the value of the `sizeOptions.axis` parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + * + * @param params Input parameters for generating color and size visual variables based on data returned from a given field or expression. See the table below for details of each parameter. + * @param params.layer The layer for which the visual variable is generated. + * @param params.basemap The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * @param params.field The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * @param params.normalizationField The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * @param params.statistics A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * @param params.minValue A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned visual variables. + * @param params.maxValue A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned visual variables. + * @param params.colorOptions Options for configuring the color portion of the visualization. + * @param params.sizeOptions Options for configuring the size portion of the visualization. + * @param params.view The SceneView instance in which the visualization will be rendered. This property is only applicable to generating visualizations with 3D symbols. + * @param params.worldScale Indicates if the size units of the symbols will be in meters. This should be `true` when generating visualizations with 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * + */ createVisualVariables(params: univariateColorSizeCreateVisualVariablesParams): IPromise; } export const univariateColorSize: univariateColorSize; - export interface univariateColorSizeContinuousRendererResult { + /** + * The result object of the [createContinuousRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#ContinuousRendererResult) + */ + export interface univariateColorSizeContinuousRendererResult extends Object { + /** + * The renderer object configured to best match the given basemap and the spread of the data. Set this on a layer's `renderer` property to update its visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#ContinuousRendererResult) + */ renderer: ClassBreaksRenderer; + /** + * Object containing visual variable and scheme information for the color portion of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#ContinuousRendererResult) + */ color: ContinuousRendererResultColor; + /** + * Object containing visual variable and scheme information for the size portion of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#ContinuousRendererResult) + */ size: ContinuousRendererResultSize; + /** + * Indicates whether default values were used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#ContinuousRendererResult) + */ defaultValuesUsed: boolean; + /** + * Basic statistics returned from a query to the service for the given field or expression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#ContinuousRendererResult) + */ statistics: SummaryStatisticsResult; + /** + * The ID of the basemap used to determine the optimal fill color of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#ContinuousRendererResult) + */ basemapId: string; } - export interface univariateColorSizeCreateContinuousRendererParams { + + export interface univariateColorSizeCreateContinuousRendererParams extends Object { + /** + * The layer for which the visual variable is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ layer: FeatureLayer | SceneLayer; + /** + * The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + * + * @default gray + */ basemap?: string | Basemap; + /** + * The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ field: string; + /** + * The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ normalizationField?: string; + /** + * A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ statistics?: SummaryStatisticsResult; + /** + * A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ minValue?: number; + /** + * A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ maxValue?: number; + /** + * Enables the `defaultSymbol` on the renderer and assigns it to features with no value and features that do not fall within the configured data range. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ defaultSymbolEnabled?: boolean; + /** + * Options for configuring the color portion of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ colorOptions?: univariateColorSizeCreateContinuousRendererParamsColorOptions; + /** + * Options for configuring the size portion of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ sizeOptions?: univariateColorSizeCreateContinuousRendererParamsSizeOptions; + /** + * The SceneView instance in which the visualization will be rendered. This parameter is required if `symbolType = "3d-volumetric" or "3d-volumetric-uniform"`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ view?: SceneView; + /** + * The type of symbol to generate. This depends on the view in which you are working and the desired visualization. Known values are described below. + * + * | Value | Description | + * | ----- | ----------- | + * | 2d | Generates a visualization using 2D symbols such as [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html), or [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html). Use this option if generating a visualization for data in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). | + * | 3d-flat | Generates a visualization using 3D symbols with flat symbol layers such as [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html), [LineSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html), or [FillSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html). Use this option if generating a 2D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). | + * | 3d-volumetric | Generates a visualization using 3D symbols with volumetric symbol layers such as [ObjectSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html), [PathSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html), or [ExtrudeSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html). Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and only the symbol's height should be variable, for example with cylinders. A SceneView instance must be provided to the `view` parameter if this option is used. | + * | 3d-volumetric-uniform | Generates a visualization using uniformly sized 3D symbols with volumetric symbol layers. Use this option if generating a 3D visualization for data in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) and the symbol should be sizes uniformly, for example with spheres. A SceneView instance must be provided to the `view` parameter if this option is used. | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + * + * @default 2d + */ symbolType?: string; } - export interface univariateColorSizeCreateContinuousRendererParamsColorOptions { + + export interface univariateColorSizeCreateContinuousRendererParamsColorOptions extends Object { + /** + * Determines which values will be emphasized in the continuous ramp and the map. Valid values are listed below. + * + * | Value | Description | Example | + * | ----- | ----------- | ------- | + * | high-to-low | High values are emphasized with strong colors. | ![high-to-low](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-high-to-low.png) | + * | above-and-below | Values centered around a given point (e.g. the average) are visualized with weak colors while other values are emphasized with strong colors. | ![above-and-below](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-above-and-below.png) | + * | centered-on | Values centered around a given point (e.g. the average) are emphasized with strong colors while other values are visualized with weak colors. | ![centered-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-centered-on.png) | + * | extremes | High and low values are emphasized with strong colors. All others are visualized with weak colors. | ![extremes](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-extremes.png) | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ theme?: string; + /** + * In authoring apps, the user may select a pre-defined color scheme. Pass the scheme object to this property to avoid getting one based on a `theme` and the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ colorScheme?: ColorScheme; + /** + * Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ legendOptions?: univariateColorSizeCreateContinuousRendererParamsColorOptionsLegendOptions; } - export interface univariateColorSizeCreateContinuousRendererParamsColorOptionsLegendOptions { + + export interface univariateColorSizeCreateContinuousRendererParamsColorOptionsLegendOptions extends Object { + /** + * The title used to represent the given field or expression in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ title: string; } - export interface univariateColorSizeCreateContinuousRendererParamsSizeOptions { + + export interface univariateColorSizeCreateContinuousRendererParamsSizeOptions extends Object { + /** + * In authoring apps, the user may select a pre-defined size scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ sizeScheme?: PointSizeScheme | PolylineSizeScheme | PolygonSizeScheme; + /** + * Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ legendOptions?: univariateColorSizeCreateContinuousRendererParamsSizeOptionsLegendOptions; } - export interface univariateColorSizeCreateContinuousRendererParamsSizeOptionsLegendOptions { + + export interface univariateColorSizeCreateContinuousRendererParamsSizeOptionsLegendOptions extends Object { + /** + * The title used to represent the given field or expression in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createContinuousRenderer) + */ title: string; } - export interface univariateColorSizeCreateVisualVariablesParams { + + export interface univariateColorSizeCreateVisualVariablesParams extends Object { + /** + * The layer for which the visual variable is generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ layer: FeatureLayer | SceneLayer; + /** + * The [named string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of the Esri basemap or basemap object that will be paired with the output visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + * + * @default gray + */ basemap?: string | Basemap; + /** + * The name of the field whose data will be queried for statistics and used for the basis of the data-driven visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ field: string; + /** + * The name of the field to normalize the values of the given `field`. Providing a normalization field helps minimize some visualization errors and standardizes the data so all features are visualized with minimal bias due to area differences or count variation. This option is commonly used when visualizing densities. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ normalizationField?: string; + /** + * A statistics object generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) function. If statistics for the field have already been generated, then pass the object here to avoid making a second statistics query to the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ statistics?: SummaryStatisticsResult; + /** + * A custom minimum value set by the user. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. This will be the lowest stop in the returned visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ minValue?: number; + /** + * A custom maximum value set by the user. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. This will be the uppermost stop in the returned visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ maxValue?: number; + /** + * Options for configuring the color portion of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ colorOptions?: univariateColorSizeCreateVisualVariablesParamsColorOptions; + /** + * Options for configuring the size portion of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ sizeOptions?: univariateColorSizeCreateVisualVariablesParamsSizeOptions; + /** + * The SceneView instance in which the visualization will be rendered. This property is only applicable to generating visualizations with 3D symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ view?: SceneView; + /** + * Indicates if the size units of the symbols will be in meters. This should be `true` when generating visualizations with 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ worldScale?: boolean; } - export interface univariateColorSizeCreateVisualVariablesParamsColorOptions { + + export interface univariateColorSizeCreateVisualVariablesParamsColorOptions extends Object { + /** + * Determines which values will be emphasized in the continuous ramp and the map. Valid values are listed below. + * + * | Value | Description | Example | + * | ----- | ----------- | ------- | + * | high-to-low | High values are emphasized with strong colors. | ![high-to-low](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-high-to-low.png) | + * | above-and-below | Values centered around a given point (e.g. the average) are visualized with weak colors while other values are emphasized with strong colors. | ![above-and-below](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-above-and-below.png) | + * | centered-on | Values centered around a given point (e.g. the average) are emphasized with strong colors while other values are visualized with weak colors. | ![centered-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-centered-on.png) | + * | extremes | High and low values are emphasized with strong colors. All others are visualized with weak colors. | ![extremes](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-extremes.png) | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ theme?: string; + /** + * In authoring apps, the user may select a pre-defined color scheme. Pass the scheme object to this property to avoid getting one based on a `theme` and the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ colorScheme?: ColorScheme; + /** + * Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ legendOptions?: univariateColorSizeCreateVisualVariablesParamsColorOptionsLegendOptions; } - export interface univariateColorSizeCreateVisualVariablesParamsColorOptionsLegendOptions { + + export interface univariateColorSizeCreateVisualVariablesParamsColorOptionsLegendOptions extends Object { + /** + * The title used to represent the given field or expression in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ title: string; } - export interface univariateColorSizeCreateVisualVariablesParamsSizeOptions { + + export interface univariateColorSizeCreateVisualVariablesParamsSizeOptions extends Object { + /** + * When set to `all`, a single size variable that scales uniformly in all dimensions is generated. When set to `height`, the result contains two size visual variables: the first one sizes the height according to the field statistics, while the second defines a constant size for width and depth. **Possible Values:** all | height + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + * + * @default all + */ axis?: boolean; + /** + * In authoring apps, the user may select a pre-defined size scheme. Pass the scheme object to this property to avoid getting one based on the `basemap`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ sizeScheme?: PointSizeScheme | PolylineSizeScheme | PolygonSizeScheme; + /** + * Provides options for setting a title to a field when an expression is provided instead of a field name. This title will represent the field in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ legendOptions?: univariateColorSizeCreateVisualVariablesParamsSizeOptionsLegendOptions; } - export interface univariateColorSizeCreateVisualVariablesParamsSizeOptionsLegendOptions { + + export interface univariateColorSizeCreateVisualVariablesParamsSizeOptionsLegendOptions extends Object { + /** + * The title used to represent the given field or expression in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) + */ title: string; } - export interface VisualVariablesResult { + /** + * The result object of the [createVisualVariables()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#createVisualVariables) method. See the table below for details of each property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#VisualVariablesResult) + */ + export interface VisualVariablesResult extends Object { + /** + * Object containing visual variable and scheme information for the color portion of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#VisualVariablesResult) + */ color: VisualVariablesResultColor; + /** + * Object containing visual variable and scheme information for the size portion of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#VisualVariablesResult) + */ size: VisualVariablesResultSize; + /** + * Indicates whether default values were used in the absence of sufficient data and/or statistics from the layer. Default values are typically used when all features have the same field value or no value at all. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#VisualVariablesResult) + */ defaultValuesUsed: boolean; + /** + * Basic statistics returned from a query to the service for the given field or expression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#VisualVariablesResult) + */ statistics: SummaryStatisticsResult; + /** + * The ID of the basemap used to determine the optimal fill color of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#VisualVariablesResult) + */ basemapId: string; + /** + * Authoring information related to the creation of the visual variables. This includes inforamation related to UI inputs from sliders and selected themes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#VisualVariablesResult) + */ authoringInfo: AuthoringInfo; } - export interface ContinuousRendererResultColor { + + export interface ContinuousRendererResultColor extends Object { + /** + * A color visual variable configured based on the statistics of the data and the given basemap and scheme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#ContinuousRendererResult) + */ visualVariable: ColorVisualVariable; + /** + * The color scheme used by the visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#ContinuousRendererResult) + */ colorScheme: ColorScheme; } - export interface ContinuousRendererResultSize { + + export interface ContinuousRendererResultSize extends Object { + /** + * The size visual variable(s) configured based on the statistics of the data and the view scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#ContinuousRendererResult) + */ visualVariables: SizeVisualVariable[]; + /** + * The size scheme used by the visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#ContinuousRendererResult) + */ sizeScheme: PointSizeScheme | PolylineSizeScheme | PolygonSizeScheme; } - export interface VisualVariablesResultColor { + + export interface VisualVariablesResultColor extends Object { + /** + * A color visual variable configured based on the statistics of the data and the given basemap and scheme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#VisualVariablesResult) + */ visualVariable: ColorVisualVariable; + /** + * The color scheme used by the visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#VisualVariablesResult) + */ colorScheme: ColorScheme; } - export interface VisualVariablesResultSize { + + export interface VisualVariablesResultSize extends Object { + /** + * The size visual variable(s) configured based on the statistics of the data and the view scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#VisualVariablesResult) + */ visualVariables: SizeVisualVariable[]; + /** + * The size scheme used by the visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html#VisualVariablesResult) + */ sizeScheme: PointSizeScheme | PolylineSizeScheme | PolygonSizeScheme; } + /** + * Function for generating class breaks for an input field in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) based on a given classification method and normalization type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html) + */ interface classBreaks { + /** + * Generates class breaks for an input field of a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) based on a given classification method and normalization type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#classBreaks) + * + * @param params See the table below for details about parameters that may be passed to this function. + * @param params.layer The layer from which to generate class breaks. + * @param params.field The class breaks will be generated based on values of this field. If a field is provided, the values from the given field from all features will be queried in the service. + * @param params.normalizationField The field by which to normalize the values returned from the given `field`. + * @param params.classificationMethod + * The method for classifying the data. See the table below for a list of possible values. + * + * | Possible Value | Description | + * |---------------|------------ | + * | natural-breaks | Data values that cluster are placed into a single class. Class breaks occur where gaps exist between clusters. You should use this method if your data is unevenly distributed; that is, many features have the same or similar values and there are gaps between groups of values. | + * | equal-interval | Each class has an equal range of values; in other words, the difference between the high and low value is equal for each class. You should use this method if your data is evenly distributed and you want to emphasize the difference in values between the features. | + * | quantile | Each class has roughly the same number of features. If your data is evenly distributed and you want to emphasize the difference in relative position between features, you should use the quantile classification method. If, for example, the point values are divided into five classes, points in the highest class would fall into the top fifth of all points. | + * | standard-deviation | Class breaks are placed above and below the mean value at intervals of `1`, `0.5`, or `0.25` standard deviations until all the data values are included in a class. | + * @param params.standardDeviationInterval When `classificationMethod = "standard-deviation"`, this sets the interval at which each class break should be set (e.g. `0.25`, `0.33`, `0.5`, `1`). + * @param params.minValue The minimum bounding value for the class breaks definition. Use this in conjunction with `maxValue` to generate class breaks between lower and upper bounds. + * @param params.maxValue The maximum bounding value for the class breaks definition. Use this in conjunction with `minValue` to generate class breaks between lower and upper bounds. + * @param params.numClasses Indicates the number of classes to generate for the class breaks definition. + * + */ classBreaks(params: classBreaksClassBreaksParams): IPromise; } @@ -4632,30 +19410,150 @@ declare namespace __esri { export const classBreaks: typeof __classBreaksMapped.classBreaks; - export interface classBreaksClassBreaksParams { + + export interface classBreaksClassBreaksParams extends Object { + /** + * The layer from which to generate class breaks. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#classBreaks) + */ layer: FeatureLayer | SceneLayer; + /** + * The class breaks will be generated based on values of this field. If a field is provided, the values from the given field from all features will be queried in the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#classBreaks) + */ field?: string; + /** + * The field by which to normalize the values returned from the given `field`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#classBreaks) + */ normalizationField?: string; + /** + * The method for classifying the data. See the table below for a list of possible values. + * + * | Possible Value | Description | + * |---------------|------------ | + * | natural-breaks | Data values that cluster are placed into a single class. Class breaks occur where gaps exist between clusters. You should use this method if your data is unevenly distributed; that is, many features have the same or similar values and there are gaps between groups of values. | + * | equal-interval | Each class has an equal range of values; in other words, the difference between the high and low value is equal for each class. You should use this method if your data is evenly distributed and you want to emphasize the difference in values between the features. | + * | quantile | Each class has roughly the same number of features. If your data is evenly distributed and you want to emphasize the difference in relative position between features, you should use the quantile classification method. If, for example, the point values are divided into five classes, points in the highest class would fall into the top fifth of all points. | + * | standard-deviation | Class breaks are placed above and below the mean value at intervals of `1`, `0.5`, or `0.25` standard deviations until all the data values are included in a class. | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#classBreaks) + */ classificationMethod?: string; + /** + * When `classificationMethod = "standard-deviation"`, this sets the interval at which each class break should be set (e.g. `0.25`, `0.33`, `0.5`, `1`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#classBreaks) + */ standardDeviationInterval?: number; + /** + * The minimum bounding value for the class breaks definition. Use this in conjunction with `maxValue` to generate class breaks between lower and upper bounds. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#classBreaks) + */ minValue?: number; + /** + * The maximum bounding value for the class breaks definition. Use this in conjunction with `minValue` to generate class breaks between lower and upper bounds. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#classBreaks) + */ maxValue?: number; + /** + * Indicates the number of classes to generate for the class breaks definition. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#classBreaks) + */ numClasses?: number; } - export interface ClassBreaksResult { + /** + * Object returned from the [classBreaks()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#classBreaks) method. This object describes classes generated from data in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) for a given field with a specified classification method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#ClassBreaksResult) + */ + export interface ClassBreaksResult extends Object { + /** + * An array of objects describing the class breaks generated from the [classBreaks()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#classBreaks) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#ClassBreaksResult) + */ classBreaksInfos: ClassBreaksResultClassBreaksInfos[]; + /** + * The minimum value of features in the dataset. This will be the lower bound of the lowest class break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#ClassBreaksResult) + */ minValue: number; + /** + * The maximum value of features in the dataset. This will be the upper bound of the highest class break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#ClassBreaksResult) + */ maxValue: number; + /** + * The normalization total if `normalizationType` is set to `percent-of-total` when generating class breaks with [createClassBreaksRenderer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html#createClassBreaksRenderer). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#ClassBreaksResult) + */ + normalizationTotal: number; } - export interface ClassBreaksResultClassBreaksInfos { + + export interface ClassBreaksResultClassBreaksInfos extends Object { + /** + * The label describing the given class break for use in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#ClassBreaksResult) + */ label: string; + /** + * The lower bound of the class break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#ClassBreaksResult) + */ minValue: number; + /** + * The upper bound of the class break. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-classBreaks.html#ClassBreaksResult) + */ maxValue: number; } + /** + * Generates a histogram based on data in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) for a given field. The returned object can be used for displaying a histogram in the UI within visualization authoring applications and analytical apps that query and display statistics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html) + */ interface histogram { + /** + * Generates a histogram for data returned from a `field` in a given `layer`. The returned object can be used for displaying a histogram to the UI in visualization authoring applications and analytical apps that query and display statistics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#histogram) + * + * @param params See the table below for details on parameters that may be passed to this function. + * @param params.layer The layer for which to generate a histogram. + * @param params.field The name of the numeric field for which the histogram will be generated. + * @param params.normalizationField The field by which to normalize the values returned from the given `field`. + * @param params.classificationMethod + * The method for classifying the data. See the table below for a list of possible values. + * + * | Possible Value | Description | + * |---------------|------------ | + * | natural-breaks | Data values that cluster are placed into a single class. Class breaks occur where gaps exist between clusters. You should use this method if your data is unevenly distributed; that is, many features have the same or similar values and there are gaps between groups of values. | + * | equal-interval | Each class has an equal range of values; in other words, the difference between the high and low value is equal for each class. You should use this method if your data is evenly distributed and you want to emphasize the difference in values between the features. | + * | quantile | Each class has roughly the same number of features. If your data is evenly distributed and you want to emphasize the difference in relative position between features, you should use the quantile classification method. If, for example, the point values are divided into five classes, points in the highest class would fall into the top fifth of all points. | + * | standard-deviation | Class breaks are placed above and below the mean value at intervals of `1`, `0.5`, or `0.25` standard deviations until all the data values are included in a class. | + * @param params.standardDeviationInterval When `classificationMethod = "standard-deviation"`, this sets the interval at which each class break should be set (e.g. `0.25`, `0.33`, `0.5`, `1`). + * @param params.minValue The minimum bounding value for the histogram. Use this in conjunction with `maxValue` to generate a histogram between custom lower and upper bounds. + * @param params.maxValue The maximum bounding value for the histogram. Use this in conjunction with `minValue` to generate a histogram between custom lower and upper bounds. + * @param params.numBins Indicates the number of classes to generate for the histogram. + * + */ histogram(params: histogramHistogramParams): IPromise; } @@ -4663,30 +19561,136 @@ declare namespace __esri { export const histogram: typeof __histogramMapped.histogram; - export interface histogramHistogramParams { + + export interface histogramHistogramParams extends Object { + /** + * The layer for which to generate a histogram. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#histogram) + */ layer: FeatureLayer | SceneLayer | PointCloudLayer; + /** + * The name of the numeric field for which the histogram will be generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#histogram) + */ field?: string; + /** + * The field by which to normalize the values returned from the given `field`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#histogram) + */ normalizationField?: string; + /** + * The method for classifying the data. See the table below for a list of possible values. + * + * | Possible Value | Description | + * |---------------|------------ | + * | natural-breaks | Data values that cluster are placed into a single class. Class breaks occur where gaps exist between clusters. You should use this method if your data is unevenly distributed; that is, many features have the same or similar values and there are gaps between groups of values. | + * | equal-interval | Each class has an equal range of values; in other words, the difference between the high and low value is equal for each class. You should use this method if your data is evenly distributed and you want to emphasize the difference in values between the features. | + * | quantile | Each class has roughly the same number of features. If your data is evenly distributed and you want to emphasize the difference in relative position between features, you should use the quantile classification method. If, for example, the point values are divided into five classes, points in the highest class would fall into the top fifth of all points. | + * | standard-deviation | Class breaks are placed above and below the mean value at intervals of `1`, `0.5`, or `0.25` standard deviations until all the data values are included in a class. | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#histogram) + */ classificationMethod?: string; + /** + * When `classificationMethod = "standard-deviation"`, this sets the interval at which each class break should be set (e.g. `0.25`, `0.33`, `0.5`, `1`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#histogram) + */ standardDeviationInterval?: number; + /** + * The minimum bounding value for the histogram. Use this in conjunction with `maxValue` to generate a histogram between custom lower and upper bounds. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#histogram) + */ minValue?: number; + /** + * The maximum bounding value for the histogram. Use this in conjunction with `minValue` to generate a histogram between custom lower and upper bounds. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#histogram) + */ maxValue?: number; + /** + * Indicates the number of classes to generate for the histogram. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#histogram) + * + * @default 10 + */ numBins?: number; } - export interface HistogramResult { + /** + * The result returned from the [histogram()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#histogram) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#HistogramResult) + */ + export interface HistogramResult extends Object { + /** + * An array of objects representing each bin in the histogram. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#HistogramResult) + */ bins: HistogramResultBins[]; + /** + * The minimum value returned by the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#HistogramResult) + */ minValue: number; + /** + * The maximum value returned by the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#HistogramResult) + */ maxValue: number; } - export interface HistogramResultBins { + + export interface HistogramResultBins extends Object { + /** + * The number of features that are contained between the indicated `minValue` and `maxValue`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#HistogramResult) + */ count: number; + /** + * The minimum value of the bin. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#HistogramResult) + */ minValue: number; + /** + * The maximum value of the bin. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html#HistogramResult) + */ maxValue: number; } + /** + * Function for generating attribute statistics in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) based on values returned from a given field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) + */ interface summaryStatistics { + /** + * Returns an object containing various statistics describing a set of values returned from a field in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#summaryStatistics) + * + * @param params See the table below for details of each parameter. + * @param params.layer The layer from which to generate statistics for the given `field`. + * @param params.field The name of the numeric field for which the summary statistics will be generated. + * @param params.normalizationField The field by which to normalize the values returned from the given `field`. + * @param params.features If the FeatureLayer is constructed with client-side graphics or you would like to calculate statistics based on a subset of features, then pass the features in this parameter. + * @param params.minValue The minimum bounding value for the statistics calculation. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. + * @param params.maxValue The maximum bounding value for the statistics calculation. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. + * + */ summaryStatistics(params: summaryStatisticsSummaryStatisticsParams): IPromise; } @@ -4694,26 +19698,114 @@ declare namespace __esri { export const summaryStatistics: typeof __summaryStatisticsMapped.summaryStatistics; - export interface SummaryStatisticsResult { + /** + * The statistics returned from the [summaryStatistics()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#summaryStatistics) query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#SummaryStatisticsResult) + */ + export interface SummaryStatisticsResult extends Object { + /** + * The average of all values returned from the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#SummaryStatisticsResult) + */ avg: number; + /** + * The number of features evaluated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#SummaryStatisticsResult) + */ count: number; + /** + * The maximum of all values returned from the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#SummaryStatisticsResult) + */ max: number; + /** + * The minimum of all values returned from the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#SummaryStatisticsResult) + */ min: number; + /** + * The standard deviation calculated from values returned from the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#SummaryStatisticsResult) + */ stddev: number; + /** + * The sum of all values returned from the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#SummaryStatisticsResult) + */ sum: number; + /** + * The calculated variance from all values returned from the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#SummaryStatisticsResult) + */ variance: number; } - export interface summaryStatisticsSummaryStatisticsParams { + + export interface summaryStatisticsSummaryStatisticsParams extends Object { + /** + * The layer from which to generate statistics for the given `field`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#summaryStatistics) + */ layer: FeatureLayer | SceneLayer | PointCloudLayer; + /** + * The name of the numeric field for which the summary statistics will be generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#summaryStatistics) + */ field?: string; + /** + * The field by which to normalize the values returned from the given `field`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#summaryStatistics) + */ normalizationField?: string; + /** + * If the FeatureLayer is constructed with client-side graphics or you would like to calculate statistics based on a subset of features, then pass the features in this parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#summaryStatistics) + */ features?: Graphic[]; + /** + * The minimum bounding value for the statistics calculation. Use this in conjunction with `maxValue` to generate statistics between lower and upper bounds. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#summaryStatistics) + */ minValue?: number; + /** + * The maximum bounding value for the statistics calculation. Use this in conjunction with `minValue` to generate statistics between lower and upper bounds. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html#summaryStatistics) + */ maxValue?: number; } + /** + * A function that queries for unique values from a field in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html) + */ interface uniqueValues { + /** + * Returns an object containing an array of unique values queried from a given field in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) along with the total count of features that belong to the given category. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html#uniqueValues) + * + * @param params See the table below for details of each parameter. + * @param params.layer The layer from which to query for unique values. + * @param params.field The name of the numeric or string field from which the unique values will be obtained. + * @param params.features If the `layer` is a FeatureLayer constructed with client-side graphics or you would like to calculate statistics based on a subset of features, then pass the features in this parameter. + * @param params.returnAllCodedValues Indicates that all domain codes should be returned if the given field has domain values. + * + */ uniqueValues(params: uniqueValuesUniqueValuesParams): IPromise; } @@ -4721,239 +19813,1298 @@ declare namespace __esri { export const uniqueValues: typeof __uniqueValuesMapped.uniqueValues; - export interface UniqueValuesResult { + /** + * An object that contains the unique values returned from the [uniqueValues()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html#uniqueValues) query of a layer's field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html#UniqueValuesResult) + */ + export interface UniqueValuesResult extends Object { + /** + * An array of objects, each containing a unique value/type/category present in the field specifed in the [uniqueValues()](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html#uniqueValues) query. See table below for the specification of each object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html#UniqueValuesResult) + */ uniqueValueInfos: UniqueValuesResultUniqueValueInfos[]; } - export interface uniqueValuesUniqueValuesParams { + + export interface uniqueValuesUniqueValuesParams extends Object { + /** + * The layer from which to query for unique values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html#uniqueValues) + */ layer: FeatureLayer | SceneLayer | PointCloudLayer; + /** + * The name of the numeric or string field from which the unique values will be obtained. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html#uniqueValues) + */ field: string; + /** + * If the `layer` is a FeatureLayer constructed with client-side graphics or you would like to calculate statistics based on a subset of features, then pass the features in this parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html#uniqueValues) + */ features?: Graphic[]; + /** + * Indicates that all domain codes should be returned if the given field has domain values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html#uniqueValues) + */ returnAllCodedValues?: boolean; } - export interface UniqueValuesResultUniqueValueInfos { + + export interface UniqueValuesResultUniqueValueInfos extends Object { + /** + * A unique value representing a type or category of features in the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html#UniqueValuesResult) + */ value: string | number; + /** + * The number of features assigned the given `value` (or belonging to the given category). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-uniqueValues.html#UniqueValuesResult) + */ count: number; } + interface symbologyColor { + /** + * Clones a color scheme object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#cloneScheme) + * + * @param scheme The color scheme object to clone. + * + */ cloneScheme(scheme: ColorScheme): ColorScheme; + /** + * Flips the colors in reverse order of the input color scheme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#flipColors) + * + * @param scheme The color scheme to reverse. + * + */ flipColors(scheme: ColorScheme): ColorScheme; + /** + * Returns a primary scheme and secondary schemes defining symbol properties for data-driven color visualizions in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). The `basemap` parameter determines the color schemes of the graphics used to visualize each feature. The `geometryType` determines which type of symbol to return. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#getSchemes) + * + * @param params See the table below for details of each parameter that may be passed to this function. + * @param params.basemap The basemap to pair with the visualization. This value indicates the best symbol colors for visualizing features against the given basemap. + * @param params.geometryType The geometry type of the features to visualize. **Known Values:** point | multipoint | polyline | polygon | mesh + * @param params.theme + * The theme determines which values will be emphasized in the continuous ramp and the map. Valid values are listed below. + * + * | Value | Description | Example | + * | ----- | ----------- | ------- | + * | high-to-low | High values are emphasized with strong colors. | ![high-to-low](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-high-to-low.png) | + * | above-and-below | Values centered around a given point (e.g. the average) are visualized with weak colors while other values are emphasized with strong colors. | ![above-and-below](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-above-and-below.png) | + * | centered-on | Values centered around a given point (e.g. the average) are emphasized with strong colors while other values are visualized with weak colors. | ![centered-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-centered-on.png) | + * | extremes | High and low values are emphasized with strong colors. All others are visualized with weak colors. | ![extremes](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-extremes.png) | + * @param params.view The SceneView instance in which the scheme will be used. This property is only applicable when the scheme will be used in conjunction with 3D symbols. + * @param params.worldScale Indicates if the size units of the scheme will be in meters. This should be `true` when the scheme is intended for 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * + */ getSchemes(params: colorGetSchemesParams): any; + /** + * Returns metadata for the available themes. If a `basemap` is provided, returns themes that look best with the given basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#getThemes) + * + * @param basemap The [Esri basemap string](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) or object that will be used with the returned theme(s). + * + */ getThemes(basemap?: string | Basemap): any[]; } export const symbologyColor: symbologyColor; - export interface colorGetSchemesParams { + + export interface colorGetSchemesParams extends Object { + /** + * The basemap to pair with the visualization. This value indicates the best symbol colors for visualizing features against the given basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#getSchemes) + */ basemap: string | Basemap; + /** + * The geometry type of the features to visualize. **Known Values:** point | multipoint | polyline | polygon | mesh + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#getSchemes) + */ geometryType: string; + /** + * The theme determines which values will be emphasized in the continuous ramp and the map. Valid values are listed below. + * + * | Value | Description | Example | + * | ----- | ----------- | ------- | + * | high-to-low | High values are emphasized with strong colors. | ![high-to-low](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-high-to-low.png) | + * | above-and-below | Values centered around a given point (e.g. the average) are visualized with weak colors while other values are emphasized with strong colors. | ![above-and-below](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-above-and-below.png) | + * | centered-on | Values centered around a given point (e.g. the average) are emphasized with strong colors while other values are visualized with weak colors. | ![centered-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-centered-on.png) | + * | extremes | High and low values are emphasized with strong colors. All others are visualized with weak colors. | ![extremes](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-extremes.png) | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#getSchemes) + */ theme: string; + /** + * The SceneView instance in which the scheme will be used. This property is only applicable when the scheme will be used in conjunction with 3D symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#getSchemes) + */ view?: SceneView; + /** + * Indicates if the size units of the scheme will be in meters. This should be `true` when the scheme is intended for 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#getSchemes) + */ worldScale?: boolean; } - export interface ColorScheme { + /** + * Properties defining the symbology scheme used to visualize features with attribute data-driven color. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ + export interface ColorScheme extends Object { + /** + * The unique id of the color scheme to usee in the visualization. The id is assigned based on the following template: `//`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ id: string; + /** + * Indicates which values will be emphasized in the continuous ramp and the map. Valid values are listed below. + * + * | Value | Description | Example | + * | ----- | ----------- | ------- | + * | high-to-low | High values are emphasized with strong colors. | ![high-to-low](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-high-to-low.png) | + * | above-and-below | Values centered around a given point (e.g. the average) are visualized with weak colors while other values are emphasized with strong colors. | ![above-and-below](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-above-and-below.png) | + * | centered-on | Values centered around a given point (e.g. the average) are emphasized with strong colors while other values are visualized with weak colors. | ![centered-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-centered-on.png) | + * | extremes | High and low values are emphasized with strong colors. All others are visualized with weak colors. | ![extremes](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/sm-extremes.png) | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ theme: string; + /** + * The continuous color ramp that will be applied to the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ colors: Color[]; + /** + * The color of the symbol used to indicate features with no data and features that are out of range. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ noDataColor: Color; + /** + * Predefined classed color schemes to use for the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ colorsForClassBreaks: ColorSchemeColorsForClassBreaks[]; + /** + * Properties for defining the outline of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ outline: ColorSchemeOutline; + /** + * The default size of the symbol in pixels or points if the geometry type is `point`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ size: number; + /** + * The default width of the symbol in pixels or points if the geometry type is `polyline`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ width: number; + /** + * The opacity of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ opacity: number; } - export interface ColorSchemeColorsForClassBreaks { + + export interface ColorSchemeColorsForClassBreaks extends Object { + /** + * An array of hex color strings. Each color is assigned to a specific break in classed color visualizations. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ colors: Color[]; + /** + * The number of classes used in the classed color visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ numClasses: number; } - export interface ColorSchemeOutline { + + export interface ColorSchemeOutline extends Object { + /** + * The outline color of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ color: Color; + /** + * The width of the symbol in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-color.html#ColorScheme) + */ width: number; } + interface symbologyLocation { + /** + * Clones a location scheme object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#cloneScheme) + * + * @param scheme The location scheme object to clone. + * + */ cloneScheme(scheme: PointLocationScheme | PolylineLocationScheme | PolygonLocationScheme): PointLocationScheme | PolylineLocationScheme | PolygonLocationScheme; + /** + * Returns a primary scheme and secondary schemes defining symbol properties for location-only visualizions in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html). The `basemap` parameter determines the color of the graphics used to visualize each feature. The `geometryType` determines which type of symbol to return. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#getSchemes) + * + * @param params See the table below for details of each parameter that may be passed to this function. + * @param params.basemap The basemap to pair with the visualization. This value indicates the best symbol color for visualizing features on top of the given basemap. + * @param params.geometryType The geometry type of the features to visualize. **Known Values:** point | multipoint | polyline | polygon | mesh + * @param params.view The SceneView instance in which the scheme will be used. This property is only applicable when the scheme will be used in conjunction with 3D symbols. + * @param params.worldScale Indicates if the size units of the scheme will be in meters. This should be `true` when the scheme is intended for 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * + */ getSchemes(params: locationGetSchemesParams): any; } export const symbologyLocation: symbologyLocation; - export interface locationGetSchemesParams { + + export interface locationGetSchemesParams extends Object { + /** + * The basemap to pair with the visualization. This value indicates the best symbol color for visualizing features on top of the given basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#getSchemes) + */ basemap: string | Basemap; + /** + * The geometry type of the features to visualize. **Known Values:** point | multipoint | polyline | polygon | mesh + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#getSchemes) + */ geometryType: string; + /** + * The SceneView instance in which the scheme will be used. This property is only applicable when the scheme will be used in conjunction with 3D symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#getSchemes) + */ view?: SceneView; + /** + * Indicates if the size units of the scheme will be in meters. This should be `true` when the scheme is intended for 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#getSchemes) + */ worldScale?: boolean; } - export interface PointLocationScheme { + /** + * Properties defining the location-only symbology scheme used to visualize point features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PointLocationScheme) + */ + export interface PointLocationScheme extends Object { + /** + * The fill color of the marker symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PointLocationScheme) + */ color: Color; + /** + * Properties for defining the outline of the marker symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PointLocationScheme) + */ outline: PointLocationSchemeOutline; + /** + * The size of the marker symbol in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PointLocationScheme) + */ size: number; + /** + * The opacity of the marker symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PointLocationScheme) + */ opacity: number; } - export interface PolygonLocationScheme { + /** + * Properties defining the location-only symbology scheme used to visualize polygon features driven by attribute data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PolygonLocationScheme) + */ + export interface PolygonLocationScheme extends Object { + /** + * The color of the fill symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PolygonLocationScheme) + */ color: Color; + /** + * Properties for defining the outline of the fill symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PolygonLocationScheme) + */ outline: PolygonLocationSchemeOutline; + /** + * The opacity of the fill symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PolygonLocationScheme) + */ opacity: number; } - export interface PolylineLocationScheme { + /** + * Properties defining the location-only symbology scheme used to visualize polyline features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PolylineLocationScheme) + */ + export interface PolylineLocationScheme extends Object { + /** + * The color of the line symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PolylineLocationScheme) + */ color: Color; + /** + * The width of the line symbol in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PolylineLocationScheme) + */ width: number; + /** + * The opacity of the line symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PolylineLocationScheme) + */ opacity: number; } - export interface PointLocationSchemeOutline { + + export interface PointLocationSchemeOutline extends Object { + /** + * The outline color of the marker symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PointLocationScheme) + */ color: Color; + /** + * The width of the marker symbol in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PointLocationScheme) + */ width: number; } - export interface PolygonLocationSchemeOutline { + + export interface PolygonLocationSchemeOutline extends Object { + /** + * The outline color of the fill symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PolygonLocationScheme) + */ color: Color; + /** + * The width of the fill symbol in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-location.html#PolygonLocationScheme) + */ width: number; } + interface symbologySize { + /** + * Clones a size scheme object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#cloneScheme) + * + * @param scheme The SizeScheme object to clone. + * + */ cloneScheme(scheme: PointSizeScheme | PolylineSizeScheme | PolygonSizeScheme): any; + /** + * Returns a primary scheme and secondary schemes defining symbol properties for size-based data-driven visualizions in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). The `basemap` parameter determines the color of the graphics used to visualize each feature. The `geometryType` determines which type of symbol to return. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#getSchemes) + * + * @param params See the table below for details of each parameter that may be passed to this function. + * @param params.basemap The basemap to pair with the visualization. This value indicates the best symbol color for visualizing features against the given basemap. + * @param params.geometryType The geometry type of the features to visualize. **Known Values:** point | multipoint | polyline | polygon + * @param params.view The SceneView instance in which the scheme will be used. This property is only applicable when the scheme will be used in conjunction with 3D symbols. + * @param params.worldScale Indicates if the size units of the scheme will be in meters. This should be `true` when the scheme is intended for 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * + */ getSchemes(params: sizeGetSchemesParams): any; } export const symbologySize: symbologySize; - export interface PointSizeScheme { + /** + * Properties defining the symbology scheme used to visualize point features driven by attribute data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PointSizeScheme) + */ + export interface PointSizeScheme extends Object { + /** + * The fill color of the marker symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PointSizeScheme) + */ color: Color; + /** + * The color of the marker symbol used to indicate features with no data and features that are out of range. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PointSizeScheme) + */ noDataColor: Color; + /** + * Properties for defining the outline of the marker symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PointSizeScheme) + */ outline: PointSizeSchemeOutline; + /** + * The default size of the marker symbol in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PointSizeScheme) + */ size: number; + /** + * The size of the marker symbol (in pixels or points) used to indicate features with no data and features that are out of range. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PointSizeScheme) + */ noDataSize: number; + /** + * The minimum size of a marker symbol in pixels or points representing features with low data values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PointSizeScheme) + */ minSize: number; + /** + * The maximum size of a marker symbol in pixels or points representing features with high data values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PointSizeScheme) + */ maxSize: number; + /** + * The opacity of the marker symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PointSizeScheme) + */ opacity: number; } - export interface PolygonSizeScheme { + /** + * Properties defining the symbology scheme used to visualize polygon features driven by attribute data. When visualized by size, polygons are represented with marker symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolygonSizeScheme) + */ + export interface PolygonSizeScheme extends Object { + /** + * The scheme defining the symbology of the marker symbol used to represent polygon features by size. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolygonSizeScheme) + */ marker: PointSizeScheme; + /** + * The schema defining the backgound symbol of the feature. This is a fill symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolygonSizeScheme) + */ background: PolygonSizeSchemeBackground; + /** + * The opacity of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolygonSizeScheme) + */ opacity: number; } - export interface PolylineSizeScheme { + /** + * Properties defining the symbology scheme used to visualize polyline features driven by attribute data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolylineSizeScheme) + */ + export interface PolylineSizeScheme extends Object { + /** + * The color of the line symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolylineSizeScheme) + */ color: Color; + /** + * The color of the line symbol used to indicate features with no data and features that are out of range. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolylineSizeScheme) + */ noDataColor: Color; + /** + * The default width of the line symbol in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolylineSizeScheme) + */ width: number; + /** + * The width of the line symbol in pixels or points used to indicate features with no data and features that are out of range. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolylineSizeScheme) + */ noDataWidth: number; + /** + * The minimum width of a line symbol in pixels or points representing features with low data values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolylineSizeScheme) + */ minWidth: number; + /** + * The maximum width of a line symbol in pixels or points representing features with high data values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolylineSizeScheme) + */ maxWidth: number; + /** + * The opacity of the line symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolylineSizeScheme) + */ opacity: number; } - export interface sizeGetSchemesParams { + + export interface sizeGetSchemesParams extends Object { + /** + * The basemap to pair with the visualization. This value indicates the best symbol color for visualizing features against the given basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#getSchemes) + */ basemap: string | Basemap; + /** + * The geometry type of the features to visualize. **Known Values:** point | multipoint | polyline | polygon + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#getSchemes) + */ geometryType: string; + /** + * The SceneView instance in which the scheme will be used. This property is only applicable when the scheme will be used in conjunction with 3D symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#getSchemes) + */ view?: SceneView; + /** + * Indicates if the size units of the scheme will be in meters. This should be `true` when the scheme is intended for 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#getSchemes) + */ worldScale?: boolean; } - export interface PointSizeSchemeOutline { + + export interface PointSizeSchemeOutline extends Object { + /** + * The outline color of the marker symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PointSizeScheme) + */ color: Color; + /** + * The width of the marker symbol in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PointSizeScheme) + */ width: number; } - export interface PolygonSizeSchemeBackground { + + export interface PolygonSizeSchemeBackground extends Object { + /** + * The color of the fill symbol representing the polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolygonSizeScheme) + */ color: Color; + /** + * Properties for defining the outline of the background fill symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolygonSizeScheme) + */ outline: PolygonSizeSchemeBackgroundOutline; } - export interface PolygonSizeSchemeBackgroundOutline { + + export interface PolygonSizeSchemeBackgroundOutline extends Object { + /** + * The outline color of the background fill symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolygonSizeScheme) + */ color: Color; + /** + * The width of the background fill symbol's outline in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-size.html#PolygonSizeScheme) + */ width: number; } + interface symbologyType { + /** + * Clones a type scheme object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#cloneScheme) + * + * @param scheme The type scheme object to clone. + * + */ cloneScheme(scheme: PointTypeScheme | PolylineTypeScheme | PolygonTypeScheme | MeshTypeScheme): any; + /** + * Returns a primary scheme and secondary schemes defining symbol properties for type-based data-driven visualizions in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). The `basemap` parameter determines the color of the graphics used to visualize each feature. The `geometryType` determines which type of symbol to return. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#getSchemes) + * + * @param params See the table below for details of each parameter that may be passed to this function. + * @param params.basemap The basemap to pair with the visualization. This value indicates the best symbol color for visualizing features against the given basemap. + * @param params.geometryType The geometry type of the features to visualize. **Known Values:** point | multipoint | polyline | polygon | mesh + * @param params.theme Determines whether to return a standardized unique value scheme for point cloud class renderers (i.e. when the `CLASS_CODE` field is driving the visualization in a [PointCloudLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html)), or to return the other default primary schemes used in other unique value renderers generated for non-point cloud layer types. **Known Values:** point-cloud-class | default + * @param params.worldScale Indicates if the size units of the scheme will be in meters. This should be `true` when the scheme is intended for 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * @param params.view The SceneView instance in which the scheme will be used. This property is only applicable when the scheme will be used in conjunction with 3D symbols. + * + */ getSchemes(params: typeGetSchemesParams): any; } export const symbologyType: symbologyType; - export interface MeshTypeScheme { + /** + * Properties defining the symbology scheme used to visualize mesh features driven by type-based attribute data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#MeshTypeScheme) + */ + export interface MeshTypeScheme extends Object { + /** + * The fill colors of the symbols comprising the theme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#MeshTypeScheme) + */ colors: Color[]; + /** + * The color of the fill symbol used to indicate features with no data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#MeshTypeScheme) + */ noDataColor: Color; + /** + * The opacity of the symbol (0 - 1). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#MeshTypeScheme) + */ opacity: number; } - export interface PointTypeScheme { + /** + * Properties defining the symbology scheme used to visualize point features driven by type-based attribute data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PointTypeScheme) + */ + export interface PointTypeScheme extends Object { + /** + * The fill colors of the point symbols comprising the theme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PointTypeScheme) + */ colors: Color[]; + /** + * The color of the point symbol used to indicate features with no data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PointTypeScheme) + */ noDataColor: Color; + /** + * Properties for defining the outline of the marker symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PointTypeScheme) + */ outline: PointTypeSchemeOutline; + /** + * The default size of the point symbol in pixels, points, or real-world units. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PointTypeScheme) + */ size: number; + /** + * The opacity of the point symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PointTypeScheme) + */ opacity: number; } - export interface PolygonTypeScheme { + /** + * Properties defining the symbology scheme used to visualize polygon features driven by type-based attribute data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolygonTypeScheme) + */ + export interface PolygonTypeScheme extends Object { + /** + * The fill colors of the symbols comprising the theme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolygonTypeScheme) + */ colors: Color[]; + /** + * The color of the fill symbol used to indicate features with no data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolygonTypeScheme) + */ noDataColor: Color; + /** + * Properties for defining the outline of the fill symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolygonTypeScheme) + */ outline: PolygonTypeSchemeOutline; + /** + * The opacity of the symbol (0 - 1). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolygonTypeScheme) + */ opacity: number; } - export interface PolylineTypeScheme { + /** + * Properties defining the symbology scheme used to visualize polyline features driven by type-based attribute data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolylineTypeScheme) + */ + export interface PolylineTypeScheme extends Object { + /** + * The colors of the line symbols comprising the theme. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolylineTypeScheme) + */ colors: Color[]; + /** + * The color of the line symbol used to indicate features with no data and features that are out of range. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolylineTypeScheme) + */ noDataColor: Color; + /** + * The default width of the line symbol in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolylineTypeScheme) + */ width: number; + /** + * The opacity of the line symbol (0 - 1). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolylineTypeScheme) + */ opacity: number; } - export interface typeGetSchemesParams { + + export interface typeGetSchemesParams extends Object { + /** + * The basemap to pair with the visualization. This value indicates the best symbol color for visualizing features against the given basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#getSchemes) + */ basemap: string | Basemap; + /** + * The geometry type of the features to visualize. **Known Values:** point | multipoint | polyline | polygon | mesh + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#getSchemes) + */ geometryType: string; + /** + * Determines whether to return a standardized unique value scheme for point cloud class renderers (i.e. when the `CLASS_CODE` field is driving the visualization in a [PointCloudLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-PointCloudLayer.html)), or to return the other default primary schemes used in other unique value renderers generated for non-point cloud layer types. **Known Values:** point-cloud-class | default + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#getSchemes) + * + * @default default + */ theme?: string; + /** + * Indicates if the size units of the scheme will be in meters. This should be `true` when the scheme is intended for 3D volumetric symbology. A `view` must be provided if this property is set to `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#getSchemes) + */ worldScale?: boolean; + /** + * The SceneView instance in which the scheme will be used. This property is only applicable when the scheme will be used in conjunction with 3D symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#getSchemes) + */ view?: SceneView; } - export interface PointTypeSchemeOutline { + + export interface PointTypeSchemeOutline extends Object { + /** + * The outline color of the marker symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PointTypeScheme) + */ color: Color; + /** + * The width of the marker symbol in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PointTypeScheme) + */ width: number; } - export interface PolygonTypeSchemeOutline { + + export interface PolygonTypeSchemeOutline extends Object { + /** + * The outline color of the fill symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolygonTypeScheme) + */ color: Color; + /** + * The width of the fill symbol's outline in pixels or points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-symbology-type.html#PolygonTypeScheme) + */ width: number; } + interface AuthoringInfo extends Accessor, JSONSupport { + /** + * Indicates which classification method was used if a classed color or classed size renderer was generated using one of the Smart Mapping functions. **Known Values:** equal-interval | manual | natural-breaks | quantile | standard-deviation + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#classificationMethod) + */ + classificationMethod: string; + /** + * An array of string values representing field names used for creating predominance renderers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#fields) + */ + fields: string[]; + /** + * **Only applicable to renderer used in web scenes.** Indicates the unit used in real-world sizes. **Known Values:** inches | feet | yards | miles | nautical-miles | millimeters | centimeters | decimeters | meters | kilometers | decimal-degrees + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#lengthUnit) + */ + lengthUnit: string; + /** + * Indicates the standard deviation interval for each stop in a classed color or classed size renderer that was generated using the `standard-deviation` classification method. **Known Values:** 0.25 | 0.33 | 0.5 | 1 + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#standardDeviationInterval) + */ + standardDeviationInterval: number; + /** + * Indicates the renderer type generated from one of the Smart Mapping functions. **Known Values:** class-breaks-size | class-breaks-color | predominance | univariate-color-size + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#type) + */ + type: string; + /** + * Contains authoring properties of visual variables generated from one of the Smart Mapping methods or sliders. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#visualVariables) + */ + visualVariables: AuthoringInfoVisualVariable[]; + + /** + * Creates a deep clone of the instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#clone) + * + * + */ + clone(): AuthoringInfo; + } + + interface AuthoringInfoConstructor { + + + new(properties?: AuthoringInfoProperties): AuthoringInfo; + + fromJSON(json: any): AuthoringInfo; + } + + export const AuthoringInfo: AuthoringInfoConstructor; + + interface AuthoringInfoProperties { + /** + * Indicates which classification method was used if a classed color or classed size renderer was generated using one of the Smart Mapping functions. **Known Values:** equal-interval | manual | natural-breaks | quantile | standard-deviation + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#classificationMethod) + */ + classificationMethod?: string; + /** + * An array of string values representing field names used for creating predominance renderers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#fields) + */ + fields?: string[]; + /** + * **Only applicable to renderer used in web scenes.** Indicates the unit used in real-world sizes. **Known Values:** inches | feet | yards | miles | nautical-miles | millimeters | centimeters | decimeters | meters | kilometers | decimal-degrees + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#lengthUnit) + */ + lengthUnit?: string; + /** + * Indicates the standard deviation interval for each stop in a classed color or classed size renderer that was generated using the `standard-deviation` classification method. **Known Values:** 0.25 | 0.33 | 0.5 | 1 + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#standardDeviationInterval) + */ + standardDeviationInterval?: number; + /** + * Indicates the renderer type generated from one of the Smart Mapping functions. **Known Values:** class-breaks-size | class-breaks-color | predominance | univariate-color-size + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#type) + */ + type?: string; + /** + * Contains authoring properties of visual variables generated from one of the Smart Mapping methods or sliders. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfo.html#visualVariables) + */ + visualVariables?: AuthoringInfoVisualVariableProperties[]; + } + + interface AuthoringInfoVisualVariable extends Accessor, JSONSupport { + /** + * If an age or timeline renderer was generated, indicates the end time of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#endTime) + */ + endTime: string | number; + /** + * Indicates the field name used for generating the data-driven visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#field) + */ + field: string; + /** + * Indicates the value of the upper handle if a slider was used to generate the visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#maxSliderValue) + */ + maxSliderValue: number; + /** + * Indicates the value of the lower handle if a slider was used to generate the visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#minSliderValue) + */ + minSliderValue: number; + /** + * If an age or timeline renderer was generated, indicates the start time of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#startTime) + */ + startTime: string | number; + /** + * If the UI offers the option to display values based on a ratio or percentage, this indicates which selection was made. **Known Values:** percent | percent-of-total | ratio + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#style) + */ + style: string; + /** + * Indicates the theme selected by the user when generating a renderer or visual variable with one of the Smart Mapping functions. **Known Values:** above-and-below | centered-on | extremes | high-to-low + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#theme) + */ + theme: string; + /** + * The type of visual variable generated. **Known Values:** color | size | opacity + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#type) + */ + type: string; + /** + * If an age or timeline renderer was generated, indicates the time units used. **Known Values:** seconds | minutes | hours | days | months | years + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#units) + */ + units: string; + + /** + * Creates a deep clone of the instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#clone) + * + * + */ + clone(): AuthoringInfoVisualVariable; + } + + interface AuthoringInfoVisualVariableConstructor { + + + new(properties?: AuthoringInfoVisualVariableProperties): AuthoringInfoVisualVariable; + + fromJSON(json: any): AuthoringInfoVisualVariable; + } + + export const AuthoringInfoVisualVariable: AuthoringInfoVisualVariableConstructor; + + interface AuthoringInfoVisualVariableProperties { + /** + * If an age or timeline renderer was generated, indicates the end time of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#endTime) + */ + endTime?: string | number; + /** + * Indicates the field name used for generating the data-driven visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#field) + */ + field?: string; + /** + * Indicates the value of the upper handle if a slider was used to generate the visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#maxSliderValue) + */ + maxSliderValue?: number; + /** + * Indicates the value of the lower handle if a slider was used to generate the visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#minSliderValue) + */ + minSliderValue?: number; + /** + * If an age or timeline renderer was generated, indicates the start time of the visualization. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#startTime) + */ + startTime?: string | number; + /** + * If the UI offers the option to display values based on a ratio or percentage, this indicates which selection was made. **Known Values:** percent | percent-of-total | ratio + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#style) + */ + style?: string; + /** + * Indicates the theme selected by the user when generating a renderer or visual variable with one of the Smart Mapping functions. **Known Values:** above-and-below | centered-on | extremes | high-to-low + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#theme) + */ + theme?: string; + /** + * The type of visual variable generated. **Known Values:** color | size | opacity + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#type) + */ + type?: string; + /** + * If an age or timeline renderer was generated, indicates the time units used. **Known Values:** seconds | minutes | hours | days | months | years + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AuthoringInfoVisualVariable.html#units) + */ + units?: string; + } + + interface supportJsonUtils { + /** + * Creates a new instance of an appropriate [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input `json` parameter often comes from a response to a query operation in the REST API or a [toJSON()](http://pro.arcgis.com/en/pro-app/tool-reference/conversion/features-to-json.htm) method from another ArcGIS product. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for details and examples of when and how to use this function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-jsonUtils.html#fromJSON) + * + * @param json A JSON representation of the instance in the ArcGIS format. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Renderer_objects/02r30000019t000000/) for examples of the structure of various input JSON objects. + * + */ fromJSON(json: any): Renderer; } export const supportJsonUtils: supportJsonUtils; interface UniqueValueRenderer extends Renderer, VisualVariablesMixin { + /** + * Label used in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) to describe features assigned the [default symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#defaultSymbol). The [default symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#defaultSymbol) is used to draw all features with unspecified, unmatched values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#defaultLabel) + */ defaultLabel: string; + /** + * The default symbol used to draw a feature whose value is not matched or specified by the renderer. If `null`, unmatched features will not be assigned a symbol. + * > **Known Limitations** SceneLayers with a `mesh` [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#geometryType) will display unmatching features with a generic symbol even if the `defaultSymbol` is `null`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#defaultSymbol) + */ defaultSymbol: Symbol; + /** + * The name of the attribute field the renderer uses to match unique values or types. A function may also be used to return a string value representing unique types if the desired type does not already explicitly exist in a field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field) + */ field: string | Function; + /** + * If needed, specifies the name of an additional attribute field the renderer will use to match values. For example, if you specify two fields: + * ```js + * var renderer = { + * type: "unique-value", // autocasts as new UniqueValueRenderer() + * field: "REGION", + * field2: "RANK", + * fieldDelimiter: ", ", // comma + space used to separate values from all fields + * uniqueValueInfos: [ + * { + * value: "North, 1", // features in the "North" region and a rank of 1 + * symbol: sym1 // will be assigned sym1 + * }, { + * value: "North, 2", // features in the "North" region and a rank of 2 + * symbol: sym2 // will be assigned sym2 + * }, + * ... + * ] + * }; + * ``` + * + * All combinations of values of [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field) and `field2` are unique values and + * may have their own symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field2) + */ field2: string; + /** + * If needed, specify the name of a third attribute field the renderer will use to match values. For example, if you specify three fields: + * ```js + * var renderer = { + * type: "unique-value", // autocasts as new UniqueValueRenderer() + * field: "REGION", + * field2: "RANK", + * field3: "CLASS", + * fieldDelimiter: ", ", // comma + space used to separate values from all fields + * uniqueValueInfos: [ + * { + * value: "North, 1, medium", // features in the "North" region, a rank of 1, and "medium" class + * symbol: sym1 // will be assigned sym1 + * }, { + * value: "North, 2, medium", // features in the "North" region, a rank of 2, and a "medium class + * symbol: sym2 // will be assigned sym2 + * }, + * ... + * ] + * }; + * ``` + * + * All combinations of values of [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field), [field2](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field2), and `field3` are unique values and + * may have their own symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field3) + */ field3: string; + /** + * String inserted between the values if multiple attribute fields are specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#fieldDelimiter) + */ fieldDelimiter: string; + /** + * An object providing options for displaying the renderer in the Legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#legendOptions) + */ legendOptions: UniqueValueRendererLegendOptions; - type: string; + /** + * The type of Renderer. For UniqueValueRenderer this value is always `unique-value`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#type) + */ + readonly type: "unique-value"; + /** + * Each element in the array is an object that provides information about a unique value associated with the renderer. Each object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#uniqueValueInfos) + */ uniqueValueInfos: UniqueValueRendererUniqueValueInfos[]; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to either a string or a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. This property is typically used as an alternative to [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field) for data-driven visualizations. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#valueExpression) + */ valueExpression: string; + /** + * The title identifying and describing the associated [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression as defined in the [valueExpression](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#valueExpression) property. This is displayed as the title of the corresponding renderer in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) in the absence of a provided `title` in the [legendOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#legendOptions) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#valueExpressionTitle) + */ valueExpressionTitle: string; - addUniqueValueInfo(valueOrInfo: string | number | any, symbol?: Symbol): void; + /** + * Adds a unique value and symbol to the renderer. You can provide the value and its associated symbol as individual arguments or as an info object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#addUniqueValueInfo) + * + * @param valueOrInfo The value to match. The value can be provided as an individual argument or as an [info object described in uniqueValueInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#uniqueValueInfos). + * @param symbol The symbol used to represent features matching the specified `value`. + * + */ + addUniqueValueInfo(valueOrInfo: string | number | any, symbol?: Symbol | SymbolProperties): void; + /** + * Creates a deep clone of the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#clone) + * + * + */ clone(): UniqueValueRenderer; + /** + * Returns rendering and legend information (as defined by the renderer) associated with the given graphic. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#getUniqueValueInfo) + * + * @param graphic The graphic whose rendering and legend information will be returned. + * + */ getUniqueValueInfo(graphic: Graphic): any; + /** + * Removes a unique value from the renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#removeUniqueValueInfo) + * + * @param value Value to remove from [uniqueValueInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#uniqueValueInfos). + * + */ removeUniqueValueInfo(value: string): void; } interface UniqueValueRendererConstructor { + /** + * UniqueValueRenderer allows you to symbolize features in a [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) based on one or more matching string attributes. This is typically done by using unique colors, fill styles, or images to represent features with equal values in a string field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html) + */ + new(properties?: UniqueValueRendererProperties): UniqueValueRenderer; fromJSON(json: any): UniqueValueRenderer; @@ -4962,44 +21113,218 @@ declare namespace __esri { export const UniqueValueRenderer: UniqueValueRendererConstructor; interface UniqueValueRendererProperties extends RendererProperties, VisualVariablesMixinProperties { + /** + * Label used in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) to describe features assigned the [default symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#defaultSymbol). The [default symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#defaultSymbol) is used to draw all features with unspecified, unmatched values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#defaultLabel) + */ defaultLabel?: string; + /** + * The default symbol used to draw a feature whose value is not matched or specified by the renderer. If `null`, unmatched features will not be assigned a symbol. + * > **Known Limitations** SceneLayers with a `mesh` [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#geometryType) will display unmatching features with a generic symbol even if the `defaultSymbol` is `null`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#defaultSymbol) + */ defaultSymbol?: SymbolProperties; + /** + * The name of the attribute field the renderer uses to match unique values or types. A function may also be used to return a string value representing unique types if the desired type does not already explicitly exist in a field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field) + */ field?: string | Function; + /** + * If needed, specifies the name of an additional attribute field the renderer will use to match values. For example, if you specify two fields: + * ```js + * var renderer = { + * type: "unique-value", // autocasts as new UniqueValueRenderer() + * field: "REGION", + * field2: "RANK", + * fieldDelimiter: ", ", // comma + space used to separate values from all fields + * uniqueValueInfos: [ + * { + * value: "North, 1", // features in the "North" region and a rank of 1 + * symbol: sym1 // will be assigned sym1 + * }, { + * value: "North, 2", // features in the "North" region and a rank of 2 + * symbol: sym2 // will be assigned sym2 + * }, + * ... + * ] + * }; + * ``` + * + * All combinations of values of [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field) and `field2` are unique values and + * may have their own symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field2) + */ field2?: string; + /** + * If needed, specify the name of a third attribute field the renderer will use to match values. For example, if you specify three fields: + * ```js + * var renderer = { + * type: "unique-value", // autocasts as new UniqueValueRenderer() + * field: "REGION", + * field2: "RANK", + * field3: "CLASS", + * fieldDelimiter: ", ", // comma + space used to separate values from all fields + * uniqueValueInfos: [ + * { + * value: "North, 1, medium", // features in the "North" region, a rank of 1, and "medium" class + * symbol: sym1 // will be assigned sym1 + * }, { + * value: "North, 2, medium", // features in the "North" region, a rank of 2, and a "medium class + * symbol: sym2 // will be assigned sym2 + * }, + * ... + * ] + * }; + * ``` + * + * All combinations of values of [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field), [field2](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field2), and `field3` are unique values and + * may have their own symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field3) + */ field3?: string; + /** + * String inserted between the values if multiple attribute fields are specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#fieldDelimiter) + */ fieldDelimiter?: string; + /** + * An object providing options for displaying the renderer in the Legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#legendOptions) + */ legendOptions?: UniqueValueRendererLegendOptions; - type?: string; + /** + * Each element in the array is an object that provides information about a unique value associated with the renderer. Each object has the following specification: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#uniqueValueInfos) + */ uniqueValueInfos?: UniqueValueRendererUniqueValueInfos[]; + /** + * An [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression evaluating to either a string or a number. This expression can reference field values using the `$feature` global variable and perform mathematical calculations and logical evaluations at runtime. This property is typically used as an alternative to [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#field) for data-driven visualizations. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#valueExpression) + */ valueExpression?: string; + /** + * The title identifying and describing the associated [Arcade](https://developers.arcgis.com/javascript/latest/guide/arcade/index.html) expression as defined in the [valueExpression](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#valueExpression) property. This is displayed as the title of the corresponding renderer in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) in the absence of a provided `title` in the [legendOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#legendOptions) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#valueExpressionTitle) + */ valueExpressionTitle?: string; } - export interface UniqueValueRendererLegendOptions { + + export interface UniqueValueRendererLegendOptions extends Object { + /** + * Describes the variable driving the visualization. This is displayed as the title of the corresponding renderer in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) and takes precedence over a [field alias](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html#alias) or [valueExpressionTitle](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#valueExpressionTitle). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#legendOptions) + */ title?: string; } - export interface UniqueValueRendererUniqueValueInfos { + + export interface UniqueValueRendererUniqueValueInfos extends Object { + /** + * The unique value used to classify features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#uniqueValueInfos) + */ value: string | number; + /** + * The symbol used to style features whose value matches `value`. This value may be autocast by specifying the symbol `type`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#uniqueValueInfos) + */ symbol: Symbol; + /** + * Label used to describe features matched to this unique value in the [Legend](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#uniqueValueInfos) + */ label?: string; } interface VisualVariablesMixin { + /** + * Visual variables define the parameters for data-driven geographic visualizations of numeric data. They allow you to easily map continuous ramps of [color](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable), [size](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable), [opacity](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable), and/or [rotation](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RotationVisualVariable) to minimum and maximum data values of one of the layer's numeric attribute fields. Visual variables can primarily be used in two ways. **1**. Thematic mapping Visual variables allow you to easily create stunning visualizations based on thematic attributes (e.g. population, education, rank, money, magnitude, etc.) in either 2D or 3D. This is accomplished by mapping data values from a numeric field attribute to color, size, and/or opacity values. The renderer then takes over and re-sizes or shades features based on the value of the given field and its position relative to the minimum and maximum values. The sample below uses three visual variables (size, color, and opacity). [![renderer-unique-vv](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/renderer-unique-vv.png)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-multivariate-2d/index.html) **2**. Mapping real-world sizes The [size](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable) visual variable can be used to visualize the true sizes of features (e.g. tree canopy, road width, building height, etc.) based on their size in the real world. This can be particularly powerful when working in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). The image below shows a layer of building footprints that uses visual variables to extrude each feature to the true height of the buildings based on data stored in an attribute field. [![renderer-vv-rw](https://developers.arcgis.com/javascript/latest/assets/img/samples/2-extrude-height.png)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-buildings-3d/index.html) The `visualVariables` property of the renderer is an array of objects called "visual variables". Each object must indicate the type of visual variable to apply (e.g. color, size, opacity, rotation), the numeric field from which to drive the visualization, and the ramp of visual values to map to the data. The following list identifies each visual variable type and provides a link to the specification table of each. + * + * Type | Object Specification | Legend Example + * -----|----------------------|--------------- + * color | [ColorVisualVariable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) | ![legend-color-vv](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/legend-color-vv.png) + * size | [SizeVisualVariable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable) | ![legend-color-vv](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/legend-size-vv.png) + * opacity | [OpacityVisualVariable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) | ![legend-color-vv](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/legend-opacity-vv.png) + * rotation | [RotationVisualVariable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RotationVisualVariable) | - + * + * See the [Visualize features with realistic 3D symbols](https://developers.arcgis.com/javascript/latest/sample-code/visualization-trees-realistic/index.html) for an example of using multiple visual variables to visualize your data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-VisualVariablesMixin.html#visualVariables) + */ visualVariables: any[]; } interface VisualVariablesMixinConstructor { + + new(): VisualVariablesMixin; } export const VisualVariablesMixin: VisualVariablesMixinConstructor; interface VisualVariablesMixinProperties { + /** + * Visual variables define the parameters for data-driven geographic visualizations of numeric data. They allow you to easily map continuous ramps of [color](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable), [size](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable), [opacity](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable), and/or [rotation](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RotationVisualVariable) to minimum and maximum data values of one of the layer's numeric attribute fields. Visual variables can primarily be used in two ways. **1**. Thematic mapping Visual variables allow you to easily create stunning visualizations based on thematic attributes (e.g. population, education, rank, money, magnitude, etc.) in either 2D or 3D. This is accomplished by mapping data values from a numeric field attribute to color, size, and/or opacity values. The renderer then takes over and re-sizes or shades features based on the value of the given field and its position relative to the minimum and maximum values. The sample below uses three visual variables (size, color, and opacity). [![renderer-unique-vv](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/renderer-unique-vv.png)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-multivariate-2d/index.html) **2**. Mapping real-world sizes The [size](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable) visual variable can be used to visualize the true sizes of features (e.g. tree canopy, road width, building height, etc.) based on their size in the real world. This can be particularly powerful when working in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). The image below shows a layer of building footprints that uses visual variables to extrude each feature to the true height of the buildings based on data stored in an attribute field. [![renderer-vv-rw](https://developers.arcgis.com/javascript/latest/assets/img/samples/2-extrude-height.png)](https://developers.arcgis.com/javascript/latest/sample-code/visualization-buildings-3d/index.html) The `visualVariables` property of the renderer is an array of objects called "visual variables". Each object must indicate the type of visual variable to apply (e.g. color, size, opacity, rotation), the numeric field from which to drive the visualization, and the ramp of visual values to map to the data. The following list identifies each visual variable type and provides a link to the specification table of each. + * + * Type | Object Specification | Legend Example + * -----|----------------------|--------------- + * color | [ColorVisualVariable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#ColorVisualVariable) | ![legend-color-vv](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/legend-color-vv.png) + * size | [SizeVisualVariable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable) | ![legend-color-vv](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/legend-size-vv.png) + * opacity | [OpacityVisualVariable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#OpacityVisualVariable) | ![legend-color-vv](https://developers.arcgis.com/javascript/latest/assets/img/apiref/renderers/legend-opacity-vv.png) + * rotation | [RotationVisualVariable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#RotationVisualVariable) | - + * + * See the [Visualize features with realistic 3D symbols](https://developers.arcgis.com/javascript/latest/sample-code/visualization-trees-realistic/index.html) for an example of using multiple visual variables to visualize your data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-VisualVariablesMixin.html#visualVariables) + */ visualVariables?: any[]; } + interface request { + /** + * Retrieves data from a remote server or uploads a file from a user's computer. If the request returns an [Error](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Error.html), the error object will include the details specified in [EsriErrorDetails](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#EsriErrorDetails). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + * + * @param url The request URL. + * @param options An object with the following properties that describe the request. + * @param options.callbackParamName Name of the callback parameter (a special service parameter) to be specified when requesting data in JSONP format. It is ignored for all other data formats. For ArcGIS services the value is always `callback`. + * @param options.query If the request URL points to a web server that requires parameters, specify them here. + * @param options.responseType Response format. When this value is `image` the `method` and `timeout` options are ignored. **Possible Values:** json | xml | text | blob | array-buffer | document | image + * @param options.headers Headers to use for the request. This is an object whose property names are header names. This is not applicable for non-XHR requests. + * @param options.timeout Indicates the amount of time in milliseconds to wait for a response from the server. Set to `0` to wait for the response indefinitely. This option is ignored when `responseType = "image"`. + * @param options.method Indicates if the request should be made using the HTTP POST method. By default, this is determined automatically based on the request size. This option is ignored when `responseType = "image"`. **Known Values:** auto | post + * @param options.body If uploading a file, specify the form data or element used to submit the file here. If a form element is specified, the parameters of the `query` will be added to the URL. If not specified, then query parameters will only be added to the URL when a GET request is used. If POST is used, then query parameters will be added to the body. + * @param options.useProxy Indicates the request should use the proxy. By default this is determined automatically based on the domain of the request url. + * @param options.cacheBust Indicates whether to send an extra query parameter to ensure the server doesn't supply cached values. + * @param options.allowImageDataAccess Indicates whether apps are allowed to read image data (when used with Canvas) from images hosted on third-party sites. Only applicable when `responseType = "image"`. + * @param options.authMode + * Indicates if and how requests to ArcGIS Services are authenticated. Only applicable when [`esriConfig.request.useIdentity = true`](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request). + * + * | Known Value | Description | + * |-------------|-------------| + * | auto | The user will be signed in when a secure resource is requested. | + * | anonymous | An error will be returned when a secure resource is requested. | + * | immediate | The user will be signed in before the resource is requested. | + * | no-prompt | Checks for whether the user is already signed in. If so, no additional prompts display for sign-in. | + * + */ esriRequest(url: string, options?: requestEsriRequestOptions): IPromise; } @@ -5007,84 +21332,371 @@ declare namespace __esri { export const request: typeof __requestMapped.esriRequest; - export interface EsriErrorDetails { + /** + * The specification of the [details object](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Error.html#details) returned in an [Error](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Error.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#EsriErrorDetails) + */ + export interface EsriErrorDetails extends Object { + /** + * A function to retrieve headers sent from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#EsriErrorDetails) + */ getHeader: GetHeader; + /** + * The status of the http request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#EsriErrorDetails) + */ httpStatus: number; + /** + * The error message code. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#EsriErrorDetails) + */ messageCode: string; + /** + * Additional error message(s). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#EsriErrorDetails) + */ messages: string[]; + /** + * The query parameters sent with the http request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#EsriErrorDetails) + */ requestOptions: any; + /** + * Indicates if the request required https. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#EsriErrorDetails) + */ ssl: boolean; + /** + * The error message subcode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#EsriErrorDetails) + */ subCode: number; + /** + * The URL of the request that returned an error message. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#EsriErrorDetails) + */ url: string; } export type GetHeader = (headerName: string) => string; - export interface requestEsriRequestOptions { + + export interface requestEsriRequestOptions extends Object { + /** + * Name of the callback parameter (a special service parameter) to be specified when requesting data in JSONP format. It is ignored for all other data formats. For ArcGIS services the value is always `callback`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + */ callbackParamName?: string; + /** + * If the request URL points to a web server that requires parameters, specify them here. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + */ query?: any; + /** + * Response format. When this value is `image` the `method` and `timeout` options are ignored. **Possible Values:** json | xml | text | blob | array-buffer | document | image + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + * + * @default json + */ responseType?: string; + /** + * Headers to use for the request. This is an object whose property names are header names. This is not applicable for non-XHR requests. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + */ headers?: any; + /** + * Indicates the amount of time in milliseconds to wait for a response from the server. Set to `0` to wait for the response indefinitely. This option is ignored when `responseType = "image"`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + * + * @default 60000 + */ timeout?: number; + /** + * Indicates if the request should be made using the HTTP POST method. By default, this is determined automatically based on the request size. This option is ignored when `responseType = "image"`. **Known Values:** auto | post + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + * + * @default auto + */ method?: string; + /** + * If uploading a file, specify the form data or element used to submit the file here. If a form element is specified, the parameters of the `query` will be added to the URL. If not specified, then query parameters will only be added to the URL when a GET request is used. If POST is used, then query parameters will be added to the body. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + */ body?: FormData | HTMLFormElement | string; + /** + * Indicates the request should use the proxy. By default this is determined automatically based on the domain of the request url. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + * + * @default false + */ useProxy?: boolean; + /** + * Indicates whether to send an extra query parameter to ensure the server doesn't supply cached values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + * + * @default false + */ cacheBust?: boolean; + /** + * Indicates whether apps are allowed to read image data (when used with Canvas) from images hosted on third-party sites. Only applicable when `responseType = "image"`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + * + * @default false + */ allowImageDataAccess?: boolean; + /** + * Indicates if and how requests to ArcGIS Services are authenticated. Only applicable when [`esriConfig.request.useIdentity = true`](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request). + * + * | Known Value | Description | + * |-------------|-------------| + * | auto | The user will be signed in when a secure resource is requested. | + * | anonymous | An error will be returned when a secure resource is requested. | + * | immediate | The user will be signed in before the resource is requested. | + * | no-prompt | Checks for whether the user is already signed in. If so, no additional prompts display for sign-in. | + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) + * + * @default auto + */ authMode?: string; } interface Action extends Accessor { + /** + * Adds a CSS class to the action's node. Can be used in conjunction with the `image` property or by itself. Any icon font may be used in this property. The [Esri Icon Font](https://developers.arcgis.com/javascript/latest/guide/esri-icon-font/index.html) is automatically made available via the ArcGIS API for JavaScript for you to use in styling custom actions. To use one of these provided icon fonts, you must prefix the class name with `esri-`. For example, the default `zoom-to` action in [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) uses the font `esri-icon-zoom-in-magnifying-glass`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#className) + */ className: string; + /** + * The name of the ID assigned to this action. This is used for differentiating actions when listening to the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#event:trigger-action) event. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#id) + */ id: string; + /** + * The URL to an image that will be used to represent the action. This property will be used as a background image for the node. It may be used in conjunction with the `className` property or by itself. If neither `image` nor `className` are specified, a default icon ![default icon](https://developers.arcgis.com/javascript/latest/assets/img/guide/whats-new/41/default-action.png) will display. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#image) + */ image: string; + /** + * The title of the action. _For popups_: When there are fewer than three actions defined in a popup, this text is displayed to the right of the icon or image representing the action. If there are three or more actions in the popup, then this text is used as a tooltip on the action. _For LayerList_: The first action is displayed in the layerlist with an icon. The layerlist has a menu that will display all actions with their titles + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#title) + */ title: string; + /** + * Indicates if the action is visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#visible) + * + * @default true + */ visible: boolean; + /** + * Creates a deep clone of this object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#clone) + * + * + */ clone(): Action; } interface ActionConstructor { + + new(properties?: ActionProperties): Action; } export const Action: ActionConstructor; interface ActionProperties { + /** + * Adds a CSS class to the action's node. Can be used in conjunction with the `image` property or by itself. Any icon font may be used in this property. The [Esri Icon Font](https://developers.arcgis.com/javascript/latest/guide/esri-icon-font/index.html) is automatically made available via the ArcGIS API for JavaScript for you to use in styling custom actions. To use one of these provided icon fonts, you must prefix the class name with `esri-`. For example, the default `zoom-to` action in [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) uses the font `esri-icon-zoom-in-magnifying-glass`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#className) + */ className?: string; + /** + * The name of the ID assigned to this action. This is used for differentiating actions when listening to the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#event:trigger-action) event. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#id) + */ id?: string; + /** + * The URL to an image that will be used to represent the action. This property will be used as a background image for the node. It may be used in conjunction with the `className` property or by itself. If neither `image` nor `className` are specified, a default icon ![default icon](https://developers.arcgis.com/javascript/latest/assets/img/guide/whats-new/41/default-action.png) will display. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#image) + */ image?: string; + /** + * The title of the action. _For popups_: When there are fewer than three actions defined in a popup, this text is displayed to the right of the icon or image representing the action. If there are three or more actions in the popup, then this text is used as a tooltip on the action. _For LayerList_: The first action is displayed in the layerlist with an icon. The layerlist has a menu that will display all actions with their titles + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#title) + */ title?: string; + /** + * Indicates if the action is visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html#visible) + * + * @default true + */ visible?: boolean; } interface LayersMixin { + /** + * A collection of operational [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). This property only contains interactive operational layers, such as [FeatureLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), [WebTileLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html) and {@link module:esri/layers/GraphicsLayer GraphicsLayers} that may be queried, assigned different renderers, analyzed, etc. It does not include [basemaps](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html). A [layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) is a collection of one or more features, or {@link module:esri/Graphic graphics}, that represent real-world phenomena. Each feature contains a {@link module:esri/symbols/Symbol symbol} and [geographic data](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) that allows it to be rendered on the map as a graphic with spatial context. Features within the layer may also contain data attributes that provide additional information that may be viewed in [popup windows](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) and used for {@link module:esri/renderers/Renderer rendering the layer}. Layers may be added in the [constructor](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#constructors-summary), with the [add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#add) or [addMany()](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#addMany) methods, or directly to the layers collection using [add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#add) or [addMany()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#addMany). + * > A [layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) may only be added to one parent. Adding the same layer to multiple [Maps](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) or [GroupLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html) is not possible. If you attempt to do so, the layer will automatically be removed from its current parent and placed in the new parent. + * > ```js + * > var layer = new GraphicsLayer(); + * > // The layer belongs to map1 + * > map1.layers.add(layer); + * > // The layer now belongs to map2 + * > // and implicitly does: map1.layers.remove(layer) + * > map2.layers.add(layer); + * > ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers) + */ layers: Collection; - add(layers: Layer, index?: number): void; + /** + * Adds a layer to the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#add) + * + * @param layer Layer to be added to the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers). + * @param index A layer can be added at a specified index in the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers). If no index is specified or the index specified is greater than the current number of layers, the layer is automatically appended to the list of layers in the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers) and the index is normalized. + * + */ + add(layer: Layer, index?: number): void; + /** + * Adds a layer or an array of layers to the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#addMany) + * + * @param layers Layer(s) to be added to the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers). + * @param index A layer can be added at a specified index in the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers). If no index is specified or the index specified is greater than the current number of layers, the layer is automatically appended to the list of layers in the [layers collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers) and the index is normalized. + * + */ addMany(layers: Layer[], index?: number): void; + /** + * Returns a layer based on the given layer id. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#findLayerById) + * + * @param layerId The ID assigned to the layer. + * + */ findLayerById(layerId: string): Layer; + /** + * Removes the specified layer from the layers collection. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#remove) + * + * @param layer Layer to remove from the layers collection. + * + */ remove(layer: Layer): Layer; + /** + * Removes all layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#removeAll) + * + * + */ removeAll(): Layer[]; + /** + * Removes the specified layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#removeMany) + * + * @param layers Array of layers to remove from the layers collection. + * + */ removeMany(layers: Layer[]): Layer[]; + /** + * Changes the layer order. The first layer added is always the base layer, even if its order is changed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#reorder) + * + * @param layer The layer to be moved. + * @param index The index location for placing the layer. The bottom-most layer has an index of `0`. + * + */ reorder(layer: Layer, index: number): Layer; } interface LayersMixinConstructor { + + new(): LayersMixin; } export const LayersMixin: LayersMixinConstructor; interface LayersMixinProperties { - layers?: CollectionProperties; + /** + * A collection of operational [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html). This property only contains interactive operational layers, such as [FeatureLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), [WebTileLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WebTileLayer.html) and {@link module:esri/layers/GraphicsLayer GraphicsLayers} that may be queried, assigned different renderers, analyzed, etc. It does not include [basemaps](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html). A [layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) is a collection of one or more features, or {@link module:esri/Graphic graphics}, that represent real-world phenomena. Each feature contains a {@link module:esri/symbols/Symbol symbol} and [geographic data](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) that allows it to be rendered on the map as a graphic with spatial context. Features within the layer may also contain data attributes that provide additional information that may be viewed in [popup windows](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) and used for {@link module:esri/renderers/Renderer rendering the layer}. Layers may be added in the [constructor](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#constructors-summary), with the [add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#add) or [addMany()](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#addMany) methods, or directly to the layers collection using [add()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#add) or [addMany()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#addMany). + * > A [layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) may only be added to one parent. Adding the same layer to multiple [Maps](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) or [GroupLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html) is not possible. If you attempt to do so, the layer will automatically be removed from its current parent and placed in the new parent. + * > ```js + * > var layer = new GraphicsLayer(); + * > // The layer belongs to map1 + * > map1.layers.add(layer); + * > // The layer now belongs to map2 + * > // and implicitly does: map1.layers.remove(layer) + * > map2.layers.add(layer); + * > ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-LayersMixin.html#layers) + */ + layers?: CollectionProperties | LayerProperties[]; } interface Callout3D extends Accessor, JSONSupport { + /** + * Creates a deep clone of the callout. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-Callout3D.html#clone) + * + * + */ clone(): Callout3D; } interface Callout3DConstructor { + /** + * When symbols have an offset from their position, it's important to still see what the real location is. This can be achieved with callouts: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-Callout3D.html) + */ + new(properties?: Callout3DProperties): Callout3D; fromJSON(json: any): Callout3D; @@ -5097,15 +21709,52 @@ declare namespace __esri { } interface LineCallout3D extends Callout3D { + /** + * The border settings of the callout line. The border of the callout line can be used to improve the contrast of the callout line color against various background colors. If the border is `null`, then no border will be visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html#border) + */ border: LineCallout3DBorder; + /** + * The color of the callout line. This can be autocast with a named string, hex string, array of rgb or rgba values, an object with `r`, `g`, `b`, and `a` properties, or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html#color) + * + * @default black + */ color: Color; + /** + * The width of the callout line in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html#size) + * + * @default 1px + */ size: number; + /** + * For LineCallout3D the type is always `line`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html#type) + */ type: string; + /** + * Creates a deep clone of the callout. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html#clone) + * + * + */ clone(): LineCallout3D; } interface LineCallout3DConstructor { + /** + * This type of callout displays a line to connect a symbol or a label with its actual location in the scene. For example when displaying points of interest in a city, visualizing them with a callout line helps to understand where the points are actually located: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html) + */ + new(properties?: LineCallout3DProperties): LineCallout3D; fromJSON(json: any): LineCallout3D; @@ -5114,26 +21763,92 @@ declare namespace __esri { export const LineCallout3D: LineCallout3DConstructor; interface LineCallout3DProperties extends Callout3DProperties { + /** + * The border settings of the callout line. The border of the callout line can be used to improve the contrast of the callout line color against various background colors. If the border is `null`, then no border will be visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html#border) + */ border?: LineCallout3DBorderProperties; - color?: Color; - size?: number; + /** + * The color of the callout line. This can be autocast with a named string, hex string, array of rgb or rgba values, an object with `r`, `g`, `b`, and `a` properties, or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html#color) + * + * @default black + */ + color?: Color | number[] | string; + /** + * The width of the callout line in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html#size) + * + * @default 1px + */ + size?: number | string; + /** + * For LineCallout3D the type is always `line`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html#type) + */ type?: string; } - export interface LineCallout3DBorderProperties { + + export interface LineCallout3DBorderProperties extends Object { + /** + * The color of the callout line border. This can be autocast with a named string, hex string, array of rgb or rgba values, an object with `r`, `g`, `b`, and `a` properties, or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html#border) + * + * @default white + */ color?: Color; } - export interface LineCallout3DBorder extends Accessor { + + export interface LineCallout3DBorder extends AnonymousAccessor { + /** + * The color of the callout line border. This can be autocast with a named string, hex string, array of rgb or rgba values, an object with `r`, `g`, `b`, and `a` properties, or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html#border) + * + * @default white + */ color?: Color; } interface ExtrudeSymbol3DLayer extends Symbol3DLayer { + /** + * The height of the extrusion in meters. Negative values will extrude the polygon surface downward towards or below the ground. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html#size) + * + * @default 1 + */ size: number; + /** + * For ExtrudeSymbol3DLayer the type is always `extrude`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html#type) + */ + readonly type: "extrude"; + /** + * Creates a deep clone of the symbol layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html#clone) + * + * + */ clone(): ExtrudeSymbol3DLayer; } interface ExtrudeSymbol3DLayerConstructor { + /** + * ExtrudeSymbol3DLayer is used to render [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) geometries by extruding them upward from the ground, creating a 3D volumetric object. This is done with a [PolygonSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PolygonSymbol3D.html) in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) does not support 3D symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html) + */ + new(properties?: ExtrudeSymbol3DLayerProperties): ExtrudeSymbol3DLayer; fromJSON(json: any): ExtrudeSymbol3DLayer; @@ -5142,14 +21857,32 @@ declare namespace __esri { export const ExtrudeSymbol3DLayer: ExtrudeSymbol3DLayerConstructor; interface ExtrudeSymbol3DLayerProperties extends Symbol3DLayerProperties { + /** + * The height of the extrusion in meters. Negative values will extrude the polygon surface downward towards or below the ground. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ExtrudeSymbol3DLayer.html#size) + * + * @default 1 + */ size?: number; } interface FillSymbol extends Symbol { + /** + * The outline of the polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol.html#outline) + */ outline: SimpleLineSymbol; } interface FillSymbolConstructor { + /** + * Fill symbols are used to draw [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) graphics in a [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html) or a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) in a 2D [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). To create new fill symbols, use either [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html) or [PictureFillSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol.html) + */ + new(properties?: FillSymbolProperties): FillSymbol; fromJSON(json: any): FillSymbol; @@ -5158,16 +21891,45 @@ declare namespace __esri { export const FillSymbol: FillSymbolConstructor; interface FillSymbolProperties extends SymbolProperties { + /** + * The outline of the polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol.html#outline) + */ outline?: SimpleLineSymbolProperties; } interface FillSymbol3DLayer extends Symbol3DLayer { + /** + * The outline used to draw a line around the filled geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#outline) + */ outline: FillSymbol3DLayerOutline; + /** + * For FillSymbol3DLayer the type is always `fill`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#type) + */ + readonly type: "fill"; + /** + * Creates a deep clone of the symbol layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#clone) + * + * + */ clone(): FillSymbol3DLayer; } interface FillSymbol3DLayerConstructor { + /** + * FillSymbol3DLayer is used to render the surfaces of flat 2D [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) geometries and 3D volumetric meshes in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) does not support 3D symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html) + */ + new(properties?: FillSymbol3DLayerProperties): FillSymbol3DLayer; fromJSON(json: any): FillSymbol3DLayer; @@ -5176,19 +21938,63 @@ declare namespace __esri { export const FillSymbol3DLayer: FillSymbol3DLayerConstructor; interface FillSymbol3DLayerProperties extends Symbol3DLayerProperties { - outline?: FillSymbol3DLayerOutline; + /** + * The outline used to draw a line around the filled geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#outline) + */ + outline?: FillSymbol3DLayerOutlineProperties; } - export interface FillSymbol3DLayerOutline { + + export interface FillSymbol3DLayerOutlineProperties extends Object { + /** + * The color of the outline. This can be autocast with a named string, hex string, array of rgb or rgba values, an object with `r`, `g`, `b`, and `a` properties, or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#outline) + */ + color?: Color | number[] | string; + /** + * The width of the outline in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#outline) + */ + size?: number | string; + } + + export interface FillSymbol3DLayerOutline extends AnonymousAccessor { + /** + * The color of the outline. This can be autocast with a named string, hex string, array of rgb or rgba values, an object with `r`, `g`, `b`, and `a` properties, or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#outline) + */ color: Color; + /** + * The width of the outline in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol3DLayer.html#outline) + */ size: number; } interface Font extends Accessor, JSONSupport { + /** + * Creates a deep clone of the font object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Font.html#clone) + * + * + */ clone(): Font; } interface FontConstructor { + /** + * The font used to display [text symbols](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html) added to the [graphics layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Font.html) + */ + new(properties?: FontProperties): Font; fromJSON(json: any): Font; @@ -5201,15 +22007,60 @@ declare namespace __esri { } interface IconSymbol3DLayer extends Symbol3DLayer { + /** + * The positioning of the icon relative to the geometry. **Possible values:** center | left | right | top | bottom | top-left | top-right | bottom-left | bottom-right + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#anchor) + * + * @default center + */ anchor: string; + /** + * The outline of the icon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#outline) + */ outline: IconSymbol3DLayerOutline; + /** + * The shape (`primitive`) or image URL (`href`) used to visualize the features. If both properties are present, `href` takes precedence and `primitive` is ignored. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#resource) + * + * @default { primitive: "circle" } + */ resource: IconSymbol3DLayerResource; + /** + * The size of the icon in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#size) + * + * @default 12 + */ size: number; + /** + * For IconSymbol3DLayer the type is always `icon`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#type) + */ + readonly type: "icon"; + /** + * Creates a deep clone of the symbol layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#clone) + * + * + */ clone(): IconSymbol3DLayer; } interface IconSymbol3DLayerConstructor { + /** + * IconSymbol3DLayer is used to render [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries using a flat 2D icon (e.g. a circle) with a [PointSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html) in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) does not support 3D symbols. [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) features may also be rendered with IconSymbol3DLayers, but the icon symbol layer must be contained within a [PolygonSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PolygonSymbol3D.html), not a [PointSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html) in that scenario. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html) + */ + new(properties?: IconSymbol3DLayerProperties): IconSymbol3DLayer; fromJSON(json: any): IconSymbol3DLayer; @@ -5218,30 +22069,139 @@ declare namespace __esri { export const IconSymbol3DLayer: IconSymbol3DLayerConstructor; interface IconSymbol3DLayerProperties extends Symbol3DLayerProperties { + /** + * The positioning of the icon relative to the geometry. **Possible values:** center | left | right | top | bottom | top-left | top-right | bottom-left | bottom-right + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#anchor) + * + * @default center + */ anchor?: string; - outline?: IconSymbol3DLayerOutline; + /** + * The outline of the icon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#outline) + */ + outline?: IconSymbol3DLayerOutlineProperties; + /** + * The shape (`primitive`) or image URL (`href`) used to visualize the features. If both properties are present, `href` takes precedence and `primitive` is ignored. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#resource) + * + * @default { primitive: "circle" } + */ resource?: IconSymbol3DLayerResource; - size?: number; + /** + * The size of the icon in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#size) + * + * @default 12 + */ + size?: number | string; } - export interface IconSymbol3DLayerOutline { + + export interface IconSymbol3DLayerOutlineProperties extends Object { + /** + * The color of the outline. This can be autocast with a named string, hex string, array of rgb or rgba values, an object with `r`, `g`, `b`, and `a` properties, or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#outline) + * + * @default black + */ + color?: Color | number[] | string; + /** + * The width of the outline in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#outline) + * + * @default 1.125 + */ + size?: number | string; + } + + export interface IconSymbol3DLayerOutline extends AnonymousAccessor { + /** + * The color of the outline. This can be autocast with a named string, hex string, array of rgb or rgba values, an object with `r`, `g`, `b`, and `a` properties, or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#outline) + * + * @default black + */ color?: Color; + /** + * The width of the outline in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#outline) + * + * @default 1.125 + */ size?: number; } - export interface IconSymbol3DLayerResource { + + export interface IconSymbol3DLayerResource extends Object { + /** + * Uses a built-in shape. See the table below for list of possible values. + * + * Value | Description + * ------|------------ + * circle | ![s3d-icon-circle](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-icon-circle.png) + * square | ![s3d-icon-square](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-icon-square.png) + * cross | ![s3d-icon-cross](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-icon-cross.png) + * x | ![s3d-icon-x](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-icon-x.png) + * kite | ![s3d-icon-kite](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-icon-kite.png) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#resource) + */ primitive?: string; + /** + * The URL or data URI for the image. If the external resource is an SVG then the SVG root node must have a set width and height, otherwise it will not render at the correct size. SVG is not supported in IE11. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html#resource) + */ href?: string; } interface LabelSymbol3D extends Symbol3D { + /** + * Settings for adding a callout visualization to the symbol. Callouts are drawn from the point feature location that is being symbolized, to the vertical offset of the symbol. This property has no effect if [verticalOffset](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#verticalOffset) is not set. At the moment only callouts of type `line` are supported. See [LineCallout3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#callout) + */ callout: Callout3D; + /** + * For LabelSymbol3D the type is always `label-3d`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#type) + */ + readonly type: "label-3d"; + /** + * Shifts the symbol along the vertical world axis by a given height. The height is set in screen space units like points or pixels. For points displayed with a [callout](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#callout) `verticalOffset` should be set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#verticalOffset) + */ verticalOffset: LabelSymbol3DVerticalOffset; + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#clone) + * + * + */ clone(): LabelSymbol3D; } interface LabelSymbol3DConstructor { + /** + * LabelSymbol3D is used to render labels for features from a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). This symbol type is not supported in 2D MapViews. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html) + */ + new(properties?: LabelSymbol3DProperties): LabelSymbol3D; fromJSON(json: any): LabelSymbol3D; @@ -5250,27 +22210,89 @@ declare namespace __esri { export const LabelSymbol3D: LabelSymbol3DConstructor; interface LabelSymbol3DProperties extends Symbol3DProperties { + /** + * Settings for adding a callout visualization to the symbol. Callouts are drawn from the point feature location that is being symbolized, to the vertical offset of the symbol. This property has no effect if [verticalOffset](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#verticalOffset) is not set. At the moment only callouts of type `line` are supported. See [LineCallout3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#callout) + */ callout?: Callout3DProperties; + /** + * Shifts the symbol along the vertical world axis by a given height. The height is set in screen space units like points or pixels. For points displayed with a [callout](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#callout) `verticalOffset` should be set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#verticalOffset) + */ verticalOffset?: LabelSymbol3DVerticalOffsetProperties; } - export interface LabelSymbol3DVerticalOffsetProperties { + + export interface LabelSymbol3DVerticalOffsetProperties extends Object { + /** + * The vertical symbol offset in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#verticalOffset) + */ screenLength?: number; + /** + * The minimum vertical symbol offset in world units. It acts as a lower bound to avoid the vertical offset becoming too small. In the following animation the green symbol on the left has `minWorldLength = 20` and for the orange symbol on the right `minWorldLength` has not been set: ![minWorldLength-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3D-line-callout-minWorldLength.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#verticalOffset) + */ minWorldLength?: number; + /** + * The maximum vertical symbol offset in world units. It acts as an upper bound to avoid vertical offset becoming too big. In the following animation the green symbols have `maxWorldLength = 50` and orange symbols don't have `maxWorldLength` set: ![maxWorldLength](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3D-line-callout-maxWorldLength.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#verticalOffset) + */ maxWorldLength?: number; } - export interface LabelSymbol3DVerticalOffset extends Accessor { + + export interface LabelSymbol3DVerticalOffset extends AnonymousAccessor { + /** + * The vertical symbol offset in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#verticalOffset) + */ screenLength: number; + /** + * The minimum vertical symbol offset in world units. It acts as a lower bound to avoid the vertical offset becoming too small. In the following animation the green symbol on the left has `minWorldLength = 20` and for the orange symbol on the right `minWorldLength` has not been set: ![minWorldLength-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3D-line-callout-minWorldLength.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#verticalOffset) + */ minWorldLength?: number; + /** + * The maximum vertical symbol offset in world units. It acts as an upper bound to avoid vertical offset becoming too big. In the following animation the green symbols have `maxWorldLength = 50` and orange symbols don't have `maxWorldLength` set: ![maxWorldLength](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3D-line-callout-maxWorldLength.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html#verticalOffset) + */ maxWorldLength?: number; } interface LineSymbol extends Symbol { + /** + * The color of the symbol. This can be autocast with a named string; hex string; array of rgb or rgba values; an object with `r`, `g`, `b`, and `a` properties; or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol.html#color) + * + * @default "black" + */ color: Color; + /** + * The width of the symbol in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol.html#width) + * + * @default 0.75 + */ width: number; } interface LineSymbolConstructor { + /** + * Line symbols are used to draw [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) features in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) in a 2D [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol.html) + */ + new(properties?: LineSymbolProperties): LineSymbol; fromJSON(json: any): LineSymbol; @@ -5279,15 +22301,49 @@ declare namespace __esri { export const LineSymbol: LineSymbolConstructor; interface LineSymbolProperties extends SymbolProperties { - color?: Color; - width?: number; + /** + * The color of the symbol. This can be autocast with a named string; hex string; array of rgb or rgba values; an object with `r`, `g`, `b`, and `a` properties; or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol.html#color) + * + * @default "black" + */ + color?: Color | number[] | string; + /** + * The width of the symbol in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol.html#width) + * + * @default 0.75 + */ + width?: number | string; } interface LineSymbol3D extends Symbol3D { + /** + * For LineSymbol3D the type is always `line-3d`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3D.html#type) + */ + readonly type: "line-3d"; + + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3D.html#clone) + * + * + */ clone(): LineSymbol3D; } interface LineSymbol3DConstructor { + /** + * LineSymbol3D is used to render features with [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) geometry in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). This symbol type is not supported in 2D MapViews. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3D.html) + */ + new(properties?: LineSymbol3DProperties): LineSymbol3D; fromJSON(json: any): LineSymbol3D; @@ -5300,12 +22356,38 @@ declare namespace __esri { } interface LineSymbol3DLayer extends Symbol3DLayer { + /** + * The width of the line in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html#size) + * + * @default 0.75 + */ size: number; + /** + * For LineSymbol3DLayer the type is always `line`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html#type) + */ + readonly type: "line"; + /** + * Creates a deep clone of the symbol layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html#clone) + * + * + */ clone(): LineSymbol3DLayer; } interface LineSymbol3DLayerConstructor { + /** + * LineSymbol3DLayer renders [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) geometries using a flat 2D line with a [LineSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3D.html) in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) does not support 3D symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html) + */ + new(properties?: LineSymbol3DLayerProperties): LineSymbol3DLayer; fromJSON(json: any): LineSymbol3DLayer; @@ -5314,16 +22396,53 @@ declare namespace __esri { export const LineSymbol3DLayer: LineSymbol3DLayerConstructor; interface LineSymbol3DLayerProperties extends Symbol3DLayerProperties { - size?: number; + /** + * The width of the line in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3DLayer.html#size) + * + * @default 0.75 + */ + size?: number | string; } interface MarkerSymbol extends Symbol { + /** + * The angle of the marker in degrees. + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html#angle) + * + * @default 0 + */ angle: number; + /** + * The offset on the x-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html#xoffset) + * + * @default 0 + */ xoffset: number; + /** + * The offset on the y-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html#yoffset) + * + * @default 0 + */ yoffset: number; } interface MarkerSymbolConstructor { + /** + * Marker symbols are used to draw [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) graphics in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or individual [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) in a 2D [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). To create new marker symbols, use either [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html) or [PictureMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html) + */ + new(properties?: MarkerSymbolProperties): MarkerSymbol; fromJSON(json: any): MarkerSymbol; @@ -5332,16 +22451,60 @@ declare namespace __esri { export const MarkerSymbol: MarkerSymbolConstructor; interface MarkerSymbolProperties extends SymbolProperties { + /** + * The angle of the marker in degrees. + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html#angle) + * + * @default 0 + */ angle?: number; - xoffset?: number; - yoffset?: number; + /** + * The offset on the x-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html#xoffset) + * + * @default 0 + */ + xoffset?: number | string; + /** + * The offset on the y-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html#yoffset) + * + * @default 0 + */ + yoffset?: number | string; } interface MeshSymbol3D extends Symbol3D { + /** + * For MeshSymbol3D, the type is always `mesh-3d`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MeshSymbol3D.html#type) + */ + readonly type: "mesh-3d"; + + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MeshSymbol3D.html#clone) + * + * + */ clone(): MeshSymbol3D; } interface MeshSymbol3DConstructor { + /** + * MeshSymbol3D is used to render 3D mesh features in a [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). This symbol type is not supported in 2D MapViews. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MeshSymbol3D.html) + */ + new(properties?: MeshSymbol3DProperties): MeshSymbol3D; fromJSON(json: any): MeshSymbol3D; @@ -5354,19 +22517,88 @@ declare namespace __esri { } interface ObjectSymbol3DLayer extends Symbol3DLayer { + /** + * The positioning of the object relative to the geometry. `origin` is only valid when an `href` resource is specified and uses the pivot point defined by the 3D model. **Possible Values:** center | top | bottom | origin + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#anchor) + * + * @default center + */ anchor: string; + /** + * The depth, or diameter from north to south, of the object in meters. If `undefined`, the depth will be calculated to maintain the original proportions of the object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#depth) + * + * @default 10 + */ depth: number; + /** + * The clockwise rotation of the symbol in the horizontal plane (i.e., around the z axis). The rotation is specified in degrees and is relative to the y-axis. If the symbol resource is aligned such that its forward facing side points in the direction of the y-axis (the y-axis always points North in WGS84 or WebMercator coordinates), its upwards facing side is pointing in the direction of the z-axis, and its right-hand side points in the direction of the x-axis (the x-axis always points East in WGS84 or WebMercator coordinates), then this angle corresponds to the heading of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#heading) + */ heading: number; + /** + * The height of the object in meters. If `undefined`, the height will be calculated to maintain the original proportions of the object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#height) + * + * @default 10 + */ height: number; + /** + * The primitive shape (`primitive`) or external 3D model (`href`) used to visualize the points. If both properties are present, `primitive` takes precedence and `href` is ignored. When using the `href` property, external 3D models must be present in a specific format, which can be generated using the ArcGIS Pro SDK. [See these instructions](https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Authoring/ExportWeb3DObjectResource#exportweb3dobjectresource) to learn how to generate a custom 3D model for use in this property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#resource) + * + * @default { primitive: "sphere" } + */ resource: ObjectSymbol3DLayerResource; + /** + * The rotation of the symbol in the lateral vertical plane (i.e., around the y axis). The rotation is specified in degrees and is relative to the x-axis. At 0 degrees, the model is level. A positive value lifts the left part and lowers the right part of the model. If the symbol resource is aligned such that its forward facing side points in the direction of the y-axis (the y-axis always points North in WGS84 or WebMercator coordinates), its upwards facing side is pointing in the direction of the z-axis, and its right-hand side points in the direction of the x-axis (the x-axis always points East in WGS84 or WebMercator coordinates), then this angle corresponds to the roll of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#roll) + */ roll: number; + /** + * The rotation of the symbol in the longitudinal vertical plane (i.e., around the x axis). The rotation is specified in degrees and is relative to the y-axis. At 0 degrees, the model is level. A positive value points lifts the front and lowers the back of the model. If the symbol resource is aligned such that its forward facing side points in the direction of the y-axis (the y-axis always points North in WGS84 or WebMercator coordinates), its upwards facing side is pointing in the direction of the z-axis, and its right-hand side points in the direction of the x-axis (the x-axis always points East in WGS84 or WebMercator coordinates), then this angle corresponds to the tilt of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#tilt) + */ tilt: number; + /** + * For ObjectSymbol3DLayer the type is always `object`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#type) + */ + readonly type: "object"; + /** + * The width, or diameter from east to west, of the object in meters. If `undefined`, the width will be calculated to maintain the original proportions of the object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#width) + * + * @default 10 + */ width: number; + /** + * Creates a deep clone of the symbol layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#clone) + * + * + */ clone(): ObjectSymbol3DLayer; } interface ObjectSymbol3DLayerConstructor { + /** + * ObjectSymbol3DLayer is used to render [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries using a volumetric 3D shape (e.g., a sphere or cylinder) with a [PointSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html) in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) does not support 3D symbols. [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) features may also be rendered with ObjectSymbol3DLayers, but the object symbol layer must be contained in a [PolygonSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PolygonSymbol3D.html), not a [PointSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html) in this scenario. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html) + */ + new(properties?: ObjectSymbol3DLayerProperties): ObjectSymbol3DLayer; fromJSON(json: any): ObjectSymbol3DLayer; @@ -5375,28 +22607,126 @@ declare namespace __esri { export const ObjectSymbol3DLayer: ObjectSymbol3DLayerConstructor; interface ObjectSymbol3DLayerProperties extends Symbol3DLayerProperties { + /** + * The positioning of the object relative to the geometry. `origin` is only valid when an `href` resource is specified and uses the pivot point defined by the 3D model. **Possible Values:** center | top | bottom | origin + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#anchor) + * + * @default center + */ anchor?: string; + /** + * The depth, or diameter from north to south, of the object in meters. If `undefined`, the depth will be calculated to maintain the original proportions of the object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#depth) + * + * @default 10 + */ depth?: number; + /** + * The clockwise rotation of the symbol in the horizontal plane (i.e., around the z axis). The rotation is specified in degrees and is relative to the y-axis. If the symbol resource is aligned such that its forward facing side points in the direction of the y-axis (the y-axis always points North in WGS84 or WebMercator coordinates), its upwards facing side is pointing in the direction of the z-axis, and its right-hand side points in the direction of the x-axis (the x-axis always points East in WGS84 or WebMercator coordinates), then this angle corresponds to the heading of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#heading) + */ heading?: number; + /** + * The height of the object in meters. If `undefined`, the height will be calculated to maintain the original proportions of the object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#height) + * + * @default 10 + */ height?: number; + /** + * The primitive shape (`primitive`) or external 3D model (`href`) used to visualize the points. If both properties are present, `primitive` takes precedence and `href` is ignored. When using the `href` property, external 3D models must be present in a specific format, which can be generated using the ArcGIS Pro SDK. [See these instructions](https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Authoring/ExportWeb3DObjectResource#exportweb3dobjectresource) to learn how to generate a custom 3D model for use in this property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#resource) + * + * @default { primitive: "sphere" } + */ resource?: ObjectSymbol3DLayerResource; + /** + * The rotation of the symbol in the lateral vertical plane (i.e., around the y axis). The rotation is specified in degrees and is relative to the x-axis. At 0 degrees, the model is level. A positive value lifts the left part and lowers the right part of the model. If the symbol resource is aligned such that its forward facing side points in the direction of the y-axis (the y-axis always points North in WGS84 or WebMercator coordinates), its upwards facing side is pointing in the direction of the z-axis, and its right-hand side points in the direction of the x-axis (the x-axis always points East in WGS84 or WebMercator coordinates), then this angle corresponds to the roll of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#roll) + */ roll?: number; + /** + * The rotation of the symbol in the longitudinal vertical plane (i.e., around the x axis). The rotation is specified in degrees and is relative to the y-axis. At 0 degrees, the model is level. A positive value points lifts the front and lowers the back of the model. If the symbol resource is aligned such that its forward facing side points in the direction of the y-axis (the y-axis always points North in WGS84 or WebMercator coordinates), its upwards facing side is pointing in the direction of the z-axis, and its right-hand side points in the direction of the x-axis (the x-axis always points East in WGS84 or WebMercator coordinates), then this angle corresponds to the tilt of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#tilt) + */ tilt?: number; + /** + * The width, or diameter from east to west, of the object in meters. If `undefined`, the width will be calculated to maintain the original proportions of the object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#width) + * + * @default 10 + */ width?: number; } - export interface ObjectSymbol3DLayerResource { + + export interface ObjectSymbol3DLayerResource extends Object { + /** + * Uses a built-in shape. See the table below for possible values. + * + * Value | Description + * ------|------------ + * sphere | ![s3d-object-sphere](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-object-sphere.png) + * cylinder | ![s3d-object-cylinder](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-object-cylinder.png) + * cube | ![s3d-object-cube](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-object-cube.png) + * cone | ![s3d-object-cone](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-object-cone.png) + * inverted-cone | ![s3d-object-inverted-cone](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-object-inverted-cone.png) + * diamond | ![s3d-object-diamond](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-object-diamond.png) + * tetrahedron | ![s3d-object-tetrahedron](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-object-tetrahedron.png) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#resource) + */ primitive?: string; + /** + * The URL to the 3D model. [See these instructions](https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Authoring/ExportWeb3DObjectResource#exportweb3dobjectresource) to learn how to create a custom 3D model. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-ObjectSymbol3DLayer.html#resource) + */ href?: string; } interface PathSymbol3DLayer extends Symbol3DLayer { + /** + * The diameter of the tube in meters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html#size) + * + * @default 1 + */ size: number; + /** + * For PathSymbol3DLayer, the type is always `path`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html#type) + */ + readonly type: "path"; + /** + * Creates a deep clone of the symbol layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html#clone) + * + * + */ clone(): PathSymbol3DLayer; } interface PathSymbol3DLayerConstructor { + /** + * PathSymbol3DLayer renders [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) geometries using a volumetric 3D tube with a [LineSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LineSymbol3D.html) in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) does not support 3D symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html) + */ + new(properties?: PathSymbol3DLayerProperties): PathSymbol3DLayer; fromJSON(json: any): PathSymbol3DLayer; @@ -5405,22 +22735,95 @@ declare namespace __esri { export const PathSymbol3DLayer: PathSymbol3DLayerConstructor; interface PathSymbol3DLayerProperties extends Symbol3DLayerProperties { + /** + * The diameter of the tube in meters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PathSymbol3DLayer.html#size) + * + * @default 1 + */ size?: number; } interface PictureFillSymbol extends FillSymbol { + /** + * The height of the image in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#height) + * + * @default 12 + */ height: number; + /** + * For PictureFillSymbol the type is always `picture-fill`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#type) + */ + readonly type: "picture-fill"; + /** + * The URL to the image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#url) + */ url: string; + /** + * The width of the image in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#width) + * + * @default 12 + */ width: number; + /** + * The offset on the x-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#xoffset) + * + * @default 0 + */ xoffset: number; + /** + * The scale factor on the x axis of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#xscale) + * + * @default 1 + */ xscale: number; + /** + * The offset on the y-axis in pixels or points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#yoffset) + * + * @default 0 + */ yoffset: number; + /** + * The scale factor on the y axis of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#yscale) + * + * @default 1 + */ yscale: number; + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#clone) + * + * + */ clone(): PictureFillSymbol; } interface PictureFillSymbolConstructor { + /** + * PictureFillSymbol uses an image in a repeating pattern to symbolize polygon features in a 2D [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). A [url](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#url) must point to a valid image. In addition, the symbol can have an optional [outline](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#outline), which is defined by a [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html). PictureFillSymbols may be applied to polygon features in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or an individual [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html) + */ + new(properties?: PictureFillSymbolProperties): PictureFillSymbol; fromJSON(json: any): PictureFillSymbol; @@ -5429,24 +22832,112 @@ declare namespace __esri { export const PictureFillSymbol: PictureFillSymbolConstructor; interface PictureFillSymbolProperties extends FillSymbolProperties { - height?: number; + /** + * The height of the image in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#height) + * + * @default 12 + */ + height?: number | string; + /** + * The URL to the image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#url) + */ url?: string; - width?: number; - xoffset?: number; + /** + * The width of the image in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#width) + * + * @default 12 + */ + width?: number | string; + /** + * The offset on the x-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#xoffset) + * + * @default 0 + */ + xoffset?: number | string; + /** + * The scale factor on the x axis of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#xscale) + * + * @default 1 + */ xscale?: number; - yoffset?: number; + /** + * The offset on the y-axis in pixels or points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#yoffset) + * + * @default 0 + */ + yoffset?: number | string; + /** + * The scale factor on the y axis of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureFillSymbol.html#yscale) + * + * @default 1 + */ yscale?: number; } interface PictureMarkerSymbol extends MarkerSymbol { + /** + * The height of the image in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html#height) + * + * @default 12 + */ height: number; + /** + * For PictureMarkerSymbol the type is always `picture-marker`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html#type) + */ + readonly type: "picture-marker"; + /** + * The URL to the image. To avoid CORS issues with this symbol, do one of the following: + * * Use an image hosted on the same domain as the application. + * * If the image is on a different domain and that server is CORS enabled, add the domain to the [corsEnabledServers](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) array. + * * Install a proxy. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html#url) + */ url: string; + /** + * The width of the image in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html#width) + * + * @default 12 + */ width: number; + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html#clone) + * + * + */ clone(): PictureMarkerSymbol; } interface PictureMarkerSymbolConstructor { + /** + * PictureMarkerSymbol renders [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) graphics in either a 2D [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) using an image. A [url](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html#url) must point to a valid image. PictureMarkerSymbols may be applied to point features in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or individual [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). The image below depicts a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) whose point features are styled with a [PictureMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html) + */ + new(properties?: PictureMarkerSymbolProperties): PictureMarkerSymbol; fromJSON(json: any): PictureMarkerSymbol; @@ -5455,19 +22946,70 @@ declare namespace __esri { export const PictureMarkerSymbol: PictureMarkerSymbolConstructor; interface PictureMarkerSymbolProperties extends MarkerSymbolProperties { - height?: number; + /** + * The height of the image in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html#height) + * + * @default 12 + */ + height?: number | string; + /** + * The URL to the image. To avoid CORS issues with this symbol, do one of the following: + * * Use an image hosted on the same domain as the application. + * * If the image is on a different domain and that server is CORS enabled, add the domain to the [corsEnabledServers](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#request) array. + * * Install a proxy. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html#url) + */ url?: string; - width?: number; + /** + * The width of the image in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html#width) + * + * @default 12 + */ + width?: number | string; } interface PointSymbol3D extends Symbol3D { + /** + * Settings for adding a callout visualization to the symbol. Callouts are drawn from the point feature location that is being symbolized, to the vertical offset of the symbol. This property has no effect if [verticalOffset](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#verticalOffset) is not set. At the moment only callouts of type line are supported. See [LineCallout3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#callout) + */ callout: Callout3D; + /** + * For PointSymbol3D the type is always `point-3d`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#type) + */ + readonly type: "point-3d"; + /** + * Shifts the symbol along the vertical world axis by a given height. The height is set in screen space units like points or pixels. For points displayed with a [callout](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#callout) `verticalOffset` should be set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#verticalOffset) + */ verticalOffset: PointSymbol3DVerticalOffset; + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#clone) + * + * + */ clone(): PointSymbol3D; } interface PointSymbol3DConstructor { + /** + * PointSymbol3D is used to render features with [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometry in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). This symbol type is not supported in 2D MapViews. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html) + */ + new(properties?: PointSymbol3DProperties): PointSymbol3D; fromJSON(json: any): PointSymbol3D; @@ -5476,26 +23018,88 @@ declare namespace __esri { export const PointSymbol3D: PointSymbol3DConstructor; interface PointSymbol3DProperties extends Symbol3DProperties { + /** + * Settings for adding a callout visualization to the symbol. Callouts are drawn from the point feature location that is being symbolized, to the vertical offset of the symbol. This property has no effect if [verticalOffset](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#verticalOffset) is not set. At the moment only callouts of type line are supported. See [LineCallout3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-callouts-LineCallout3D.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#callout) + */ callout?: Callout3DProperties; + /** + * Shifts the symbol along the vertical world axis by a given height. The height is set in screen space units like points or pixels. For points displayed with a [callout](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#callout) `verticalOffset` should be set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#verticalOffset) + */ verticalOffset?: PointSymbol3DVerticalOffsetProperties; } - export interface PointSymbol3DVerticalOffsetProperties { + + export interface PointSymbol3DVerticalOffsetProperties extends Object { + /** + * The vertical symbol offset in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#verticalOffset) + */ screenLength?: number; + /** + * The minimum vertical symbol offset in world units. It acts as a lower bound to avoid vertical offset becoming too small. In the following animation the green symbol on the left has `minWorldLength = 20` and for the orange symbol on the right `minWorldLength` has not been set: ![minWorldLength-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3D-line-callout-minWorldLength.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#verticalOffset) + */ minWorldLength?: number; + /** + * The maximum vertical symbol offset in world units. It acts as an upper bound to avoid vertical offset becoming too big. In the following animation the green symbols have `maxWorldLength = 50` and orange symbols don't have `maxWorldLength` set: ![maxWorldLength](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3D-line-callout-maxWorldLength.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#verticalOffset) + */ maxWorldLength?: number; } - export interface PointSymbol3DVerticalOffset extends Accessor { + + export interface PointSymbol3DVerticalOffset extends AnonymousAccessor { + /** + * The vertical symbol offset in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#verticalOffset) + */ screenLength: number; + /** + * The minimum vertical symbol offset in world units. It acts as a lower bound to avoid vertical offset becoming too small. In the following animation the green symbol on the left has `minWorldLength = 20` and for the orange symbol on the right `minWorldLength` has not been set: ![minWorldLength-on](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3D-line-callout-minWorldLength.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#verticalOffset) + */ minWorldLength?: number; + /** + * The maximum vertical symbol offset in world units. It acts as an upper bound to avoid vertical offset becoming too big. In the following animation the green symbols have `maxWorldLength = 50` and orange symbols don't have `maxWorldLength` set: ![maxWorldLength](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3D-line-callout-maxWorldLength.gif) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html#verticalOffset) + */ maxWorldLength?: number; } interface PolygonSymbol3D extends Symbol3D { + /** + * For PolygonSymbol3D the type is always `polygon-3d`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PolygonSymbol3D.html#type) + */ + readonly type: "polygon-3d"; + + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PolygonSymbol3D.html#clone) + * + * + */ clone(): PolygonSymbol3D; } interface PolygonSymbol3DConstructor { + /** + * PolygonSymbol3D is used to render features with [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) geometry in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). This symbol type is not supported in 2D MapViews. Polygon features may also be rendered as points with icons or objects at the centroid of each polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PolygonSymbol3D.html) + */ + new(properties?: PolygonSymbol3DProperties): PolygonSymbol3D; fromJSON(json: any): PolygonSymbol3D; @@ -5508,13 +23112,59 @@ declare namespace __esri { } interface SimpleFillSymbol extends FillSymbol { + /** + * The color of the symbol. This can be autocast with a named string; hex string; array of rgb or rgba values; an object with `r`, `g`, `b`, and `a` properties; or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html#color) + * + * @default [0, 0, 0, 0.25] - black, semitransparent + */ color: Color; + /** + * The fill style. Valid values are listed in the table below: + * + * Value | Description + * ------|------------- + * backward-diagonal | ![sfs-backward-diagonal](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-backward-diagonal.png) + * cross | ![sfs-cross](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-cross.png) + * diagonal-cross | ![sfs-diagonal-cross](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-diagonal-cross.png) + * forward-diagonal | ![sfs-forward-diagonal](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-forward-diagonal.png) + * horizontal | ![sfs-horizontal](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-horizontal.png) + * none | The polygon has no fill. + * solid | ![sfs-solid](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-solid.png) + * vertical | ![sfs-vertical](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-vertical.png) + * + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html#style) + * + * @default solid + */ style: string; + /** + * For SimpleFillSymbol the type is always `simple-fill`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html#type) + */ + readonly type: "simple-fill"; + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html#clone) + * + * + */ clone(): SimpleFillSymbol; } interface SimpleFillSymbolConstructor { + /** + * SimpleFillSymbol is used for rendering 2D polygons in either a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). It can be filled with a solid [color](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html#color), or a [pattern](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html#style). In addition, the symbol can have an optional [outline](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html#outline), which is defined by a [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html) + */ + new(properties?: SimpleFillSymbolProperties): SimpleFillSymbol; fromJSON(json: any): SimpleFillSymbol; @@ -5523,20 +23173,116 @@ declare namespace __esri { export const SimpleFillSymbol: SimpleFillSymbolConstructor; interface SimpleFillSymbolProperties extends FillSymbolProperties { - color?: Color; + /** + * The color of the symbol. This can be autocast with a named string; hex string; array of rgb or rgba values; an object with `r`, `g`, `b`, and `a` properties; or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html#color) + * + * @default [0, 0, 0, 0.25] - black, semitransparent + */ + color?: Color | number[] | string; + /** + * The fill style. Valid values are listed in the table below: + * + * Value | Description + * ------|------------- + * backward-diagonal | ![sfs-backward-diagonal](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-backward-diagonal.png) + * cross | ![sfs-cross](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-cross.png) + * diagonal-cross | ![sfs-diagonal-cross](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-diagonal-cross.png) + * forward-diagonal | ![sfs-forward-diagonal](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-forward-diagonal.png) + * horizontal | ![sfs-horizontal](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-horizontal.png) + * none | The polygon has no fill. + * solid | ![sfs-solid](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-solid.png) + * vertical | ![sfs-vertical](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sfs-vertical.png) + * + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleFillSymbol.html#style) + * + * @default solid + */ style?: string; } interface SimpleLineSymbol extends LineSymbol { + /** + * Specifies the cap style. The cap is the end of a line segment. **Known Values:** butt | round | square + * > **Known Limitations** + * * This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * * This property does not persist when applied to a symbol used in a layer saved to a web map or portal item. See the [web map specification](https://developers.arcgis.com/web-map-specification/objects/esriSLS_symbol/) for more details about properties that persist when a SimpleLineSymbol is saved to an ArcGIS Online or Portal item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html#cap) + * + * @default butt + */ cap: string; + /** + * Specifies the join style. **Known Values:** miter | round | bevel + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html#join) + * + * @default miter + */ join: string; + /** + * Size threshold for showing mitered line joins. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html#miterLimit) + * + * @default 0.75 + */ miterLimit: number; + /** + * Specifies the line style. Valid values are listed in the table below: + * + * Value | Description + * ------|------------- + * dash | ![sls-dash](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-dash.png) + * dash-dot | ![sls-dash-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-dash-dot.png) + * dot | ![sls-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-dot.png) + * long-dash | ![sls-long-dash](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-long-dash.png) + * long-dash-dot | ![sls-long-dash-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-long-dash-dot.png) + * long-dash-dot-dot | ![sls-dash-dot-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-dash-dot-dot.png) + * none | The line has no symbol. + * short-dash | ![sls-short-dash](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-short-dash.png) + * short-dash-dot | ![sls-short-dash-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-short-dash-dot.png) + * short-dash-dot-dot | ![sls-short-dash-dot-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-short-dash-dot-dot.png) + * short-dot | ![sls-short-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-short-dot.png) + * solid | ![sls-solid](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-solid.png) + * + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html#style) + * + * @default solid + */ style: string; + /** + * For SimpleLineSymbol, the type is always `simple-line`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html#type) + */ + readonly type: "simple-line"; + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html#clone) + * + * + */ clone(): SimpleLineSymbol; } interface SimpleLineSymbolConstructor { + /** + * SimpleLineSymbol is used for rendering 2D [polyline geometries](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) in a 2D [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). SimpleLineSymbol is also used for rendering outlines for [marker symbols](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html) and [fill symbols](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-FillSymbol.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html) + */ + new(properties?: SimpleLineSymbolProperties): SimpleLineSymbol; fromJSON(json: any): SimpleLineSymbol; @@ -5545,23 +23291,134 @@ declare namespace __esri { export const SimpleLineSymbol: SimpleLineSymbolConstructor; interface SimpleLineSymbolProperties extends LineSymbolProperties { + /** + * Specifies the cap style. The cap is the end of a line segment. **Known Values:** butt | round | square + * > **Known Limitations** + * * This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * * This property does not persist when applied to a symbol used in a layer saved to a web map or portal item. See the [web map specification](https://developers.arcgis.com/web-map-specification/objects/esriSLS_symbol/) for more details about properties that persist when a SimpleLineSymbol is saved to an ArcGIS Online or Portal item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html#cap) + * + * @default butt + */ cap?: string; + /** + * Specifies the join style. **Known Values:** miter | round | bevel + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html#join) + * + * @default miter + */ join?: string; - miterLimit?: number; + /** + * Size threshold for showing mitered line joins. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html#miterLimit) + * + * @default 0.75 + */ + miterLimit?: number | string; + /** + * Specifies the line style. Valid values are listed in the table below: + * + * Value | Description + * ------|------------- + * dash | ![sls-dash](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-dash.png) + * dash-dot | ![sls-dash-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-dash-dot.png) + * dot | ![sls-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-dot.png) + * long-dash | ![sls-long-dash](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-long-dash.png) + * long-dash-dot | ![sls-long-dash-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-long-dash-dot.png) + * long-dash-dot-dot | ![sls-dash-dot-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-dash-dot-dot.png) + * none | The line has no symbol. + * short-dash | ![sls-short-dash](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-short-dash.png) + * short-dash-dot | ![sls-short-dash-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-short-dash-dot.png) + * short-dash-dot-dot | ![sls-short-dash-dot-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-short-dash-dot-dot.png) + * short-dot | ![sls-short-dot](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-short-dot.png) + * solid | ![sls-solid](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sls-solid.png) + * + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html#style) + * + * @default solid + */ style?: string; } interface SimpleMarkerSymbol extends MarkerSymbol { + /** + * The color of the symbol. This can be autocast with a named string; hex string; array of rgb or rgba values; an object with `r`, `g`, `b`, and `a` properties; or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * > The `color` property does not apply to marker symbols defined with the `cross` or `x` [style](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#style). Since these styles are wholly comprised of outlines, you must modify the [outline.color](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#outline) property to set the color of symbols with those styles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#color) + * + * @default [255, 255, 255, 0.25] - white, semitransparent + */ color: Color; + /** + * The outline of the marker symbol. The `color` property of this object directly modifies the overall color of marker symbols defined with the `cross` or `x` [style](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#style). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#outline) + */ outline: SimpleLineSymbol; + /** + * The SVG path of the icon. + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#path) + */ path: string; + /** + * The size of the marker in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#size) + * + * @default 12 + */ size: number; + /** + * The marker style. Possible values are in the table below. + * + * Value | Description + * ------|------------ + * circle | ![sms_circle](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sms-circle.png) + * cross | ![sms_cross](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sms-cross.png) + * diamond | ![sms_diamond](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sms-diamond.png) + * square | ![sms_square](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sms-square.png) + * x | ![sms_x](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sms-x.png) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#style) + * + * @default circle + */ style: string; + /** + * For SimpleMarkerSymbol the type is always `simple-marker`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#type) + */ + readonly type: "simple-marker"; + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#clone) + * + * + */ clone(): SimpleMarkerSymbol; } interface SimpleMarkerSymbolConstructor { + /** + * SimpleMarkerSymbol is used for rendering 2D [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometries with a simple shape and [color](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#color) in either a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). It may be filled with a solid [color](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#color) and have an optional [outline](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#outline), which is defined with a [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html) + */ + new(properties?: SimpleMarkerSymbolProperties): SimpleMarkerSymbol; fromJSON(json: any): SimpleMarkerSymbol; @@ -5570,24 +23427,155 @@ declare namespace __esri { export const SimpleMarkerSymbol: SimpleMarkerSymbolConstructor; interface SimpleMarkerSymbolProperties extends MarkerSymbolProperties { - color?: Color; + /** + * The color of the symbol. This can be autocast with a named string; hex string; array of rgb or rgba values; an object with `r`, `g`, `b`, and `a` properties; or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * > The `color` property does not apply to marker symbols defined with the `cross` or `x` [style](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#style). Since these styles are wholly comprised of outlines, you must modify the [outline.color](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#outline) property to set the color of symbols with those styles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#color) + * + * @default [255, 255, 255, 0.25] - white, semitransparent + */ + color?: Color | number[] | string; + /** + * The outline of the marker symbol. The `color` property of this object directly modifies the overall color of marker symbols defined with the `cross` or `x` [style](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#style). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#outline) + */ outline?: SimpleLineSymbolProperties; + /** + * The SVG path of the icon. + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#path) + */ path?: string; - size?: number; + /** + * The size of the marker in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#size) + * + * @default 12 + */ + size?: number | string; + /** + * The marker style. Possible values are in the table below. + * + * Value | Description + * ------|------------ + * circle | ![sms_circle](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sms-circle.png) + * cross | ![sms_cross](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sms-cross.png) + * diamond | ![sms_diamond](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sms-diamond.png) + * square | ![sms_square](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sms-square.png) + * x | ![sms_x](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols-sms-x.png) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html#style) + * + * @default circle + */ style?: string; } + interface symbolsSupportJsonUtils { + /** + * Creates a new instance of an appropriate [Symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol.html) class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input `json` parameter often comes from a response to a query operation in the REST API or a [toJSON()](http://pro.arcgis.com/en/pro-app/tool-reference/conversion/features-to-json.htm) method from another ArcGIS product. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for details and examples of when and how to use this function. When you create a [MarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html), [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html) or [PictureMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PictureMarkerSymbol.html) from a JSON object, you may specify a property angle to rotate the symbol. Be aware that the angle in the JSON is different from [MarkerSymbol.angle](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-MarkerSymbol.html#angle). The angle in the JSON follows the traditional ArcGIS specification and is rotated counter-clockwise, whereas the angle in the symbol is rotated clockwise. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-jsonUtils.html#fromJSON) + * + * @param json A JSON representation of the instance in the ArcGIS format. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Symbol_Objects/02r3000000n5000000/) for examples of the structure of various input JSON objects. + * + */ fromJSON(json: any): Symbol; } export const symbolsSupportJsonUtils: symbolsSupportJsonUtils; + + interface symbolPreview { + /** + * Generates a preview image of a given symbol that can be displayed in a custom widget or other DOM element. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-symbolPreview.html#renderPreviewHTML) + * + * @param symbol The symbol for which to generate a preview image. + * @param options Formatting options for the symbol preview image. + * @param options.node The parent node to append to the symbol. + * @param options.size The size of the symbol preview in points. + * @param options.maxSize The maximum size of the symbol preview in points. + * @param options.opacity The opacity of the layer represented by the `symbol`. + * @param options.scale Indicates whether to scale the symbol preview. + * @param options.disableUpsampling Indicates whether to disable upsampling for raster images. + * @param options.symbolConfig For "tall" symbols in portrait view, then the `tall` value should be used here. + * + */ + renderPreviewHTML(symbol: Symbol, options?: symbolPreviewRenderPreviewHTMLOptions): IPromise; + } + + export const symbolPreview: symbolPreview; + + + export interface symbolPreviewRenderPreviewHTMLOptions extends Object { + /** + * The parent node to append to the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-symbolPreview.html#renderPreviewHTML) + */ + node?: HTMLElement; + /** + * The size of the symbol preview in points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-symbolPreview.html#renderPreviewHTML) + */ + size?: number; + /** + * The maximum size of the symbol preview in points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-symbolPreview.html#renderPreviewHTML) + */ + maxSize?: number; + /** + * The opacity of the layer represented by the `symbol`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-symbolPreview.html#renderPreviewHTML) + */ + opacity?: number; + /** + * Indicates whether to scale the symbol preview. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-symbolPreview.html#renderPreviewHTML) + */ + scale?: boolean; + /** + * Indicates whether to disable upsampling for raster images. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-symbolPreview.html#renderPreviewHTML) + */ + disableUpsampling?: boolean; + /** + * For "tall" symbols in portrait view, then the `tall` value should be used here. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-support-symbolPreview.html#renderPreviewHTML) + */ + symbolConfig?: string; + } + interface Symbol extends Accessor, JSONSupport { - type: string; + /** + * The symbol type. **Possible values:** simple-marker | picture-marker | simple-line | cartographic-line-symbol | simple-fill | picture-fill | text | shield-label-symbol | point-3d | line-3d | polygon-3d | mesh-3d | label-3d + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol.html#type) + */ + readonly type: string; } interface SymbolConstructor { + /** + * Symbol is the base class for all symbols. Symbols represent point, line, polygon, and mesh geometries as vector graphics within a [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). They can be set on individual [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#symbol) or in a [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) that is applied to a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol.html) + */ + new(properties?: SymbolProperties): Symbol; fromJSON(json: any): Symbol; @@ -5596,15 +23584,31 @@ declare namespace __esri { export const Symbol: SymbolConstructor; interface SymbolProperties { - type?: string; + } interface Symbol3D extends Symbol { - styleOrigin: Symbol3DStyleOrigin; + /** + * The origin of the style from which the symbol was originally referenced. A reference to the style origin can be either by styleName or by styleUrl (but not both). This information is part of the WebScene persistence model and may be used to understand where a symbol was originally sourced from. It does not affect actual appearance or rendering of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3D.html#styleOrigin) + */ + readonly styleOrigin: Symbol3DStyleOrigin; + /** + * A Collection of [Symbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3DLayer.html) objects used to visualize the graphic or feature. Individual symbol layers may be autocast as objects and specified using the `type` property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3D.html#symbolLayers) + */ symbolLayers: Collection; } interface Symbol3DConstructor { + /** + * Symbol3D is the base class for all 3D symbols. It is used to render 2D [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html), [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html), and [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) features in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) and 3D mesh features in a [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html). All 3D symbols must be used in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) instance; there is no support for 3D rendering in [MapViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3D.html) + */ + new(properties?: Symbol3DProperties): Symbol3D; fromJSON(json: any): Symbol3D; @@ -5613,22 +23617,69 @@ declare namespace __esri { export const Symbol3D: Symbol3DConstructor; interface Symbol3DProperties extends SymbolProperties { - styleOrigin?: Symbol3DStyleOrigin; + /** + * A Collection of [Symbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3DLayer.html) objects used to visualize the graphic or feature. Individual symbol layers may be autocast as objects and specified using the `type` property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3D.html#symbolLayers) + */ symbolLayers?: CollectionProperties; } - export interface Symbol3DStyleOrigin { + + export interface Symbol3DStyleOrigin extends Object { + /** + * a well-known esri-provided style, such as `EsriThematicShapesStyle` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3D.html#styleOrigin) + */ styleName?: string; + /** + * url to a style definition + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3D.html#styleOrigin) + */ styleUrl?: string; + /** + * name of the symbol in the style referenced by styleName or styleUrl + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3D.html#styleOrigin) + */ name: string; } interface Symbol3DLayer extends Accessor, JSONSupport { + /** + * The material used to shade the geometry. For `material` properties, see the documentation of the individual symbol layer classes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3DLayer.html#material) + */ material: any; - type: string; + /** + * The 3D symbol layer type. See the table below for a list of possible values. + * + * Value | Description + * ------|------------ + * icon | ![s3d-icon](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-icon-circle.png) + * object | ![s3d-object](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-object-sphere.png) + * line | ![s3d-line](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-line-line.png) + * path | ![s3d-path](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-path-tube.png) + * fill | ![s3d-fill](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-fill-solid.png) + * extrusion | ![s3d-extrusion](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-extrude-solid.png) + * text | ![s3d-text](https://developers.arcgis.com/javascript/latest/assets/img/apiref/symbols/symbols3d-label-text.png) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3DLayer.html#type) + */ + readonly type: string; } interface Symbol3DLayerConstructor { + /** + * Symbol layers are used to define the visualization of [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html), [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html), [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html), and mesh geometries rendered with [3D symbols](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3D.html). [3D symbols](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3D.html) may only be used to render features in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html), or standalone [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). There is no support for 3D symbols in 2D [MapViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3DLayer.html) + */ + new(properties?: Symbol3DLayerProperties): Symbol3DLayer; fromJSON(json: any): Symbol3DLayer; @@ -5637,31 +23688,158 @@ declare namespace __esri { export const Symbol3DLayer: Symbol3DLayerConstructor; interface Symbol3DLayerProperties { + /** + * The material used to shade the geometry. For `material` properties, see the documentation of the individual symbol layer classes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-Symbol3DLayer.html#material) + */ material?: any; - type?: string; } interface TextSymbol extends Symbol { + /** + * The angle of the text. `0` is horizontal and the angle moves clockwise. + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#angle) + * + * @default 0 + */ angle: number; + /** + * The background color of the label's bounding box. This property is only supported for [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#backgroundColor) + */ backgroundColor: Color; + /** + * The border color of the label's bounding box. This property is only supported for [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#borderLineColor) + */ borderLineColor: Color; + /** + * The border size or width of the label's bounding box. This property is only supported for [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#borderLineSize) + */ borderLineSize: number; + /** + * The color of the text. This can be autocast with a named string; hex string; array of rgb or rgba values; an object with `r`, `g`, `b`, and `a` properties; or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#color) + */ color: Color; + /** + * The font used to style the text. + * > **Known Limitations** This property is not fully supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#font) + */ font: Font; + /** + * The color of the text symbol's halo. To include a halo in the TextSymbol, you must also set the size of the halo in [haloSize](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#haloSize). + * > **Known Limitations** + * * Not supported in IE 9 or below. + * * Sub-pixel halo (i.e. fractional size such as 1.25px) renders inconsistently in various browsers. + * * Not supported in [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html), but will be in a future release. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#haloColor) + */ haloColor: Color; + /** + * The size in points of the text symbol's halo. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). To include a halo in the TextSymbol, you must also set the color of the halo in [haloColor](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#haloColor). + * > **Known Limitations** + * * Not supported in IE 9 or below. + * * Sub-pixel halo (i.e. fractional size such as 1.25px) renders inconsistently in various browsers. + * * Not supported in [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html), but will be in a future release. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#haloSize) + */ haloSize: number; + /** + * The horizontal alignment of the text with respect to the graphic. **Possible Values:** left | right | center | justify + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#horizontalAlignment) + * + * @default center + */ horizontalAlignment: string; + /** + * Determines whether to adjust the spacing between characters in the text string. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#kerning) + * + * @default true + */ kerning: boolean; + /** + * Determines whether every character in the text string is rotated. + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#rotated) + * + * @default false + */ rotated: boolean; + /** + * The text string to display in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#text) + */ text: string; + /** + * For TextSymbol, the type is always `text`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#type) + */ + readonly type: "text"; + /** + * The vertical alignment of the text with respect to the graphic. **Possible Values:** baseline | top | middle | bottom + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#verticalAlignment) + * + * @default baseline + */ verticalAlignment: string; + /** + * The offset on the x-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#xoffset) + * + * @default 0 + */ xoffset: number; + /** + * The offset on the y-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#yoffset) + * + * @default 0 + */ yoffset: number; + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#clone) + * + * + */ clone(): TextSymbol; } interface TextSymbolConstructor { + /** + * Text symbols are used to define the graphic for displaying labels on a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html). With this class, you may alter the [color](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#color), [font](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#font), [halo](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#haloSize), and other properties of the label graphic. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html) + */ + new(properties?: TextSymbolProperties): TextSymbol; fromJSON(json: any): TextSymbol; @@ -5670,33 +23848,178 @@ declare namespace __esri { export const TextSymbol: TextSymbolConstructor; interface TextSymbolProperties extends SymbolProperties { + /** + * The angle of the text. `0` is horizontal and the angle moves clockwise. + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#angle) + * + * @default 0 + */ angle?: number; - backgroundColor?: Color; - borderLineColor?: Color; + /** + * The background color of the label's bounding box. This property is only supported for [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#backgroundColor) + */ + backgroundColor?: Color | number[] | string; + /** + * The border color of the label's bounding box. This property is only supported for [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#borderLineColor) + */ + borderLineColor?: Color | number[] | string; + /** + * The border size or width of the label's bounding box. This property is only supported for [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#borderLineSize) + */ borderLineSize?: number; - color?: Color; + /** + * The color of the text. This can be autocast with a named string; hex string; array of rgb or rgba values; an object with `r`, `g`, `b`, and `a` properties; or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#color) + */ + color?: Color | number[] | string; + /** + * The font used to style the text. + * > **Known Limitations** This property is not fully supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#font) + */ font?: FontProperties; + /** + * The color of the text symbol's halo. To include a halo in the TextSymbol, you must also set the size of the halo in [haloSize](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#haloSize). + * > **Known Limitations** + * * Not supported in IE 9 or below. + * * Sub-pixel halo (i.e. fractional size such as 1.25px) renders inconsistently in various browsers. + * * Not supported in [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html), but will be in a future release. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#haloColor) + */ haloColor?: Color; - haloSize?: number; + /** + * The size in points of the text symbol's halo. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). To include a halo in the TextSymbol, you must also set the color of the halo in [haloColor](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#haloColor). + * > **Known Limitations** + * * Not supported in IE 9 or below. + * * Sub-pixel halo (i.e. fractional size such as 1.25px) renders inconsistently in various browsers. + * * Not supported in [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html), but will be in a future release. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#haloSize) + */ + haloSize?: number | string; + /** + * The horizontal alignment of the text with respect to the graphic. **Possible Values:** left | right | center | justify + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#horizontalAlignment) + * + * @default center + */ horizontalAlignment?: string; + /** + * Determines whether to adjust the spacing between characters in the text string. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#kerning) + * + * @default true + */ kerning?: boolean; + /** + * Determines whether every character in the text string is rotated. + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#rotated) + * + * @default false + */ rotated?: boolean; + /** + * The text string to display in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#text) + */ text?: string; + /** + * The vertical alignment of the text with respect to the graphic. **Possible Values:** baseline | top | middle | bottom + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#verticalAlignment) + * + * @default baseline + */ verticalAlignment?: string; - xoffset?: number; - yoffset?: number; + /** + * The offset on the x-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#xoffset) + * + * @default 0 + */ + xoffset?: number | string; + /** + * The offset on the y-axis in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * > **Known Limitations** This property is not supported in 3D [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol.html#yoffset) + * + * @default 0 + */ + yoffset?: number | string; } interface TextSymbol3DLayer extends Symbol3DLayer { + /** + * The font of the text label. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#font) + */ font: TextSymbol3DLayerFont; + /** + * The halo surrounding the text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#halo) + */ halo: TextSymbol3DLayerHalo; + /** + * Size of the text label in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#size) + * + * @default 9 + */ size: number; + /** + * The text to be displayed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#text) + */ text: string; + /** + * For TextSymbol3DLayer the type is always `text`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#type) + */ + readonly type: "text"; + /** + * Creates a deep clone of the symbol layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#clone) + * + * + */ clone(): TextSymbol3DLayer; } interface TextSymbol3DLayerConstructor { + /** + * TextSymbol3DLayer is used to draw text labels for features of any geometry type. This is typically done by adding it to a [LabelSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-LabelSymbol3D.html) in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) does not support 3D symbols. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html) + */ + new(properties?: TextSymbol3DLayerProperties): TextSymbol3DLayer; fromJSON(json: any): TextSymbol3DLayer; @@ -5705,34 +24028,158 @@ declare namespace __esri { export const TextSymbol3DLayer: TextSymbol3DLayerConstructor; interface TextSymbol3DLayerProperties extends Symbol3DLayerProperties { + /** + * The font of the text label. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#font) + */ font?: TextSymbol3DLayerFont; - halo?: TextSymbol3DLayerHalo; - size?: number; + /** + * The halo surrounding the text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#halo) + */ + halo?: TextSymbol3DLayerHaloProperties; + /** + * Size of the text label in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#size) + * + * @default 9 + */ + size?: number | string; + /** + * The text to be displayed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#text) + */ text?: string; } - export interface TextSymbol3DLayerFont { + + export interface TextSymbol3DLayerFont extends Object { + /** + * The font family. See [MDN: font-family](https://developer.mozilla.org/en-US/docs/Web/CSS/font-family). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#font) + * + * @default Arial + */ family?: string; + /** + * The font weight. **Known Values:** normal | bold + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#font) + * + * @default normal + */ weight?: string; + /** + * The font style. **Known Values:** normal | italic + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#font) + * + * @default normal + */ style?: string; } - export interface TextSymbol3DLayerHalo { + + export interface TextSymbol3DLayerHaloProperties extends Object { + /** + * The color of the halo. This can be autocast with a named string, hex string, array of rgb or rgba values, an object with `r`, `g`, `b`, and `a` properties, or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#halo) + * + * @default black + */ + color?: Color | number[] | string; + /** + * The size of the halo in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#halo) + * + * @default 0 + */ + size?: number | string; + } + + export interface TextSymbol3DLayerHalo extends AnonymousAccessor { + /** + * The color of the halo. This can be autocast with a named string, hex string, array of rgb or rgba values, an object with `r`, `g`, `b`, and `a` properties, or a [Color](https://developers.arcgis.com/javascript/latest/api-reference/esri-Color.html) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#halo) + * + * @default black + */ color?: Color; + /** + * The size of the halo in points. This value may be autocast with a string expressing size in points or pixels (e.g. `12px`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-TextSymbol3DLayer.html#halo) + * + * @default 0 + */ size?: number; } interface WebStyleSymbol extends Symbol { + /** + * The name of the symbol within the web style. Each symbol in a web style is identified by a unique name. Only [Esri-provided web style symbol names](https://developers.arcgis.com/javascript/latest/guide/esri-web-style-symbols/index.html) can be referenced here. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#name) + */ name: string; + /** + * The portal that contains the web style this symbol refers to. Only required when [styleName](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#styleName) is set. Defaults to the value in [config.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl) (e.g. https://www.arcgis.com). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#portal) + */ portal: Portal; + /** + * A registered web style name. Only [Esri-provided web style names](https://developers.arcgis.com/javascript/latest/guide/esri-web-style-symbols/index.html) can be referenced here. Requires [portal](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#portal) property to be set. Can not be used in conjunction with [styleUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#styleUrl). See class description for example. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#styleName) + */ styleName: string; + /** + * URL that points to the web style definition. Cannot be used in conjunction with [styleName](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#styleName) and [portal](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#portal). See class description for example. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#styleUrl) + */ styleUrl: string; + /** + * For WebStyleSymbol the type is always `web-style`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#type) + */ + readonly type: "web-style"; + /** + * Creates a deep clone of the symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#clone) + * + * + */ clone(): WebStyleSymbol; + /** + * Downloads and returns the [PointSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html) instance the WebStyleSymbol refers to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#fetchSymbol) + * + * + */ fetchSymbol(): IPromise; } interface WebStyleSymbolConstructor { + /** + * WebStyleSymbol is a class used to conveniently create realistic and thematic 3D symbols. It is a wrapper for creating [PointSymbol3D](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-PointSymbol3D.html) objects that point to a web style resource available in the API. This symbol type is not supported in 2D MapViews. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html) + */ + new(properties?: WebStyleSymbolProperties): WebStyleSymbol; fromJSON(json: any): WebStyleSymbol; @@ -5741,17 +24188,52 @@ declare namespace __esri { export const WebStyleSymbol: WebStyleSymbolConstructor; interface WebStyleSymbolProperties extends SymbolProperties { + /** + * The name of the symbol within the web style. Each symbol in a web style is identified by a unique name. Only [Esri-provided web style symbol names](https://developers.arcgis.com/javascript/latest/guide/esri-web-style-symbols/index.html) can be referenced here. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#name) + */ name?: string; + /** + * The portal that contains the web style this symbol refers to. Only required when [styleName](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#styleName) is set. Defaults to the value in [config.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl) (e.g. https://www.arcgis.com). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#portal) + */ portal?: PortalProperties; + /** + * A registered web style name. Only [Esri-provided web style names](https://developers.arcgis.com/javascript/latest/guide/esri-web-style-symbols/index.html) can be referenced here. Requires [portal](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#portal) property to be set. Can not be used in conjunction with [styleUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#styleUrl). See class description for example. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#styleName) + */ styleName?: string; + /** + * URL that points to the web style definition. Cannot be used in conjunction with [styleName](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#styleName) and [portal](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#portal). See class description for example. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-WebStyleSymbol.html#styleUrl) + */ styleUrl?: string; } interface ClosestFacilityTask extends Task { + /** + * Solves the closest facility. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ClosestFacilityTask.html#solve) + * + * @param params Defines the parameters of the closest facility analysis. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ solve(params: ClosestFacilityParameters, requestOptions?: any): IPromise; } interface ClosestFacilityTaskConstructor { + /** + * Helps you find closest facilities around any location (incident) on a network. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ClosestFacilityTask.html) + */ + new(properties?: ClosestFacilityTaskProperties): ClosestFacilityTask; } @@ -5762,46 +24244,282 @@ declare namespace __esri { } interface FindTask extends Task { + /** + * The geodatabase version. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-FindTask.html#gdbVersion) + */ gdbVersion: string; + /** + * Sends a request to the ArcGIS REST map service resource to perform a search based on the input [params](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-FindTask.html#execute) + * + * @param params Specifies the layers and fields that are used for the search. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ execute(params: FindParameters, requestOptions?: any): IPromise; } interface FindTaskConstructor { + /** + * Search a map service exposed by the ArcGIS Server REST API based on a string value. The search can be conducted on a single field of a single layer, on many fields of a layer, or on many fields of many layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-FindTask.html) + */ + new(properties?: FindTaskProperties): FindTask; } export const FindTask: FindTaskConstructor; interface FindTaskProperties extends TaskProperties { + /** + * The geodatabase version. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-FindTask.html#gdbVersion) + */ gdbVersion?: string; } interface GeometryService extends Task { + /** + * Computes the area and length for the input [polygons](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#areasAndLengths) + * + * @param areasAndLengthsParameters Specify the input polygons and optionally the linear and area units. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ areasAndLengths(areasAndLengthsParameters: AreasAndLengthsParameters, requestOptions?: any): IPromise; + /** + * The Auto Complete operation is performed on a geometry service resource. The AutoComplete operation simplifies the process of constructing new polygons that are adjacent to other polygons. It constructs polygons that fill in the gaps between existing polygons and a set of polylines. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#autoComplete) + * + * @param polygons The array of polygons that will provide boundaries for new polygons. + * @param polylines An array of polylines that will provide the remaining boundaries for new polygons. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ autoComplete(polygons: Polygon[], polylines: Polyline[], requestOptions?: any): IPromise; + /** + * Creates buffer polygons at a specified distance around the given geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#buffer) + * + * @param bufferParameters Specifies the input geometries, buffer distances, and other options. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ buffer(bufferParameters: BufferParameters, requestOptions?: any): IPromise; + /** + * The convexHull operation is performed on a geometry service resource. It returns the convex hull of the input geometry. The input geometry can be a point, multipoint, polyline or polygon. The hull is typically a polygon but can also be a polyline or point in degenerate cases. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#convexHull) + * + * @param geometries The geometries whose convex hull is to be created. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ convexHull(geometries: Geometry[], requestOptions?: any): IPromise; + /** + * The cut operation is performed on a geometry service resource. This operation splits the input polyline or polygon where it crosses a cutting polyline. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#cut) + * + * @param geometries The polylines or polygons to be cut. + * @param cutter The polyline that will be used to divide the target into pieces where it crosses the target. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ cut(geometries: Geometry[], cutter: Polyline, requestOptions?: any): IPromise; + /** + * The densify operation is performed on a geometry service resource. This operation densifies geometries by plotting points between existing vertices. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#densify) + * + * @param densifyParameters The DensifyParameters objects contains `geometries`, `geodesic`, `lengthUnit`, and `maxSegmentLength` properties. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ densify(densifyParameters: DensifyParameters, requestOptions?: any): IPromise; + /** + * The difference operation is performed on a geometry service resource. This operation constructs the set-theoretic difference between an array of geometries and another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#difference) + * + * @param geometries An array of points, multipoints, polylines or polygons. + * @param geometry A single geometry of any type, with a dimension equal to or greater than the items in geometries. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ difference(geometries: Geometry[], geometry: Geometry, requestOptions?: any): IPromise; + /** + * Measures the planar or geodesic distance between geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#distance) + * + * @param params Sets the input geometries to measure, distance units, and other parameters. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ distance(params: DistanceParameters, requestOptions?: any): IPromise; + /** + * Converts an array of well-known strings into xy-coordinates based on the conversion type and spatial reference supplied by the user. Only available with ArcGIS Server 10.3 or above. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#fromGeoCoordinateString) + * + * @param params See the object specifications table below for the structure of the `params` object. + * @param params.strings An array of formatted strings as specified by `conversionType`. Example: `["01N AA 66021 00000" , "11S NT 00000 62155" , "31U BT 94071 65288"]` + * @param params.sr The spatial reference or well-known ID to convert the input string coordinates to. + * @param params.conversionType The converstion type of the input strings. **Possible Values:** mrgs | usng | utm | geo-ref | gars | dms | ddm | dd + * @param params.conversionMode Conversion options for mrgs, utm and gars conversion types. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000026z000000) for valid values and their descriptions. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ fromGeoCoordinateString(params: GeometryServiceFromGeoCoordinateStringParams, requestOptions?: any): IPromise; + /** + * Generalizes the input geometries using the Douglas-Peucker algorithm. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#generalize) + * + * @param params An array of geometries to generalize and a maximum deviation. Optionally set the deviation units. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ generalize(params: GeneralizeParameters, requestOptions?: any): IPromise; + /** + * The intersect operation is performed on a geometry service resource. This operation constructs the set-theoretic intersection between an array of geometries and another geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#intersect) + * + * @param geometries An array of points, multipoints, polylines, or polygons. + * @param intersector A single geometry of any type, of dimension equal to or greater than the dimension of the items in `geometries`. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ intersect(geometries: Geometry[], intersector: Geometry, requestOptions?: any): IPromise; + /** + * Calculates an interior point for each polygon specified. These interior points can be used by clients for labeling the polygons. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#labelPoints) + * + * @param polygons The polygon graphics to process. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ labelPoints(polygons: Polygon[], requestOptions?: any): IPromise; + /** + * Gets the lengths for a [Geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) when the geometry type is [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#lengths) + * + * @param params Specify the polylines and optionally the length unit and the geodesic length option. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ lengths(params: LengthsParameters, requestOptions?: any): IPromise; + /** + * Constructs the offset of the input geometries based on a planar distance. If the offsetDistance is positive the constructed offset will be on the right side of the geometry. Left side offsets are constructed with negative values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#offset) + * + * @param params Set the geometries to offset, distance, and units. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ offset(params: OffsetParameters, requestOptions?: any): IPromise; + /** + * Projects a set of geometries to a new spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#project) + * + * @param params The input projection parameters. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ project(params: ProjectParameters, requestOptions?: any): IPromise; + /** + * Computes the set of pairs of geometries from the input geometry arrays that belong to the specified relation. Both arrays are assumed to be in the same spatial reference. The relations are evaluated in 2D. Z-coordinates are not used. Geometry types cannot be mixed within an array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#relation) + * + * @param params The set of parameters required to perform the comparison. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ relation(params: RelationParameters, requestOptions?: any): IPromise; + /** + * The reshape operation is performed on a geometry service resource. It reshapes a [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html) or a part of a [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html) using a reshaping line. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#reshape) + * + * @param targetGeometry The Polyline or Polygon to be reshaped. + * @param reshaper The single-part polyline that performs the reshaping. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ reshape(targetGeometry: Geometry, reshaper: Geometry, requestOptions?: any): IPromise; + /** + * Alters the given geometries to make their definitions topologically legal with respect to their geometry type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#simplify) + * + * @param geometries The geometries to simplify. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ simplify(geometries: Geometry[], requestOptions?: any): IPromise; + /** + * Converts an array of XY-coordinates into well-known strings based on the conversion type and spatial reference supplied by the user. Only available with ArcGIS Server 10.3 or above. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#toGeoCoordinateString) + * + * @param params See the object specifications table below for the structure of the `params` object. + * @param params.sr The spatial reference (or WKID of the spatial reference) of the XY-coordinates to be converted. + * @param params.coordinates An array of XY-coordinates (in JSON format) to be converted. + * @param params.conversionType The conversion type of the input strings. **Possible values:** mgrs | usng | utm | geo-ref | gars | dms | ddm | dd + * @param params.conversionMode Conversion options for mgrs and utm conversion types. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000026w000000) for valid conversion modes and their descriptions. + * @param params.numOfDigits The number of digits to output for each of the numerical portions in the string. The default value depends of `conversionType`. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000026z000000) for default values. + * @param params.rounding If `true`, then numeric portions of the string are rounded to the nearest whole magnitude as specified by `numOfDigits`. Otherwise, numeric portions of the string are truncated. The rounding parameter applies only to conversion types `mgrs`, `usng` and `geo-ref`. + * @param params.addSpaces If `true`, then spaces are added between components of the string. The `addSpaces` parameter applies only to conversion types `mgrs`, `usng` and `utm`. The default value for `mgrs` is `false` , while the default value for both `usng` and `utm` is `true`. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ toGeoCoordinateString(params: GeometryServiceToGeoCoordinateStringParams, requestOptions?: any): IPromise; + /** + * Trims or extends the input polylines using the user specified guide polyline. When trimming features, the portion to the left of the cutting line is preserved in the output and the rest is discarded. If the input polyline is not cut or extended then an empty polyline is added to the output array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#trimExtend) + * + * @param params Input parameters for the `trimExtend` operation. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ trimExtend(params: TrimExtendParameters, requestOptions?: any): IPromise; + /** + * The union operation is performed on a geometry service resource. This operation constructs the set-theoretic union of the geometries in the input array. All inputs must be of the same type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#union) + * + * @param geometries An array of the geometries to be unioned. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ union(geometries: Geometry[], requestOptions?: any): IPromise; } interface GeometryServiceConstructor { + /** + * Represents a geometry service resource exposed by the ArcGIS REST API. It is used to perform various operations on geometries such as project, simplify, buffer, and relationships. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html) + */ + new(properties?: GeometryServiceProperties): GeometryService; } @@ -5811,71 +24529,301 @@ declare namespace __esri { } - export interface GeometryServiceFromGeoCoordinateStringParams { + + export interface GeometryServiceFromGeoCoordinateStringParams extends Object { + /** + * An array of formatted strings as specified by `conversionType`. Example: `["01N AA 66021 00000" , "11S NT 00000 62155" , "31U BT 94071 65288"]` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#fromGeoCoordinateString) + */ strings: string[]; + /** + * The spatial reference or well-known ID to convert the input string coordinates to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#fromGeoCoordinateString) + */ sr: SpatialReference | string; - conversionType: string; + /** + * The converstion type of the input strings. **Possible Values:** mrgs | usng | utm | geo-ref | gars | dms | ddm | dd + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#fromGeoCoordinateString) + * + * @default mrgs + */ + conversionType?: string; + /** + * Conversion options for mrgs, utm and gars conversion types. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000026z000000) for valid values and their descriptions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#fromGeoCoordinateString) + */ conversionMode?: string; } - export interface GeometryServiceToGeoCoordinateStringParams { + + export interface GeometryServiceToGeoCoordinateStringParams extends Object { + /** + * The spatial reference (or WKID of the spatial reference) of the XY-coordinates to be converted. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#toGeoCoordinateString) + */ sr: SpatialReference | string; + /** + * An array of XY-coordinates (in JSON format) to be converted. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#toGeoCoordinateString) + */ coordinates: number[][]; + /** + * The conversion type of the input strings. **Possible values:** mgrs | usng | utm | geo-ref | gars | dms | ddm | dd + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#toGeoCoordinateString) + */ conversionType: string; + /** + * Conversion options for mgrs and utm conversion types. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000026w000000) for valid conversion modes and their descriptions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#toGeoCoordinateString) + */ conversionMode?: string; + /** + * The number of digits to output for each of the numerical portions in the string. The default value depends of `conversionType`. See the [ArcGIS REST API documentation](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r30000026z000000) for default values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#toGeoCoordinateString) + */ numOfDigits?: number; + /** + * If `true`, then numeric portions of the string are rounded to the nearest whole magnitude as specified by `numOfDigits`. Otherwise, numeric portions of the string are truncated. The rounding parameter applies only to conversion types `mgrs`, `usng` and `geo-ref`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#toGeoCoordinateString) + * + * @default true + */ rounding?: boolean; + /** + * If `true`, then spaces are added between components of the string. The `addSpaces` parameter applies only to conversion types `mgrs`, `usng` and `utm`. The default value for `mgrs` is `false` , while the default value for both `usng` and `utm` is `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-GeometryService.html#toGeoCoordinateString) + */ addSpaces?: boolean; } interface Geoprocessor extends Task { + /** + * The spatial reference of the output geometries. If not specified, the output geometries will be in the spatial reference of the input geometries. If [processSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#processSpatialReference) is specified and `outSpatialReference` is not specified, the output geometries will be in the spatial reference of the process spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#outSpatialReference) + */ outSpatialReference: SpatialReference; + /** + * The spatial reference that the model will use to perform geometry operations. If `processSpatialReference` is specified and [outputSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#outputSpatialReference) is not specified, the output geometries will be in the spatial reference of the process spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#processSpatialReference) + */ processSpatialReference: SpatialReference; + /** + * The time interval in milliseconds between each job status request sent to an asynchronous GP task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#updateDelay) + * + * @default 1000 + */ updateDelay: number; + /** + * Cancels an asynchronous geoprocessing job. Requires an ArcGIS Server 10.1 service or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#cancelJob) + * + * @param jobId A string that uniquely identifies a job on the server. It is created when a job is submitted for execution and later used to check its status and retrieve the results. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ cancelJob(jobId: string, requestOptions?: any): IPromise; + /** + * Cancels the periodic job status updates automatically initiated when [submitJob()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#submitJob) is invoked for the job identified by `jobId`. You can still obtain the status of this job by calling the [checkJobStatus()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#checkJobStatus) method at your own discretion. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#cancelJobStatusUpdates) + * + * @param jobId A string that uniquely identifies the job for which the job updates are cancelled. + * + */ cancelJobStatusUpdates(jobId: string): void; + /** + * Sends a request to the GP Task for the current state of the job identified by `jobId`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#checkJobStatus) + * + * @param jobId The jobId returned from [JobInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-JobInfo.html). + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ checkJobStatus(jobId: string, requestOptions?: any): IPromise; + /** + * Sends a request to the server to execute a synchronous GP task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#execute) + * + * @param params ``` + * Specifies the input parameters accepted by the task and their corresponding values. These input parameters are listed in the parameters field of the associated GP Task resource. For example, assume that a GP Task resource has the following input parameters: + * * `` Input_Points + * * `` Distance + * + * + * The `params` argument would then be an Object of the form: + * ``` + * { + * Input_Points: , + * Distance: + * } + * + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ execute(params: any, requestOptions?: any): IPromise; + /** + * Sends a request to the GP Task to get the task result identified by `jobId` and `resultName`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#getResultData) + * + * @param jobId The jobId returned from [JobInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-JobInfo.html). + * @param resultName The name of the result parameter as defined in Services Directory. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getResultData(jobId: string, resultName: string, requestOptions?: any): IPromise; + /** + * Sends a request to the GP Task to get the task result identified by `jobId` and `resultName` as an image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#getResultImage) + * + * @param jobId The jobId returned from [JobInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-JobInfo.html). + * @param resultName The name of the result parameter as defined in the Services Directory. + * @param imageParams Specifies the properties of the result image. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getResultImage(jobId: string, resultName: string, imageParams: ImageParameters, requestOptions?: any): IPromise; + /** + * Get the task result identified by `jobId` as an [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). This method supports MapImageLayer 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#getResultMapImageLayer) + * + * @param jobId The jobId returned from [JobInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-JobInfo.html). + * + */ getResultMapImageLayer(jobId: string): MapImageLayer; + /** + * Submits a job to the server for asynchronous processing by the GP task. The task execution results can be retrieved using the [getResultData()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#getResultData), [getResultImage()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#getResultImage), or [getResultMapImageLayer()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#getResultMapImageLayer) methods. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#submitJob) + * + * @param params ``` + * specifies the input parameters accepted by the task and their corresponding values. These input parameters are listed in the parameters field of the associated GP Task resource. For example, assume that a GP Task resource has the following input parameters: + * * `` Input_Points + * * `` Distance + * + * + * The `params` argument would then be an Object of the form: + * ``` + * { + * Input_Points: , + * Distance: + * } + * + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ submitJob(params: any, requestOptions?: any): IPromise; } interface GeoprocessorConstructor { + + new(properties?: GeoprocessorProperties): Geoprocessor; } export const Geoprocessor: GeoprocessorConstructor; interface GeoprocessorProperties extends TaskProperties { + /** + * The spatial reference of the output geometries. If not specified, the output geometries will be in the spatial reference of the input geometries. If [processSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#processSpatialReference) is specified and `outSpatialReference` is not specified, the output geometries will be in the spatial reference of the process spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#outSpatialReference) + */ outSpatialReference?: SpatialReferenceProperties; + /** + * The spatial reference that the model will use to perform geometry operations. If `processSpatialReference` is specified and [outputSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#outputSpatialReference) is not specified, the output geometries will be in the spatial reference of the process spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#processSpatialReference) + */ processSpatialReference?: SpatialReferenceProperties; + /** + * The time interval in milliseconds between each job status request sent to an asynchronous GP task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Geoprocessor.html#updateDelay) + * + * @default 1000 + */ updateDelay?: number; } interface IdentifyTask extends Task { + /** + * Specifies the geodatabase version to display. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-IdentifyTask.html#gdbVersion) + */ gdbVersion: string; + /** + * Sends a request to the ArcGIS REST map service resource to identify features based on the [IdentifyParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html) specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-IdentifyTask.html#execute) + * + * @param params Specifies the criteria used to identify the features. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ execute(params: IdentifyParameters, requestOptions?: any): IPromise; } interface IdentifyTaskConstructor { + /** + * Performs an identify operation on the layers of a map service exposed by the ArcGIS Server REST API. Use [IdentifyParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html) to set the parameters for the identify operation and [IdentifyResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyResult.html) to work with the results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-IdentifyTask.html) + */ + new(properties?: IdentifyTaskProperties): IdentifyTask; } export const IdentifyTask: IdentifyTaskConstructor; interface IdentifyTaskProperties extends TaskProperties { + /** + * Specifies the geodatabase version to display. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-IdentifyTask.html#gdbVersion) + */ gdbVersion?: string; } interface ImageServiceIdentifyTask extends Task { + /** + * Sends a request to the ArcGIS REST image service resource to identify content based on the [ImageServiceIdentifyParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html) specified in the `params` argument. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ImageServiceIdentifyTask.html#execute) + * + * @param params Specifies the criteria used to identify the features. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ execute(params: ImageServiceIdentifyParameters, requestOptions?: any): IPromise; } interface ImageServiceIdentifyTaskConstructor { + + new(properties?: ImageServiceIdentifyTaskProperties): ImageServiceIdentifyTask; } @@ -5886,103 +24834,462 @@ declare namespace __esri { } interface Locator extends Task { + /** + * Limit the results to one or more categories. For example "Populated Place" or "airport". Only applicable when using the World Geocode Service. View the [World Geocoding Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#categories) + */ categories: string[]; + /** + * Limits the results to only search in the country provided. For example `US` for United States or `SE` for Sweden. Only applies to the World Geocode Service. See the [World Geocoding Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#countryCode) + */ countryCode: string; + /** + * The spatial reference of the output geometries. If not specified, the output geometries are in the spatial reference of the input geometries when performing a reverse geocode and in the default spatial reference returned by the service if finding locations by address. If `processSpatialReference` is specified and `outSpatialReference` is not specified, the output geometries are in the spatial reference of the process spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#outSpatialReference) + */ outSpatialReference: SpatialReference; + /** + * Find address candidates for multiple input addresses. This method requires an ArcGIS Server 10.1 or greater geocode service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressesToLocations) + * + * @param params See specifications below. + * @param params.addresses ``` + * The input addresses in the format supported by the geocode service. If the service supports 'Single Line Input' the input addresses will be in the following format: + * ```js + * { + * "OBJECTID": 0, + * "Single Line Input":"440 Arguello Blvd, 94118" + * } + * @param params.countryCode Limits the results to only search in the country provided. For example `US` for United States or `SE` for Sweden. Only applies to the World Geocode Service. See the [World Geocoding Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm) for more information. + * @param params.categories Limit result to one or more categories. For example, "Populated Place" or "Scandinavian Food". Only applies to the World Geocode Service. See [Category filtering (World Geocoding Service)](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm#ESRI_SECTION1_502B3FE2028145D7B189C25B1A00E17B) for more information. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ addressesToLocations(params: LocatorAddressesToLocationsParams, requestOptions?: any): IPromise; + /** + * Sends a request to the ArcGIS REST geocode resource to find candidates for a single address specified in the address parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations) + * + * @param params Specify at least the address and optionally other properties. See the object specifications table below. + * @param params.address visit the ArcGIS Online Geocoding Service help for more details on the World Geocoder. + * The address argument is data object that contains properties representing the various address fields accepted by the corresponding geocode service. These fields are listed in the addressFields property of the associated geocode service resource. For example, if the *addressFields* of a geocode service resource includes fields with the following names: Street, City, State and Zone, then the address argument is of the form: + * ```js + * { + * Street: "1234 W Main St", + * City: "Small Town", + * State: "WA", + * Zone: "99027" + * } + * ``` + * + * Locators published using ArcGIS 10 or later support a single line address field, which + * can be specified using the following syntax where field_name is the name of the single + * line address field. You can find this name by viewing the help or services directory for + * your locator services. Common values are *SingleLine* and *SingleLineFieldName*: + * ```js + * var address = { "field_name": "380 New York St, Redlands, CA 92373" }; + * ``` + * The Services Directory can be used to find out the required and optional address fields + * and the correct names for the input name fields. If you are using the World Geocoding Service + * @param params.categories Limit result to one or more categories. For example, "Populated Place" or "Scandinavian Food". Only applies to the World Geocode Service. See [Category filtering (World Geocoding Service)](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm#ESRI_SECTION1_502B3FE2028145D7B189C25B1A00E17B) for more information. + * @param params.countryCode Limit result to a specific country. For example, "US" for United States or "SE" for Sweden. Only applies to the World Geocode Service. See Geocode coverage (World Geocoding Service) for more information. + * @param params.distance Used in combination with `location` option to weight returned results within this distance (meters). + * @param params.forStorage Allows the results of single geocode transactions to be persisted. + * @param params.location Used in combination with `distance` option to weight returned results for a specified area. + * @param params.magicKey A `suggestLocations` result ID (magicKey). Used to query for a specific results information. + * @param params.maxLocations Maximum results to return from the query. + * @param params.outFields The list of fields included in the returned result set. This list is a comma delimited list of field names. If you specify the shape field in the list of return fields, it is ignored. For non-intersection addresses you can specify the candidate fields as defined in the geocode service. For intersection addresses you can specify the intersection candidate fields. + * @param params.searchExtent Defines the extent within which the geocode server will search. Requires ArcGIS Server version 10.1 or greater. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ addressToLocations(params: LocatorAddressToLocationsParams, requestOptions?: any): IPromise; + /** + * Locates an address based on a given point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#locationToAddress) + * + * @param location The point at which to search for the closest address. The location should be in the same spatial reference as that of the geocode service. + * @param distance The distance in meters from the given location within which a matching address should be searched. If this parameter is not provided or an invalid value is provided, a default value of 0 meters is used. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ locationToAddress(location: Point, distance?: number, requestOptions?: any): IPromise; - suggestLocations(params: LocatorSuggestLocationsParams, requestOptions?: any): IPromise; + /** + * Get character by character auto complete suggestions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#suggestLocations) + * + * @param params An object that defines suggest parameters. See specifications below. + * @param params.categories A place or address type which can be used to filter suggest results. The parameter supports input of single category values or multiple comma-separated values. + * @param params.distance Used with the `location` property. The `distance` property specifies the radial distance from the location. + * @param params.location Defines a normalized location point that is used with the distance parameter to sort geocoding candidates based upon their proximity to the given location. + * @param params.text The input text entered by a user which is used by the suggest operation to generate a list of possible matches. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ + suggestLocations(params: LocatorSuggestLocationsParams, requestOptions?: any): IPromise; } interface LocatorConstructor { + /** + * Represents a geocode service resource exposed by the ArcGIS Server REST API. It is used to generate candidates for an address. It is also used to generate batch results for a set of addresses. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html) + */ + new(properties?: LocatorProperties): Locator; } export const Locator: LocatorConstructor; interface LocatorProperties extends TaskProperties { + /** + * Limit the results to one or more categories. For example "Populated Place" or "airport". Only applicable when using the World Geocode Service. View the [World Geocoding Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#categories) + */ categories?: string[]; + /** + * Limits the results to only search in the country provided. For example `US` for United States or `SE` for Sweden. Only applies to the World Geocode Service. See the [World Geocoding Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#countryCode) + */ countryCode?: string; + /** + * The spatial reference of the output geometries. If not specified, the output geometries are in the spatial reference of the input geometries when performing a reverse geocode and in the default spatial reference returned by the service if finding locations by address. If `processSpatialReference` is specified and `outSpatialReference` is not specified, the output geometries are in the spatial reference of the process spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#outSpatialReference) + */ outSpatialReference?: SpatialReferenceProperties; } - export interface LocatorAddressesToLocationsParams { + + export interface LocatorAddressesToLocationsParams extends Object { + /** + * The input addresses in the format supported by the geocode service. If the service supports 'Single Line Input' the input addresses will be in the following format: + * ```js + * { + * "OBJECTID": 0, + * "Single Line Input":"440 Arguello Blvd, 94118" + * } + * ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressesToLocations) + */ addresses: any[]; + /** + * Limits the results to only search in the country provided. For example `US` for United States or `SE` for Sweden. Only applies to the World Geocode Service. See the [World Geocoding Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressesToLocations) + */ countryCode: string; + /** + * Limit result to one or more categories. For example, "Populated Place" or "Scandinavian Food". Only applies to the World Geocode Service. See [Category filtering (World Geocoding Service)](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm#ESRI_SECTION1_502B3FE2028145D7B189C25B1A00E17B) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressesToLocations) + */ categories: string[]; } - export interface LocatorAddressToLocationsParams { + + export interface LocatorAddressToLocationsParams extends Object { + /** + * The address argument is data object that contains properties representing the various address fields accepted by the corresponding geocode service. These fields are listed in the addressFields property of the associated geocode service resource. For example, if the *addressFields* of a geocode service resource includes fields with the following names: Street, City, State and Zone, then the address argument is of the form: + * ```js + * { + * Street: "1234 W Main St", + * City: "Small Town", + * State: "WA", + * Zone: "99027" + * } + * ``` + * + * Locators published using ArcGIS 10 or later support a single line address field, which + * can be specified using the following syntax where field_name is the name of the single + * line address field. You can find this name by viewing the help or services directory for + * your locator services. Common values are *SingleLine* and *SingleLineFieldName*: + * ```js + * var address = { "field_name": "380 New York St, Redlands, CA 92373" }; + * ``` + * The Services Directory can be used to find out the required and optional address fields + * and the correct names for the input name fields. If you are using the World Geocoding Service + * visit the ArcGIS Online Geocoding Service help for more details on the World Geocoder. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations) + */ address: any; + /** + * Limit result to one or more categories. For example, "Populated Place" or "Scandinavian Food". Only applies to the World Geocode Service. See [Category filtering (World Geocoding Service)](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm#ESRI_SECTION1_502B3FE2028145D7B189C25B1A00E17B) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations) + */ categories: string[]; + /** + * Limit result to a specific country. For example, "US" for United States or "SE" for Sweden. Only applies to the World Geocode Service. See Geocode coverage (World Geocoding Service) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations) + */ countryCode: string; + /** + * Used in combination with `location` option to weight returned results within this distance (meters). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations) + */ distance: number; + /** + * Allows the results of single geocode transactions to be persisted. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations) + */ forStorage: boolean; + /** + * Used in combination with `distance` option to weight returned results for a specified area. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations) + */ location: Point; + /** + * A `suggestLocations` result ID (magicKey). Used to query for a specific results information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations) + */ magicKey: string; + /** + * Maximum results to return from the query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations) + */ maxLocations: number; + /** + * The list of fields included in the returned result set. This list is a comma delimited list of field names. If you specify the shape field in the list of return fields, it is ignored. For non-intersection addresses you can specify the candidate fields as defined in the geocode service. For intersection addresses you can specify the intersection candidate fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations) + */ outFields: string[]; + /** + * Defines the extent within which the geocode server will search. Requires ArcGIS Server version 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations) + */ searchExtent: Extent; } - export interface LocatorSuggestLocationsParams { + + export interface LocatorSuggestLocationsParams extends Object { + /** + * A place or address type which can be used to filter suggest results. The parameter supports input of single category values or multiple comma-separated values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#suggestLocations) + */ categories: string[]; + /** + * Used with the `location` property. The `distance` property specifies the radial distance from the location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#suggestLocations) + */ distance: number; + /** + * Defines a normalized location point that is used with the distance parameter to sort geocoding candidates based upon their proximity to the given location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#suggestLocations) + */ location: Point; + /** + * The input text entered by a user which is used by the suggest operation to generate a list of possible matches. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#suggestLocations) + */ text: string; } - export interface SuggestionResult { + /** + * Describes the object representing the result of the [suggestLocations()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#suggestLocations) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#SuggestionResult) + */ + export interface SuggestionResult extends Object { + /** + * Indicates if the result is a Collection. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#SuggestionResult) + */ isCollection: boolean; + /** + * ID used in combination with the `text` property to uniquely identify a suggestion. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#SuggestionResult) + */ magicKey: string; + /** + * The string name of the suggested location to geocode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#SuggestionResult) + */ text: string; } interface PrintTask extends Task { - mode: string; + /** + * The mode for the print task execution. **Known Values:** async | sync + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-PrintTask.html#mode) + * + * @default sync + */ + readonly mode: string; + /** + * The time interval in milliseconds between each job status request sent to an asynchronous GP task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-PrintTask.html#updateDelay) + * + * @default 1000 + */ updateDelay: number; + /** + * Sends a request to the print service to create a print page using the options specified in the [PrintParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintParameters.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-PrintTask.html#execute) + * + * @param params Defines the printing options. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ execute(params: PrintParameters, requestOptions?: any): IPromise; } interface PrintTaskConstructor { + /** + * The PrintTask generates a printer-ready version of the map using an [Export Web Map Task](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Web_Map_Task/02r3000001m3000000/) available with ArGIS Server 10.1 and later. This class is used when you want to have more granular control over the user interface, for example, if you want to provide users the ability to define what appears on the printed page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-PrintTask.html) + */ + new(properties?: PrintTaskProperties): PrintTask; } export const PrintTask: PrintTaskConstructor; interface PrintTaskProperties extends TaskProperties { - mode?: string; + /** + * The time interval in milliseconds between each job status request sent to an asynchronous GP task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-PrintTask.html#updateDelay) + * + * @default 1000 + */ updateDelay?: number; } interface QueryTask extends Task { + /** + * Specify the geodatabase version to display. Requires ArcGIS Server service 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html#gdbVersion) + */ gdbVersion: string; - execute(params: Query, requestOptions?: any): IPromise; - executeForCount(params: Query, requestOptions?: any): IPromise; - executeForExtent(params: Query, requestOptions?: any): IPromise; - executeForIds(params: Query, requestOptions?: any): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against an ArcGIS Server map layer. The result is returned as a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html), which can be accessed using the `.then()` method. A [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) contains an array of [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) features, which can be added to the map. This array will not be populated if no results are found. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html#execute) + * + * @param params Specifies the attributes and spatial filter of the query. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ + execute(params: Query | QueryProperties, requestOptions?: any): IPromise; + /** + * Gets a count of the number of features that satisfy the input query. Valid only for layers published using ArcGIS Server 10 SP1 or greater. Layers published with earlier versions of ArcGIS Server return an error to the `errback` param of `.then()`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html#executeForCount) + * + * @param params Specifies the attributes and spatial filter of the query. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ + executeForCount(params: Query | QueryProperties, requestOptions?: any): IPromise; + /** + * Gets the extent of the features that satisfy the input query. The count of features that satisfy the input query is returned upon resolution as well. Valid only for [hosted feature services](http://doc.arcgis.com/en/arcgis-online/share-maps/hosted-web-layers.htm) on [arcgis.com](http://arcgis.com) and for ArcGIS Server 10.3.1 and later. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html#executeForExtent) + * + * @param params Specifies the attributes and spatial filter of the query. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ + executeForExtent(params: Query | QueryProperties, requestOptions?: any): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against an ArcGIS Server map layer. The result is an array of the object IDs of features that satisfy the input query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html#executeForIds) + * + * @param params Specifies the attributes and spatial filter of the query. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ + executeForIds(params: Query | QueryProperties, requestOptions?: any): IPromise; + /** + * Executes a [RelationshipQuery](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html) against an ArcGIS Server map layer (or table). If the query is successful, the result is returned as a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html), which can be accessed using the `.then()` method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html#executeRelationshipQuery) + * + * @param params Specifies the attributes and spatial filter of the query. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ executeRelationshipQuery(params: RelationshipQuery, requestOptions?: any): IPromise; } interface QueryTaskConstructor { + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) operation on a layer. The most common method used in this class is [execute()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html#execute), which executes the query as defined in the [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) object that is passed as a parameter to the function. `QueryTask.execute()` returns a Promise that resolves to a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html), which contains the features in the layer that satisfy the [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html) + */ + new(properties?: QueryTaskProperties): QueryTask; } export const QueryTask: QueryTaskConstructor; interface QueryTaskProperties extends TaskProperties { + /** + * Specify the geodatabase version to display. Requires ArcGIS Server service 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html#gdbVersion) + */ gdbVersion?: string; } interface RouteTask extends Task { + /** + * Solves the route against the route layer with the route parameters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html#solve) + * + * @param params Route parameters used as input to generate the route. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ solve(params: RouteParameters, requestOptions?: any): IPromise; } interface RouteTaskConstructor { + /** + * Find routes between two or more locations and optionally get driving directions. The RouteTask uses ArcGIS Server network analysis services to calculate routes. Network analysis services allow you to solve simple routing problems as well as complex ones that take into account multiple stops, barriers, and time windows. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html) + */ + new(properties?: RouteTaskProperties): RouteTask; } @@ -5993,10 +25300,25 @@ declare namespace __esri { } interface ServiceAreaTask extends Task { + /** + * Determines the service area based on a set of parameters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html#solve) + * + * @param params The parameters needed to define the service area. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ solve(params: ServiceAreaParameters, requestOptions?: any): IPromise; } interface ServiceAreaTaskConstructor { + /** + * ServiceAreaTask helps you find service areas around any location on a network. A network service area is a region that encompasses all accessible streets (streets that are within a specified impedance). For instance, the 5-minute service area for a point includes all the streets that can be reached within five minutes from that point. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html) + */ + new(properties?: ServiceAreaTaskProperties): ServiceAreaTask; } @@ -6007,14 +25329,41 @@ declare namespace __esri { } interface AddressCandidate extends Accessor, JSONSupport { + /** + * Address of the candidate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#address) + */ address: string; + /** + * Name value pairs of field name and field value as defined in `outFields` in [Locator.addressToLocations()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#attributes) + */ attributes: any; + /** + * The minimum and maximum X and Y coordinates of a bounding box of the address candidate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#extent) + */ extent: Extent; + /** + * The [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) object representing the location of the [address](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#address). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#location) + */ location: Point; + /** + * Numeric score between `0` and `100` for geocode candidates. A candidate with a score of `100` means a perfect match, and `0` means no match. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#score) + */ score: number; } interface AddressCandidateConstructor { + + new(properties?: AddressCandidateProperties): AddressCandidate; fromJSON(json: any): AddressCandidate; @@ -6023,161 +25372,769 @@ declare namespace __esri { export const AddressCandidate: AddressCandidateConstructor; interface AddressCandidateProperties { + /** + * Address of the candidate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#address) + */ address?: string; + /** + * Name value pairs of field name and field value as defined in `outFields` in [Locator.addressToLocations()](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressToLocations). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#attributes) + */ attributes?: any; + /** + * The minimum and maximum X and Y coordinates of a bounding box of the address candidate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#extent) + */ extent?: ExtentProperties; + /** + * The [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) object representing the location of the [address](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#address). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#location) + */ location?: PointProperties; + /** + * Numeric score between `0` and `100` for geocode candidates. A candidate with a score of `100` means a perfect match, and `0` means no match. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AddressCandidate.html#score) + */ score?: number; } interface AreasAndLengthsParameters extends Accessor { + /** + * The area unit in which areas of polygons will be calculated. Use the strings listed below or [any other valid area unit](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.AreaUnit.Code.ACRE). **Possible Values:** acres | hectares | square-miles | square-kilometers | square-meters | square-feet | square-yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AreasAndLengthsParameters.html#areaUnit) + */ areaUnit: string; + /** + * Defines the type of calculation for the geometry. The type can be one of the following: + * + * Value | Description + * ------|------------ + * planar | Planar measurements use 2D Cartesian mathematics to calculate length. Use this type if the length needs to be calculated in the input spatial reference. Otherwise use `preserveShape`. + * geodesic | Use this type to calculate an area or length using only the vertices of the polygon to define the lines connecting the vertices as geodesic segments independent of the actual shape of the polygon. **Note:** a geodesic segment is the shortest path between two points on an ellipsoid. + * preserve-shape | Calculate the area or length of the geometry on the surface of the Earth ellipsoid (for geometries defined in a projected or geographic coordinate system). This method preserves the shape of the geometry in its coordinate system, which means the true area or length will be calculated for the geometry that is displayed on the map. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AreasAndLengthsParameters.html#calculationType) + */ calculationType: string; + /** + * The length unit in which perimeters of polygons will be calculated. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AreasAndLengthsParameters.html#lengthUnit) + */ lengthUnit: string; + /** + * Polygon geometries for which to compute areas and lengths. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AreasAndLengthsParameters.html#polygons) + */ polygons: Polygon[]; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AreasAndLengthsParameters.html#toJSON) + * + * + */ toJSON(): any; } interface AreasAndLengthsParametersConstructor { + + new(properties?: AreasAndLengthsParametersProperties): AreasAndLengthsParameters; } export const AreasAndLengthsParameters: AreasAndLengthsParametersConstructor; interface AreasAndLengthsParametersProperties { + /** + * The area unit in which areas of polygons will be calculated. Use the strings listed below or [any other valid area unit](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.AreaUnit.Code.ACRE). **Possible Values:** acres | hectares | square-miles | square-kilometers | square-meters | square-feet | square-yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AreasAndLengthsParameters.html#areaUnit) + */ areaUnit?: string; + /** + * Defines the type of calculation for the geometry. The type can be one of the following: + * + * Value | Description + * ------|------------ + * planar | Planar measurements use 2D Cartesian mathematics to calculate length. Use this type if the length needs to be calculated in the input spatial reference. Otherwise use `preserveShape`. + * geodesic | Use this type to calculate an area or length using only the vertices of the polygon to define the lines connecting the vertices as geodesic segments independent of the actual shape of the polygon. **Note:** a geodesic segment is the shortest path between two points on an ellipsoid. + * preserve-shape | Calculate the area or length of the geometry on the surface of the Earth ellipsoid (for geometries defined in a projected or geographic coordinate system). This method preserves the shape of the geometry in its coordinate system, which means the true area or length will be calculated for the geometry that is displayed on the map. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AreasAndLengthsParameters.html#calculationType) + */ calculationType?: string; + /** + * The length unit in which perimeters of polygons will be calculated. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AreasAndLengthsParameters.html#lengthUnit) + */ lengthUnit?: string; + /** + * Polygon geometries for which to compute areas and lengths. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-AreasAndLengthsParameters.html#polygons) + */ polygons?: PolygonProperties[]; } interface BufferParameters extends Accessor { + /** + * The spatial reference in which the geometries are buffered. If `bufferSpatialReference` is not specified, the geometries are buffered in the spatial reference specified by `outSpatialReference`. If `outSpatialReference` is also not specified, they are buffered in the spatial reference of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#bufferSpatialReference) + */ bufferSpatialReference: SpatialReference; + /** + * The distances the input features are buffered. The distance units are specified by `unit`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#distances) + */ distances: number[]; + /** + * If the input geometries are in a geographic coordinate system, set geodesic to `true` to generate a buffer polygon using a geodesic distance. The `bufferSpatialReference` property is ignored when geodesic is set to `true`. Requires ArcGIS Server 10.1 or greater geometry service. For more information, see the ArcGIS REST API documentation on the GeometryService buffer operation and the geodesic property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#geodesic) + */ geodesic: boolean; + /** + * The input geometries to buffer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#geometries) + */ geometries: Geometry[]; + /** + * The spatial reference for the returned geometries. If `outSpatialReference` is not specified, the output geometries are in the spatial reference specified by `bufferSpatialReference`. If `bufferSpatialReference` also is not specified, they are in the spatial reference of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#outSpatialReference) + */ outSpatialReference: SpatialReference; + /** + * If `true`, all geometries buffered at a given distance are unioned into a single (possibly multipart) polygon, and the unioned geometry is placed in the output array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#unionResults) + */ unionResults: boolean; + /** + * The units for calculating each buffer distance. If `unit` is not specified, the units are derived from `bufferSpatialReference`. If `bufferSpatialReference` is not specified, the units are derived from the features. For a list of valid units, see [esriSRUnitType Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnitType_Constants/000w00000042000000/) and [esriSRUnit2Type Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnit2Type_Constants/000w00000041000000/). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#unit) + */ unit: string; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#toJSON) + * + * + */ toJSON(): any; } interface BufferParametersConstructor { + + new(properties?: BufferParametersProperties): BufferParameters; } export const BufferParameters: BufferParametersConstructor; interface BufferParametersProperties { + /** + * The spatial reference in which the geometries are buffered. If `bufferSpatialReference` is not specified, the geometries are buffered in the spatial reference specified by `outSpatialReference`. If `outSpatialReference` is also not specified, they are buffered in the spatial reference of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#bufferSpatialReference) + */ bufferSpatialReference?: SpatialReferenceProperties; + /** + * The distances the input features are buffered. The distance units are specified by `unit`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#distances) + */ distances?: number[]; + /** + * If the input geometries are in a geographic coordinate system, set geodesic to `true` to generate a buffer polygon using a geodesic distance. The `bufferSpatialReference` property is ignored when geodesic is set to `true`. Requires ArcGIS Server 10.1 or greater geometry service. For more information, see the ArcGIS REST API documentation on the GeometryService buffer operation and the geodesic property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#geodesic) + */ geodesic?: boolean; + /** + * The input geometries to buffer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#geometries) + */ geometries?: GeometryProperties[]; + /** + * The spatial reference for the returned geometries. If `outSpatialReference` is not specified, the output geometries are in the spatial reference specified by `bufferSpatialReference`. If `bufferSpatialReference` also is not specified, they are in the spatial reference of the features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#outSpatialReference) + */ outSpatialReference?: SpatialReferenceProperties; + /** + * If `true`, all geometries buffered at a given distance are unioned into a single (possibly multipart) polygon, and the unioned geometry is placed in the output array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#unionResults) + */ unionResults?: boolean; + /** + * The units for calculating each buffer distance. If `unit` is not specified, the units are derived from `bufferSpatialReference`. If `bufferSpatialReference` is not specified, the units are derived from the features. For a list of valid units, see [esriSRUnitType Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnitType_Constants/000w00000042000000/) and [esriSRUnit2Type Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnit2Type_Constants/000w00000041000000/). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-BufferParameters.html#unit) + */ unit?: string; } interface ClosestFacilityParameters extends Accessor { + /** + * The list of network attribute names to be accumulated with the analysis, i.e., which attributes should be returned as part of the response. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#accumulateAttributes) + */ accumulateAttributes: string[]; + /** + * An array of attribute parameter values that determine which network elements can be used by a vehicle. View the object specifications below for properties of the individual objects in this array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#attributeParameterValues) + */ attributeParameterValues: ClosestFacilityParametersAttributeParameterValues[]; + /** + * The cutoff value used to determine when to stop traversing. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#defaultCutoff) + */ defaultCutoff: number; + /** + * The number of facilities to find. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#defaultTargetFacilityCount) + */ defaultTargetFacilityCount: number; + /** + * The language used when generating driving directions. This parameter applies only when [returnDirections](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnDirections) parameter is set to `true`. If an unsupported language code is specified, the service returns the directions using the default language, English. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#directionsLanguage) + */ directionsLanguage: string; + /** + * The length units used when computing driving directions. This parameter applies only when [returnDirections](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnDirections) parameter is set to `true`. If not specified the task will use the value defined by the routing network layer is used. **Known Values:** centimeters | decimal-degrees | decimeters | feet | inches | kilometers | meters | miles | millimeters | nautical-miles | points | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#directionsLengthUnits) + */ directionsLengthUnits: string; + /** + * Defines the amount of direction information returned. The default value is standard. **Known Values:** complete | complete-no-events | instructions-only | standard | summary-only + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#directionsOutputType) + */ directionsOutputType: string; + /** + * The style to be used when returning directions. The default will be as defined in the network layer. View the REST layer description for your network service to see a list of supported styles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#directionsStyleName) + */ directionsStyleName: string; + /** + * The name of the attribute field that contains the drive time values. If not specified, the task will use the attribute field defined by the routing network layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#directionsTimeAttribute) + */ directionsTimeAttribute: string; + /** + * When `true`, restricted network elements should be considered when finding network locations. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#doNotLocateOnRestrictedElements) + * + * @default true + */ doNotLocateOnRestrictedElements: boolean; + /** + * The set of facilities loaded as network locations during analysis. These can be specified as either a [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html) or a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#facilities) + */ facilities: DataLayer | FeatureSet; + /** + * The network attribute field name used as the impedance attribute during analysis. If not specified the default value defined by the routing network layer. Valid values include any attribute name listed in the Service Directory under Network Dataset > Network Attributes with a Usage Type of `esriNauTCost`. Specify none to indicate that no network attributes should be used for impedance. If you specify an empty string the default value defined by the service will be used. See the [Understanding the network attribute](https://resources.arcgis.com/en/help/main/10.2/index.html#//00470000000m000000) help topic for more details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#impedanceAttribute) + */ impedanceAttribute: string; + /** + * The set of incidents loaded as network locations during analysis. Can be an instance of [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html) or [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#incidents) + */ incidents: DataLayer | FeatureSet; + /** + * The output geometry precision. When `0`, no generalization of the output geometry is performed. Positive values represent the `MaximumAllowableOffset` parameter used by generalize. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#outputGeometryPrecision) + */ outputGeometryPrecision: number; + /** + * The units of the output geometry precision. **Known Values:** centimeters | decimal-degrees | decimeters | feet | inches | kilometers | meters | miles | millimeters | nautical-miles | points | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#outputGeometryPrecisionUnits) + */ outputGeometryPrecisionUnits: string; + /** + * The type of output lines to be generated in the result. The default is defined in the specific routing network layer used in your RouteTask. See NAOutputLine for a list of valid values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#outputLines) + */ outputLines: string; + /** + * The well-known id of the spatial reference or the spatial reference object for the geometries returned with the analysis results. If `outSpatialReference` is not specified, the geometries are returned in the spatial reference of the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#outSpatialReference) + */ outSpatialReference: SpatialReference | string; + /** + * The set of point barriers loaded as network locations during analysis. Can be an instance of [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html) or [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#pointBarriers) + */ pointBarriers: DataLayer | FeatureSet; + /** + * The set of polygon barriers loaded as network locations during analysis. Can be an instance of [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html) or [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#polygonBarriers) + */ polygonBarriers: DataLayer | FeatureSet; + /** + * The set of polyline barriers loaded as network locations during analysis. Can be an instance of [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html) or [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#polylineBarriers) + */ polylineBarriers: DataLayer | FeatureSet; + /** + * The list of network attribute names to be used as restrictions with the analysis. The default is as defined in the specific routing network layer used in your RouteTask. Possible values are listed in the Service Directory under Network Dataset > Network Attributes. You can also specify a value of none to indicate that no network attributes should be used as restrictions. If you specify an empty array, it will default to the default of the service. Use `["none"]` to override the service defaults and specify that no restrictions should be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#restrictionAttributes) + */ restrictionAttributes: string[]; + /** + * Specifies how U-Turns should be handled. The default is as defined in the specific routing network layer used in your module:"esri/tasks/ClosestFacilityTask". **Known Values:** allow-backtrack | at-dead-ends-only | no-backtrack | at-dead-ends-and-intersections + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#restrictUTurns) + */ restrictUTurns: string; + /** + * Indicates whether the service should generate driving directions for each route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnDirections) + * + * @default false + */ returnDirections: boolean; + /** + * If `true`, facilities will be returned with the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnFacilities) + * + * @default false + */ returnFacilities: boolean; + /** + * If `true`, incidents will be returned with the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnIncidents) + * + * @default false + */ returnIncidents: boolean; + /** + * If `true`, point barriers will be returned in the barriers property of the [ClosestFacilitySolveResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnPointBarriers) + * + * @default false + */ returnPointBarriers: boolean; + /** + * If `true`, polygon barriers will be returned in the barriers property of the [ClosestFacilitySolveResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnPolygonBarriers) + * + * @default false + */ returnPolygonBarriers: boolean; + /** + * If `true`, polyline barriers will be returned in the barriers property of the [ClosestFacilitySolveResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnPolylineBarriers) + * + * @default false + */ returnPolylineBarriers: boolean; + /** + * When `true`, closest facility routes will be generated and returned in the route property of each [ClosestFacilitySolveResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnRoutes) + * + * @default true + */ returnRoutes: boolean; + /** + * The arrival or departure date and time. For example, if the travelDirection is set to `TO_FACILITY` and `timeOfDayUsage` is set to "end" and `timeOfDay` is set to 8:00 a.m., the returned route(s) will be setup to arrive at the facility at 8:00 a.m. local time. *Requires ArcGIS Server service version 10.1 or greater.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#timeOfDay) + */ timeOfDay: Date; + /** + * Defines the way the `timeOfDay` value is used. The default value is defined in the network layer. *Requires ArcGIS Server service version 10.1 or greater.* **Known Values:** start | end + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#timeOfDayUsage) + */ timeOfDayUsage: string; + /** + * Options for traveling to or from the facility. Default values are defined by the newtork layer. See NATravelDirection for a list of valid values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#travelDirection) + */ travelDirection: string; + /** + * If `true`, the hierarchy attribute for the network will be used in analysis. The default is defined in the routing network layer used by the [ClosestFacilityTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ClosestFacilityTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#useHierarchy) + * + * @default false + */ useHierarchy: boolean; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#toJSON) + * + * + */ toJSON(): any; } interface ClosestFacilityParametersConstructor { + /** + * Input parameters for [ClosestFacilityTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ClosestFacilityTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html) + */ + new(properties?: ClosestFacilityParametersProperties): ClosestFacilityParameters; } export const ClosestFacilityParameters: ClosestFacilityParametersConstructor; interface ClosestFacilityParametersProperties { + /** + * The list of network attribute names to be accumulated with the analysis, i.e., which attributes should be returned as part of the response. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#accumulateAttributes) + */ accumulateAttributes?: string[]; + /** + * An array of attribute parameter values that determine which network elements can be used by a vehicle. View the object specifications below for properties of the individual objects in this array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#attributeParameterValues) + */ attributeParameterValues?: ClosestFacilityParametersAttributeParameterValues[]; + /** + * The cutoff value used to determine when to stop traversing. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#defaultCutoff) + */ defaultCutoff?: number; + /** + * The number of facilities to find. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#defaultTargetFacilityCount) + */ defaultTargetFacilityCount?: number; + /** + * The language used when generating driving directions. This parameter applies only when [returnDirections](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnDirections) parameter is set to `true`. If an unsupported language code is specified, the service returns the directions using the default language, English. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#directionsLanguage) + */ directionsLanguage?: string; + /** + * The length units used when computing driving directions. This parameter applies only when [returnDirections](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnDirections) parameter is set to `true`. If not specified the task will use the value defined by the routing network layer is used. **Known Values:** centimeters | decimal-degrees | decimeters | feet | inches | kilometers | meters | miles | millimeters | nautical-miles | points | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#directionsLengthUnits) + */ directionsLengthUnits?: string; + /** + * Defines the amount of direction information returned. The default value is standard. **Known Values:** complete | complete-no-events | instructions-only | standard | summary-only + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#directionsOutputType) + */ directionsOutputType?: string; + /** + * The style to be used when returning directions. The default will be as defined in the network layer. View the REST layer description for your network service to see a list of supported styles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#directionsStyleName) + */ directionsStyleName?: string; + /** + * The name of the attribute field that contains the drive time values. If not specified, the task will use the attribute field defined by the routing network layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#directionsTimeAttribute) + */ directionsTimeAttribute?: string; + /** + * When `true`, restricted network elements should be considered when finding network locations. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#doNotLocateOnRestrictedElements) + * + * @default true + */ doNotLocateOnRestrictedElements?: boolean; + /** + * The set of facilities loaded as network locations during analysis. These can be specified as either a [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html) or a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#facilities) + */ facilities?: DataLayerProperties | FeatureSetProperties; + /** + * The network attribute field name used as the impedance attribute during analysis. If not specified the default value defined by the routing network layer. Valid values include any attribute name listed in the Service Directory under Network Dataset > Network Attributes with a Usage Type of `esriNauTCost`. Specify none to indicate that no network attributes should be used for impedance. If you specify an empty string the default value defined by the service will be used. See the [Understanding the network attribute](https://resources.arcgis.com/en/help/main/10.2/index.html#//00470000000m000000) help topic for more details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#impedanceAttribute) + */ impedanceAttribute?: string; + /** + * The set of incidents loaded as network locations during analysis. Can be an instance of [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html) or [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#incidents) + */ incidents?: DataLayerProperties | FeatureSetProperties; + /** + * The output geometry precision. When `0`, no generalization of the output geometry is performed. Positive values represent the `MaximumAllowableOffset` parameter used by generalize. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#outputGeometryPrecision) + */ outputGeometryPrecision?: number; + /** + * The units of the output geometry precision. **Known Values:** centimeters | decimal-degrees | decimeters | feet | inches | kilometers | meters | miles | millimeters | nautical-miles | points | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#outputGeometryPrecisionUnits) + */ outputGeometryPrecisionUnits?: string; + /** + * The type of output lines to be generated in the result. The default is defined in the specific routing network layer used in your RouteTask. See NAOutputLine for a list of valid values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#outputLines) + */ outputLines?: string; + /** + * The well-known id of the spatial reference or the spatial reference object for the geometries returned with the analysis results. If `outSpatialReference` is not specified, the geometries are returned in the spatial reference of the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#outSpatialReference) + */ outSpatialReference?: SpatialReferenceProperties | string; + /** + * The set of point barriers loaded as network locations during analysis. Can be an instance of [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html) or [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#pointBarriers) + */ pointBarriers?: DataLayerProperties | FeatureSetProperties; + /** + * The set of polygon barriers loaded as network locations during analysis. Can be an instance of [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html) or [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#polygonBarriers) + */ polygonBarriers?: DataLayerProperties | FeatureSetProperties; + /** + * The set of polyline barriers loaded as network locations during analysis. Can be an instance of [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html) or [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#polylineBarriers) + */ polylineBarriers?: DataLayerProperties | FeatureSetProperties; + /** + * The list of network attribute names to be used as restrictions with the analysis. The default is as defined in the specific routing network layer used in your RouteTask. Possible values are listed in the Service Directory under Network Dataset > Network Attributes. You can also specify a value of none to indicate that no network attributes should be used as restrictions. If you specify an empty array, it will default to the default of the service. Use `["none"]` to override the service defaults and specify that no restrictions should be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#restrictionAttributes) + */ restrictionAttributes?: string[]; + /** + * Specifies how U-Turns should be handled. The default is as defined in the specific routing network layer used in your module:"esri/tasks/ClosestFacilityTask". **Known Values:** allow-backtrack | at-dead-ends-only | no-backtrack | at-dead-ends-and-intersections + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#restrictUTurns) + */ restrictUTurns?: string; + /** + * Indicates whether the service should generate driving directions for each route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnDirections) + * + * @default false + */ returnDirections?: boolean; + /** + * If `true`, facilities will be returned with the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnFacilities) + * + * @default false + */ returnFacilities?: boolean; + /** + * If `true`, incidents will be returned with the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnIncidents) + * + * @default false + */ returnIncidents?: boolean; + /** + * If `true`, point barriers will be returned in the barriers property of the [ClosestFacilitySolveResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnPointBarriers) + * + * @default false + */ returnPointBarriers?: boolean; + /** + * If `true`, polygon barriers will be returned in the barriers property of the [ClosestFacilitySolveResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnPolygonBarriers) + * + * @default false + */ returnPolygonBarriers?: boolean; + /** + * If `true`, polyline barriers will be returned in the barriers property of the [ClosestFacilitySolveResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnPolylineBarriers) + * + * @default false + */ returnPolylineBarriers?: boolean; + /** + * When `true`, closest facility routes will be generated and returned in the route property of each [ClosestFacilitySolveResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#returnRoutes) + * + * @default true + */ returnRoutes?: boolean; + /** + * The arrival or departure date and time. For example, if the travelDirection is set to `TO_FACILITY` and `timeOfDayUsage` is set to "end" and `timeOfDay` is set to 8:00 a.m., the returned route(s) will be setup to arrive at the facility at 8:00 a.m. local time. *Requires ArcGIS Server service version 10.1 or greater.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#timeOfDay) + */ timeOfDay?: DateProperties; + /** + * Defines the way the `timeOfDay` value is used. The default value is defined in the network layer. *Requires ArcGIS Server service version 10.1 or greater.* **Known Values:** start | end + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#timeOfDayUsage) + */ timeOfDayUsage?: string; + /** + * Options for traveling to or from the facility. Default values are defined by the newtork layer. See NATravelDirection for a list of valid values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#travelDirection) + */ travelDirection?: string; + /** + * If `true`, the hierarchy attribute for the network will be used in analysis. The default is defined in the routing network layer used by the [ClosestFacilityTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ClosestFacilityTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#useHierarchy) + * + * @default false + */ useHierarchy?: boolean; } - export interface ClosestFacilityParametersAttributeParameterValues { + + export interface ClosestFacilityParametersAttributeParameterValues extends Object { + /** + * The name of the attribute. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#attributeParameterValues) + */ attributeName: string; + /** + * The parameter name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#attributeParameterValues) + */ parameterName: string; + /** + * The parameter value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilityParameters.html#attributeParameterValues) + */ value: string; } interface ClosestFacilitySolveResult extends Accessor, JSONSupport { + /** + * An array of directions. A direction is an instance of [DirectionsFeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html). Route directions are returned if `returnDirections = true` (default is false). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#directions) + */ directions: DirectionsFeatureSet; + /** + * An array of points representing facilities. Only returned when `ClosestFacilityParameters.returnFacilities = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#facilities) + */ facilities: Point[]; + /** + * An array of points representing incidents. Only returned when `ClosestFacilityParameters.returnIncidents = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#incidents) + */ incidents: Point[]; + /** + * Message received when the solve is complete. If a closest facility cannot be solved, the message returned by the server identifies the incident that could not be solved. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#messages) + */ messages: NAMessage[]; + /** + * The point barriers are an array of points. They are returned only if `ClosestFacilityParameters.returnPointBarriers` was set to `true` (which is not the default). If you send in the point barriers as a FeatureSet (instead of using DataLayer), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#pointBarriers) + */ pointBarriers: Point[]; + /** + * The polygon barriers are an array of polygons. They are returned only if `ClosestFacilityParameters.returnPolygonBarriers` was set to `true` (which is not the default). If you send in the polygon barriers as a FeatureSet (instead of using DataLayer), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#polygonBarriers) + */ polygonBarriers: Polygon[]; + /** + * The polyline barriers are an array of polylines. They are returned only if `ClosestFacilityParameters.returnPolylineBarriers` was set to `true` (which is not the default). If you send in the polyline barriers as a FeatureSet (instead of using DataLayer), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#polylineBarriers) + */ polylineBarriers: Polyline[]; + /** + * The array of routes. Route graphics are returned if `returnRoutes = true` and `outputLines` does not equal `esriNAOutputLineNone`. From version 2.0 to 2.5 the type is an array of Polylines. At version 2.6 the type is an array of Graphics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#routes) + */ routes: Graphic[]; } interface ClosestFacilitySolveResultConstructor { + /** + * The result from [ClosestFacilityTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ClosestFacilityTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html) + */ + new(properties?: ClosestFacilitySolveResultProperties): ClosestFacilitySolveResult; fromJSON(json: any): ClosestFacilitySolveResult; @@ -6186,22 +26143,74 @@ declare namespace __esri { export const ClosestFacilitySolveResult: ClosestFacilitySolveResultConstructor; interface ClosestFacilitySolveResultProperties { + /** + * An array of directions. A direction is an instance of [DirectionsFeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html). Route directions are returned if `returnDirections = true` (default is false). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#directions) + */ directions?: DirectionsFeatureSetProperties; + /** + * An array of points representing facilities. Only returned when `ClosestFacilityParameters.returnFacilities = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#facilities) + */ facilities?: PointProperties[]; + /** + * An array of points representing incidents. Only returned when `ClosestFacilityParameters.returnIncidents = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#incidents) + */ incidents?: PointProperties[]; + /** + * Message received when the solve is complete. If a closest facility cannot be solved, the message returned by the server identifies the incident that could not be solved. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#messages) + */ messages?: NAMessageProperties[]; + /** + * The point barriers are an array of points. They are returned only if `ClosestFacilityParameters.returnPointBarriers` was set to `true` (which is not the default). If you send in the point barriers as a FeatureSet (instead of using DataLayer), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#pointBarriers) + */ pointBarriers?: PointProperties[]; + /** + * The polygon barriers are an array of polygons. They are returned only if `ClosestFacilityParameters.returnPolygonBarriers` was set to `true` (which is not the default). If you send in the polygon barriers as a FeatureSet (instead of using DataLayer), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#polygonBarriers) + */ polygonBarriers?: PolygonProperties[]; + /** + * The polyline barriers are an array of polylines. They are returned only if `ClosestFacilityParameters.returnPolylineBarriers` was set to `true` (which is not the default). If you send in the polyline barriers as a FeatureSet (instead of using DataLayer), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#polylineBarriers) + */ polylineBarriers?: PolylineProperties[]; + /** + * The array of routes. Route graphics are returned if `returnRoutes = true` and `outputLines` does not equal `esriNAOutputLineNone`. From version 2.0 to 2.5 the type is an array of Polylines. At version 2.6 the type is an array of Graphics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ClosestFacilitySolveResult.html#routes) + */ routes?: GraphicProperties[]; } interface DataFile extends Accessor, JSONSupport { + /** + * The ID of the uploaded file returned as a result of the upload operation. For ArcGIS Server 10.1 and greater services that support uploads, this class can be used to specify an uploaded item as input by specifying the ItemID. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html#itemId) + */ itemId: string; + /** + * URL to the location of the data file. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html#url) + */ url: string; } interface DataFileConstructor { + + new(properties?: DataFileProperties): DataFile; fromJSON(json: any): DataFile; @@ -6210,38 +26219,141 @@ declare namespace __esri { export const DataFile: DataFileConstructor; interface DataFileProperties { + /** + * The ID of the uploaded file returned as a result of the upload operation. For ArcGIS Server 10.1 and greater services that support uploads, this class can be used to specify an uploaded item as input by specifying the ItemID. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html#itemId) + */ itemId?: string; + /** + * URL to the location of the data file. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html#url) + */ url?: string; } interface DataLayer extends Accessor { + /** + * The geometry to apply to the spatial filter. The spatial relationship as specified by [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html#spatialRelationship) is applied to this geometry while performing the query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html#geometry) + */ geometry: Geometry; + /** + * The name of the data layer in the map service that is being referenced. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html#name) + */ name: string; + /** + * The spatial relationship to be applied on the input geometry while performing the query. + * + * Possible Value | Description + * ---------------|------------ + * intersects | Part of a feature from feature class 1 is contained in a feature from feature class 2. + * contains | Part or all of a feature from feature class 1 is contained within a feature from feature class 2. + * crosses | The feature from feature class 1 crosses a feature from feature class 2. + * envelope-intersects | The envelope of feature class 1 intersects with the envelope of feature class 2. + * index-intersects | The envelope of the query feature class intersects the index entry for the target feature class. + * overlaps | Features from feature class 1 overlap features in feature class 2. + * touches | The feature from feature class 1 touches the border of a feature from feature class 2. + * within | The feature from feature class 1 is completely enclosed by the feature from feature class 2. + * relation | Allows specification of any relationship defined using the [Shape Comparison Language](http://resources.esri.com/help/9.3/arcgisengine/dotnet/concepts_start.htm#40de6491-9b2d-440d-848b-2609efcd46b1.htm). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html#spatialRelationship) + */ spatialRelationship: string; + /** + * A where clause for the query. Any legal SQL where clause operating on the fields in the layer is allowed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html#where) + */ where: string; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html#toJSON) + * + * + */ toJSON(): any; } interface DataLayerConstructor { + /** + * Input for properties of ClosestFacilityParameters,RouteParameters or ServiceAreaParameters. The DataLayer can be used to define the following for each paramater type: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html) + */ + new(properties?: DataLayerProperties): DataLayer; } export const DataLayer: DataLayerConstructor; interface DataLayerProperties { + /** + * The geometry to apply to the spatial filter. The spatial relationship as specified by [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html#spatialRelationship) is applied to this geometry while performing the query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html#geometry) + */ geometry?: GeometryProperties; + /** + * The name of the data layer in the map service that is being referenced. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html#name) + */ name?: string; + /** + * The spatial relationship to be applied on the input geometry while performing the query. + * + * Possible Value | Description + * ---------------|------------ + * intersects | Part of a feature from feature class 1 is contained in a feature from feature class 2. + * contains | Part or all of a feature from feature class 1 is contained within a feature from feature class 2. + * crosses | The feature from feature class 1 crosses a feature from feature class 2. + * envelope-intersects | The envelope of feature class 1 intersects with the envelope of feature class 2. + * index-intersects | The envelope of the query feature class intersects the index entry for the target feature class. + * overlaps | Features from feature class 1 overlap features in feature class 2. + * touches | The feature from feature class 1 touches the border of a feature from feature class 2. + * within | The feature from feature class 1 is completely enclosed by the feature from feature class 2. + * relation | Allows specification of any relationship defined using the [Shape Comparison Language](http://resources.esri.com/help/9.3/arcgisengine/dotnet/concepts_start.htm#40de6491-9b2d-440d-848b-2609efcd46b1.htm). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html#spatialRelationship) + */ spatialRelationship?: string; + /** + * A where clause for the query. Any legal SQL where clause operating on the fields in the layer is allowed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html#where) + */ where?: string; } interface supportDate extends Accessor, JSONSupport { + /** + * Date value returned from server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Date.html#date) + */ date: Date; + /** + * The format of the date used in the date property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Date.html#format) + * + * @default EEE MMM dd HH:mm:ss zzz yyyy + */ format: string; } interface supportDateConstructor { + + new(properties?: supportDateProperties): supportDate; fromJSON(json: any): supportDate; @@ -6250,44 +26362,151 @@ declare namespace __esri { export const supportDate: supportDateConstructor; interface supportDateProperties { + /** + * Date value returned from server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Date.html#date) + */ date?: DateProperties; + /** + * The format of the date used in the date property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Date.html#format) + * + * @default EEE MMM dd HH:mm:ss zzz yyyy + */ format?: string; } interface DensifyParameters extends Accessor { + /** + * If `true`, Geographic Coordinate System spatial references are used or densify geodesic will be performed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DensifyParameters.html#geodesic) + */ geodesic: boolean; + /** + * The array of geometries to be densified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DensifyParameters.html#geometries) + */ geometries: Geometry[]; + /** + * The length unit of `maxSegmentLength`. For a list of valid units, see [esriSRUnitType Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnitType_Constants/000w00000042000000/) and [esriSRUnit2Type Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnit2Type_Constants/000w00000041000000/). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DensifyParameters.html#lengthUnit) + */ lengthUnit: string; + /** + * All segments longer than `maxSegmentLength` are replaced with sequences of lines no longer than `maxSegmentLength.` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DensifyParameters.html#maxSegmentLength) + */ maxSegmentLength: number; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DensifyParameters.html#toJSON) + * + * + */ toJSON(): any; } interface DensifyParametersConstructor { + + new(properties?: DensifyParametersProperties): DensifyParameters; } export const DensifyParameters: DensifyParametersConstructor; interface DensifyParametersProperties { + /** + * If `true`, Geographic Coordinate System spatial references are used or densify geodesic will be performed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DensifyParameters.html#geodesic) + */ geodesic?: boolean; + /** + * The array of geometries to be densified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DensifyParameters.html#geometries) + */ geometries?: GeometryProperties[]; + /** + * The length unit of `maxSegmentLength`. For a list of valid units, see [esriSRUnitType Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnitType_Constants/000w00000042000000/) and [esriSRUnit2Type Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnit2Type_Constants/000w00000041000000/). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DensifyParameters.html#lengthUnit) + */ lengthUnit?: string; + /** + * All segments longer than `maxSegmentLength` are replaced with sequences of lines no longer than `maxSegmentLength.` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DensifyParameters.html#maxSegmentLength) + */ maxSegmentLength?: number; } interface DirectionsFeatureSet extends FeatureSet, Accessor { + /** + * The extent of the route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#extent) + */ extent: Extent; + /** + * A single polyline representing the route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#mergedGeometry) + */ mergedGeometry: Polyline; + /** + * The ID of the route returned from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#routeId) + */ routeId: string; + /** + * Name specified in [RouteParameters.stops](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#stops). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#routeName) + */ routeName: string; + /** + * Lists additional information about the directions depending on the value of [RouteParameters.directionsOutputType](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsOutputType). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#strings) + */ strings: any[]; + /** + * Actual drive time calculated for the route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#totalDriveTime) + */ totalDriveTime: number; + /** + * The length of the route as specified in the units set in [RouteParameters.directionsLengthUnits](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsLengthUnits). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#totalLength) + */ totalLength: number; + /** + * The total time calculated for the route as specified in the units set in [RouteParameters.directionsTimeAttribute](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsTimeAttribute). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#totalTime) + */ totalTime: number; } interface DirectionsFeatureSetConstructor { + /** + * A [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) that has properties specific to routing. The [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#features) property contains the turn by turn directions text and geometry of the route. The attributes for each feature provide information associated with the corresponding route segment. The following attributes are returned: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html) + */ + new(properties?: DirectionsFeatureSetProperties): DirectionsFeatureSet; fromJSON(json: any): DirectionsFeatureSet; @@ -6296,48 +26515,169 @@ declare namespace __esri { export const DirectionsFeatureSet: DirectionsFeatureSetConstructor; interface DirectionsFeatureSetProperties extends FeatureSetProperties { + /** + * The extent of the route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#extent) + */ extent?: ExtentProperties; + /** + * A single polyline representing the route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#mergedGeometry) + */ mergedGeometry?: PolylineProperties; + /** + * The ID of the route returned from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#routeId) + */ routeId?: string; + /** + * Name specified in [RouteParameters.stops](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#stops). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#routeName) + */ routeName?: string; + /** + * Lists additional information about the directions depending on the value of [RouteParameters.directionsOutputType](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsOutputType). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#strings) + */ strings?: any[]; + /** + * Actual drive time calculated for the route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#totalDriveTime) + */ totalDriveTime?: number; + /** + * The length of the route as specified in the units set in [RouteParameters.directionsLengthUnits](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsLengthUnits). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#totalLength) + */ totalLength?: number; + /** + * The total time calculated for the route as specified in the units set in [RouteParameters.directionsTimeAttribute](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsTimeAttribute). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DirectionsFeatureSet.html#totalTime) + */ totalTime?: number; } interface DistanceParameters extends Accessor { + /** + * Specifies the units for measuring distance between [geometry1](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry1) and [geometry2](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry2). If the unit is not specified the units are derived from the spatial reference. For a list of valid units, see [esriSRUnitType Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnitType_Constants/000w00000042000000/) and [esriSRUnit2Type Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnit2Type_Constants/000w00000041000000/). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#distanceUnit) + */ distanceUnit: string; + /** + * When `true`, the geodesic distance between [geometry1](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry1) and [geometry2](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry2) is measured. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geodesic) + */ geodesic: boolean; + /** + * The geometry from which the distance is to be measured. The geometry can be a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html), [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html), [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html), or a [Multipoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry1) + */ geometry1: Geometry[]; + /** + * The geometry to which the distance is to be measured. The geometry can be a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html), [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html), [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html), or a [Multipoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry2) + */ geometry2: Geometry[]; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#toJSON) + * + * + */ toJSON(): any; } interface DistanceParametersConstructor { + + new(properties?: DistanceParametersProperties): DistanceParameters; } export const DistanceParameters: DistanceParametersConstructor; interface DistanceParametersProperties { + /** + * Specifies the units for measuring distance between [geometry1](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry1) and [geometry2](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry2). If the unit is not specified the units are derived from the spatial reference. For a list of valid units, see [esriSRUnitType Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnitType_Constants/000w00000042000000/) and [esriSRUnit2Type Constants](http://resources.arcgis.com/en/help/arcobjects-cpp/componenthelp/index.html#/esriSRUnit2Type_Constants/000w00000041000000/). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#distanceUnit) + */ distanceUnit?: string; + /** + * When `true`, the geodesic distance between [geometry1](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry1) and [geometry2](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry2) is measured. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geodesic) + */ geodesic?: boolean; + /** + * The geometry from which the distance is to be measured. The geometry can be a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html), [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html), [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html), or a [Multipoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry1) + */ geometry1?: GeometryProperties[]; + /** + * The geometry to which the distance is to be measured. The geometry can be a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html), [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html), [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html), or a [Multipoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DistanceParameters.html#geometry2) + */ geometry2?: GeometryProperties[]; } interface FeatureSet extends Accessor, JSONSupport { + /** + * The name of the layer's primary display field. The value of this property matches the name of one of the fields of the feature. This is only applicable when the FeatureSet is returned from a task. It is ignored when the FeatureSet is used as input to a geoprocessing task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#displayFieldName) + */ displayFieldName: string; + /** + * Typically, a layer has a limit on the number of features (i.e., records) returned by the query operation. If `maxRecordCount` is configured for a layer, `exceededTransferLimit` will be `true` if a query matches more than the `maxRecordCount` features. It will be `false` otherwise. Supported by ArcGIS Server version 10.1 and later. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#exceededTransferLimit) + */ exceededTransferLimit: boolean; + /** + * The array of graphics returned from a task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#features) + */ features: Graphic[]; + /** + * Information about each field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#fields) + */ fields: Field[]; + /** + * The geometry type of the FeatureSet. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#geometryType) + */ geometryType: string; + /** + * When a FeatureSet is used as input to Geoprocessor, the spatial reference is set to the map's spatial reference by default. This value can be changed. When a FeatureSet is returned from a task, the value is the result as returned from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#spatialReference) + */ spatialReference: SpatialReference; } interface FeatureSetConstructor { + + new(properties?: FeatureSetProperties): FeatureSet; fromJSON(json: any): FeatureSet; @@ -6346,54 +26686,213 @@ declare namespace __esri { export const FeatureSet: FeatureSetConstructor; interface FeatureSetProperties { + /** + * The name of the layer's primary display field. The value of this property matches the name of one of the fields of the feature. This is only applicable when the FeatureSet is returned from a task. It is ignored when the FeatureSet is used as input to a geoprocessing task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#displayFieldName) + */ displayFieldName?: string; + /** + * Typically, a layer has a limit on the number of features (i.e., records) returned by the query operation. If `maxRecordCount` is configured for a layer, `exceededTransferLimit` will be `true` if a query matches more than the `maxRecordCount` features. It will be `false` otherwise. Supported by ArcGIS Server version 10.1 and later. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#exceededTransferLimit) + */ exceededTransferLimit?: boolean; + /** + * The array of graphics returned from a task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#features) + */ features?: GraphicProperties[]; + /** + * Information about each field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#fields) + */ fields?: FieldProperties[]; + /** + * The geometry type of the FeatureSet. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#geometryType) + */ geometryType?: string; + /** + * When a FeatureSet is used as input to Geoprocessor, the spatial reference is set to the map's spatial reference by default. This value can be changed. When a FeatureSet is returned from a task, the value is the result as returned from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html#spatialReference) + */ spatialReference?: SpatialReferenceProperties; } interface FindParameters extends Accessor { + /** + * Determines whether to look for an exact match of the search text or not. If `true`, searches for a value that contains the provided [searchText](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#searchText). This is a case-insensitive search. If `false`, searches for an exact match of the [searchText](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#searchText) string. The exact match is case-sensitive. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#contains) + * + * @default true + */ contains: boolean; + /** + * Specify the number of decimal places for the geometries returned by the task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#geometryPrecision) + */ geometryPrecision: number; + /** + * The layers to perform the find operation on. The layers are specified as a comma-separated list of layer ids. The list of ids is returned in [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html) layerInfos. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#layerIds) + */ layerIds: number[]; + /** + * The maximum allowable offset used for generalizing geometries returned by the find operation. The offset is in the units of [outSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#outSpatialReference). If [outSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#outSpatialReference) is not defined, the spatial reference of the map is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#maxAllowableOffset) + */ maxAllowableOffset: number; + /** + * The spatial reference of the output geometries. If this is not specified, the output geometries are returned in the spatial reference of the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#outSpatialReference) + */ outSpatialReference: SpatialReference; + /** + * If `true`, the output will include the geometry associated with each result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#returnGeometry) + * + * @default false + */ returnGeometry: boolean; + /** + * The names of the fields of a layer to search. The fields are specified as a comma-separated list of field names. If this parameter is not specified, all fields are searched by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#searchFields) + */ searchFields: string[]; + /** + * The text that is searched across the layers and the fields as specified in the `layers` and [searchFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#searchFields) properties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#searchText) + */ searchText: string; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#toJSON) + * + * + */ toJSON(): any; } interface FindParametersConstructor { + + new(properties?: FindParametersProperties): FindParameters; } export const FindParameters: FindParametersConstructor; interface FindParametersProperties { + /** + * Determines whether to look for an exact match of the search text or not. If `true`, searches for a value that contains the provided [searchText](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#searchText). This is a case-insensitive search. If `false`, searches for an exact match of the [searchText](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#searchText) string. The exact match is case-sensitive. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#contains) + * + * @default true + */ contains?: boolean; + /** + * Specify the number of decimal places for the geometries returned by the task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#geometryPrecision) + */ geometryPrecision?: number; + /** + * The layers to perform the find operation on. The layers are specified as a comma-separated list of layer ids. The list of ids is returned in [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html) layerInfos. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#layerIds) + */ layerIds?: number[]; + /** + * The maximum allowable offset used for generalizing geometries returned by the find operation. The offset is in the units of [outSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#outSpatialReference). If [outSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#outSpatialReference) is not defined, the spatial reference of the map is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#maxAllowableOffset) + */ maxAllowableOffset?: number; + /** + * The spatial reference of the output geometries. If this is not specified, the output geometries are returned in the spatial reference of the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#outSpatialReference) + */ outSpatialReference?: SpatialReferenceProperties; + /** + * If `true`, the output will include the geometry associated with each result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#returnGeometry) + * + * @default false + */ returnGeometry?: boolean; + /** + * The names of the fields of a layer to search. The fields are specified as a comma-separated list of field names. If this parameter is not specified, all fields are searched by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#searchFields) + */ searchFields?: string[]; + /** + * The text that is searched across the layers and the fields as specified in the `layers` and [searchFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#searchFields) properties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindParameters.html#searchText) + */ searchText?: string; } interface FindResult extends Accessor, JSONSupport { + /** + * The name of the layer's primary display field. The value of this property matches the name of one of the fields of the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#displayFieldName) + */ displayFieldName: string; + /** + * The found feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#feature) + */ feature: Graphic; + /** + * The name of the field that contains the search text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#foundFieldName) + */ foundFieldName: string; + /** + * Unique ID of the layer that contains the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#layerId) + */ layerId: number; + /** + * The layer name that contains the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#layerName) + */ layerName: string; + /** + * The value of the `foundFieldName` in the feature's attributes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#value) + */ value: void; } interface FindResultConstructor { + + new(properties?: FindResultProperties): FindResult; fromJSON(json: any): FindResult; @@ -6402,40 +26901,121 @@ declare namespace __esri { export const FindResult: FindResultConstructor; interface FindResultProperties { + /** + * The name of the layer's primary display field. The value of this property matches the name of one of the fields of the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#displayFieldName) + */ displayFieldName?: string; + /** + * The found feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#feature) + */ feature?: GraphicProperties; + /** + * The name of the field that contains the search text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#foundFieldName) + */ foundFieldName?: string; + /** + * Unique ID of the layer that contains the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#layerId) + */ layerId?: number; + /** + * The layer name that contains the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#layerName) + */ layerName?: string; + /** + * The value of the `foundFieldName` in the feature's attributes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FindResult.html#value) + */ value?: void; } interface GeneralizeParameters extends Accessor { + /** + * The maximum deviation unit. If the unit is not specified, units are derived from the spatial reference. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-GeneralizeParameters.html#deviationUnit) + */ deviationUnit: string; + /** + * The array of input geometries to generalize. All geometries in this array must be of the same geometry type (e.g. `esriGeometryPolyline` or `esriGeometryPolygon`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-GeneralizeParameters.html#geometries) + */ geometries: Geometry[]; + /** + * The maximum deviation for constructing a generalized geometry based on the input geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-GeneralizeParameters.html#maxDeviation) + */ maxDeviation: number; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-GeneralizeParameters.html#toJSON) + * + * + */ toJSON(): any; } interface GeneralizeParametersConstructor { + + new(properties?: GeneralizeParametersProperties): GeneralizeParameters; } export const GeneralizeParameters: GeneralizeParametersConstructor; interface GeneralizeParametersProperties { + /** + * The maximum deviation unit. If the unit is not specified, units are derived from the spatial reference. Use one of the possible values listed below or any of the [numeric codes for linear units](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-GeneralizeParameters.html#deviationUnit) + */ deviationUnit?: string; + /** + * The array of input geometries to generalize. All geometries in this array must be of the same geometry type (e.g. `esriGeometryPolyline` or `esriGeometryPolygon`). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-GeneralizeParameters.html#geometries) + */ geometries?: GeometryProperties[]; + /** + * The maximum deviation for constructing a generalized geometry based on the input geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-GeneralizeParameters.html#maxDeviation) + */ maxDeviation?: number; } interface GPMessage extends Accessor, JSONSupport { + /** + * The geoprocessing message. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-GPMessage.html#description) + */ description: string; + /** + * The geoprocessing message type. **Known Values:** informative | process-definition | process-start | process-stop | warning | error | empty | abort + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-GPMessage.html#type) + */ type: string; } interface GPMessageConstructor { + + new(properties?: GPMessageProperties): GPMessage; fromJSON(json: any): GPMessage; @@ -6444,56 +27024,251 @@ declare namespace __esri { export const GPMessage: GPMessageConstructor; interface GPMessageProperties { + /** + * The geoprocessing message. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-GPMessage.html#description) + */ description?: string; + /** + * The geoprocessing message type. **Known Values:** informative | process-definition | process-start | process-stop | warning | error | empty | abort + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-GPMessage.html#type) + */ type?: string; } interface IdentifyParameters extends Accessor { + /** + * Resolution of the current map view in dots per inch. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#dpi) + * + * @default 96 + */ dpi: number; + /** + * The geometry used to select features during the Identify operation. The type of the geometry is specified by [Geometry.type](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#type). The most common geometry used with Identify is a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#geometry) + */ geometry: Geometry; + /** + * Specify the number of decimal places for the geometries returned by the task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#geometryPrecision) + */ geometryPrecision: number; + /** + * Height of the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#height) + * + * @default 400 + */ height: number; + /** + * The layers on which to perform the identify operation. The layers are specified as a comma-separated list of layer IDs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#layerIds) + */ layerIds: number[]; + /** + * Specifies which layers to use when using Identify. + * + * Possible values | Description + * --------------- | ----------- + * top | Only the top-most visible layer is identified. + * visible | All visible layers are identified. + * all | All layers are identified, even if they are not visible. If your service has many layers, a request using this option will not perform well. A visible layer means you can see it in the map at the current extent. If a layer is turned off or not in range based on its scale dependency settings, it cannot be identified. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#layerOption) + * + * @default top + */ layerOption: string; + /** + * The Extent or bounding box of the current map view. The `mapExtent` property is assumed to be in the spatial reference of the map unless [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#spatialReference) has been specified. The values for [mapExtent](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#mapExtent), [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#height), [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#width), and [dpi](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#dpi) are used to determine the current map scale. Once the scale is known, the map service can exclude layers based on their scale dependency settings. The map service is not performing a spatial intersection based on the provided extent. These properties are also used to calculate the search distance on the map based on the tolerance in screen pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#mapExtent) + */ mapExtent: Extent; + /** + * The maximum allowable offset used for generalizing geometries returned by the identify operation. The offset is in the units of the [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#spatialReference). If a [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#spatialReference) is not defined the spatial reference of the view is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#maxAllowableOffset) + */ maxAllowableOffset: number; + /** + * If `true`, the result set includes the geometry associated with each result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#returnGeometry) + * + * @default false + */ returnGeometry: boolean; + /** + * The spatial reference of the input and output geometries as well as of the [mapExtent](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#mapExtent). If the spatial reference is not specified, the geometry and the extent are assumed to be in the spatial reference of the view, and the output geometries will also be in the spatial reference of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#spatialReference) + */ spatialReference: SpatialReference; + /** + * The distance in screen pixels from the specified geometry within which the identify should be performed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#tolerance) + */ tolerance: number; + /** + * Width of the current map view in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#width) + * + * @default 400 + */ width: number; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#toJSON) + * + * + */ toJSON(): any; } interface IdentifyParametersConstructor { + + new(properties?: IdentifyParametersProperties): IdentifyParameters; } export const IdentifyParameters: IdentifyParametersConstructor; interface IdentifyParametersProperties { + /** + * Resolution of the current map view in dots per inch. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#dpi) + * + * @default 96 + */ dpi?: number; + /** + * The geometry used to select features during the Identify operation. The type of the geometry is specified by [Geometry.type](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html#type). The most common geometry used with Identify is a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#geometry) + */ geometry?: GeometryProperties; + /** + * Specify the number of decimal places for the geometries returned by the task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#geometryPrecision) + */ geometryPrecision?: number; + /** + * Height of the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#height) + * + * @default 400 + */ height?: number; + /** + * The layers on which to perform the identify operation. The layers are specified as a comma-separated list of layer IDs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#layerIds) + */ layerIds?: number[]; + /** + * Specifies which layers to use when using Identify. + * + * Possible values | Description + * --------------- | ----------- + * top | Only the top-most visible layer is identified. + * visible | All visible layers are identified. + * all | All layers are identified, even if they are not visible. If your service has many layers, a request using this option will not perform well. A visible layer means you can see it in the map at the current extent. If a layer is turned off or not in range based on its scale dependency settings, it cannot be identified. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#layerOption) + * + * @default top + */ layerOption?: string; + /** + * The Extent or bounding box of the current map view. The `mapExtent` property is assumed to be in the spatial reference of the map unless [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#spatialReference) has been specified. The values for [mapExtent](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#mapExtent), [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#height), [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#width), and [dpi](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#dpi) are used to determine the current map scale. Once the scale is known, the map service can exclude layers based on their scale dependency settings. The map service is not performing a spatial intersection based on the provided extent. These properties are also used to calculate the search distance on the map based on the tolerance in screen pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#mapExtent) + */ mapExtent?: ExtentProperties; + /** + * The maximum allowable offset used for generalizing geometries returned by the identify operation. The offset is in the units of the [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#spatialReference). If a [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#spatialReference) is not defined the spatial reference of the view is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#maxAllowableOffset) + */ maxAllowableOffset?: number; + /** + * If `true`, the result set includes the geometry associated with each result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#returnGeometry) + * + * @default false + */ returnGeometry?: boolean; + /** + * The spatial reference of the input and output geometries as well as of the [mapExtent](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#mapExtent). If the spatial reference is not specified, the geometry and the extent are assumed to be in the spatial reference of the view, and the output geometries will also be in the spatial reference of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#spatialReference) + */ spatialReference?: SpatialReferenceProperties; + /** + * The distance in screen pixels from the specified geometry within which the identify should be performed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#tolerance) + */ tolerance?: number; + /** + * Width of the current map view in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyParameters.html#width) + * + * @default 400 + */ width?: number; } interface IdentifyResult extends Accessor, JSONSupport { + /** + * The name of the layer's primary display field. The value of this property matches the name of one of the fields of the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyResult.html#displayFieldName) + */ displayFieldName: string; + /** + * An identified feature from the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyResult.html#feature) + */ feature: Graphic; + /** + * Unique ID of the layer that contains the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyResult.html#layerId) + */ layerId: number; + /** + * The layer name that contains the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyResult.html#layerName) + */ layerName: string; } interface IdentifyResultConstructor { + + new(properties?: IdentifyResultProperties): IdentifyResult; fromJSON(json: any): IdentifyResult; @@ -6502,55 +27277,219 @@ declare namespace __esri { export const IdentifyResult: IdentifyResultConstructor; interface IdentifyResultProperties { + /** + * The name of the layer's primary display field. The value of this property matches the name of one of the fields of the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyResult.html#displayFieldName) + */ displayFieldName?: string; + /** + * An identified feature from the map service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyResult.html#feature) + */ feature?: GraphicProperties; + /** + * Unique ID of the layer that contains the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyResult.html#layerId) + */ layerId?: number; + /** + * The layer name that contains the feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-IdentifyResult.html#layerName) + */ layerName?: string; } interface ImageServiceIdentifyParameters extends Accessor { + /** + * Input geometry that defines the location to be identified. The location can be a point or a polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#geometry) + */ geometry: Point | Polygon; + /** + * Specifies the mosaic rules defining the image sorting order. When a mosaic rule is not specified, `center` is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#mosaicRule) + */ mosaicRule: MosaicRule; + /** + * The pixel or RGB color value representing no information. It can be defined as a number `noData = 0` representing a pixel value or as a string `noData = "58,128,187"` representing an RGB color value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#noData) + */ noData: string | number; + /** + * Specifies the pixel level being identified on the x and y axis. Defaults to the base resolution of the dataset when not specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#pixelSize) + */ pixelSize: Symbol; + /** + * The pixel level being identified (or the resolution being looked at) on the x-axis. If not specified, it will default to the base resolution of the dataset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#pixelSizeX) + */ pixelSizeX: number; + /** + * The pixel level being identified (or the resolution being looked at) on the y-axis. If not specified, it will default to the base resolution of the dataset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#pixelSizeY) + */ pixelSizeY: number; + /** + * Specifies the rendering rule for how the requested image should be rendered. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#renderingRule) + */ renderingRule: RasterFunction; + /** + * If `true`, returns both geometry and attributes of the catalog items. Set to `false` when catalog items are not needed to significantly improve identify operation's performance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#returnCatalogItems) + * + * @default true + */ returnCatalogItems: boolean; + /** + * When `true`, each feature in the catalog items includes the geometry. Set to `false` to not display the features on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#returnGeometry) + * + * @default false + */ returnGeometry: boolean; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#toJSON) + * + * + */ toJSON(): any; } interface ImageServiceIdentifyParametersConstructor { + + new(properties?: ImageServiceIdentifyParametersProperties): ImageServiceIdentifyParameters; } export const ImageServiceIdentifyParameters: ImageServiceIdentifyParametersConstructor; interface ImageServiceIdentifyParametersProperties { + /** + * Input geometry that defines the location to be identified. The location can be a point or a polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#geometry) + */ geometry?: PointProperties | PolygonProperties; + /** + * Specifies the mosaic rules defining the image sorting order. When a mosaic rule is not specified, `center` is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#mosaicRule) + */ mosaicRule?: MosaicRuleProperties; + /** + * The pixel or RGB color value representing no information. It can be defined as a number `noData = 0` representing a pixel value or as a string `noData = "58,128,187"` representing an RGB color value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#noData) + */ noData?: string | number; + /** + * Specifies the pixel level being identified on the x and y axis. Defaults to the base resolution of the dataset when not specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#pixelSize) + */ pixelSize?: SymbolProperties; + /** + * The pixel level being identified (or the resolution being looked at) on the x-axis. If not specified, it will default to the base resolution of the dataset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#pixelSizeX) + */ pixelSizeX?: number; + /** + * The pixel level being identified (or the resolution being looked at) on the y-axis. If not specified, it will default to the base resolution of the dataset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#pixelSizeY) + */ pixelSizeY?: number; + /** + * Specifies the rendering rule for how the requested image should be rendered. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#renderingRule) + */ renderingRule?: RasterFunctionProperties; + /** + * If `true`, returns both geometry and attributes of the catalog items. Set to `false` when catalog items are not needed to significantly improve identify operation's performance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#returnCatalogItems) + * + * @default true + */ returnCatalogItems?: boolean; + /** + * When `true`, each feature in the catalog items includes the geometry. Set to `false` to not display the features on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyParameters.html#returnGeometry) + * + * @default false + */ returnGeometry?: boolean; } interface ImageServiceIdentifyResult extends Accessor, JSONSupport { + /** + * The set of catalog items that overlap the input geometry. Catalog Items are returned only when the image service source is a mosaic dataset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#catalogItems) + */ catalogItems: FeatureSet; + /** + * The set of visible areas for the identified catalog items. `CatalogItemVisibilities` are returned only when the image service source is a mosaic dataset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#catalogItemVisibilities) + */ catalogItemVisibilities: number[]; + /** + * The identified location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#location) + */ location: Point; + /** + * The identify property name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#name) + */ name: string; + /** + * The identify property id. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#objectId) + */ objectId: number; + /** + * The attributes of the identified object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#properties) + */ properties: any; + /** + * The identify property pixel value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#value) + */ value: string; } interface ImageServiceIdentifyResultConstructor { + + new(properties?: ImageServiceIdentifyResultProperties): ImageServiceIdentifyResult; fromJSON(json: any): ImageServiceIdentifyResult; @@ -6559,22 +27498,74 @@ declare namespace __esri { export const ImageServiceIdentifyResult: ImageServiceIdentifyResultConstructor; interface ImageServiceIdentifyResultProperties { + /** + * The set of catalog items that overlap the input geometry. Catalog Items are returned only when the image service source is a mosaic dataset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#catalogItems) + */ catalogItems?: FeatureSetProperties; + /** + * The set of visible areas for the identified catalog items. `CatalogItemVisibilities` are returned only when the image service source is a mosaic dataset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#catalogItemVisibilities) + */ catalogItemVisibilities?: number[]; + /** + * The identified location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#location) + */ location?: PointProperties; + /** + * The identify property name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#name) + */ name?: string; + /** + * The identify property id. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#objectId) + */ objectId?: number; + /** + * The attributes of the identified object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#properties) + */ properties?: any; + /** + * The identify property pixel value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ImageServiceIdentifyResult.html#value) + */ value?: string; } interface JobInfo extends Accessor, JSONSupport { + /** + * The unique job ID assigned by ArcGIS Server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-JobInfo.html#jobId) + */ jobId: string; + /** + * The job status. **Known Values:** job-cancelled | job-cancelling | job-deleted | job-deleting | job-timed-out | job-executing | job-failed | job-new | job-submitted | job-succeeded | job-waiting + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-JobInfo.html#jobStatus) + */ jobStatus: string; + /** + * An array of messages that include the message type and a description. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-JobInfo.html#messages) + */ messages: GPMessage[]; } interface JobInfoConstructor { + + new(properties?: JobInfoProperties): JobInfo; fromJSON(json: any): JobInfo; @@ -6583,57 +27574,181 @@ declare namespace __esri { export const JobInfo: JobInfoConstructor; interface JobInfoProperties { + /** + * The unique job ID assigned by ArcGIS Server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-JobInfo.html#jobId) + */ jobId?: string; + /** + * The job status. **Known Values:** job-cancelled | job-cancelling | job-deleted | job-deleting | job-timed-out | job-executing | job-failed | job-new | job-submitted | job-succeeded | job-waiting + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-JobInfo.html#jobStatus) + */ jobStatus?: string; + /** + * An array of messages that include the message type and a description. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-JobInfo.html#messages) + */ messages?: GPMessageProperties[]; } interface LegendLayer extends Accessor { + /** + * The id of the operational layer to include in the printout's legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LegendLayer.html#layerId) + */ layerId: string; + /** + * The ids of the sublayers to include in the printout's legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LegendLayer.html#subLayerIds) + */ subLayerIds: string[]; + /** + * The title of the feature layer. Use this property to modify feature layer name in the legend for the printout. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LegendLayer.html#title) + */ title: string; } interface LegendLayerConstructor { + + new(properties?: LegendLayerProperties): LegendLayer; } export const LegendLayer: LegendLayerConstructor; interface LegendLayerProperties { + /** + * The id of the operational layer to include in the printout's legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LegendLayer.html#layerId) + */ layerId?: string; + /** + * The ids of the sublayers to include in the printout's legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LegendLayer.html#subLayerIds) + */ subLayerIds?: string[]; + /** + * The title of the feature layer. Use this property to modify feature layer name in the legend for the printout. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LegendLayer.html#title) + */ title?: string; } interface LengthsParameters extends Accessor { + /** + * Defines the type of calculation for the geometry. The type can be one of the following: + * + * Value | Description + * ---------------|--------------- + * planar | Planar measurements use 2D Cartesian mathematics to calculate length. Use this type if the length needs to be calculated in the input spatial reference otherwise use `preserve-shape`. + * geodesic | Use this type to calculate an area or length using only the vertices of the polygon to define the lines connecting the vertices as geodesic segments independent of the actual shape of the polygon. **Note:** a geodesic segment is the shortest path between two points on an ellipsoid. + * preserve-shape | Calculate the area or length of the geometry on the surface of the Earth ellipsoid, for geometries defined in a projected or geographic coordinate system. This method preserves the shape of the geometry in its coordinate system which means the true area or length will be calculated for the geometry that is displayed on the map. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LengthsParameters.html#calculationType) + */ calculationType: string; + /** + * If polylines are in a geographic coordinate system, then geodesic needs to be set to `true` in order to calculate the ellipsoidal shortest path distance between each pair of the vertices in the polylines. If `lengthUnit` is not specified, the output is returned in meters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LengthsParameters.html#geodesic) + */ geodesic: boolean; + /** + * The length unit in which perimeters of polygons will be calculated. For a list of valid units, see [linear unit codes](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LengthsParameters.html#lengthUnit) + */ lengthUnit: number | string; + /** + * The array of polylines whose lengths are to be computed. The structure of each polyline in the array is same as the structure of the JSON polyline objects returned by the ArcGIS REST API. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LengthsParameters.html#polylines) + */ polylines: Polyline[]; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LengthsParameters.html#toJSON) + * + * + */ toJSON(): any; } interface LengthsParametersConstructor { + + new(properties?: LengthsParametersProperties): LengthsParameters; } export const LengthsParameters: LengthsParametersConstructor; interface LengthsParametersProperties { + /** + * Defines the type of calculation for the geometry. The type can be one of the following: + * + * Value | Description + * ---------------|--------------- + * planar | Planar measurements use 2D Cartesian mathematics to calculate length. Use this type if the length needs to be calculated in the input spatial reference otherwise use `preserve-shape`. + * geodesic | Use this type to calculate an area or length using only the vertices of the polygon to define the lines connecting the vertices as geodesic segments independent of the actual shape of the polygon. **Note:** a geodesic segment is the shortest path between two points on an ellipsoid. + * preserve-shape | Calculate the area or length of the geometry on the surface of the Earth ellipsoid, for geometries defined in a projected or geographic coordinate system. This method preserves the shape of the geometry in its coordinate system which means the true area or length will be calculated for the geometry that is displayed on the map. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LengthsParameters.html#calculationType) + */ calculationType?: string; + /** + * If polylines are in a geographic coordinate system, then geodesic needs to be set to `true` in order to calculate the ellipsoidal shortest path distance between each pair of the vertices in the polylines. If `lengthUnit` is not specified, the output is returned in meters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LengthsParameters.html#geodesic) + */ geodesic?: boolean; + /** + * The length unit in which perimeters of polygons will be calculated. For a list of valid units, see [linear unit codes](https://developers.arcgis.com/java/api-reference/constant-values.html#com.esri.core.geometry.LinearUnit.Code.CENTIMETER). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LengthsParameters.html#lengthUnit) + */ lengthUnit?: number | string; + /** + * The array of polylines whose lengths are to be computed. The structure of each polyline in the array is same as the structure of the JSON polyline objects returned by the ArcGIS REST API. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LengthsParameters.html#polylines) + */ polylines?: PolylineProperties[]; } interface LinearUnit extends Accessor, JSONSupport { + /** + * Specifies the value of the linear distance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LinearUnit.html#distance) + * + * @default 0 + */ distance: number; + /** + * Specifies the unit type of the linear distance. **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LinearUnit.html#units) + */ units: string; } interface LinearUnitConstructor { + + new(properties?: LinearUnitProperties): LinearUnit; fromJSON(json: any): LinearUnit; @@ -6642,16 +27757,40 @@ declare namespace __esri { export const LinearUnit: LinearUnitConstructor; interface LinearUnitProperties { + /** + * Specifies the value of the linear distance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LinearUnit.html#distance) + * + * @default 0 + */ distance?: number; + /** + * Specifies the unit type of the linear distance. **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LinearUnit.html#units) + */ units?: string; } interface NAMessage extends Accessor, JSONSupport { + /** + * A description of the network analyst message. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-NAMessage.html#description) + */ description: string; + /** + * The network analyst message type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-NAMessage.html#type) + */ type: any; } interface NAMessageConstructor { + + new(properties?: NAMessageProperties): NAMessage; fromJSON(json: any): NAMessage; @@ -6660,40 +27799,151 @@ declare namespace __esri { export const NAMessage: NAMessageConstructor; interface NAMessageProperties { + /** + * A description of the network analyst message. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-NAMessage.html#description) + */ description?: string; + /** + * The network analyst message type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-NAMessage.html#type) + */ type?: any; } interface OffsetParameters extends Accessor { + /** + * The `bevelRatio` is multiplied by the offset distance and the result determines how far a mitered offset intersection can be located before it is beveled. When mitered is specified, the value set for `bevelRatio` is ignored and `10` is used internally. If beveled is specified, `1.1` will be used if no value is set for bevelRatio. The bevelRatio is ignored when `rounded` is specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-OffsetParameters.html#bevelRatio) + */ bevelRatio: number; + /** + * The array of geometries to be offset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-OffsetParameters.html#geometries) + */ geometries: Geometry[]; + /** + * Specifies the planar distance for constructing an offset based on the input geometries. If the `offsetDistance` parameter is positive, the constructed offset will be on the right side of the curve. Left side offsets are constructed with negative values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-OffsetParameters.html#offsetDistance) + */ offsetDistance: number; + /** + * Options that determine how the ends intersect. Set to one of the following options: + * + * Possible Value | Description + * ---------------|------------- + * bevelled | Squares off the corner after a given ratio distance. + * mitered | Attempts to allow extended offsets to naturally intersect. If the intersection occurs too far from a corner, the corner will be beveled off at a fixed distance. + * rounded | Rounds the corner between extended offsets. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-OffsetParameters.html#offsetHow) + */ offsetHow: string; + /** + * The offset distance unit. For a list of valid units see [esriSRUnitType constants](http://resources.esri.com/help/9.3/ArcGISDesktop/ArcObjects/esriGeometry/esriSRUnitType.htm) or [esriSRUnit2Type constants](http://resources.esri.com/help/9.3/ArcGISDesktop/ArcObjects/esriGeometry/esriSRUnit2Type.htm). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-OffsetParameters.html#offsetUnit) + */ offsetUnit: string; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-OffsetParameters.html#toJSON) + * + * + */ toJSON(): any; } interface OffsetParametersConstructor { + + new(properties?: OffsetParametersProperties): OffsetParameters; } export const OffsetParameters: OffsetParametersConstructor; interface OffsetParametersProperties { + /** + * The `bevelRatio` is multiplied by the offset distance and the result determines how far a mitered offset intersection can be located before it is beveled. When mitered is specified, the value set for `bevelRatio` is ignored and `10` is used internally. If beveled is specified, `1.1` will be used if no value is set for bevelRatio. The bevelRatio is ignored when `rounded` is specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-OffsetParameters.html#bevelRatio) + */ bevelRatio?: number; + /** + * The array of geometries to be offset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-OffsetParameters.html#geometries) + */ geometries?: GeometryProperties[]; + /** + * Specifies the planar distance for constructing an offset based on the input geometries. If the `offsetDistance` parameter is positive, the constructed offset will be on the right side of the curve. Left side offsets are constructed with negative values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-OffsetParameters.html#offsetDistance) + */ offsetDistance?: number; + /** + * Options that determine how the ends intersect. Set to one of the following options: + * + * Possible Value | Description + * ---------------|------------- + * bevelled | Squares off the corner after a given ratio distance. + * mitered | Attempts to allow extended offsets to naturally intersect. If the intersection occurs too far from a corner, the corner will be beveled off at a fixed distance. + * rounded | Rounds the corner between extended offsets. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-OffsetParameters.html#offsetHow) + */ offsetHow?: string; + /** + * The offset distance unit. For a list of valid units see [esriSRUnitType constants](http://resources.esri.com/help/9.3/ArcGISDesktop/ArcObjects/esriGeometry/esriSRUnitType.htm) or [esriSRUnit2Type constants](http://resources.esri.com/help/9.3/ArcGISDesktop/ArcObjects/esriGeometry/esriSRUnit2Type.htm). **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-OffsetParameters.html#offsetUnit) + */ offsetUnit?: string; } interface ParameterValue extends Accessor, JSONSupport { + /** + * Specifies the parameter's data type. **Possible Values:** string | double | long | boolean | date | linear-unit | data-file | raster-data | record-set | raster-data-layer | feature-record-set-layer | multi-value + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ParameterValue.html#dataType) + */ dataType: string; + /** + * The value of the parameter. The data structure of this value depends on the `dataType`. + * + * Data Type | JavaScript Type + * ----------|---------------- + * string | [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) + * double | [Number (float)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) + * long | [Number (int)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) + * boolean | [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) + * date | [Date](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Date.html) + * linear-unit | [LinearUnit](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LinearUnit.html) + * data-file | [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html) + * raster-data | [RasterData](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RasterData.html) + * record-set | [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) + * raster-data-layer | [RasterData](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RasterData.html) + * feature-record-set-layer | [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) + * multi-value | [String[]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ParameterValue.html#value) + */ value: any; } interface ParameterValueConstructor { + + new(properties?: ParameterValueProperties): ParameterValue; fromJSON(json: any): ParameterValue; @@ -6702,176 +27952,874 @@ declare namespace __esri { export const ParameterValue: ParameterValueConstructor; interface ParameterValueProperties { + /** + * Specifies the parameter's data type. **Possible Values:** string | double | long | boolean | date | linear-unit | data-file | raster-data | record-set | raster-data-layer | feature-record-set-layer | multi-value + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ParameterValue.html#dataType) + */ dataType?: string; + /** + * The value of the parameter. The data structure of this value depends on the `dataType`. + * + * Data Type | JavaScript Type + * ----------|---------------- + * string | [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) + * double | [Number (float)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) + * long | [Number (int)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) + * boolean | [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) + * date | [Date](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Date.html) + * linear-unit | [LinearUnit](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LinearUnit.html) + * data-file | [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html) + * raster-data | [RasterData](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RasterData.html) + * record-set | [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) + * raster-data-layer | [RasterData](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RasterData.html) + * feature-record-set-layer | [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) + * multi-value | [String[]](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ParameterValue.html#value) + */ value?: any; } interface PrintParameters extends Accessor { + /** + * Additional parameters for the print service. When an arcpy script is published as a custom print service there may be additional parameters associated with the print service. To determine the extra parameters visit the ArcGIS REST Services Directory page for the print service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintParameters.html#extraParameters) + */ extraParameters: any; + /** + * Specify the output spatial reference for the printout. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintParameters.html#outSpatialReference) + */ outSpatialReference: SpatialReference; + /** + * Defines the layout template used for the printed map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintParameters.html#template) + */ template: PrintTemplate; + /** + * The view to print. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintParameters.html#view) + */ view: MapView; } interface PrintParametersConstructor { + + new(properties?: PrintParametersProperties): PrintParameters; } export const PrintParameters: PrintParametersConstructor; interface PrintParametersProperties { + /** + * Additional parameters for the print service. When an arcpy script is published as a custom print service there may be additional parameters associated with the print service. To determine the extra parameters visit the ArcGIS REST Services Directory page for the print service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintParameters.html#extraParameters) + */ extraParameters?: any; + /** + * Specify the output spatial reference for the printout. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintParameters.html#outSpatialReference) + */ outSpatialReference?: SpatialReferenceProperties; + /** + * Defines the layout template used for the printed map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintParameters.html#template) + */ template?: PrintTemplateProperties; + /** + * The view to print. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintParameters.html#view) + */ view?: MapViewProperties; } interface PrintTemplate extends Accessor { + /** + * When `false`, the attribution is not displayed on the printout. This only applies when the [layout](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layout) value is `map-only`. Reference our policies on [Licensing & Attribution](https://developers.arcgis.com/javascript/latest/guide/licensing/) for specific attribution requirements. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#attributionVisible) + * + * @default true + */ attributionVisible: boolean; + /** + * Define the map width, height and dpi. Required when `layout = 'map-only'`. See the object specification table below for available options to set for exportOptions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#exportOptions) + */ exportOptions: PrintTemplateExportOptions; + /** + * The output format for the printed map. **Known Values:** pdf | png32 | png8 | jpg | gif | eps | svg | svgz + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#format) + * + * @default png32 + */ format: string; + /** + * The layout used for the print output. When the value is `map-only` or is empty, the output map does not contain any page layout surroundings (for example, title, legend, scale bar and so forth). The print service provides out-of-the-box templates listed in possible values. The server administrator can add additional templates to the print service. Possible values are listed below: + * + * Value | Description + * | --- | --- + * map-only | Map does not contain any layout elements. Only map image is printed. + * a3-landscape | 16.54 x 11.69 in + * a3-portrait | 11.69 x 16.54 in + * a4-landscape | 11.69 x 8.27 in + * a4-portrait | 8.27 × 11.69 in + * letter-ansi-a-landscape | 11.0 x 8.5 in + * letter-ansi-a-portrait | 8.5 x 11.0 in + * tabloid-ansi-b-landscape| 17.0 x 11.0 in + * tabloid-ansi-b-portrait | 11.0 x 17.0 in + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layout) + * + * @default map-only + */ layout: string; + /** + * Defines the layout elements. It's an object with the following properties: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layoutOptions) + */ layoutOptions: PrintTemplateLayoutOptions; + /** + * The optional map scale of the printed map. Only applies when `preserveScale = true`. If `outScale` is less than 1, then the printed map will use the scale of the input map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#outScale) + * + * @default 0 + */ outScale: number; + /** + * Define whether the printed map should preserve map scale or map extent. If `true`, the printed map will use the `outScale` property or default to the scale of the input map. If `false`, the printed map will use the same extent as the input map and thus scale might change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#preserveScale) + * + * @default true + */ preserveScale: boolean; + /** + * When `true`, labels will be shown on the layout. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#showLabels) + * + * @default true + */ showLabels: boolean; } interface PrintTemplateConstructor { + + new(properties?: PrintTemplateProperties): PrintTemplate; } export const PrintTemplate: PrintTemplateConstructor; interface PrintTemplateProperties { + /** + * When `false`, the attribution is not displayed on the printout. This only applies when the [layout](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layout) value is `map-only`. Reference our policies on [Licensing & Attribution](https://developers.arcgis.com/javascript/latest/guide/licensing/) for specific attribution requirements. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#attributionVisible) + * + * @default true + */ attributionVisible?: boolean; + /** + * Define the map width, height and dpi. Required when `layout = 'map-only'`. See the object specification table below for available options to set for exportOptions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#exportOptions) + */ exportOptions?: PrintTemplateExportOptions; + /** + * The output format for the printed map. **Known Values:** pdf | png32 | png8 | jpg | gif | eps | svg | svgz + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#format) + * + * @default png32 + */ format?: string; + /** + * The layout used for the print output. When the value is `map-only` or is empty, the output map does not contain any page layout surroundings (for example, title, legend, scale bar and so forth). The print service provides out-of-the-box templates listed in possible values. The server administrator can add additional templates to the print service. Possible values are listed below: + * + * Value | Description + * | --- | --- + * map-only | Map does not contain any layout elements. Only map image is printed. + * a3-landscape | 16.54 x 11.69 in + * a3-portrait | 11.69 x 16.54 in + * a4-landscape | 11.69 x 8.27 in + * a4-portrait | 8.27 × 11.69 in + * letter-ansi-a-landscape | 11.0 x 8.5 in + * letter-ansi-a-portrait | 8.5 x 11.0 in + * tabloid-ansi-b-landscape| 17.0 x 11.0 in + * tabloid-ansi-b-portrait | 11.0 x 17.0 in + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layout) + * + * @default map-only + */ layout?: string; + /** + * Defines the layout elements. It's an object with the following properties: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layoutOptions) + */ layoutOptions?: PrintTemplateLayoutOptions; + /** + * The optional map scale of the printed map. Only applies when `preserveScale = true`. If `outScale` is less than 1, then the printed map will use the scale of the input map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#outScale) + * + * @default 0 + */ outScale?: number; + /** + * Define whether the printed map should preserve map scale or map extent. If `true`, the printed map will use the `outScale` property or default to the scale of the input map. If `false`, the printed map will use the same extent as the input map and thus scale might change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#preserveScale) + * + * @default true + */ preserveScale?: boolean; + /** + * When `true`, labels will be shown on the layout. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#showLabels) + * + * @default true + */ showLabels?: boolean; } - export interface PrintTemplateExportOptions { + + export interface PrintTemplateExportOptions extends Object { + /** + * Map width. Default value is 800. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#exportOptions) + */ width?: number; + /** + * Map height. Default value is 1100. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#exportOptions) + */ height?: number; + /** + * Resolution in dots per inch. Default value is 96. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#exportOptions) + */ dpi?: number; } - export interface PrintTemplateLayoutOptions { + + export interface PrintTemplateLayoutOptions extends Object { + /** + * The text used for the map title if the specified layout contains a title text element. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layoutOptions) + */ titleText: string; + /** + * The text used for the author if the specified layout contains an author text element. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layoutOptions) + */ authorText: string; + /** + * The text used for the copyright if the specified layout contains an copyright text element. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layoutOptions) + */ copyrightText: string; - scalebarUnit: string; + /** + * The unit used for the scalebar. **Known Values:** `Miles` | `Kilometers` | `Meters` | `Feet` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layoutOptions) + * + * @default Miles + */ + scalebarUnit?: string; + /** + * An array of [LegendLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-LegendLayer.html) containing the id's of the layers that will be included in the legend. If `legendLayers` is not specified, all operational layers will be present in the legend. To specify that no layers will be included in the legend set `legendLayer = []`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layoutOptions) + */ legendLayers: LegendLayer[]; + /** + * An array of name-value pairs. Use this property to update the text for custom text elements on the page layout. Values must be strings. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html#layoutOptions) + */ customTextElements: any[]; } interface ProjectParameters extends Accessor { + /** + * The input geometries to project. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#geometries) + */ geometries: Geometry[]; + /** + * The spatial reference to which you are projecting the geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#outSpatialReference) + */ outSpatialReference: SpatialReference; + /** + * The spatial reference to which you are projecting the geometries. Use [outSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#outSpatialReference) instead. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#outSR) + */ outSR: SpatialReference; + /** + * The well-known id {wkid:number} or well-known text {wkt:string} of the datum transformation to be applied to the projected geometries. See [Datum transformations](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000r8000000) for a list of valid datum transformations that may be used here. If a transformation is specified, a value must also be specified in the [transformForward](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#transformForward) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#transformation) + */ transformation: ProjectParametersTransformation; + /** + * Indicates whether to transform forward or not. The forward or reverse direction of transformation is implied in the name of the transformation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#transformForward) + */ transformForward: boolean; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#toJSON) + * + * + */ toJSON(): any; } interface ProjectParametersConstructor { + + new(properties?: ProjectParametersProperties): ProjectParameters; } export const ProjectParameters: ProjectParametersConstructor; interface ProjectParametersProperties { + /** + * The input geometries to project. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#geometries) + */ geometries?: GeometryProperties[]; + /** + * The spatial reference to which you are projecting the geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#outSpatialReference) + */ outSpatialReference?: SpatialReferenceProperties; + /** + * The spatial reference to which you are projecting the geometries. Use [outSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#outSpatialReference) instead. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#outSR) + */ outSR?: SpatialReferenceProperties; + /** + * The well-known id {wkid:number} or well-known text {wkt:string} of the datum transformation to be applied to the projected geometries. See [Datum transformations](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000r8000000) for a list of valid datum transformations that may be used here. If a transformation is specified, a value must also be specified in the [transformForward](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#transformForward) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#transformation) + */ transformation?: ProjectParametersTransformation; + /** + * Indicates whether to transform forward or not. The forward or reverse direction of transformation is implied in the name of the transformation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#transformForward) + */ transformForward?: boolean; } - export interface ProjectParametersTransformation { + + export interface ProjectParametersTransformation extends Object { + /** + * The well-known ID of the datum transformation to apply to the projection. [List of valid IDs for Datum transformations](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#//02r3000000r8000000). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#transformation) + */ wkid?: number; + /** + * The well-known text that defines a spatial reference. Many browsers have a limit to the length of a GET request of approximately 2048 characters. When using well-known text to specify the spatial reference you can easily exceed this limit. In these cases, you will need to [setup and use a proxy page](https://developers.arcgis.com/javascript/latest/guide/proxies/index.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ProjectParameters.html#transformation) + */ wkt?: string; } - interface Query extends Accessor { + interface Query extends Accessor, JSONSupport { + /** + * Buffer distance for input geometries. The distance unit is specified by [units property](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#units). Query results will include features within the distance specified of the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry) of the query. This parameter only applies if [supportsQueryWithDistance](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Query_Feature_Service_Layer/02r3000000r1000000/) is `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#distance) + */ distance: number; + /** + * The geometry to apply to the spatial filter. The spatial relationship as specified by `spatialRelationship` is applied to this geometry while performing the query. The valid geometry types are [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html), [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html), [Multipoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html), [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html), or [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry) + */ geometry: Geometry; + /** + * Specify the number of decimal places for the geometries returned by the query operation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometryPrecision) + */ geometryPrecision: number; + /** + * One or more field names that will be used to group the statistics. This is only valid when `outStatistics` has been defined. Requires ArcGIS Server service version 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#groupByFieldsForStatistics) + */ groupByFieldsForStatistics: string[]; + /** + * The maximum allowable offset used for generalizing geometries returned by the query operation. The offset is in the units of `outSpatialReference`. If `outSpatialReference` is not defined, the spatial reference of the map is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#maxAllowableOffset) + */ maxAllowableOffset: number; + /** + * Parameter dictates how the geometry of a multipatch feature will be returned. Currently, the only supported value is `xyFootprint` and the xy footprint of each multipatch geometry will be returned in the result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#multipatchOption) + */ multipatchOption: string; + /** + * Number of features to retrieve. Should be used in conjunction with [start property](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#start). Use this to implement paging and retrieve "pages" of results when querying. If not provided, but an instance of Query has a start property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#num) + */ num: number; + /** + * A comma delimited list of ObjectIds for the features in the layer/table being queried. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds) + */ objectIds: number[]; + /** + * One or more field names that will be used to order the query results. Specfiy `ASC` (ascending) or `DESC` (descending) after the field name to control the order. The default order is `ASC`. `orderByFields` is only supported on [MapImageLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html) and tables where `supportsAdvancedQueries = true`. *Requires ArcGIS Server service version 10.1 or greater.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#orderByFields) + */ orderByFields: string[]; + /** + * Attribute fields to include in the FeatureSet. Fields must exist in the map layer. You must list actual field names rather than the alias names. You are, however, able to use the alias names when you display the results. You can set field alias names in the map document. When specifying the output fields, you should limit the fields to only those you expect to use in the query or the results. The fewer fields you include, the faster the response will be. Each query must have access to the Shape and ObjectId fields for a layer. However, your list of fields does not need to include these two fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#outFields) + */ outFields: string[]; + /** + * The spatial reference for the returned geometry. If not specified, the geometry is returned in the spatial reference of the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#outSpatialReference) + */ outSpatialReference: SpatialReference; + /** + * The definitions for one or more field-based statistics to be calculated. `outStatistics` is only supported on layers/tables where `supportsStatistics = true`. If `outStatistics` is specified the only other query parameters that will be used are `groupByFieldsForStatistics`, `orderByFields`, `text` and `where`. *Requires ArcGIS Server service version 10.1 or greater.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#outStatistics) + */ outStatistics: StatisticDefinition[]; + /** + * Specify the pixel level to be identified on the X and Y axis. Defaults to the base resolution of the dataset if not specified. Applicable only to Image Service layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#pixelSize) + */ pixelSize: Symbol; + /** + * Used to project the geometry onto a virtual grid, likely representing pixels on the screen. *Only works with ArcGIS Online hosted services.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#quantizationParameters) + */ quantizationParameters: QueryQuantizationParameters; - relationParam: string; + /** + * The string describes the spatial relationship to be tested when the spatial relationship is `relation`. The [Relational functions for ST_Geometry](https://desktop.arcgis.com/en/arcmap/latest/manage-data/using-sql-with-gdbs/relational-functions-for-st-geometry.htm) topic has additional details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#relationParameter) + */ + relationParameter: string; + /** + * If `true`, each feature in the [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) each polygon geometry will be returned with a centroid. This operation is only supported in ArcGIS Online hosted feature services. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnCentroid) + * + * @default false + */ + returnCentroid: boolean; + /** + * If `true` then the query returns distinct values based on the fields specified in `outFields`. This parameter applies only if `supportsAdvancedQueries` property of the layer is `true`. *Requires ArcGIS Server 10.1 Service Pack 1 or later.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnDistinctValues) + * + * @default false + */ returnDistinctValues: boolean; + /** + * If `true`, then all features are returned for each tile request, even if they exceed the maximum record limit per query indicated on the service by `maxRecordCount`. If `false`, the tile request will not return any features if the `maxRecordCount` limit is exceeded. **Support is limited to feature services hosted on ArcGIS Online.** + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnExceededLimitFeatures) + * + * @default true + */ + returnExceededLimitFeatures: boolean; + /** + * If `true`, each feature in the [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) includes the geometry. Set to `false` (default) if you do not plan to include highlighted features on a map since the geometry takes up a significant portion of the response. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnGeometry) + * + * @default false + */ returnGeometry: boolean; + /** + * If `true`, and [returnGeometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnGeometry) is `true`, then m-values are returned in the geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnM) + * + * @default false + */ + returnM: boolean; + /** + * If `true`, and [returnGeometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnGeometry) is `true`, then z-values are returned in the geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnZ) + * + * @default false + */ returnZ: boolean; + /** + * The spatial relationship to be applied to the input geometry while performing the query. The valid values are listed in the table below: + * + * Value | Description + * ------|------------- + * intersects | Part of a feature from feature class 1 intersects a feature from feature class 2. + * contains | Part or all of a feature from feature class 1 is contained within a feature from feature class 2. + * crosses | The feature from feature class 1 crosses a feature from feature class 2. + * envelope-intersects | The envelope of feature class 1 intersects with the envelope of feature class 2. + * index-intersects | The envelope of the query feature class intersects the index entry for the target feature class. + * overlaps | Features from feature class 1 overlap features in feature class 2. + * touches | The feature from feature class 1 touches the border of a feature from feature class 2. + * within | The feature from feature class 1 is completely enclosed by the feature from feature class 2. + * relation | Allows specification of any relationship defined using the [Shape Comparison Language](http://resources.esri.com/help/9.3/arcgisengine/dotnet/concepts_start.htm#40de6491-9b2d-440d-848b-2609efcd46b1.htm). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) + * + * @default intersects + */ spatialRelationship: string; + /** + * Zero-based index indicating where to begin retrieving features. Should be used in conjunction with [num](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#num). Use this to implement paging and retrieve "pages" of results when querying. Features are sorted ascending by object ID by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#start) + */ start: number; + /** + * Shorthand for a where clause using "like". The field used is the display field defined in the map document. You can determine what the display field is for a layer in the Services Directory. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#text) + * + * @default null + */ text: string; + /** + * The unit for calculating the buffer distance. if unit is not specified, the unit is derived from the geometry spatial reference. If the geometry spatial reference is not specified, the unit is derived from the feature service spatial reference. This parameter only applies if [supportsQueryWithDistance](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Query_Feature_Service_Layer/02r3000000r1000000/) is `true`. **Known Values:** feet | miles | nautical-miles | us-nautical-miles | meters | kilometers + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#units) + */ units: string; + /** + * A where clause for the query. Any legal SQL where clause operating on the fields in the layer is allowed. Be sure to have the correct sequence of single and double quotes when writing the where clause in JavaScript. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#where) + */ where: string; - toJSON(): any; + /** + * Creates a deep clone of Query object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#clone) + * + * + */ + clone(): Query; } interface QueryConstructor { + /** + * Query is used to define parameters to filter a layer's features, either by its attributes or its geometry. Once a Query object is created, you can set its properties to conform to the filtering requirements of the application. Once a Query object is created and its properties are set, it is then ready to be passed into an executable function in [QueryTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html) (e.g. `QueryTask.execute(Query)`). The returned result is often a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) + */ + new(properties?: QueryProperties): Query; + + fromJSON(json: any): Query; } export const Query: QueryConstructor; interface QueryProperties { + /** + * Buffer distance for input geometries. The distance unit is specified by [units property](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#units). Query results will include features within the distance specified of the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry) of the query. This parameter only applies if [supportsQueryWithDistance](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Query_Feature_Service_Layer/02r3000000r1000000/) is `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#distance) + */ distance?: number; + /** + * The geometry to apply to the spatial filter. The spatial relationship as specified by `spatialRelationship` is applied to this geometry while performing the query. The valid geometry types are [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html), [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html), [Multipoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html), [Polyline](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polyline.html), or [Polygon](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Polygon.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry) + */ geometry?: GeometryProperties; + /** + * Specify the number of decimal places for the geometries returned by the query operation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometryPrecision) + */ geometryPrecision?: number; + /** + * One or more field names that will be used to group the statistics. This is only valid when `outStatistics` has been defined. Requires ArcGIS Server service version 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#groupByFieldsForStatistics) + */ groupByFieldsForStatistics?: string[]; + /** + * The maximum allowable offset used for generalizing geometries returned by the query operation. The offset is in the units of `outSpatialReference`. If `outSpatialReference` is not defined, the spatial reference of the map is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#maxAllowableOffset) + */ maxAllowableOffset?: number; + /** + * Parameter dictates how the geometry of a multipatch feature will be returned. Currently, the only supported value is `xyFootprint` and the xy footprint of each multipatch geometry will be returned in the result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#multipatchOption) + */ multipatchOption?: string; + /** + * Number of features to retrieve. Should be used in conjunction with [start property](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#start). Use this to implement paging and retrieve "pages" of results when querying. If not provided, but an instance of Query has a start property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#num) + */ num?: number; + /** + * A comma delimited list of ObjectIds for the features in the layer/table being queried. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds) + */ objectIds?: number[]; + /** + * One or more field names that will be used to order the query results. Specfiy `ASC` (ascending) or `DESC` (descending) after the field name to control the order. The default order is `ASC`. `orderByFields` is only supported on [MapImageLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html) and tables where `supportsAdvancedQueries = true`. *Requires ArcGIS Server service version 10.1 or greater.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#orderByFields) + */ orderByFields?: string[]; + /** + * Attribute fields to include in the FeatureSet. Fields must exist in the map layer. You must list actual field names rather than the alias names. You are, however, able to use the alias names when you display the results. You can set field alias names in the map document. When specifying the output fields, you should limit the fields to only those you expect to use in the query or the results. The fewer fields you include, the faster the response will be. Each query must have access to the Shape and ObjectId fields for a layer. However, your list of fields does not need to include these two fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#outFields) + */ outFields?: string[]; + /** + * The spatial reference for the returned geometry. If not specified, the geometry is returned in the spatial reference of the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#outSpatialReference) + */ outSpatialReference?: SpatialReferenceProperties; + /** + * The definitions for one or more field-based statistics to be calculated. `outStatistics` is only supported on layers/tables where `supportsStatistics = true`. If `outStatistics` is specified the only other query parameters that will be used are `groupByFieldsForStatistics`, `orderByFields`, `text` and `where`. *Requires ArcGIS Server service version 10.1 or greater.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#outStatistics) + */ outStatistics?: StatisticDefinitionProperties[]; + /** + * Specify the pixel level to be identified on the X and Y axis. Defaults to the base resolution of the dataset if not specified. Applicable only to Image Service layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#pixelSize) + */ pixelSize?: SymbolProperties; + /** + * Used to project the geometry onto a virtual grid, likely representing pixels on the screen. *Only works with ArcGIS Online hosted services.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#quantizationParameters) + */ quantizationParameters?: QueryQuantizationParameters; - relationParam?: string; + /** + * The string describes the spatial relationship to be tested when the spatial relationship is `relation`. The [Relational functions for ST_Geometry](https://desktop.arcgis.com/en/arcmap/latest/manage-data/using-sql-with-gdbs/relational-functions-for-st-geometry.htm) topic has additional details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#relationParameter) + */ + relationParameter?: string; + /** + * If `true`, each feature in the [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) each polygon geometry will be returned with a centroid. This operation is only supported in ArcGIS Online hosted feature services. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnCentroid) + * + * @default false + */ + returnCentroid?: boolean; + /** + * If `true` then the query returns distinct values based on the fields specified in `outFields`. This parameter applies only if `supportsAdvancedQueries` property of the layer is `true`. *Requires ArcGIS Server 10.1 Service Pack 1 or later.* + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnDistinctValues) + * + * @default false + */ returnDistinctValues?: boolean; + /** + * If `true`, then all features are returned for each tile request, even if they exceed the maximum record limit per query indicated on the service by `maxRecordCount`. If `false`, the tile request will not return any features if the `maxRecordCount` limit is exceeded. **Support is limited to feature services hosted on ArcGIS Online.** + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnExceededLimitFeatures) + * + * @default true + */ + returnExceededLimitFeatures?: boolean; + /** + * If `true`, each feature in the [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) includes the geometry. Set to `false` (default) if you do not plan to include highlighted features on a map since the geometry takes up a significant portion of the response. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnGeometry) + * + * @default false + */ returnGeometry?: boolean; + /** + * If `true`, and [returnGeometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnGeometry) is `true`, then m-values are returned in the geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnM) + * + * @default false + */ + returnM?: boolean; + /** + * If `true`, and [returnGeometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnGeometry) is `true`, then z-values are returned in the geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#returnZ) + * + * @default false + */ returnZ?: boolean; + /** + * The spatial relationship to be applied to the input geometry while performing the query. The valid values are listed in the table below: + * + * Value | Description + * ------|------------- + * intersects | Part of a feature from feature class 1 intersects a feature from feature class 2. + * contains | Part or all of a feature from feature class 1 is contained within a feature from feature class 2. + * crosses | The feature from feature class 1 crosses a feature from feature class 2. + * envelope-intersects | The envelope of feature class 1 intersects with the envelope of feature class 2. + * index-intersects | The envelope of the query feature class intersects the index entry for the target feature class. + * overlaps | Features from feature class 1 overlap features in feature class 2. + * touches | The feature from feature class 1 touches the border of a feature from feature class 2. + * within | The feature from feature class 1 is completely enclosed by the feature from feature class 2. + * relation | Allows specification of any relationship defined using the [Shape Comparison Language](http://resources.esri.com/help/9.3/arcgisengine/dotnet/concepts_start.htm#40de6491-9b2d-440d-848b-2609efcd46b1.htm). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) + * + * @default intersects + */ spatialRelationship?: string; + /** + * Zero-based index indicating where to begin retrieving features. Should be used in conjunction with [num](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#num). Use this to implement paging and retrieve "pages" of results when querying. Features are sorted ascending by object ID by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#start) + */ start?: number; + /** + * Shorthand for a where clause using "like". The field used is the display field defined in the map document. You can determine what the display field is for a layer in the Services Directory. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#text) + * + * @default null + */ text?: string; + /** + * The unit for calculating the buffer distance. if unit is not specified, the unit is derived from the geometry spatial reference. If the geometry spatial reference is not specified, the unit is derived from the feature service spatial reference. This parameter only applies if [supportsQueryWithDistance](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Query_Feature_Service_Layer/02r3000000r1000000/) is `true`. **Known Values:** feet | miles | nautical-miles | us-nautical-miles | meters | kilometers + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#units) + */ units?: string; + /** + * A where clause for the query. Any legal SQL where clause operating on the fields in the layer is allowed. Be sure to have the correct sequence of single and double quotes when writing the where clause in JavaScript. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#where) + */ where?: string; } - export interface QueryQuantizationParameters { + + export interface QueryQuantizationParameters extends Object { + /** + * An extent defining the quantization grid bounds. Its [SpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html) matches the input geometry spatial reference if one is specified for the query. Otherwise, the extent will be in the layer's spatial reference. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#quantizationParameters) + */ extent?: Extent; + /** + * Geometry coordinates are optimized for viewing and displaying of data. **Known Values:** view + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#quantizationParameters) + */ mode?: string; + /** + * The integer's coordinates will be returned relative to the origin position defined by this property value. **Known Values:** upper-left | lower-left + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#quantizationParameters) + * + * @default upper-left + */ originPosition?: string; + /** + * The size of one pixel in the units of outSpatialReference. This number is used to convert coordinates to integers by building a grid with a resolution matching the tolerance. Each coordinate is then snapped to one pixel on the grid. Consecutive coordinates snapped to the same pixel are removed for reducing the overall response size. The units of tolerance will match the units of outSpatialReference. If outSpatialReference is not specified, then tolerance is assumed to be in the units of the spatial reference of the layer. If tolerance is not specified, the maxAllowableOffset is used. If tolerance and maxAllowableOffset are not specified, a grid of 10,000 * 10,000 grid is used by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#quantizationParameters) + */ tolerance?: number; } interface RasterData extends Accessor, JSONSupport { + /** + * Specifies the format of the raster data, such as "jpg", "tif", etc. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RasterData.html#format) + */ format: string; + /** + * The ID of the uploaded file returned as a result of the upload operation. For ArcGIS Server 10.1 and greater, this class can be used to specify an uploaded item as input by specifying the ItemID. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RasterData.html#itemId) + */ itemId: string; + /** + * URL to the location of the raster data file. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RasterData.html#url) + */ url: string; } interface RasterDataConstructor { + + new(properties?: RasterDataProperties): RasterData; fromJSON(json: any): RasterData; @@ -6880,159 +28828,791 @@ declare namespace __esri { export const RasterData: RasterDataConstructor; interface RasterDataProperties { + /** + * Specifies the format of the raster data, such as "jpg", "tif", etc. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RasterData.html#format) + */ format?: string; + /** + * The ID of the uploaded file returned as a result of the upload operation. For ArcGIS Server 10.1 and greater, this class can be used to specify an uploaded item as input by specifying the ItemID. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RasterData.html#itemId) + */ itemId?: string; + /** + * URL to the location of the raster data file. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RasterData.html#url) + */ url?: string; } interface RelationParameters extends Accessor { + /** + * The first array of geometries to compute the relation. The structure of each geometry in the array is same as the structure of the json geometry objects returned by the ArcGIS REST API. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationParameters.html#geometries1) + */ geometries1: Geometry[]; + /** + * The second array of geometries to compute the relation. The structure of each geometry in the array is same as the structure of the json geometry objects returned by the ArcGIS REST API. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationParameters.html#geometries2) + */ geometries2: Geometry[]; + /** + * The spatial relationship to be tested between the two input geometry arrays. See table below for a list of possible values. If the relation is specified as `relation`, the `relationParamater` parameter describes the spatial relationship and must be specified. + * + * Value | Description + * ------|------------ + * cross | Two polylines cross if they share only points in common, at least one of which is not an endpoint. A polyline and an polygon cross if they share a polyline in common on the interior of the polygon which is not equivalent to the entire polyline. Cross is a Clementini operator. If either one of the geometries is empty, the geometries do not cross. + * disjoint | Two geometries are disjoint if their intersection is empty. Two geometries intersect if disjoint is "false". + * in | The base geometry is within the comparison geometry if the base geometry is the intersection of the geometries and the intersection of their interiors is not empty. An empty geometry is within another geometry, unless the other geometry is empty. + * interior-intersection | Geometries intersect excluding boundary touch. + * intersection | Geometry interiors intersect or boundaries touch, same as 'not disjoint'. + * line-coincidence | The boundaries of the geometries must share an intersection, but the relationship between the interiors of the shapes is not considered (they could overlap, one could be contained in the other, or their interiors could be disjoint). This relation applies to polylines and polygons. + * line-touch | Two geometries are said to touch when the intersection of the geometries is non-empty, but the intersection of their interiors is empty. This evaluates if the touch occurs along a boundary (not a point). Valid for polygons. + * overlap | Two polylines share a common sub-line, or two polygons share a common sub-area. Two geometries do not overlap if either one is empty. + * point-touch | Two geometries are said to touch when the intersection of the geometries is non-empty, but the intersection of their interiors is empty. This evaluates if the touch occurs at a point (not a boundary). + * relation | Allows specification of any relationship defined using the Shape Comparison Language. If this value is used, a value for `relationParameter` must be specified. + * touch | The union of point touch and line touch. Two geometries are said to touch when the intersection of the geometries is non-empty, but the intersection of their interiors is empty. For example, a point touches a polyline only if the point is coincident with one of the polyline end points. If either one of the two geometries is empty, the geometries are not touched. + * within | Same as `in` but also allows polylines that are strictly on the boundaries of polygons to be considered in the polygon. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationParameters.html#relation) + */ relation: string; - relationParam: string; + /** + * The string describes the spatial relationship to be tested when `RelationParameters.relation = 'relation'`. The [Relational functions for ST_Geometry](https://desktop.arcgis.com/en/arcmap/latest/manage-data/using-sql-with-gdbs/relational-functions-for-st-geometry.htm) topic has additional details. An example of a valid string is: `FFFTTT**`. Also see the description of [geometryEngine.relate()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#relate) for additional examples of valid strings. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationParameters.html#relationParameter) + */ + relationParameter: string; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationParameters.html#toJSON) + * + * + */ toJSON(): any; } interface RelationParametersConstructor { + + new(properties?: RelationParametersProperties): RelationParameters; } export const RelationParameters: RelationParametersConstructor; interface RelationParametersProperties { + /** + * The first array of geometries to compute the relation. The structure of each geometry in the array is same as the structure of the json geometry objects returned by the ArcGIS REST API. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationParameters.html#geometries1) + */ geometries1?: GeometryProperties[]; + /** + * The second array of geometries to compute the relation. The structure of each geometry in the array is same as the structure of the json geometry objects returned by the ArcGIS REST API. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationParameters.html#geometries2) + */ geometries2?: GeometryProperties[]; + /** + * The spatial relationship to be tested between the two input geometry arrays. See table below for a list of possible values. If the relation is specified as `relation`, the `relationParamater` parameter describes the spatial relationship and must be specified. + * + * Value | Description + * ------|------------ + * cross | Two polylines cross if they share only points in common, at least one of which is not an endpoint. A polyline and an polygon cross if they share a polyline in common on the interior of the polygon which is not equivalent to the entire polyline. Cross is a Clementini operator. If either one of the geometries is empty, the geometries do not cross. + * disjoint | Two geometries are disjoint if their intersection is empty. Two geometries intersect if disjoint is "false". + * in | The base geometry is within the comparison geometry if the base geometry is the intersection of the geometries and the intersection of their interiors is not empty. An empty geometry is within another geometry, unless the other geometry is empty. + * interior-intersection | Geometries intersect excluding boundary touch. + * intersection | Geometry interiors intersect or boundaries touch, same as 'not disjoint'. + * line-coincidence | The boundaries of the geometries must share an intersection, but the relationship between the interiors of the shapes is not considered (they could overlap, one could be contained in the other, or their interiors could be disjoint). This relation applies to polylines and polygons. + * line-touch | Two geometries are said to touch when the intersection of the geometries is non-empty, but the intersection of their interiors is empty. This evaluates if the touch occurs along a boundary (not a point). Valid for polygons. + * overlap | Two polylines share a common sub-line, or two polygons share a common sub-area. Two geometries do not overlap if either one is empty. + * point-touch | Two geometries are said to touch when the intersection of the geometries is non-empty, but the intersection of their interiors is empty. This evaluates if the touch occurs at a point (not a boundary). + * relation | Allows specification of any relationship defined using the Shape Comparison Language. If this value is used, a value for `relationParameter` must be specified. + * touch | The union of point touch and line touch. Two geometries are said to touch when the intersection of the geometries is non-empty, but the intersection of their interiors is empty. For example, a point touches a polyline only if the point is coincident with one of the polyline end points. If either one of the two geometries is empty, the geometries are not touched. + * within | Same as `in` but also allows polylines that are strictly on the boundaries of polygons to be considered in the polygon. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationParameters.html#relation) + */ relation?: string; - relationParam?: string; + /** + * The string describes the spatial relationship to be tested when `RelationParameters.relation = 'relation'`. The [Relational functions for ST_Geometry](https://desktop.arcgis.com/en/arcmap/latest/manage-data/using-sql-with-gdbs/relational-functions-for-st-geometry.htm) topic has additional details. An example of a valid string is: `FFFTTT**`. Also see the description of [geometryEngine.relate()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html#relate) for additional examples of valid strings. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationParameters.html#relationParameter) + */ + relationParameter?: string; } interface RelationshipQuery extends Accessor { + /** + * The definition expression to be applied to the related table or layer. Only records that fit the definition expression and are in the list of `objectIds` will be returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#definitionExpression) + */ definitionExpression: string; + /** + * Specify the number of decimal places for the geometries returned by the query operation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#geometryPrecision) + */ geometryPrecision: number; + /** + * The maximum allowable offset used for generalizing geometries returned by the query operation. The offset is in the units of the `outSpatialReference`. If `outSpatialReference` is not defined, the spatial reference of the map is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#maxAllowableOffset) + */ maxAllowableOffset: number; + /** + * A comma delimited list of `ObjectIds` for the features in the layer/table that you want to query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#objectIds) + */ objectIds: number[]; + /** + * Attribute fields to include in the [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). Fields must exist in the map layer. You must list the actual field names rather than the alias names. Returned fields are also the actual field names. However, you are able to use the alias names when you display the results. You can set field alias names in the map document. When you specify the output fields, you should limit the fields to only those you expect to use in the query or the results. The fewer fields you include, the faster the response will be. Each query must have access to the Shape and ObjectId fields for a layer, but your list of fields does not need to include these two fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#outFields) + */ outFields: string[]; + /** + * The spatial reference for the returned geometry. If not specified, the geometry is returned in the spatial reference of the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#outSpatialReference) + */ outSpatialReference: SpatialReference; + /** + * The ID of the relationship to test. The ids for the relationships the table or layer participates in are listed in the ArcGIS Services directory. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#relationshipId) + */ relationshipId: number; + /** + * If `true`, each feature in the [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) includes the geometry. Set to `false` (default) if you do not plan to include highlighted features on a map since the geometry makes up a significant portion of the response. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#returnGeometry) + */ returnGeometry: boolean; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#toJSON) + * + * + */ toJSON(): any; } interface RelationshipQueryConstructor { + + new(properties?: RelationshipQueryProperties): RelationshipQuery; } export const RelationshipQuery: RelationshipQueryConstructor; interface RelationshipQueryProperties { + /** + * The definition expression to be applied to the related table or layer. Only records that fit the definition expression and are in the list of `objectIds` will be returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#definitionExpression) + */ definitionExpression?: string; + /** + * Specify the number of decimal places for the geometries returned by the query operation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#geometryPrecision) + */ geometryPrecision?: number; + /** + * The maximum allowable offset used for generalizing geometries returned by the query operation. The offset is in the units of the `outSpatialReference`. If `outSpatialReference` is not defined, the spatial reference of the map is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#maxAllowableOffset) + */ maxAllowableOffset?: number; + /** + * A comma delimited list of `ObjectIds` for the features in the layer/table that you want to query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#objectIds) + */ objectIds?: number[]; + /** + * Attribute fields to include in the [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). Fields must exist in the map layer. You must list the actual field names rather than the alias names. Returned fields are also the actual field names. However, you are able to use the alias names when you display the results. You can set field alias names in the map document. When you specify the output fields, you should limit the fields to only those you expect to use in the query or the results. The fewer fields you include, the faster the response will be. Each query must have access to the Shape and ObjectId fields for a layer, but your list of fields does not need to include these two fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#outFields) + */ outFields?: string[]; + /** + * The spatial reference for the returned geometry. If not specified, the geometry is returned in the spatial reference of the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#outSpatialReference) + */ outSpatialReference?: SpatialReferenceProperties; + /** + * The ID of the relationship to test. The ids for the relationships the table or layer participates in are listed in the ArcGIS Services directory. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#relationshipId) + */ relationshipId?: number; + /** + * If `true`, each feature in the [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) includes the geometry. Set to `false` (default) if you do not plan to include highlighted features on a map since the geometry makes up a significant portion of the response. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RelationshipQuery.html#returnGeometry) + */ returnGeometry?: boolean; } interface RouteParameters extends Accessor { + /** + * The list of network attribute names to be accumulated with the analysis. For example, which attributes should be returned as part of the response. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attribute names listed in the Service Directory under `Network Dataset -> Network Attributes` as `Usage Type: esriNAUTCost`. See also [Understanding the network attribute](http://resources.arcgis.com/en/help/main/10.2/index.html#//00470000000m000000). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#accumulateAttributes) + */ accumulateAttributes: string[]; + /** + * Each element in the array is an object that describes the parameter values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#attributeParameterValues) + */ attributeParameterValues: AttributeParamValue; + /** + * The set of point barriers loaded as network locations during analysis. At ArcGIS Server 10.1 an optional url property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#barriers) + */ barriers: DataLayer | FeatureSet; + /** + * The language used when computing directions. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). By default, NAServer gets installed with `en_US` only - it is up to the server administrator to add additional languages. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsLanguage) + */ directionsLanguage: string; + /** + * The length units to use when computing directions. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). **Known Values:** centimeters | decimal-degrees | decimeters | feet | inches | kilometers | meters | miles | millimeters | nautical-miles | points | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsLengthUnits) + */ directionsLengthUnits: string; + /** + * Defines the amount of direction information returned. **Known Values:** complete | complete-no-events | instructions-only | standard | summary-only + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsOutputType) + * + * @default standard + */ directionsOutputType: string; + /** + * The style to be used when returning directions. The default will be as defined in the network layer. View the REST layer description for your network service to see a list of supported styles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsStyleName) + */ directionsStyleName: string; + /** + * The name of network attribute to use for the drive time when computing directions. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsTimeAttribute) + */ directionsTimeAttribute: string; + /** + * If `true`, avoids network elements restricted by barriers or restrictions specified in [restrictionAttributes](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#restrictionAttributes). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#doNotLocateOnRestrictedElements) + * + * @default true + */ doNotLocateOnRestrictedElements: boolean; + /** + * The [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html) can help you find the most efficient path for visiting a given list of stops. This is sometimes known as the "traveling salesperson" problem. When the `findBestSequence = true`, the route solver is solving the Traveling Salesperson problem by computing the optimal sequence to visit the stops. As this is a combinatorial problem, we employ heuristics to solve this in a reasonable time. The heuristics do not guarantee the optimal sequence (as there is no good/fast way to prove optimality for large number of stops). It returns a solution that is close to optimal if not the optimal. The heuristic performs favorably when tested with known TSP benchmarks available in the OR research community. For these stops to be visited in the most efficient way, specify the following parameters: + * ```js + * routeParams.findBestSequence = true; + * routeParams.preserveFirstStop = false; + * routeParams.preserveLastStop = false; + * routeParams.returnStops = true; + * ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#findBestSequence) + */ findBestSequence: boolean; + /** + * In routes where a stop is not located on a network or a stop could not be reached, the results will differ depending on the value of this property: + * * When `false`, the solve operation will fail if at least one of the stops specified cannot be located or reached. + * * When `true`, as long as there are at least two valid stops that have been connected by a route, a valid result is returned. If multiple routes are processed in a single request, as long as least one route is built, a valid result is returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#ignoreInvalidLocations) + */ ignoreInvalidLocations: boolean; + /** + * The network attribute name to be used as the impedance attribute in the analysis. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attribute names listed in the Service Directory under `Network Dataset -> Network Attributes` as `Usage Type: esriNAUTCost`. You can also specify a value of `none` to indicate that no network attributes should be used for impedance. If you specify an empty array, it will default to the default of the service. For example, set `impedanceAttribute = "Time"` for the quickest route and `impedanceAttribute = "Length"` for shortest drive, assuming the service has those two esriNAUTCost attributes. For more information, see [Understanding the network attribute](http://resources.arcgis.com/en/help/main/10.2/index.html#//00470000000m000000). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#impedanceAttribute) + */ impedanceAttribute: string; + /** + * The precision of the output geometry after generalization. If `0`, no generalization of output geometry is performed. If present and positive, it represents the `MaximumAllowableOffset` parameter and generalization is performed according to `IPolycurve.Generalize`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#outputGeometryPrecision) + */ outputGeometryPrecision: number; + /** + * The units of the output geometry precision. **Known Values:** centimeters | decimal-degrees | decimeters | feet | inches | kilometers | meters | miles | millimeters | nautical-miles | points | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#outputGeometryPrecisionUnits) + */ outputGeometryPrecisionUnits: string; + /** + * The type of output lines to be generated in the result. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). **Known Values:** none | straight | true-shape | true-shape-with-measure + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#outputLines) + * + * @default true-shape + */ outputLines: string; + /** + * The well-known ID of the spatial reference for the geometries returned with the analysis results. If not specified, the geometries are returned in the spatial reference of the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#outSpatialReference) + */ outSpatialReference: SpatialReference; + /** + * The set of polygon barriers loaded as network locations during analysis. At ArcGIS Server 10.1, an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the `features` or `url` property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#polygonBarriers) + */ polygonBarriers: DataLayer | FeatureSet; + /** + * The set of polyline barriers loaded as network locations during analysis. At ArcGIS Server 10.1, an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the `features` or `url` property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#polylineBarriers) + */ polylineBarriers: DataLayer | FeatureSet; + /** + * If `true`, keeps the first stop fixed in the sequence even when `findBestSequence = true`. Only applicable if `findBestSequence = true`. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#preserveFirstStop) + */ preserveFirstStop: boolean; + /** + * If `true`, keeps the last stop fixed in the sequence even when `findBestSequence = true`. Only applicable if `findBestSequence = true`. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#preserveLastStop) + */ preserveLastStop: boolean; + /** + * The list of network attribute names to be used as restrictions with the analysis. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). Possible values are listed in the Service Directory under `Network Dataset -> Network Attributes`. You can also specify a value of `none` to indicate that no network attributes should be used as restrictions. If you specify an empty array, it will default to the default of the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#restrictionAttributes) + */ restrictionAttributes: string[]; + /** + * Specifies how U-Turns should be handled. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). **Known Values:** allow-backtrack | at-dead-ends-only | no-backtrack | at-dead-ends-and-intersections + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#restrictUTurns) + */ restrictUTurns: string; + /** + * If `true`, barriers are returned with the [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnBarriers) + * + * @default false + */ returnBarriers: boolean; + /** + * If `true`, barriers are returned in the [directions property of each RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html#directions). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnDirections) + * + * @default false + */ returnDirections: boolean; + /** + * If `true`, polygon barriers are returned in the [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnPolygonBarriers) + * + * @default false + */ returnPolygonBarriers: boolean; + /** + * If `true`, polyline barriers are returned in the [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnPolylineBarriers) + * + * @default false + */ returnPolylineBarriers: boolean; + /** + * If `true`, routes are generated and returned in the route property of each [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnRoutes) + * + * @default true + */ returnRoutes: boolean; + /** + * If `true`, stops are returned in the stops property of each [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnStops) + * + * @default false + */ returnStops: boolean; + /** + * If `true`, `z` values are returned in the [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnZ) + * + * @default true + */ returnZ: boolean; + /** + * The time the route begins. If not specified, the default is the time specified in the route service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#startTime) + */ startTime: Date; + /** + * If `true`, the start time will be in UTC format. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#startTimeIsUTC) + */ startTimeIsUTC: boolean; + /** + * The set of stops loaded as network locations during analysis. When `stops` takes a FeatureSet, each feature in the FeatureSet must have a defined spatial reference. If the feature contains `x` and `y` attributes, those values are used for the stop, even if the feature includes geometry. At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The `url` property can be specified using DataFile Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#stops) + */ stops: DataLayer | FeatureSet; + /** + * If `true`, the hierarchy attribute for the network should be used in analysis. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#useHierarchy) + */ useHierarchy: boolean; + /** + * A useful feature of the [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html) is the ability to constrain stop visits to certain times of day, or "time windows". If you were required to deliver orders to four homes and each customer was available during a limited time period during the day, the route task could help you find the most efficient path for making all the deliveries. Time windows are treated as a "soft" constraint. This means that although the solver attempts to honor time windows, if necessary, it will violate the time windows of some stops in order to reach them. Remember, the stops will be visited in the order they were added unless you set `RouteParameters.findBestSequence = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#useTimeWindows) + */ useTimeWindows: boolean; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#toJSON) + * + * + */ toJSON(): any; } interface RouteParametersConstructor { + + new(properties?: RouteParametersProperties): RouteParameters; } export const RouteParameters: RouteParametersConstructor; interface RouteParametersProperties { + /** + * The list of network attribute names to be accumulated with the analysis. For example, which attributes should be returned as part of the response. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attribute names listed in the Service Directory under `Network Dataset -> Network Attributes` as `Usage Type: esriNAUTCost`. See also [Understanding the network attribute](http://resources.arcgis.com/en/help/main/10.2/index.html#//00470000000m000000). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#accumulateAttributes) + */ accumulateAttributes?: string[]; + /** + * Each element in the array is an object that describes the parameter values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#attributeParameterValues) + */ attributeParameterValues?: AttributeParamValue; + /** + * The set of point barriers loaded as network locations during analysis. At ArcGIS Server 10.1 an optional url property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#barriers) + */ barriers?: DataLayerProperties | FeatureSetProperties; + /** + * The language used when computing directions. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). By default, NAServer gets installed with `en_US` only - it is up to the server administrator to add additional languages. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsLanguage) + */ directionsLanguage?: string; + /** + * The length units to use when computing directions. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). **Known Values:** centimeters | decimal-degrees | decimeters | feet | inches | kilometers | meters | miles | millimeters | nautical-miles | points | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsLengthUnits) + */ directionsLengthUnits?: string; + /** + * Defines the amount of direction information returned. **Known Values:** complete | complete-no-events | instructions-only | standard | summary-only + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsOutputType) + * + * @default standard + */ directionsOutputType?: string; + /** + * The style to be used when returning directions. The default will be as defined in the network layer. View the REST layer description for your network service to see a list of supported styles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsStyleName) + */ directionsStyleName?: string; + /** + * The name of network attribute to use for the drive time when computing directions. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#directionsTimeAttribute) + */ directionsTimeAttribute?: string; + /** + * If `true`, avoids network elements restricted by barriers or restrictions specified in [restrictionAttributes](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#restrictionAttributes). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#doNotLocateOnRestrictedElements) + * + * @default true + */ doNotLocateOnRestrictedElements?: boolean; + /** + * The [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html) can help you find the most efficient path for visiting a given list of stops. This is sometimes known as the "traveling salesperson" problem. When the `findBestSequence = true`, the route solver is solving the Traveling Salesperson problem by computing the optimal sequence to visit the stops. As this is a combinatorial problem, we employ heuristics to solve this in a reasonable time. The heuristics do not guarantee the optimal sequence (as there is no good/fast way to prove optimality for large number of stops). It returns a solution that is close to optimal if not the optimal. The heuristic performs favorably when tested with known TSP benchmarks available in the OR research community. For these stops to be visited in the most efficient way, specify the following parameters: + * ```js + * routeParams.findBestSequence = true; + * routeParams.preserveFirstStop = false; + * routeParams.preserveLastStop = false; + * routeParams.returnStops = true; + * ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#findBestSequence) + */ findBestSequence?: boolean; + /** + * In routes where a stop is not located on a network or a stop could not be reached, the results will differ depending on the value of this property: + * * When `false`, the solve operation will fail if at least one of the stops specified cannot be located or reached. + * * When `true`, as long as there are at least two valid stops that have been connected by a route, a valid result is returned. If multiple routes are processed in a single request, as long as least one route is built, a valid result is returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#ignoreInvalidLocations) + */ ignoreInvalidLocations?: boolean; + /** + * The network attribute name to be used as the impedance attribute in the analysis. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attribute names listed in the Service Directory under `Network Dataset -> Network Attributes` as `Usage Type: esriNAUTCost`. You can also specify a value of `none` to indicate that no network attributes should be used for impedance. If you specify an empty array, it will default to the default of the service. For example, set `impedanceAttribute = "Time"` for the quickest route and `impedanceAttribute = "Length"` for shortest drive, assuming the service has those two esriNAUTCost attributes. For more information, see [Understanding the network attribute](http://resources.arcgis.com/en/help/main/10.2/index.html#//00470000000m000000). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#impedanceAttribute) + */ impedanceAttribute?: string; + /** + * The precision of the output geometry after generalization. If `0`, no generalization of output geometry is performed. If present and positive, it represents the `MaximumAllowableOffset` parameter and generalization is performed according to `IPolycurve.Generalize`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#outputGeometryPrecision) + */ outputGeometryPrecision?: number; + /** + * The units of the output geometry precision. **Known Values:** centimeters | decimal-degrees | decimeters | feet | inches | kilometers | meters | miles | millimeters | nautical-miles | points | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#outputGeometryPrecisionUnits) + */ outputGeometryPrecisionUnits?: string; + /** + * The type of output lines to be generated in the result. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). **Known Values:** none | straight | true-shape | true-shape-with-measure + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#outputLines) + * + * @default true-shape + */ outputLines?: string; + /** + * The well-known ID of the spatial reference for the geometries returned with the analysis results. If not specified, the geometries are returned in the spatial reference of the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#outSpatialReference) + */ outSpatialReference?: SpatialReferenceProperties; + /** + * The set of polygon barriers loaded as network locations during analysis. At ArcGIS Server 10.1, an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the `features` or `url` property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#polygonBarriers) + */ polygonBarriers?: DataLayerProperties | FeatureSetProperties; + /** + * The set of polyline barriers loaded as network locations during analysis. At ArcGIS Server 10.1, an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the `features` or `url` property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#polylineBarriers) + */ polylineBarriers?: DataLayerProperties | FeatureSetProperties; + /** + * If `true`, keeps the first stop fixed in the sequence even when `findBestSequence = true`. Only applicable if `findBestSequence = true`. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#preserveFirstStop) + */ preserveFirstStop?: boolean; + /** + * If `true`, keeps the last stop fixed in the sequence even when `findBestSequence = true`. Only applicable if `findBestSequence = true`. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#preserveLastStop) + */ preserveLastStop?: boolean; + /** + * The list of network attribute names to be used as restrictions with the analysis. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). Possible values are listed in the Service Directory under `Network Dataset -> Network Attributes`. You can also specify a value of `none` to indicate that no network attributes should be used as restrictions. If you specify an empty array, it will default to the default of the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#restrictionAttributes) + */ restrictionAttributes?: string[]; + /** + * Specifies how U-Turns should be handled. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). **Known Values:** allow-backtrack | at-dead-ends-only | no-backtrack | at-dead-ends-and-intersections + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#restrictUTurns) + */ restrictUTurns?: string; + /** + * If `true`, barriers are returned with the [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnBarriers) + * + * @default false + */ returnBarriers?: boolean; + /** + * If `true`, barriers are returned in the [directions property of each RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html#directions). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnDirections) + * + * @default false + */ returnDirections?: boolean; + /** + * If `true`, polygon barriers are returned in the [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnPolygonBarriers) + * + * @default false + */ returnPolygonBarriers?: boolean; + /** + * If `true`, polyline barriers are returned in the [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnPolylineBarriers) + * + * @default false + */ returnPolylineBarriers?: boolean; + /** + * If `true`, routes are generated and returned in the route property of each [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnRoutes) + * + * @default true + */ returnRoutes?: boolean; + /** + * If `true`, stops are returned in the stops property of each [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnStops) + * + * @default false + */ returnStops?: boolean; + /** + * If `true`, `z` values are returned in the [RouteResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#returnZ) + * + * @default true + */ returnZ?: boolean; + /** + * The time the route begins. If not specified, the default is the time specified in the route service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#startTime) + */ startTime?: DateProperties; + /** + * If `true`, the start time will be in UTC format. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#startTimeIsUTC) + */ startTimeIsUTC?: boolean; + /** + * The set of stops loaded as network locations during analysis. When `stops` takes a FeatureSet, each feature in the FeatureSet must have a defined spatial reference. If the feature contains `x` and `y` attributes, those values are used for the stop, even if the feature includes geometry. At ArcGIS Server 10.1 an optional `url` property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The `url` property can be specified using DataFile Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#stops) + */ stops?: DataLayerProperties | FeatureSetProperties; + /** + * If `true`, the hierarchy attribute for the network should be used in analysis. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#useHierarchy) + */ useHierarchy?: boolean; + /** + * A useful feature of the [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html) is the ability to constrain stop visits to certain times of day, or "time windows". If you were required to deliver orders to four homes and each customer was available during a limited time period during the day, the route task could help you find the most efficient path for making all the deliveries. Time windows are treated as a "soft" constraint. This means that although the solver attempts to honor time windows, if necessary, it will violate the time windows of some stops in order to reach them. Remember, the stops will be visited in the order they were added unless you set `RouteParameters.findBestSequence = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#useTimeWindows) + */ useTimeWindows?: boolean; } - export interface AttributeParamValue { + /** + * An object describing the parameter values for the [attributeParameterValues](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#attributeParameterValues) property of [RouteParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#AttributeParamValue) + */ + export interface AttributeParamValue extends Object { + /** + * The name of the attribute. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#AttributeParamValue) + */ attributeName: string; + /** + * The name of the parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#AttributeParamValue) + */ parameterName: string; + /** + * The parameter's value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html#AttributeParamValue) + */ value: string; } interface RouteResult extends Accessor, JSONSupport { + /** + * Route directions are returned if `RouteParameters.returnDirections = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html#directions) + */ directions: DirectionsFeatureSet; + /** + * The Route graphic that is returned if `RouteParameters.returnRoutes = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html#route) + */ route: Graphic; + /** + * The name of the route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html#routeName) + */ routeName: string; + /** + * Array of stops. Returned only if `RouteParameters.returnStops = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html#stops) + */ stops: Graphic[]; } interface RouteResultConstructor { + + new(properties?: RouteResultProperties): RouteResult; fromJSON(json: any): RouteResult; @@ -7041,101 +29621,583 @@ declare namespace __esri { export const RouteResult: RouteResultConstructor; interface RouteResultProperties { + /** + * Route directions are returned if `RouteParameters.returnDirections = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html#directions) + */ directions?: DirectionsFeatureSetProperties; + /** + * The Route graphic that is returned if `RouteParameters.returnRoutes = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html#route) + */ route?: GraphicProperties; + /** + * The name of the route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html#routeName) + */ routeName?: string; + /** + * Array of stops. Returned only if `RouteParameters.returnStops = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html#stops) + */ stops?: GraphicProperties[]; } interface ServiceAreaParameters extends Accessor { + /** + * The list of network attribute names to be accumulated with the analysis (i.e. which attributes should be returned as part of the response). The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attributes names listed in the Service Directory under `Network Dataset > Network Attributes` as `Usage Type: esriNAUTCost`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#accumulateAttributes) + */ accumulateAttributes: string[]; + /** + * A set of attribute parameter values that can be parameterized to determine which network elements can be used by a vehicle. The parameter holding a vehicle characteristic is compared to a value coming from a descriptor attribute to determine whether or not a network element is traversable. For example, a parameterized restriction attribute can compare the height of your vehicle with a descriptor attribute that holds the clearance under overpasses through tunnels. If the vehicle's height is greater than the clearance, the edge is restricted. Parameterized cost attributes that reference other cost attributes and scale them, can also be used. This is useful when inclement weather like ice, fog or heavy rain, descends on the study area and hinders normal flow of traffic. By having a parameter already outfitted on a cost attribute, travel-time expectations and traversable network paths can be adjusted with respect to changes in traffic speeds. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#attributeParameterValues) + */ attributeParameterValues: any[]; + /** + * An array of numbers defining the breaks. The default value is defined in the network analysis layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#defaultBreaks) + */ defaultBreaks: number[]; + /** + * When `true`, restricted network elements should be considered when finding network locations. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#doNotLocateOnRestrictedElements) + * + * @default true + */ doNotLocateOnRestrictedElements: boolean; + /** + * An array of network source names to NOT use when generating polygons. This property specifies if certain network sources should be excluded from the service area polygon generation. A service area on a multi-modal network where only one mode is being used to compute the service area would get a more appropriate shape if other modes are excluded from the polygons. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#excludeSourcesFromPolygons) + */ excludeSourcesFromPolygons: string[]; + /** + * The set of facilities loaded as network locations during analysis. At ArcGIS Server 10.1, an optional url property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using `DataFile`. Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#facilities) + */ facilities: DataLayer | FeatureSet; + /** + * The network attribute name used as the impedance attribute in analysis. The default is as defined in the routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attribute names listed in the Service Directory under `Network Dataset > Network Attributes` as `Usage Type: esriNAUTCost`. You can also specify a value of `none` to indicate that no network attributes should be used for impedance. If you specify an empty string, it will use the default of the service. For example, set `impedanceAttribute = 'Time'` for quickest route and `impedanceAttribute = 'Length'` for shortest drive. Assuming the service has those two esriNAUTCost attributes. View the [Understanding the network attribute](http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00470000000M000000.htm) ArcGIS desktop help topic for more details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#impedanceAttribute) + */ impedanceAttribute: string; + /** + * If `true`, similar ranges will be merged in the resulting polygons. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#mergeSimilarPolygonRanges) + * + * @default false + */ mergeSimilarPolygonRanges: boolean; + /** + * The precision of the output geometry after generalization. If `0`, no generalization of output geometry is performed. If present and positive, it represents the `MaximumAllowableOffset` parameter and generalization is performed according to IPolycurve.Generalize. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outputGeometryPrecision) + */ outputGeometryPrecision: number; + /** + * The units of the output geometry precision. **Known Values:** centimeters | decimal-degrees | decimeters | feet | inches | kilometers | meters | miles | millimeters | nautical-miles | points | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outputGeometryPrecisionUnits) + */ outputGeometryPrecisionUnits: string; + /** + * The type of output lines to be generated in the result. The default is defined in the specific routing network layer used in your [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). + * + * Possible Value | Description + * ---------------|------------ + * none | No lines are returned + * straight | Only returns straight lines + * true-shape | Return the true shape of the lines + * true-shape-with-measure | Return the true shape of the lines with their measurments + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outputLines) + */ outputLines: string; + /** + * The type of output polygons to be generated in the result. The default is as defined in the specific routing network layer used in your [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). **Possible Values:** none | simplified | detailed + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outputPolygons) + */ outputPolygons: string; + /** + * The well-known ID of the spatial reference for the geometries returned with the analysis results. If `outSpatialReference` is not specified, the geometries are returned in the spatial reference of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outSpatialReference) + */ outSpatialReference: SpatialReference; + /** + * Indicates if the lines should overlap from multiple facilities. The default is defined by the network analysis layer in your [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#overlapLines) + * + * @default false + */ overlapLines: boolean; + /** + * Indicates if the polygons should overlap from multiple facilities. The default is defined by the network analysis layer in your [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#overlapPolygons) + * + * @default false + */ overlapPolygons: boolean; + /** + * The set of point barriers loaded as network locations during analysis. At ArcGIS Server 10.1, an optional url property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#pointBarriers) + */ pointBarriers: DataLayer | FeatureSet; + /** + * The set of polygon barriers loaded as network locations during analysis. At ArcGIS Server 10.1, an optional url property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#polygonBarriers) + */ polygonBarriers: DataLayer | FeatureSet; + /** + * The set of polyline barriers loaded as network locations during analysis. At ArcGIS Server 10.1, an optional url property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#polylineBarriers) + */ polylineBarriers: DataLayer | FeatureSet; + /** + * The list of network attribute names to be used as restrictions with the analysis. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attributes names listed in the Service Directory under `Network Dataset > Network Attributes` as `Usage Type: esriNAUTCost`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#restrictionAttributes) + */ restrictionAttributes: string[]; + /** + * Specifies how U-turns should be handled. The default is defined in the routing network layer used in your RouteTask. + * + * Possible Value | Description + * ---------------|------------ + * allow-backtrack | Allows U-turns on everywhere + * at-dead-ends-only | Only allows U-turns at dead ends + * no-backtrack | Restricts U-turns everywhere + * at-dead-ends-and-intersections | Only allows U-turns at dead ends and intersections + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#restrictUTurns) + */ restrictUTurns: string; + /** + * If `true`, facilities will be returned with the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#returnFacilities) + * + * @default false + */ returnFacilities: boolean; + /** + * If `true`, point barriers will be returned in the [pointBarriers](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#pointBarriers) property of the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#returnPointBarriers) + * + * @default false + */ returnPointBarriers: boolean; + /** + * If `true`, polygon barriers will be returned in the [polygonBarriers](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#polygonBarriers) property of the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#returnPolygonBarriers) + * + * @default false + */ returnPolygonBarriers: boolean; + /** + * If `true`, polyline barriers will be returned in the [polylineBarriers](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#polylineBarriers) property of the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#returnPolylineBarriers) + * + * @default false + */ returnPolylineBarriers: boolean; + /** + * If `true`, lines will be split at breaks. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#splitLinesAtBreaks) + * + * @default false + */ splitLinesAtBreaks: boolean; + /** + * If `true`, polygons will be split at breaks. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#splitPolygonsAtBreaks) + * + * @default false + */ splitPolygonsAtBreaks: boolean; + /** + * Local date and time at the facility. if `travelDirection = "esriNATravelDirectionToFacility"`, the `timeOfDay` value specifies arrival time at the facility. if `travelDirection = "esriNATravelDirectionFromFacility"`, `timeOfDay` specifies departure time from the facility. Requires ArcGIS Server service version 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#timeOfDay) + */ timeOfDay: Date; + /** + * Options for traveling to or from the facility. Default values are defined by the network layer. + * + * Possible Value | Description + * ---------------|------------ + * from-facility | Sets travel direction from the facility + * to-facility | Sets travel direction to the facility + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#travelDirection) + */ travelDirection: string; + /** + * If `true`, the outermost polygon (at the maximum break value) will be trimmed. The default is defined in the network analysis layer in your [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#trimOuterPolygon) + * + * @default false + */ trimOuterPolygon: boolean; + /** + * If polygons are being trimmed, provides the distance to trim. The default value is defined in the network analysis layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#trimPolygonDistance) + */ trimPolygonDistance: number; + /** + * If polygons are being trimmed, specifies the units of [trimPolygonDistance](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#trimPolygonDistance). The default is defined in the network analysis layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#trimPolygonDistanceUnits) + */ trimPolygonDistanceUnits: string; + /** + * When `true`, the hierarchy attributes for the network will be used in the analysis. The default value is defined in the network layer. `useHierarchy` cannot be used in conjunction with [outputLines](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outputLines). Requires an ArcGIS Server service version 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#useHierarchy) + */ useHierarchy: boolean; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#toJSON) + * + * + */ toJSON(): any; } interface ServiceAreaParametersConstructor { + /** + * Input parameters for [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html) + */ + new(properties?: ServiceAreaParametersProperties): ServiceAreaParameters; } export const ServiceAreaParameters: ServiceAreaParametersConstructor; interface ServiceAreaParametersProperties { + /** + * The list of network attribute names to be accumulated with the analysis (i.e. which attributes should be returned as part of the response). The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attributes names listed in the Service Directory under `Network Dataset > Network Attributes` as `Usage Type: esriNAUTCost`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#accumulateAttributes) + */ accumulateAttributes?: string[]; + /** + * A set of attribute parameter values that can be parameterized to determine which network elements can be used by a vehicle. The parameter holding a vehicle characteristic is compared to a value coming from a descriptor attribute to determine whether or not a network element is traversable. For example, a parameterized restriction attribute can compare the height of your vehicle with a descriptor attribute that holds the clearance under overpasses through tunnels. If the vehicle's height is greater than the clearance, the edge is restricted. Parameterized cost attributes that reference other cost attributes and scale them, can also be used. This is useful when inclement weather like ice, fog or heavy rain, descends on the study area and hinders normal flow of traffic. By having a parameter already outfitted on a cost attribute, travel-time expectations and traversable network paths can be adjusted with respect to changes in traffic speeds. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#attributeParameterValues) + */ attributeParameterValues?: any[]; + /** + * An array of numbers defining the breaks. The default value is defined in the network analysis layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#defaultBreaks) + */ defaultBreaks?: number[]; + /** + * When `true`, restricted network elements should be considered when finding network locations. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#doNotLocateOnRestrictedElements) + * + * @default true + */ doNotLocateOnRestrictedElements?: boolean; + /** + * An array of network source names to NOT use when generating polygons. This property specifies if certain network sources should be excluded from the service area polygon generation. A service area on a multi-modal network where only one mode is being used to compute the service area would get a more appropriate shape if other modes are excluded from the polygons. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#excludeSourcesFromPolygons) + */ excludeSourcesFromPolygons?: string[]; + /** + * The set of facilities loaded as network locations during analysis. At ArcGIS Server 10.1, an optional url property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using `DataFile`. Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#facilities) + */ facilities?: DataLayerProperties | FeatureSetProperties; + /** + * The network attribute name used as the impedance attribute in analysis. The default is as defined in the routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attribute names listed in the Service Directory under `Network Dataset > Network Attributes` as `Usage Type: esriNAUTCost`. You can also specify a value of `none` to indicate that no network attributes should be used for impedance. If you specify an empty string, it will use the default of the service. For example, set `impedanceAttribute = 'Time'` for quickest route and `impedanceAttribute = 'Length'` for shortest drive. Assuming the service has those two esriNAUTCost attributes. View the [Understanding the network attribute](http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00470000000M000000.htm) ArcGIS desktop help topic for more details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#impedanceAttribute) + */ impedanceAttribute?: string; + /** + * If `true`, similar ranges will be merged in the resulting polygons. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#mergeSimilarPolygonRanges) + * + * @default false + */ mergeSimilarPolygonRanges?: boolean; + /** + * The precision of the output geometry after generalization. If `0`, no generalization of output geometry is performed. If present and positive, it represents the `MaximumAllowableOffset` parameter and generalization is performed according to IPolycurve.Generalize. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outputGeometryPrecision) + */ outputGeometryPrecision?: number; + /** + * The units of the output geometry precision. **Known Values:** centimeters | decimal-degrees | decimeters | feet | inches | kilometers | meters | miles | millimeters | nautical-miles | points | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outputGeometryPrecisionUnits) + */ outputGeometryPrecisionUnits?: string; + /** + * The type of output lines to be generated in the result. The default is defined in the specific routing network layer used in your [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). + * + * Possible Value | Description + * ---------------|------------ + * none | No lines are returned + * straight | Only returns straight lines + * true-shape | Return the true shape of the lines + * true-shape-with-measure | Return the true shape of the lines with their measurments + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outputLines) + */ outputLines?: string; + /** + * The type of output polygons to be generated in the result. The default is as defined in the specific routing network layer used in your [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). **Possible Values:** none | simplified | detailed + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outputPolygons) + */ outputPolygons?: string; + /** + * The well-known ID of the spatial reference for the geometries returned with the analysis results. If `outSpatialReference` is not specified, the geometries are returned in the spatial reference of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outSpatialReference) + */ outSpatialReference?: SpatialReferenceProperties; + /** + * Indicates if the lines should overlap from multiple facilities. The default is defined by the network analysis layer in your [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#overlapLines) + * + * @default false + */ overlapLines?: boolean; + /** + * Indicates if the polygons should overlap from multiple facilities. The default is defined by the network analysis layer in your [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#overlapPolygons) + * + * @default false + */ overlapPolygons?: boolean; + /** + * The set of point barriers loaded as network locations during analysis. At ArcGIS Server 10.1, an optional url property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#pointBarriers) + */ pointBarriers?: DataLayerProperties | FeatureSetProperties; + /** + * The set of polygon barriers loaded as network locations during analysis. At ArcGIS Server 10.1, an optional url property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#polygonBarriers) + */ polygonBarriers?: DataLayerProperties | FeatureSetProperties; + /** + * The set of polyline barriers loaded as network locations during analysis. At ArcGIS Server 10.1, an optional url property was added. Use this property to specify a REST query request to a Feature, Map or GP Service that returns a JSON feature set. The url property can be specified using [DataFile](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataFile.html). Note that either the features or url property should be specified. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#polylineBarriers) + */ polylineBarriers?: DataLayerProperties | FeatureSetProperties; + /** + * The list of network attribute names to be used as restrictions with the analysis. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attributes names listed in the Service Directory under `Network Dataset > Network Attributes` as `Usage Type: esriNAUTCost`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#restrictionAttributes) + */ restrictionAttributes?: string[]; + /** + * Specifies how U-turns should be handled. The default is defined in the routing network layer used in your RouteTask. + * + * Possible Value | Description + * ---------------|------------ + * allow-backtrack | Allows U-turns on everywhere + * at-dead-ends-only | Only allows U-turns at dead ends + * no-backtrack | Restricts U-turns everywhere + * at-dead-ends-and-intersections | Only allows U-turns at dead ends and intersections + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#restrictUTurns) + */ restrictUTurns?: string; + /** + * If `true`, facilities will be returned with the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#returnFacilities) + * + * @default false + */ returnFacilities?: boolean; + /** + * If `true`, point barriers will be returned in the [pointBarriers](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#pointBarriers) property of the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#returnPointBarriers) + * + * @default false + */ returnPointBarriers?: boolean; + /** + * If `true`, polygon barriers will be returned in the [polygonBarriers](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#polygonBarriers) property of the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#returnPolygonBarriers) + * + * @default false + */ returnPolygonBarriers?: boolean; + /** + * If `true`, polyline barriers will be returned in the [polylineBarriers](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#polylineBarriers) property of the analysis results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#returnPolylineBarriers) + * + * @default false + */ returnPolylineBarriers?: boolean; + /** + * If `true`, lines will be split at breaks. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#splitLinesAtBreaks) + * + * @default false + */ splitLinesAtBreaks?: boolean; + /** + * If `true`, polygons will be split at breaks. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#splitPolygonsAtBreaks) + * + * @default false + */ splitPolygonsAtBreaks?: boolean; + /** + * Local date and time at the facility. if `travelDirection = "esriNATravelDirectionToFacility"`, the `timeOfDay` value specifies arrival time at the facility. if `travelDirection = "esriNATravelDirectionFromFacility"`, `timeOfDay` specifies departure time from the facility. Requires ArcGIS Server service version 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#timeOfDay) + */ timeOfDay?: DateProperties; + /** + * Options for traveling to or from the facility. Default values are defined by the network layer. + * + * Possible Value | Description + * ---------------|------------ + * from-facility | Sets travel direction from the facility + * to-facility | Sets travel direction to the facility + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#travelDirection) + */ travelDirection?: string; + /** + * If `true`, the outermost polygon (at the maximum break value) will be trimmed. The default is defined in the network analysis layer in your [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#trimOuterPolygon) + * + * @default false + */ trimOuterPolygon?: boolean; + /** + * If polygons are being trimmed, provides the distance to trim. The default value is defined in the network analysis layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#trimPolygonDistance) + */ trimPolygonDistance?: number; + /** + * If polygons are being trimmed, specifies the units of [trimPolygonDistance](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#trimPolygonDistance). The default is defined in the network analysis layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#trimPolygonDistanceUnits) + */ trimPolygonDistanceUnits?: string; + /** + * When `true`, the hierarchy attributes for the network will be used in the analysis. The default value is defined in the network layer. `useHierarchy` cannot be used in conjunction with [outputLines](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#outputLines). Requires an ArcGIS Server service version 10.1 or greater. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaParameters.html#useHierarchy) + */ useHierarchy?: boolean; } interface ServiceAreaSolveResult extends Accessor, JSONSupport { + /** + * Array of points only returned if `ServiceAreaParameters.returnFacilities = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#facilities) + */ facilities: Point[]; + /** + * Message received when solve is completed. If a service area cannot be solved, the message returned by the server identifies the incident that could not be solved. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#messages) + */ messages: NAMessage[]; + /** + * The point barriers are returned only if `ServiceAreaParameters.returnPointBarriers = true` (which is not the default). If you send in the point barriers as a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) (instead of using [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html)), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#pointBarriers) + */ pointBarriers: Point[]; + /** + * The polygon barriers are returned only if `ServiceAreaParameters.returnPolygonBarriers = true` (which is not the default). If you send in the polygon barriers as a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) (instead of using [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html)), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#polygonBarriers) + */ polygonBarriers: Polygon[]; + /** + * The polyline barriers are returned only if `ServiceAreaParameters.returnPolylineBarriers = true` (which is not the default). If you send in the polyline barriers as a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) (instead of using [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html)), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#polylineBarriers) + */ polylineBarriers: Polyline[]; + /** + * An array of service area polygon graphics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#serviceAreaPolygons) + */ serviceAreaPolygons: Graphic[]; + /** + * An array of service area polyline graphics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#serviceAreaPolylines) + */ serviceAreaPolylines: Graphic[]; } interface ServiceAreaSolveResultConstructor { + /** + * The result from [ServiceAreaTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-ServiceAreaTask.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html) + */ + new(properties?: ServiceAreaSolveResultProperties): ServiceAreaSolveResult; fromJSON(json: any): ServiceAreaSolveResult; @@ -7144,842 +30206,4021 @@ declare namespace __esri { export const ServiceAreaSolveResult: ServiceAreaSolveResultConstructor; interface ServiceAreaSolveResultProperties { + /** + * Array of points only returned if `ServiceAreaParameters.returnFacilities = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#facilities) + */ facilities?: PointProperties[]; + /** + * Message received when solve is completed. If a service area cannot be solved, the message returned by the server identifies the incident that could not be solved. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#messages) + */ messages?: NAMessageProperties[]; + /** + * The point barriers are returned only if `ServiceAreaParameters.returnPointBarriers = true` (which is not the default). If you send in the point barriers as a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) (instead of using [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html)), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#pointBarriers) + */ pointBarriers?: PointProperties[]; + /** + * The polygon barriers are returned only if `ServiceAreaParameters.returnPolygonBarriers = true` (which is not the default). If you send in the polygon barriers as a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) (instead of using [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html)), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#polygonBarriers) + */ polygonBarriers?: PolygonProperties[]; + /** + * The polyline barriers are returned only if `ServiceAreaParameters.returnPolylineBarriers = true` (which is not the default). If you send in the polyline barriers as a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html) (instead of using [DataLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-DataLayer.html)), you already have the barriers and might not need to request them back from the server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#polylineBarriers) + */ polylineBarriers?: PolylineProperties[]; + /** + * An array of service area polygon graphics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#serviceAreaPolygons) + */ serviceAreaPolygons?: GraphicProperties[]; + /** + * An array of service area polyline graphics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-ServiceAreaSolveResult.html#serviceAreaPolylines) + */ serviceAreaPolylines?: GraphicProperties[]; } - interface StatisticDefinition extends Accessor { + interface StatisticDefinition extends Accessor, JSONSupport { + /** + * Defines the field for which statistics will be calculated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-StatisticDefinition.html#onStatisticField) + */ onStatisticField: string; + /** + * Specifies the output field name. Output field names can only contain alpha-numeric characters and an underscore. If no output field name is specified, the map server assigns a field name to the returned statistic field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-StatisticDefinition.html#outStatisticFieldName) + */ outStatisticFieldName: string; + /** + * Defines the type of statistic. **Known Values:** count | sum | min | max | avg | stddev | var + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-StatisticDefinition.html#statisticType) + */ statisticType: string; - - toJSON(): any; } interface StatisticDefinitionConstructor { + + new(properties?: StatisticDefinitionProperties): StatisticDefinition; + + fromJSON(json: any): StatisticDefinition; } export const StatisticDefinition: StatisticDefinitionConstructor; interface StatisticDefinitionProperties { + /** + * Defines the field for which statistics will be calculated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-StatisticDefinition.html#onStatisticField) + */ onStatisticField?: string; + /** + * Specifies the output field name. Output field names can only contain alpha-numeric characters and an underscore. If no output field name is specified, the map server assigns a field name to the returned statistic field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-StatisticDefinition.html#outStatisticFieldName) + */ outStatisticFieldName?: string; + /** + * Defines the type of statistic. **Known Values:** count | sum | min | max | avg | stddev | var + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-StatisticDefinition.html#statisticType) + */ statisticType?: string; } interface TrimExtendParameters extends Accessor { + /** + * A flag used with the `trimExtend` operation. + * + * Possible Value | Description + * ---------------|------------- + * default-curve-extension | The extension considers both ends of the path. The old ends remain and new points are added to the extended ends. The new points have attributes that are extrapolated from existing adjacent segments. + * relocate-ends | When an extension is performed at an end, relocate the end point to the new position. + * keep-end-attributes | When an extension is performed at an end, do not extrapolate the end segments attributes for the new point. Instead, the attributes will be the same as the current end. + * no-end-attributes | When an extension is performed at an end, do not extrapolate the end segments attributes for the new point. Instead the attributes will be empty. + * no-extend-at-from | Do not extend the 'from' end of any path. + * no-extend-at-to | Do not extend the 'to' end of any path. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-TrimExtendParameters.html#extendHow) + * + * @default default-curve-extension + */ extendHow: string; + /** + * The array of polylines to trim or extend. The structure of each geometry in the array is the same as the structure of the JSON polyline objects returned by the ArcGIS REST API. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-TrimExtendParameters.html#polylines) + */ polylines: Polyline[]; + /** + * A polyline used as a guide for trimming or extending input polylines. The structure of the polyline is the same as the structure of the JSON polyline object returned by the ArcGIS REST API. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-TrimExtendParameters.html#trimExtendTo) + */ trimExtendTo: Polyline; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-TrimExtendParameters.html#toJSON) + * + * + */ toJSON(): any; } interface TrimExtendParametersConstructor { + + new(properties?: TrimExtendParametersProperties): TrimExtendParameters; } export const TrimExtendParameters: TrimExtendParametersConstructor; interface TrimExtendParametersProperties { + /** + * A flag used with the `trimExtend` operation. + * + * Possible Value | Description + * ---------------|------------- + * default-curve-extension | The extension considers both ends of the path. The old ends remain and new points are added to the extended ends. The new points have attributes that are extrapolated from existing adjacent segments. + * relocate-ends | When an extension is performed at an end, relocate the end point to the new position. + * keep-end-attributes | When an extension is performed at an end, do not extrapolate the end segments attributes for the new point. Instead, the attributes will be the same as the current end. + * no-end-attributes | When an extension is performed at an end, do not extrapolate the end segments attributes for the new point. Instead the attributes will be empty. + * no-extend-at-from | Do not extend the 'from' end of any path. + * no-extend-at-to | Do not extend the 'to' end of any path. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-TrimExtendParameters.html#extendHow) + * + * @default default-curve-extension + */ extendHow?: string; + /** + * The array of polylines to trim or extend. The structure of each geometry in the array is the same as the structure of the JSON polyline objects returned by the ArcGIS REST API. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-TrimExtendParameters.html#polylines) + */ polylines?: PolylineProperties[]; + /** + * A polyline used as a guide for trimming or extending input polylines. The structure of the polyline is the same as the structure of the JSON polyline object returned by the ArcGIS REST API. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-TrimExtendParameters.html#trimExtendTo) + */ trimExtendTo?: PolylineProperties; } interface Task extends Accessor { + /** + * The [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for data requests. These options can also be controlled through the `requestOptions` method parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Task.html#requestOptions) + */ requestOptions: any; + /** + * The ArcGIS Server REST service URL (usually of a Feature Service Layer or Map Service Layer) for use in a task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Task.html#url) + */ url: string; } interface TaskConstructor { + + new(properties?: TaskProperties): Task; } export const Task: TaskConstructor; interface TaskProperties { + /** + * The [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for data requests. These options can also be controlled through the `requestOptions` method parameter. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Task.html#requestOptions) + */ requestOptions?: any; + /** + * The ArcGIS Server REST service URL (usually of a Feature Service Layer or Map Service Layer) for use in a task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Task.html#url) + */ url?: string; } interface ConfigurationTask extends Task { + /** + * URL to the ArcGIS Workflow Manager REST service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#url) + */ url: string; + /** + * Gets an array of all the user groups that are configured in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getAllGroups) + * + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getAllGroups(requestOptions?: any): IPromise; + /** + * Gets an array of all the users that are configured in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getAllUsers) + * + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getAllUsers(requestOptions?: any): IPromise; + /** + * Gets the properties and an array of geodatabase versions for a data workspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getDataWorkspaceDetails) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.dataWorkspaceId The unique id of the data workspace, whose version will be returned. + * @param params.user The user name of the user who is requesting the information. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getDataWorkspaceDetails(params: ConfigurationTaskGetDataWorkspaceDetailsParams, requestOptions?: any): IPromise; + /** + * Gets a single user group in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getGroup) + * + * @param groupId The unique id of the group whose information will be retrieved. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getGroup(groupId: number, requestOptions?: any): IPromise; + /** + * Gets the detailed configuration properties of a job type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getJobTypeDetails) + * + * @param jobTypeId The unique id of a job type. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getJobTypeDetails(jobTypeId: number, requestOptions?: any): IPromise; + /** + * Gets the configuration of a publicly accessible job query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getPublicJobQueryDetails) + * + * @param queryId The unique id of public query. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getPublicJobQueryDetails(queryId: number, requestOptions?: any): IPromise; + /** + * Gets the [configuration information](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) specific to a Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getServiceInfo) + * + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getServiceInfo(requestOptions?: any): IPromise; + /** + * Gets an array of registered [table relationships](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#TableRelationship) in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getTableRelationshipsDetails) + * + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getTableRelationshipsDetails(requestOptions?: any): IPromise; + /** + * Gets information for a single user in the system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getUser) + * + * @param user The user name of the user whose information will be returned. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getUser(user: string, requestOptions?: any): IPromise; + /** + * Gets the configuration of a user-owned job query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getUserJobQueryDetails) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.queryId The unique id of user query. + * @param params.user The user name of the user who is requesting the information. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getUserJobQueryDetails(params: ConfigurationTaskGetUserJobQueryDetailsParams, requestOptions?: any): IPromise; + /** + * Gets all the job types a user is allowed to see and create. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getVisibleJobTypes) + * + * @param user The user name of the user for whom the information will be retrieved. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getVisibleJobTypes(user: string, requestOptions?: any): IPromise; } interface ConfigurationTaskConstructor { + + new(properties?: ConfigurationTaskProperties): ConfigurationTask; } export const ConfigurationTask: ConfigurationTaskConstructor; interface ConfigurationTaskProperties extends TaskProperties { + /** + * URL to the ArcGIS Workflow Manager REST service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#url) + */ url?: string; } - export interface ConfigurationTaskGetDataWorkspaceDetailsParams { + + export interface ConfigurationTaskGetDataWorkspaceDetailsParams extends Object { + /** + * The unique id of the data workspace, whose version will be returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getDataWorkspaceDetails) + */ dataWorkspaceId: string; + /** + * The user name of the user who is requesting the information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getDataWorkspaceDetails) + */ user: string; } - export interface ConfigurationTaskGetUserJobQueryDetailsParams { + + export interface ConfigurationTaskGetUserJobQueryDetailsParams extends Object { + /** + * The unique id of user query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getUserJobQueryDetails) + */ queryId: number; + /** + * The user name of the user who is requesting the information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#getUserJobQueryDetails) + */ user: string; } - export interface DataWorkspace { + /** + * A geospatial database that will be used for editing in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#DataWorkspace) + */ + export interface DataWorkspace extends Object { + /** + * The unique id of the data workspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#DataWorkspace) + */ id: string; + /** + * The name of the data workspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#DataWorkspace) + */ name: string; } - export interface GroupMembership { + /** + * The membership attributes of a group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#GroupMembership) + */ + export interface GroupMembership extends Object { + /** + * The unique id for the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#GroupMembership) + */ id: number; + /** + * The name of the group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#GroupMembership) + */ name: string; } - export interface HoldType { + /** + * The type of hold that can be applied to suspend the execution of a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#HoldType) + */ + export interface HoldType extends Object { + /** + * The description of the type of hold. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#HoldType) + */ description: string; + /** + * The unique id for the hold type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#HoldType) + */ id: number; + /** + * The name of the hold type + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#HoldType) + */ name: string; } - export interface JobPriority { + /** + * The properties of a job priority. Job priority is a way to assign a level of importance to the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobPriority) + */ + export interface JobPriority extends Object { + /** + * The description of the priority. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobPriority) + */ description: string; + /** + * The name of the priority. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobPriority) + */ name: string; + /** + * The unique id of the priority. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobPriority) + */ value: number; } - export interface JobQuery { + /** + * A query that is available to the user to execute. A query returns jobs based on a specific criteria. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQuery) + */ + export interface JobQuery extends Object { + /** + * The unique id for the query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQuery) + */ id: number; + /** + * The name of the priority. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQuery) + */ name: string; } - export interface JobQueryContainer { + /** + * A container of job queries, it can also contain nested containers with child job query containers under it. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryContainer) + */ + export interface JobQueryContainer extends Object { + /** + * One or more [job query containers](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryContainer) which are nested under the parent container. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryContainer) + */ containers: JobQueryContainer[]; + /** + * The unique id for the container. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryContainer) + */ id: number; + /** + * The name of the query container. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryContainer) + */ name: string; + /** + * An array of [queries](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQuery) inside the query container. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryContainer) + */ queries: JobQuery[]; } - export interface JobQueryDetails { + /** + * Detailed properties of a job query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryDetails) + */ + export interface JobQueryDetails extends Object { + /** + * An array of field aliases included in the select statement. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryDetails) + */ aliases: string[]; + /** + * An array of fields included in the select statement. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryDetails) + */ fields: string[]; + /** + * The unique id for the query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryDetails) + */ id: number; + /** + * The name of the query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryDetails) + */ name: string; + /** + * The field used to order the results returned by the query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryDetails) + */ orderBy: string; + /** + * An array of tables selected from and used in the where clause. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryDetails) + */ tables: string[]; + /** + * The where clause used as filter for selecting job information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryDetails) + */ where: string; } - export interface JobStatus { + /** + * Properties of a job status. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobStatus) + */ + export interface JobStatus extends Object { + /** + * An alias name for the status. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobStatus) + */ caption: string; + /** + * The description of the type of status. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobStatus) + */ description: string; + /** + * The unique id for the status type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobStatus) + */ id: number; + /** + * The name of the status type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobStatus) + */ name: string; } - export interface JobType { + /** + * A list of properties that describe a job type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobType) + */ + export interface JobType extends Object { + /** + * A category to group other similar job types. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobType) + */ category: string; + /** + * The description of the job type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobType) + */ description: string; + /** + * The unique id for the job type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobType) + */ id: string; + /** + * The name of the job type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobType) + */ name: string; + /** + * The state of the job type. **Possible Values:** draft | active | retired + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobType) + */ state: string; } - export interface JobTypeDetails { + /** + * Detailed information of a job type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ + export interface JobTypeDetails extends Object { + /** + * The name of the geodatabase version that will be assigned the parent version of the job's geodatabase by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ defaultParentVersionName: string; + /** + * Indicates whether jobs of this type will have their workflows automatically executed, when created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ autoExecuteCreatedJobs: boolean; + /** + * The category of the job type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ category: string; + /** + * The name of the user or group that the job will be assigned to by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ defaultAssignedTo: string; + /** + * Indicates whether the job is assigned to a user, group or unassigned by default. **Possible Values:** unassigned | user | group + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ defaultAssignedType: string; + /** + * The unique id of the default data workspace of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ defaultDataWorkspaceId: string; + /** + * The description that gets associated with the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ defaultDescription: string; + /** + * The default due date of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ defaultDueDate: string; + /** + * The duration for completing the job assigned by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ defaultJobDuration: number; + /** + * Indicates whether jobs of this type allows users to modify the current data workspace in the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ canDataWorkspaceChange: boolean; + /** + * The numeric priority value assigned to the job by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ defaultPriority: string; + /** + * The default start date of this job type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ defaultStartDate: Date; + /** + * The description of the job type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ description: string; + /** + * The unique id automatically generated for this job type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ id: string; + /** + * The naming scheme for this job type, which would serve as template for the name of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ jobNamingScheme: string; + /** + * The naming scheme for this job type, which would serve as template for the name of job's version. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ jobVersionNamingScheme: string; + /** + * The naming scheme for this job type, which would serve as template for the name of job's map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ mxdNamingScheme: string; + /** + * The job type name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ name: string; + /** + * The state of the job type. **Possible Values:** draft | active | retired + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobTypeDetails) + */ state: string; } - export interface Privilege { + /** + * A privilege in the Workflow Manager system that controls application access. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#Privilege) + */ + export interface Privilege extends Object { + /** + * The description of the privilege. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#Privilege) + */ description: string; + /** + * The unique id for the privilege. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#Privilege) + */ id: number; + /** + * The name of the privilege. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#Privilege) + */ name: string; } - export interface TableRelationship { + /** + * TableRelationship represents a list of extended properties tables and the properties that identify them like name and cardinality. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#TableRelationship) + */ + export interface TableRelationship extends Object { + /** + * The type of extra property table relationship, one-to-one represents one row for each property and one-to-many represents there will be multiple values for the property. **Possible Values:** one-to-one | one-to-many + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#TableRelationship) + */ cardinality: string; + /** + * The foreign key field used to join the jobs table. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#TableRelationship) + */ linkField: string; + /** + * The alias name of the table. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#TableRelationship) + */ tableAlias: string; + /** + * The name of the extended properties table. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#TableRelationship) + */ tableName: string; } - export interface UserDetails { + /** + * A list of properties including groups and privileges associated with a Workflow Manager user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ + export interface UserDetails extends Object { + /** + * The last name of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ lastName: string; + /** + * The address of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ address: string; + /** + * The fax number of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ faxNumber: string; + /** + * The first name of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ firstName: string; + /** + * The full name of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ fullName: string; + /** + * An array of [group memberships](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#GroupMembership) of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ groups: GroupMembership[]; + /** + * The email address of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ email: string; + /** + * The phone number of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ phoneNumber: string; + /** + * An array of [application privileges](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#Privilege) of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ privileges: Privilege[]; + /** + * The room number of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ roomNumber: string; + /** + * The login username for the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ userName: string; + /** + * An array of [queries](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryContainer) owned by the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ userQueries: JobQueryContainer[]; + /** + * The zip code of the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#UserDetails) + */ zipCode: string; } - export interface VersionInfo { + /** + * A list of properties that describe a geodatabase version. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#VersionInfo) + */ + export interface VersionInfo extends Object { + /** + * The level of access to the geodatabase version. **Possible Values:** esriVersionAccessPrivate | esriVersionAccessPublic | esriVersionAccessProtected + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#VersionInfo) + */ access: string; + /** + * The name of the geodatabase version. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#VersionInfo) + */ name: string; + /** + * The name of the parent version of the geodatabase. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#VersionInfo) + */ parent: string; } - export interface WorkflowManagerServiceInfo { + /** + * The base properties of a Workflow Manager service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ + export interface WorkflowManagerServiceInfo extends Object { + /** + * An array of [job priorities](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobPriority) in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ jobPriorities: JobPriority[]; + /** + * An array of activity types in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ activityTypes: ActivityType[]; + /** + * The current software version. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ currentVersion: number; + /** + * An array of [data workspaces](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#DataWorkspace) in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ dataWorkspaces: DataWorkspace[]; + /** + * An array of [hold types](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#HoldType) in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ holdTypes: HoldType[]; + /** + * The configuration properties of the Workflow Manager system stored in the database table as key/value pairs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ configProperties: WorkflowManagerServiceInfoConfigProperties; + /** + * An array of [job statuses](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobStatus) in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ jobStatuses: JobStatus[]; + /** + * An array of [job types](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobType) in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ jobTypes: JobType[]; + /** + * An array of notification types in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ notificationTypes: NotificationType[]; + /** + * An array of [privileges](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#Privilege) in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ privileges: Privilege[]; + /** + * The array of [public queries](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#JobQueryContainer). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ publicQueries: JobQueryContainer[]; } - export interface WorkflowManagerServiceInfoConfigProperties { + + export interface WorkflowManagerServiceInfoConfigProperties extends Object { + /** + * Indicates whether the location of interest (LOI) for jobs are allowed to overlap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ AOIOVERLAP: string; + /** + * The color of the current job's LOI when selected in the LOI tab. The value is in range of 0 to 167772155. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ AOISELECTIONCOLOR: number; + /** + * Indicates whether the job will be automatically assigned based on step assignment. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ AUTOASSIGNJOB: boolean; + /** + * Indicates whether the job will be automatically closed after the last step in the workflow is marked as complete. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ AUTOCLOSEJOB: boolean; + /** + * Indicates whether the job workflow witll be automatically committed to the database when saved. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ AUTOCOMMITWORKFLOW: boolean; + /** + * Indicates whether the status of the jobs will be automatically assigned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ AUTOSTATUSASSIGN: boolean; + /** + * Indicates whether the user will be required to confirm that they want to mark the current procedural step as complete. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ CONFIRMPROCEDURALCHECK: boolean; + /** + * The default email address to be used in the sender field when sending notifications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ DEFAULT_SENDER_EMAIL: string; + /** + * The default name displayed to be used in the sender field when sending notifications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ DEFAULT_SENDER_NAME: string; + /** + * Indicates whether notifications will be sent as HTML. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ HTML_SUPPORT: string; + /** + * The starting value of job ids in the system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ JOB_ID_START_VALUE: string; + /** + * Indicates whether the the number of days for each hold is taken out of the pending days calculation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ PENDING_DAYS_USE_HOLDS: boolean; + /** + * Indicates whether the user attempting to delete a job version would be prompted to enter a password for the sde owner of the versions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ PROMPTSDEPWD: boolean; + /** + * Indicates whether it will be required to mark procedural steps as started. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ REQUIREPROCEDURALCHECKSTART: number; + /** + * Indicates whether the editing behavior will be restricted to data in the job's AOI using editing restriction rules. **Possible Values:** Warn | NoSelect | Off + * * `Warn` - Warn users when selecting features outside the job AOI. + * * `NoSelect` - Prevent users from selecting features outside the job AOI. + * * `Off` - Allow edits to features outside the job AOI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ RESTRICT_AOI_OPTION: string; + /** + * Indicates whether the spatial notifications will be sent on Workflow Manager Post. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ SEND_SN_CUSTOM_POST: boolean; + /** + * Indicates whether to show step ids on workflow. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ SHOW_STEP_IDS: boolean; + /** + * Indicates whether the step completion percentage will be displayed on the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ SHOW_STEP_PERCENT_COMPLETE: boolean; + /** + * The password of the authenticated SMTP user in the secure SMTP server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ SMTP_PASSWORD: string; + /** + * Indicates whether the pending days will be displayed in the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ SHOW_PENDING_DAYS: boolean; + /** + * The SMTP server port to be used for sending notifications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ SMTP_PORT: string; + /** + * SMTP Authentication protocol. **Possible Values:** SSL | TLS + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ SMTP_PROTOCOL: string; + /** + * The name of the SMTP Server to be used for sending notifications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ SMTP_SERVER: string; + /** + * The user name that is authenticated in the secure SMTP server. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ SMTP_USERNAME: string; + /** + * Indicates whether to use step status assignment such that the job's status updates to match the step status when the step is reached. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ USE_STEP_STATUS: boolean; + /** + * Indicates the user store of the Workflow Manager system, whether the users will be stored in a Portal or the Workflow Manager system. **Possible Values:** traditional | portal + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ USER_STORE: string; + /** + * Indicates whether a user will be authenticated using domain along with the user name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ USEUSERDOMAIN: boolean; + /** + * The fill color of a selected step in a workflow. The value is in range of 0 to 167772155. When the option is disabled it's value is -1. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ WF_SEL_STEP_FILL_COLOR: number; + /** + * The outline color of a selected step in a workflow. The value is in range of 0 to 167772155. When the option is disabled it's value is -1. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ WF_SEL_STEP_OUTLINE_COLOR: number; + /** + * The outline width of a selected step in a workflow. **Possible Values:** 1 | 2 | 3 + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ WF_SEL_STEP_OUTLINE_WIDTH: number; + /** + * Indicates whether the LOI of the job will be automatically zoomed to in the LOI tab. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ConfigurationTask.html#WorkflowManagerServiceInfo) + */ ZOOMTOAOI: boolean; } interface JobTask extends Task { + /** + * URL to the ArcGIS Workflow Manager REST service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#url) + */ url: string; + /** + * Uploads a file and attaches it to the job as an embedded attachment. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addEmbeddedAttachment) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.form The form element that contains the file input control. The form parameter can be an instance of FormData. Using FormData you can send a "multipart/form-data" request to the server without having to create an HTML form element in markup. Note that the FormData api is not available in all browsers. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ addEmbeddedAttachment(params: JobTaskAddEmbeddedAttachmentParams, requestOptions?: any): IPromise; + /** + * Adds a linked attachment to a job (url or file). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addLinkedAttachment) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.attachmentType The type of attachment to be added. **Possible Values:** linked-file | url + * @param params.path The file path to the attachment. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ addLinkedAttachment(params: JobTaskAddLinkedAttachmentParams, requestOptions?: any): IPromise; + /** + * Adds a linked property record to a job's linked properties table. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addLinkedRecord) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.tableName The name of the table to which the record will be added. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ addLinkedRecord(params: JobTaskAddLinkedRecordParams, requestOptions?: any): IPromise; + /** + * Assigns one or more jobs to a user or group. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#assignJobs) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobIds An array of unique job Ids. + * @param params.assignedType Indicates whether the job is assigned to a user, group or unassigned. **Possible Values:** unassigned | user | group + * @param params.assignedTo The name of the user or group to whom the job will be assigned. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ assignJobs(params: JobTaskAssignJobsParams, requestOptions?: any): IPromise; + /** + * Closes one or more jobs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#closeJobs) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobIds An array of unique job Ids. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ closeJobs(params: JobTaskCloseJobsParams, requestOptions?: any): IPromise; + /** + * Creates a job dependency. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createDependency) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.heldOnType Indicates whether the current job (to which the dependency is being added) will be held at a step, stage or status. **Possible Values:** step | stage | status + * @param params.heldOnValue The value of the step, stage or status at which the current job will be held. + * @param params.depJobId The unique id of the job on which the current job will depend. + * @param params.depOnType Indicates whether the current job (to which the dependency is being added) will be dependent on a step, stage or status of the other job. **Possible Values:** step | stage | status + * @param params.depOnValue The value of the step or status of the other job on which the current job will be dependent. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ createDependency(params: JobTaskCreateDependencyParams, requestOptions?: any): IPromise; + /** + * Creates a job hold. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createHold) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.holdTypeId The unique id representing the hold type to be placed on the job. + * @param params.comments Reason or more detailed information regarding why the hold is being added. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ createHold(params: JobTaskCreateHoldParams, requestOptions?: any): IPromise; + /** + * Creates new jobs based on the provided parameters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createJobs) + * + * @param params The parameters to be used for job creation, parameters defined in the job type can be overritten. The jobTypeId and user are required parameters when creating a job. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ createJobs(params: JobCreationParameters, requestOptions?: any): IPromise; + /** + * Creates a version specific to the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createJobVersion) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.name The name of the version to be created. + * @param params.parent The name of the job's assigned geodatabase (data workspace) version, based on which the new version will be created. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ createJobVersion(params: JobTaskCreateJobVersionParams, requestOptions?: any): IPromise; + /** + * Deletes an attachment from a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteAttachment) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.attachmentId The unique id of the attachment to be deleted. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ deleteAttachment(params: JobTaskDeleteAttachmentParams, requestOptions?: any): IPromise; + /** + * Deletes a job dependency. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteDependency) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.dependencyId The unique id of the dependency to be deleted. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ deleteDependency(params: JobTaskDeleteDependencyParams, requestOptions?: any): IPromise; + /** + * Delete one or more jobs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteJobs) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobIds An array of unique job Ids. + * @param params.deleteHistory Indicates whether or not to delete the associated job history, the default is to delete job history. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ deleteJobs(params: JobTaskDeleteJobsParams, requestOptions?: any): IPromise; + /** + * Deletes a record from a job's linked properties table. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteLinkedRecord) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.tableName The name of the table from which linked record will be deleted. + * @param params.recordId The unique id of the record in the table. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ deleteLinkedRecord(params: JobTaskDeleteLinkedRecordParams, requestOptions?: any): IPromise; + /** + * Gets the activity log for a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#getActivityLog) + * + * @param jobId The unique id of the job. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getActivityLog(jobId: number, requestOptions?: any): IPromise; + /** + * Gets the URL to access the file content of an embedded job attachment. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#getAttachmentContentUrl) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.attachmentId The Id of the attachment to be retrieved. + * + */ getAttachmentContentUrl(params: JobTaskGetAttachmentContentUrlParams): string; + /** + * Gets all the attachments associated with the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#getAttachments) + * + * @param jobId The unique id of the job. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getAttachments(jobId: number, requestOptions?: any): IPromise; + /** + * Gets an array of dependencies configured for a job. A job with a dependency is held at a step, stage or status of the other job, and cannot progress until the other job reaches the step, stage or status defined in the dependency. Once the other job reaches step, stage or status as defined in the dependency criteria the dependency is released and the dependent job can progress. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#getDependencies) + * + * @param jobId The unique id of the job. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getDependencies(jobId: number, requestOptions?: any): IPromise; + /** + * Gets an array of [extended properties](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordContainer) for a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#getExtendedProperties) + * + * @param jobId The unique id of the job. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getExtendedProperties(jobId: number, requestOptions?: any): IPromise; + /** + * Gets an array of holds on a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#getHolds) + * + * @param jobId The unique id of the job. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getHolds(jobId: number, requestOptions?: any): IPromise; + /** + * Gets the [job](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) object based on the given id. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#getJob) + * + * @param jobId The unique id of the job to be retrieved. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getJob(jobId: number, requestOptions?: any): IPromise; + /** + * Gets all the job ids in the system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#getJobIds) + * + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getJobIds(requestOptions?: any): IPromise; + /** + * Gets the notes for a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#getNotes) + * + * @param jobId The unique id of the job. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getNotes(jobId: number, requestOptions?: any): IPromise; + /** + * Gets an array of [values and descriptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#FieldValue) for a geodatabase domain or table list extended property field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#listFieldValues) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.tableName The name of the extended property table. + * @param params.field The field name of the extended property for which to retrieve values. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ listFieldValues(params: JobTaskListFieldValuesParams, requestOptions?: any): IPromise; + /** + * Gets an array of [display values](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#FieldValue) for a given fields that comprise a multi-level table list extended property. As each display field is selected, for example using a dropdown UI control, this method can be called to obtain a list of values to display in the subsequent dropdown control. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#listMultiLevelFieldValues) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.field The name of the field. + * @param params.previousSelectedValues The array of previous values, on which the current value is dependent on. For example, when selecting a city based on the state and county. The value for the state and county would be the previous values. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ listMultiLevelFieldValues(params: JobTaskListMultiLevelFieldValuesParams, requestOptions?: any): IPromise; + /** + * Logs an action in a job's activity log. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#logAction) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.activityTypeId The unique id representing the [activity type](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#ActivityType) of the action associated with this log record. + * @param params.comments The comment that is added to the history. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ logAction(params: JobTaskLogActionParams, requestOptions?: any): IPromise; + /** + * Queries the jobs using the queryId of an existing query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#queryJobs) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.queryId The unique id of a query, used to query jobs in the database. + * @param params.user The username of the user who is requesting query. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ queryJobs(params: JobTaskQueryJobsParams, requestOptions?: any): IPromise; + /** + * Queries the jobs using an ad-hoc query definition and gets the [query result](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#QueryResult). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#queryJobsAdHoc) + * + * @param params The [parameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobQueryParameters) to query jobs. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ queryJobsAdHoc(params: JobQueryParameters, requestOptions?: any): IPromise; + /** + * Gets an array of string values representing the current display values for each display field in a multi-level table list extended property. The values from this method should be used to pre-select items in dropdown lists when initially displaying the extended properties of a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#queryMultiLevelSelectedValues) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.field The name of the field. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ queryMultiLevelSelectedValues(params: JobTaskQueryMultiLevelSelectedValuesParams, requestOptions?: any): IPromise; + /** + * Releases a job hold. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#releaseHold) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.holdId The unique id of the hold. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ releaseHold(params: JobTaskReleaseHoldParams, requestOptions?: any): IPromise; + /** + * Reopens one or more closed jobs. Supported from 10.3 onwards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#reopenClosedJobs) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobIds An array of unique job Ids. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ reopenClosedJobs(params: JobTaskReopenClosedJobsParams, requestOptions?: any): IPromise; + /** + * Performs a freeform text search and returns a set of matching job records. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#searchJobs) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.text The text which will be used to perform the search. + * @param params.user The username of the user who is requesting search. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ searchJobs(params: JobTaskSearchJobsParams, requestOptions?: any): IPromise; + /** + * Unassigns one or more jobs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#unassignJobs) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobIds An array of unique job Ids. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ unassignJobs(params: JobTaskUnassignJobsParams, requestOptions?: any): IPromise; + /** + * Update a job's properties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#updateJob) + * + * @param params The [parameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) to be used for job properties update, the jobId and the user are required when updating jobs. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ updateJob(params: JobUpdateParameters, requestOptions?: any): IPromise; + /** + * Updates the notes for a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#updateNotes) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.notes The new notes for the job. Set to an empty (zero-length) string to clear the job notes. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ updateNotes(params: JobTaskUpdateNotesParams, requestOptions?: any): IPromise; + /** + * Updates the values of an extended or linked properties record. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#updateRecord) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.record The record to be updated. + * @param params.user The user name of the user who is requesting the change. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ updateRecord(params: JobTaskUpdateRecordParams, requestOptions?: any): IPromise; } interface JobTaskConstructor { + /** + * Helps you work with Workflow Manager jobs. A job is a single unit of work that is carried out within an organization. Various methods are available in the class to work with the following: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html) + */ + new(properties?: JobTaskProperties): JobTask; } export const JobTask: JobTaskConstructor; interface JobTaskProperties extends TaskProperties { + /** + * URL to the ArcGIS Workflow Manager REST service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#url) + */ url?: string; } - export interface ActivityType { + /** + * ActivityType represents an activity type template that gets logged on a job when a certain event is fired in the application. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#ActivityType) + */ + export interface ActivityType extends Object { + /** + * The description of the activity being recorded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#ActivityType) + */ desription: string; + /** + * The unique id of the activity that is logged. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#ActivityType) + */ id: number; + /** + * The message that will be logged when this type of activity occurs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#ActivityType) + */ message: string; + /** + * The name of the activity that occured. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#ActivityType) + */ name: string; } - export interface AuxRecord { + /** + * AuxRecord represents the extended/linked properties record information associated with a job so that you can fetch or update the information for a specified record. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecord) + */ + export interface AuxRecord extends Object { + /** + * The display value of the record. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecord) + */ displayProperty: any; + /** + * The unique id of the record. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecord) + */ id: number; + /** + * The array of the values in the [records](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecord) + */ recordvalues: AuxRecordValue; } - export interface AuxRecordContainer { + /** + * AuxRecordContainer represents the extended/linked properties table characteristics. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordContainer) + */ + export interface AuxRecordContainer extends Object { + /** + * The array of extended property [records](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecord). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordContainer) + */ records: AuxRecord; + /** + * The type of extended property relationship. **Possible Values:** one-to-one | one-to-many + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordContainer) + */ relationshipType: string; + /** + * The table alias. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordContainer) + */ tableAlias: string; + /** + * The table name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordContainer) + */ tableName: string; } - export interface AuxRecordDescription { + /** + * AuxRecordDescription represents the type of value that is captured in a specific AuxRecord field. There are multiple data types supported in Workflow Manager like - file, folder, text, date, etc. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordDescription) + */ + export interface AuxRecordDescription extends Object { + /** + * The array of property/value pairs of the record. + * + * [Read more...](properties.html) + */ properties: any; + /** + * The unique id of the record. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordDescription) + */ recordId: number; + /** + * The table name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordDescription) + */ tableName: string; } - export interface AuxRecordValue { + /** + * AuxRecordValue represents the values of extended/linked properties associated with a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ + export interface AuxRecordValue extends Object { + /** + * The filter to restrict the types of records supported. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ filter: string; + /** + * The alias for the field in the table. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ alias: string; + /** + * The data contained in the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ data: any; + /** + * The type of data expected in the field. **Possible Values:** small-integer | integer | single | double | string | date | oid | geometry | blob | raster | guid | global-id | xml + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ dataType: string; + /** + * The order each field is displayed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ displayOrder: number; + /** + * The type of extended property item. **Possible Values:** default | text | date | domain | file | geo-file | folder | list | table-list | multi-level-table-list + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ displayType: string; + /** + * The domain value configured for the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ domain: string; + /** + * Indicates whether the extended property value can be updated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ canUpdate: boolean; + /** + * The length of the property string. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ length: number; + /** + * The name property associated with the record. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ name: string; + /** + * Indicates whether the property is a required or optional field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ required: boolean; + /** + * The lookup table that contains the list of values which will be selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ tableListClass: string; + /** + * The field that will be displayed for the extended property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ tableListDisplayField: string; + /** + * The field that contains the value that gets stored as the extended property value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ tableListStoreField: string; + /** + * Indicates whether the value will be visible to the user or not. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#AuxRecordValue) + */ userVisible: boolean; } - export interface FieldValue { + /** + * FieldValue represents a single entry of a geodatabase domain or table list, applicable to constraining the values of an extended or linked property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#FieldValue) + */ + export interface FieldValue extends Object { + /** + * The description of the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#FieldValue) + */ description: string; + /** + * The value that is stored for the extended properties record. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#FieldValue) + */ value: any; } - export interface JobAttachment { + /** + * JobAttachment represents an attachments associated with a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobAttachment) + */ + export interface JobAttachment extends Object { + /** + * The name of the file attachment. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobAttachment) + */ filename: string; + /** + * The file folder path or a URL. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobAttachment) + */ folder: string; + /** + * The unique id of the attachment. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobAttachment) + */ id: number; + /** + * The storage type of the attachment. **Possible Values:** linked-file | embedded | url + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobAttachment) + */ storageType: string; } - export interface JobCreationParameters { + /** + * JobCreationParameters provides information about the properties used for creating a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ + export interface JobCreationParameters extends Object { + /** + * The geometry of the job's location of interest (LOI). Supported geometry types include point, multipoint and polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ loi: Geometry; + /** + * The name of the user or group to whom the job will be assigned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ assignedTo: string; + /** + * Indicates whether the workflow will be automatically committed upon creation of the job. The workflow cannot be edited after being committed to the system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ autoCommitWorkflow: boolean; + /** + * Indicates whether the job workflow will start execution automatically upon creation of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ autoExecute: boolean; + /** + * The unique id of the data workspace of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ dataWorkspaceId: string; + /** + * The description of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ description: string; + /** + * The date on which the job is expected to be complete. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ dueDate: Date; + /** + * The unique id of the job type from which to create the new job from. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ jobTypeId: number; + /** + * Indicates whether the job is assigned to a user, group or unassigned. **Possible Values:** unassigned | user | group + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ assignedType: string; + /** + * The name of the new job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ name: string; + /** + * The number of jobs to be created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ numJobs: string; + /** + * The name of the user that will own the job. Job ownership allows modification of job properties and not workflow execution. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ ownedBy: string; + /** + * The unique id of the job that will be designated as the parent job of the new job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ parentJobId: number; + /** + * The name of the geodatabase version that will be the parent version of the new job's version. By default it'll be the parent version of the data workspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ parentVersion: string; + /** + * The numeric value to denote priority of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ priority: number; + /** + * The date on which the job is scheduled to begin. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ startDate: Date; + /** + * The username of the user creating the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobCreationParameters) + */ user: string; } - export interface JobDependency { + /** + * JobDependency represents a dependency associated with a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobDependency) + */ + export interface JobDependency extends Object { + /** + * The unique id of the job on which the current job depends. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobDependency) + */ depJobId: number; + /** + * Indicates whether the job is dependent on a step, stage or status of the other job. **Possible Values:** step | stage | status + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobDependency) + */ depOnType: string; + /** + * The value of the step, stage or status of the other job on which the current job is dependent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobDependency) + */ depOnValue: string; + /** + * The value of the step, stage or status at which the current job will be held. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobDependency) + */ heldOnValue: number; + /** + * Indicates whether the job is held at a step, stage or status. **Possible Values:** step | stage | status + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobDependency) + */ holdOnType: string; + /** + * The unique id of the dependency. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobDependency) + */ id: number; + /** + * The unique id of the job on which the dependency exists. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobDependency) + */ jobID: string; } - export interface JobTaskJobInfo { + /** + * JobInfo represents a collection of job properties + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ + export interface JobTaskJobInfo extends Object { + /** + * The name of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ name: string; + /** + * The name of the user or group to whom the job is assigned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ assignedTo: string; + /** + * An array of unique job ids designated as child jobs for the current job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ childJobIds: number[]; + /** + * The user name of the person that created the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ createdBy: string; + /** + * The date the job was created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ createdDate: Date; + /** + * The unique id of the data workspace of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ dataWorkspaceId: string; + /** + * The description of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ description: string; + /** + * The date on which the job is expected to be complete. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ dueDate: Date; + /** + * The actual date the job's workflow was completed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ endDate: Date; + /** + * The unique id to identify the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ id: number; + /** + * The unique id of the job type whose instance is the current job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ jobTypeId: number; + /** + * The geometry of the job's location of interest (LOI). Supported geometry types include point, multipoint and polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ loi: Geometry; + /** + * Indicates whether the job is assigned to a user, group or unassigned. **Possible Values:** unassigned | user | group + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ assignedType: string; + /** + * The name of the user that will own the job. Job ownership allows modification of job properties and not workflow execution. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ ownedBy: string; + /** + * The unique id of the job that will be designated as the parent job of the new job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ parentJobId: number; + /** + * The name of the geodatabase version that is the parent version of the job's version. By default it'll be the parent version of the data workspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ parentVersion: string; + /** + * The number of days that the job has been active. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ pendingDays: number; + /** + * The percentage of work completed on the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ percentageComplete: number; + /** + * The numeric value to denote priority of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ priority: number; + /** + * The internal stage of the job which corresponds to the status of the job. **Possible Values:** created | ready | working | done | closed + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ stage: string; + /** + * The date on which the job is scheduled to begin. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ startDate: Date; + /** + * The numeric value to represent the current status of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ status: number; + /** + * Indicates whether a version exists for the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ versionExists: boolean; + /** + * The information about job's geodatabase version. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ versionInfo: JobVersionInfo; + /** + * The name of the job's geodatabase version. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobInfo) + */ versionName: string; } - export interface JobQueryParameters { + /** + * JobQueryParameters is a full query definition of the selected query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobQueryParameters) + */ + export interface JobQueryParameters extends Object { + /** + * An alias of fields included in the select statement. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobQueryParameters) + */ aliases: string; + /** + * An array of fields included in the select statement. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobQueryParameters) + */ fields: string; + /** + * The field that will be used to order the results returned by the query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobQueryParameters) + */ orderBy: string; + /** + * The tables that will be used in the where clause for selection. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobQueryParameters) + */ tables: string; + /** + * The where clause used as a filter for selecting job information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobQueryParameters) + */ where: string; + /** + * The username of the user who is requesting query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobQueryParameters) + */ user: string; } - export interface JobTaskAddEmbeddedAttachmentParams { + + export interface JobTaskAddEmbeddedAttachmentParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addEmbeddedAttachment) + */ jobId: number; + /** + * The form element that contains the file input control. The form parameter can be an instance of FormData. Using FormData you can send a "multipart/form-data" request to the server without having to create an HTML form element in markup. Note that the FormData api is not available in all browsers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addEmbeddedAttachment) + */ form: any; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addEmbeddedAttachment) + */ user: string; } - export interface JobTaskAddLinkedAttachmentParams { + + export interface JobTaskAddLinkedAttachmentParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addLinkedAttachment) + */ jobId: number; + /** + * The type of attachment to be added. **Possible Values:** linked-file | url + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addLinkedAttachment) + */ attachmentType: number; + /** + * The file path to the attachment. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addLinkedAttachment) + */ path: string; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addLinkedAttachment) + */ user: string; } - export interface JobTaskAddLinkedRecordParams { + + export interface JobTaskAddLinkedRecordParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addLinkedRecord) + */ jobId: number; + /** + * The name of the table to which the record will be added. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addLinkedRecord) + */ tableName: string; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#addLinkedRecord) + */ user: string; } - export interface JobTaskAssignJobsParams { + + export interface JobTaskAssignJobsParams extends Object { + /** + * An array of unique job Ids. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#assignJobs) + */ jobIds: number[]; + /** + * Indicates whether the job is assigned to a user, group or unassigned. **Possible Values:** unassigned | user | group + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#assignJobs) + */ assignedType: string; + /** + * The name of the user or group to whom the job will be assigned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#assignJobs) + */ assignedTo: string; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#assignJobs) + */ user: string; } - export interface JobTaskCloseJobsParams { + + export interface JobTaskCloseJobsParams extends Object { + /** + * An array of unique job Ids. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#closeJobs) + */ jobIds: number[]; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#closeJobs) + */ user: string; } - export interface JobTaskCreateDependencyParams { + + export interface JobTaskCreateDependencyParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createDependency) + */ jobId: number; + /** + * Indicates whether the current job (to which the dependency is being added) will be held at a step, stage or status. **Possible Values:** step | stage | status + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createDependency) + */ heldOnType: string; + /** + * The value of the step, stage or status at which the current job will be held. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createDependency) + */ heldOnValue: number; + /** + * The unique id of the job on which the current job will depend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createDependency) + */ depJobId: number; + /** + * Indicates whether the current job (to which the dependency is being added) will be dependent on a step, stage or status of the other job. **Possible Values:** step | stage | status + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createDependency) + */ depOnType: string; + /** + * The value of the step or status of the other job on which the current job will be dependent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createDependency) + */ depOnValue: number; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createDependency) + */ user: string; } - export interface JobTaskCreateHoldParams { + + export interface JobTaskCreateHoldParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createHold) + */ jobId: number; + /** + * The unique id representing the hold type to be placed on the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createHold) + */ holdTypeId: number; + /** + * Reason or more detailed information regarding why the hold is being added. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createHold) + */ comments: string; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createHold) + */ user: string; } - export interface JobTaskCreateJobVersionParams { + + export interface JobTaskCreateJobVersionParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createJobVersion) + */ jobId: number; + /** + * The name of the version to be created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createJobVersion) + */ name: string; + /** + * The name of the job's assigned geodatabase (data workspace) version, based on which the new version will be created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createJobVersion) + */ parent: string; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#createJobVersion) + */ user: string; } - export interface JobTaskDeleteAttachmentParams { + + export interface JobTaskDeleteAttachmentParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteAttachment) + */ jobId: number; + /** + * The unique id of the attachment to be deleted. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteAttachment) + */ attachmentId: number; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteAttachment) + */ user: string; } - export interface JobTaskDeleteDependencyParams { + + export interface JobTaskDeleteDependencyParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteDependency) + */ jobId: number; + /** + * The unique id of the dependency to be deleted. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteDependency) + */ dependencyId: number; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteDependency) + */ user: string; } - export interface JobTaskDeleteJobsParams { + + export interface JobTaskDeleteJobsParams extends Object { + /** + * An array of unique job Ids. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteJobs) + */ jobIds: number[]; + /** + * Indicates whether or not to delete the associated job history, the default is to delete job history. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteJobs) + */ deleteHistory?: boolean; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteJobs) + */ user: string; } - export interface JobTaskDeleteLinkedRecordParams { + + export interface JobTaskDeleteLinkedRecordParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteLinkedRecord) + */ jobId: number; + /** + * The name of the table from which linked record will be deleted. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteLinkedRecord) + */ tableName: string; + /** + * The unique id of the record in the table. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteLinkedRecord) + */ recordId: number; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#deleteLinkedRecord) + */ user: string; } - export interface JobTaskGetAttachmentContentUrlParams { + + export interface JobTaskGetAttachmentContentUrlParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#getAttachmentContentUrl) + */ jobId: number; + /** + * The Id of the attachment to be retrieved. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#getAttachmentContentUrl) + */ attachmentId: number; } - export interface JobTaskListFieldValuesParams { + + export interface JobTaskListFieldValuesParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#listFieldValues) + */ jobId: number; + /** + * The name of the extended property table. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#listFieldValues) + */ tableName: string; + /** + * The field name of the extended property for which to retrieve values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#listFieldValues) + */ field: string; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#listFieldValues) + */ user: string; } - export interface JobTaskListMultiLevelFieldValuesParams { + + export interface JobTaskListMultiLevelFieldValuesParams extends Object { + /** + * The name of the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#listMultiLevelFieldValues) + */ field: string; + /** + * The array of previous values, on which the current value is dependent on. For example, when selecting a city based on the state and county. The value for the state and county would be the previous values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#listMultiLevelFieldValues) + */ previousSelectedValues: string[]; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#listMultiLevelFieldValues) + */ user: string; } - export interface JobTaskLogActionParams { + + export interface JobTaskLogActionParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#logAction) + */ jobId: number; + /** + * The unique id representing the [activity type](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#ActivityType) of the action associated with this log record. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#logAction) + */ activityTypeId: number; + /** + * The comment that is added to the history. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#logAction) + */ comments: string; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#logAction) + */ user: string; } - export interface JobTaskQueryJobsParams { + + export interface JobTaskQueryJobsParams extends Object { + /** + * The unique id of a query, used to query jobs in the database. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#queryJobs) + */ queryId: number; + /** + * The username of the user who is requesting query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#queryJobs) + */ user: string; } - export interface JobTaskQueryMultiLevelSelectedValuesParams { + + export interface JobTaskQueryMultiLevelSelectedValuesParams extends Object { + /** + * The name of the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#queryMultiLevelSelectedValues) + */ field: string; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#queryMultiLevelSelectedValues) + */ user: string; } - export interface JobTaskReleaseHoldParams { + + export interface JobTaskReleaseHoldParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#releaseHold) + */ jobId: number; + /** + * The unique id of the hold. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#releaseHold) + */ holdId: number; } - export interface JobTaskReopenClosedJobsParams { + + export interface JobTaskReopenClosedJobsParams extends Object { + /** + * An array of unique job Ids. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#reopenClosedJobs) + */ jobIds: number[]; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#reopenClosedJobs) + */ user: string; } - export interface JobTaskSearchJobsParams { + + export interface JobTaskSearchJobsParams extends Object { + /** + * The text which will be used to perform the search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#searchJobs) + */ text: string; + /** + * The username of the user who is requesting search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#searchJobs) + */ user: string; } - export interface JobTaskUnassignJobsParams { + + export interface JobTaskUnassignJobsParams extends Object { + /** + * An array of unique job Ids. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#unassignJobs) + */ jobIds: number[]; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#unassignJobs) + */ user: string; } - export interface JobTaskUpdateNotesParams { + + export interface JobTaskUpdateNotesParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#updateNotes) + */ jobId: number; + /** + * The new notes for the job. Set to an empty (zero-length) string to clear the job notes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#updateNotes) + */ notes: string; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#updateNotes) + */ user: string; } - export interface JobTaskUpdateRecordParams { + + export interface JobTaskUpdateRecordParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#updateRecord) + */ jobId: number; + /** + * The record to be updated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#updateRecord) + */ record: AuxRecordDescription; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#updateRecord) + */ user: string; } - export interface JobUpdateParameters { + /** + * JobUpdateParameters is a collection of properties that can be updated for jobs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ + export interface JobUpdateParameters extends Object { + /** + * The name of the user that will own the job. Job ownership allows modification of job properties and not workflow execution. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ ownedBy: string; + /** + * The name of the user or group to whom the job will be assigned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ assignedTo: string; + /** + * The unique id of the data workspace of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ dataWorkspaceId: string; + /** + * The description of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ description: string; + /** + * The date on which the job is expected to be complete. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ dueDate: Date; + /** + * The geometry of the job's location of interest (LOI). Supported geometry types include point, multipoint and polygon. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ loi: Geometry; + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ jobId: number; + /** + * The name of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ name: string; + /** + * Indicates whether the job is assigned to a user, group or unassigned. **Possible Values:** unassigned | user | group + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ assignedType: string; + /** + * The unique id of the job that will be designated as the parent job of the new job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ parentJobId: number; + /** + * The name of the geodatabase version that will be the parent version of the new job's version. By default it'll be the parent version of the data workspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ parentVersion: string; + /** + * The percentage of work completed on the job's current step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ percent: number; + /** + * The numeric value to denote priority of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ priority: number; + /** + * The date on which the job is scheduled to begin. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ startDate: Date; + /** + * The unique id of the job's new status. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ status: number; + /** + * The name of the geodatabase version to be used for the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ versionName: string; + /** + * The user name of the user who is requesting the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobUpdateParameters) + */ user: string; } - export interface JobVersionInfo { + /** + * JobVersionInfo represents a collection of properties for a job's version. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobVersionInfo) + */ + export interface JobVersionInfo extends Object { + /** + * The unique id of the data workspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobVersionInfo) + */ dataWorkspaceId: string; + /** + * The name of the data workspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobVersionInfo) + */ name: string; + /** + * The parent version of the geodatabase. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobVersionInfo) + */ parent: string; + /** + * Indicates whether the version has been created or not. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobVersionInfo) + */ created: boolean; + /** + * The name of the version owner. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#JobVersionInfo) + */ owner: string; } - export interface QueryFieldInfo { + /** + * QueryFieldInfo represents a collection of field properties that are returned as part of a query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#QueryFieldInfo) + */ + export interface QueryFieldInfo extends Object { + /** + * The alias name of the field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#QueryFieldInfo) + */ alias: string; + /** + * The field length. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#QueryFieldInfo) + */ length: string; + /** + * The name of the data workspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#QueryFieldInfo) + */ name: string; + /** + * The type of data expected in the field. **Possible Values:** small-integer | integer | single | double | string | date | oid | geometry | blob | raster | guid | global-id | xml + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#QueryFieldInfo) + */ type: string; } - export interface QueryResult { + /** + * QueryResult contains the result of a query after it has been executed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#QueryResult) + */ + export interface QueryResult extends Object { + /** + * An array of fields and field properties in the query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#QueryResult) + */ fields: QueryFieldInfo[]; + /** + * The rows of results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-JobTask.html#QueryResult) + */ rows: string[]; } interface NotificationTask extends Task { + /** + * URL to the ArcGIS Workflow Manager REST service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#url) + */ url: string; + /** + * Creates a new spatial notification change rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#addChangeRule) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.rule The [change rule](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) to be added. + * @param params.user The username requesting the addition of the rule. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ addChangeRule(params: NotificationTaskAddChangeRuleParams, requestOptions?: any): IPromise; + /** + * Deletes a spatial notification change rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#deleteChangeRule) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.ruleId The unique id of the rule to be deleted. + * @param params.user The username requesting the deletion of the rule. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ deleteChangeRule(params: NotificationTaskDeleteChangeRuleParams, requestOptions?: any): IPromise; + /** + * Get an array of all the spatial notification [change rules](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) configured in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#getAllChangeRules) + * + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getAllChangeRules(requestOptions?: any): IPromise; + /** + * Get a single spatial notification [change rule](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) by ruleId. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#getChangeRule) + * + * @param ruleId The unique id of the [change rule](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule). + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getChangeRule(ruleId: string, requestOptions?: any): IPromise; + /** + * Get information about a [match](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRuleMatch) for a change and change rule related to a spatial notification. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#getChangeRuleMatch) + * + * @param matchId The unique id of the spatial notification match. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getChangeRuleMatch(matchId: string, requestOptions?: any): IPromise; + /** + * Get the current time of the database. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#getDatabaseTime) + * + * @param dataWorkspaceId The unique id of the dataWorkspace. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getDatabaseTime(dataWorkspaceId: string, requestOptions?: any): IPromise; + /** + * Get an array of [matches](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRuleMatch) that match the change rule criteria in a specific editing session. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#getSessionMatches) + * + * @param sessionId The unique id of the spatial notification session. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getSessionMatches(sessionId: string, requestOptions?: any): IPromise; + /** + * Sends the notifications configured for the matches found during a rule evaluation session. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#notifySession) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.sessionid The unique id of the spatial notification session. + * @param params.deleteAfter Indicates whether to delete the session matches after sending any notifications. The default is false. + * @param params.user The username requesting the sending of notification. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ notifySession(params: NotificationTaskNotifySessionParams, requestOptions?: any): IPromise; + /** + * Queries the array of spatial notification [change rules](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) based on specified criteria. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#queryChangeRules) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.name A search string to find within change rule names. + * @param params.description A search string to find within change rule descriptions. + * @param params.searchType The type of search to perform, default is contains. **Possible Values:** contains | exact | starts-with | ends-with + * @param params.user The username requesting the search. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ queryChangeRules(params: NotificationTaskQueryChangeRulesParams, requestOptions?: any): IPromise; + /** + * Executes the configured spatial notification change rules on a data workspace by evaluating the geodatabase archive. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#runSpatialNotificationOnHistory) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.dataWorkspaceId The unique id of the dataWorkspace. + * @param params.from The starting time to query for new changes. + * @param params.to The ending time to query for new changes. + * @param params.logMatches Indicates whether to keep the matches found, stored in the ArcGIS Workflow Manager repository. The default is false. + * @param params.send Indicates whether to the send notifications at the time matches are found. The default is false. + * @param params.user The username requesting the execution of the rule. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ runSpatialNotificationOnHistory(params: NotificationTaskRunSpatialNotificationOnHistoryParams, requestOptions?: any): IPromise; + /** + * Sends an email of the specified [notification type](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#sendNotification) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.notificationType The name of the [notification type](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType) to be sent. + * @param params.user The username requesting to send the notification. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ sendNotification(params: NotificationTaskSendNotificationParams, requestOptions?: any): IPromise; + /** + * Adds an email address to the subscriber list for a specific notification type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#subscribeToNotification) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.notificationTypeId The unique id of the notification type to which the email address will be added. + * @param params.email The email address to add to the notification type's subscriber list. May contain tokens. + * @param params.user The username requesting the addition of email address to the notification subscriber's list. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ subscribeToNotification(params: NotificationTaskSubscribeToNotificationParams, requestOptions?: any): IPromise; + /** + * Removes an email address from the subscriber list for a specific notification type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#unsubscribeFromNotification) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.notificationTypeId The unique id of the notification type from which the email address will be removed. + * @param params.email The email address to remove from the notification type's subscriber list. May contain tokens. + * @param params.user The username requesting the removal of email address to the notification subscriber's list. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ unsubscribeFromNotification(params: NotificationTaskUnsubscribeFromNotificationParams, requestOptions?: any): IPromise; } interface NotificationTaskConstructor { + /** + * Exposes functions to perform operations with Workflow Manager notifications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html) + */ + new(properties?: NotificationTaskProperties): NotificationTask; } export const NotificationTask: NotificationTaskConstructor; interface NotificationTaskProperties extends TaskProperties { + /** + * URL to the ArcGIS Workflow Manager REST service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#url) + */ url?: string; } - export interface AOIEvaluator { + /** + * AOIEvaluator represents the rules that triggers a spatial notification based on area of interest(AOI). This contains the geometric operation and the criteria to be used based on the AOI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#AOIEvaluator) + */ + export interface AOIEvaluator extends Object { + /** + * The area of interest. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#AOIEvaluator) + */ aoi: Polygon; + /** + * Indicates whether to inverse the spatial relationship or not. For example, if the spatial relationship is inversed for operator Within, then features that are not within will be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#AOIEvaluator) + */ inverse: boolean; + /** + * The name of the AOI evaluator. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#AOIEvaluator) + */ name: string; + /** + * The spatial relationship to be applied for evaluation of the rule. **Possible Values:** intersects | contains | crosses | envelope-intersects | index-intersects | overlaps | touches | within | relation + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#AOIEvaluator) + */ relation: string; + /** + * The type of the AOI evaluator. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#AOIEvaluator) + */ type: string; + /** + * Indicates whether job AOI should be used as the extent or not for the evaluation of the rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#AOIEvaluator) + */ useJobAOI: boolean; } - export interface ChangeRule { + /** + * ChangeRule represents a single change rule that triggers a spatial notification. When the criteria defined in the rule is met an email notification is sent to recipients. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) + */ + export interface ChangeRule extends Object { + /** + * The description of the change rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) + */ description: string; + /** + * An array of [AOI](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#AOIEvaluator) and [Dataset](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DataSetEvaluator) evaluators. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) + */ evaluators: any[]; + /** + * The unique id of the change rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) + */ id: number; + /** + * The name of the change rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) + */ name: string; + /** + * The type of notifier, the default is [email notifier](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#EmailNotifier). This can be extended to use your own notifiers like SMS, instant messaging. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) + */ notifier: any; + /** + * Indicates whether to summarize email contents or not. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) + */ summarize: boolean; } - export interface ChangeRuleMatch { + /** + * ChangeRuleMatch represents information about the change and change rule related to a spatial notification match. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRuleMatch) + */ + export interface ChangeRuleMatch extends Object { + /** + * The time the change occured to the data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRuleMatch) + */ changeTime: Date; + /** + * The type of change that happened to the data. **Possible Values:** add | modify | delete | all + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRuleMatch) + */ changeType: string; + /** + * The dataset that changed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRuleMatch) + */ dataset: string; + /** + * The unique id of the data workspace containing the changed data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRuleMatch) + */ dataWorkspaceId: string; + /** + * The unique id of the associated to the change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRuleMatch) + */ id: string; + /** + * The unique id of the job where the change was made. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRuleMatch) + */ jobID: string; + /** + * The unique id of the change rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRuleMatch) + */ ruleID: string; } - export interface DatasetConfiguration { + /** + * DatasetConfiguration represents the criteria and dataset that the change rule applies to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DatasetConfiguration) + */ + export interface DatasetConfiguration extends Object { + /** + * This indicates whether the notification will be sent always or if values change to defined in whereConditions or if values change from defined in whereConditions. **Possible Values:** always | changed-to | changed-from + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DatasetConfiguration) + */ changeCondition: number; + /** + * The name of the fields, changes to which trigger the notification. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DatasetConfiguration) + */ changeFields: string; + /** + * The name of the dataset that will trigger the notification. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DatasetConfiguration) + */ dataset: string; + /** + * The unique id of the data workspace containing the changed data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DatasetConfiguration) + */ dataWorkspaceId: string; + /** + * The name of the dataset configuration rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DatasetConfiguration) + */ name: string; + /** + * The [where conditions](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#WhereCondition) defining the criteria to trigger the rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DatasetConfiguration) + */ whereConditions: WhereCondition[]; } - export interface DataSetEvaluator { + /** + * DataSetEvaluator represents the rules that triggers a spatial notification based on the changes in a dataset. This contains the specific features and feature class that are participating in a spatial notification rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DataSetEvaluator) + */ + export interface DataSetEvaluator extends Object { + /** + * The array of [DatasetConfigurations](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DatasetConfiguration) representing the dataset to which the rule applies. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DataSetEvaluator) + */ dataSetConfigurations: DatasetConfiguration[]; + /** + * The name of the dataset evaluator. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DataSetEvaluator) + */ name: string; + /** + * The type of the dataset evaluator. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DataSetEvaluator) + */ type: string; } - export interface EmailNotifier { + /** + * EmailNotifier represents the properties of a notification type that is configured in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#EmailNotifier) + */ + export interface EmailNotifier extends Object { + /** + * Indicates whether the job's file attachment will be attached to the email. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#EmailNotifier) + */ attachJobAttachments: boolean; + /** + * The message content sent as part of the email. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#EmailNotifier) + */ message: string; + /** + * The name of the notifier. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#EmailNotifier) + */ name: string; + /** + * The sender's (from) email address. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#EmailNotifier) + */ senderEmail: string; + /** + * The sender's (from) name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#EmailNotifier) + */ senderName: string; + /** + * The subject of the email. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#EmailNotifier) + */ subject: string; + /** + * The array of subscribers who will get the email. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#EmailNotifier) + */ subscribers: string[]; + /** + * The type of notifier. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#EmailNotifier) + */ type: string; } - export interface NotificationTaskAddChangeRuleParams { + + export interface NotificationTaskAddChangeRuleParams extends Object { + /** + * The [change rule](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#ChangeRule) to be added. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#addChangeRule) + */ rule: ChangeRule; + /** + * The username requesting the addition of the rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#addChangeRule) + */ user: string; } - export interface NotificationTaskDeleteChangeRuleParams { + + export interface NotificationTaskDeleteChangeRuleParams extends Object { + /** + * The unique id of the rule to be deleted. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#deleteChangeRule) + */ ruleId: string; + /** + * The username requesting the deletion of the rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#deleteChangeRule) + */ user: string; } - export interface NotificationTaskNotifySessionParams { + + export interface NotificationTaskNotifySessionParams extends Object { + /** + * The unique id of the spatial notification session. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#notifySession) + */ sessionid: string; + /** + * Indicates whether to delete the session matches after sending any notifications. The default is false. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#notifySession) + */ deleteAfter: boolean; + /** + * The username requesting the sending of notification. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#notifySession) + */ user: string; } - export interface NotificationTaskQueryChangeRulesParams { + + export interface NotificationTaskQueryChangeRulesParams extends Object { + /** + * A search string to find within change rule names. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#queryChangeRules) + */ name: string; + /** + * A search string to find within change rule descriptions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#queryChangeRules) + */ description: string; + /** + * The type of search to perform, default is contains. **Possible Values:** contains | exact | starts-with | ends-with + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#queryChangeRules) + */ searchType: string; + /** + * The username requesting the search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#queryChangeRules) + */ user: string; } - export interface NotificationTaskRunSpatialNotificationOnHistoryParams { + + export interface NotificationTaskRunSpatialNotificationOnHistoryParams extends Object { + /** + * The unique id of the dataWorkspace. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#runSpatialNotificationOnHistory) + */ dataWorkspaceId: string; + /** + * The starting time to query for new changes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#runSpatialNotificationOnHistory) + */ from: Date; + /** + * The ending time to query for new changes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#runSpatialNotificationOnHistory) + */ to: Date; + /** + * Indicates whether to keep the matches found, stored in the ArcGIS Workflow Manager repository. The default is false. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#runSpatialNotificationOnHistory) + */ logMatches: boolean; + /** + * Indicates whether to the send notifications at the time matches are found. The default is false. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#runSpatialNotificationOnHistory) + */ send: boolean; + /** + * The username requesting the execution of the rule. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#runSpatialNotificationOnHistory) + */ user: string; } - export interface NotificationTaskSendNotificationParams { + + export interface NotificationTaskSendNotificationParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#sendNotification) + */ jobId: number; + /** + * The name of the [notification type](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType) to be sent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#sendNotification) + */ notificationType: string; + /** + * The username requesting to send the notification. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#sendNotification) + */ user: string; } - export interface NotificationTaskSubscribeToNotificationParams { + + export interface NotificationTaskSubscribeToNotificationParams extends Object { + /** + * The unique id of the notification type to which the email address will be added. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#subscribeToNotification) + */ notificationTypeId: number; + /** + * The email address to add to the notification type's subscriber list. May contain tokens. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#subscribeToNotification) + */ email: string; + /** + * The username requesting the addition of email address to the notification subscriber's list. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#subscribeToNotification) + */ user: string; } - export interface NotificationTaskUnsubscribeFromNotificationParams { + + export interface NotificationTaskUnsubscribeFromNotificationParams extends Object { + /** + * The unique id of the notification type from which the email address will be removed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#unsubscribeFromNotification) + */ notificationTypeId: number; + /** + * The email address to remove from the notification type's subscriber list. May contain tokens. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#unsubscribeFromNotification) + */ email: string; + /** + * The username requesting the removal of email address to the notification subscriber's list. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#unsubscribeFromNotification) + */ user: string; } - export interface NotificationType { + /** + * NotificationType represents the properties of a notification type that are sent when certain events happen in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType) + */ + export interface NotificationType extends Object { + /** + * Indicates whether the job's file attachment will be attached to the email. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType) + */ attachJobAttachments: boolean; + /** + * The unique id of the notification type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType) + */ id: number; + /** + * The message content sent as part of the email. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType) + */ message: string; + /** + * The sender's (from) email address. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType) + */ senderEmail: string; + /** + * The sender's (from) name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType) + */ senderName: string; + /** + * The subject of the email. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType) + */ subject: string; + /** + * The array of subscribers who will get the email. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType) + */ subscribers: string[]; + /** + * The type of notifier. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#NotificationType) + */ type: string; } - export interface WhereCondition { + /** + * WhereCondition returns the condition set in [DatasetConfiguration](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DatasetConfiguration) for a [Dataset](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#DataSetEvaluator) evaluator. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#WhereCondition) + */ + export interface WhereCondition extends Object { + /** + * The value to be compared/evaluated with. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#WhereCondition) + */ compareValue: any; + /** + * The field name that contains the value to be compared. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#WhereCondition) + */ field: string; + /** + * The operator to be used for comparison. **Possible Values:** equal | not-equal | greater-than | greater-or-equal | less-than | less-or-equal | contains + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-NotificationTask.html#WhereCondition) + */ operator: string; } interface ReportTask extends Task { + /** + * URL to the ArcGIS Workflow Manager REST service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#url) + */ url: string; + /** + * Generates a report and returns the output as formatted HTML. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#generateReport) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.reportId The id of the report. + * @param params.user The user name requesting the report. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ generateReport(params: ReportTaskGenerateReportParams, requestOptions?: any): IPromise; + /** + * Gets all the [reports](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#Report) that are configured in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#getAllReports) + * + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getAllReports(requestOptions?: any): IPromise; + /** + * Returns the URL string for the report content. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#getReportContentUrl) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.reportId The id of the report. + * @param params.user The username of the user requesting the report content. + * + */ getReportContentUrl(params: ReportTaskGetReportContentUrlParams): string; + /** + * Executes a report and returns the raw [report data](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportData). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#getReportData) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.reportId The id of the report. + * @param params.user The username of the user requesting the report data. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getReportData(params: ReportTaskGetReportDataParams, requestOptions?: any): IPromise; + /** + * Gets the XSLT stylesheet for the specified report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#getReportStylesheet) + * + * @param reportId The id of the report. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getReportStylesheet(reportId: number, requestOptions?: any): IPromise; } interface ReportTaskConstructor { + /** + * Helps you generate reports about the work being managed in your Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html) + */ + new(properties?: ReportTaskProperties): ReportTask; } export const ReportTask: ReportTaskConstructor; interface ReportTaskProperties extends TaskProperties { + /** + * URL to the ArcGIS Workflow Manager REST service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#url) + */ url?: string; } - export interface Report { + /** + * Report represents a configured report in the Workflow Manager system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#Report) + */ + export interface Report extends Object { + /** + * A description of the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#Report) + */ description: string; + /** + * The category to which the report belongs in the system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#Report) + */ hierarchy: string; + /** + * A unique id for the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#Report) + */ id: number; + /** + * The name of the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#Report) + */ name: string; + /** + * The title of the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#Report) + */ title: string; } - export interface ReportData { + /** + * ReportData is the generated result of a report after it has been executed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportData) + */ + export interface ReportData extends Object { + /** + * The name of columns returned as part of the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportData) + */ columns: string[]; + /** + * A description of the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportData) + */ description: string; + /** + * The [aggregation of the report data](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportDataGroup) into subcategories. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportData) + */ groups: ReportDataGroup[]; + /** + * The title of the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportData) + */ title: string; } - export interface ReportDataGroup { + /** + * ReportDataGroup aggregates the report results into user defined categories. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportDataGroup) + */ + export interface ReportDataGroup extends Object { + /** + * The label of the aggregate category as defined in the report, eg. Total Jobs. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportDataGroup) + */ aggregateLabel: string; + /** + * The value of the aggregate category based on the calculation defined in the report section options. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportDataGroup) + */ aggregateValue: string; + /** + * The rows containing the data returned in the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportDataGroup) + */ row: string[]; + /** + * The data value based on which the section is created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#ReportDataGroup) + */ value: string; } - export interface ReportTaskGenerateReportParams { + + export interface ReportTaskGenerateReportParams extends Object { + /** + * The id of the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#generateReport) + */ reportId: number; + /** + * The user name requesting the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#generateReport) + */ user: string; } - export interface ReportTaskGetReportContentUrlParams { + + export interface ReportTaskGetReportContentUrlParams extends Object { + /** + * The id of the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#getReportContentUrl) + */ reportId: number; + /** + * The username of the user requesting the report content. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#getReportContentUrl) + */ user: number; } - export interface ReportTaskGetReportDataParams { + + export interface ReportTaskGetReportDataParams extends Object { + /** + * The id of the report. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#getReportData) + */ reportId: number; + /** + * The username of the user requesting the report data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-ReportTask.html#getReportData) + */ user: string; } interface TokenTask extends Task { + /** + * Parses a string with embedded tokens using user and job information. The string is returned with embedded tokens replaced by their actual values. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-TokenTask.html#parseTokens) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId A unique id for the job. + * @param params.stringToParse The string representing the tokens to be parsed. + * @param params.user The username of the user requesting token parsing. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ parseTokens(params: TokenTaskParseTokensParams, requestOptions?: any): IPromise; } interface TokenTaskConstructor { + /** + * Helps you parse Workflow Manager tokens to the actual value of tokens in the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-TokenTask.html) + */ + new(properties?: TokenTaskProperties): TokenTask; } @@ -7989,217 +34230,1033 @@ declare namespace __esri { } - export interface TokenTaskParseTokensParams { + + export interface TokenTaskParseTokensParams extends Object { + /** + * A unique id for the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-TokenTask.html#parseTokens) + */ jobId: any; + /** + * The string representing the tokens to be parsed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-TokenTask.html#parseTokens) + */ stringToParse: string; + /** + * The username of the user requesting token parsing. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-TokenTask.html#parseTokens) + */ user: string; } interface WorkflowTask extends Task { + /** + * URL to the ArcGIS Workflow Manager REST service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#url) + */ url: string; + /** + * Get the information which indicates whether this workflow step can be run. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#canRunStep) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.stepId The unique id of the step. + * @param params.user The user name of the user wanting to run the step. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ canRunStep(params: WorkflowTaskCanRunStepParams, requestOptions?: any): IPromise; + /** + * Executes the specified steps in order and gets back [execution information](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) of the steps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#executeSteps) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.stepIds The array of unique step Ids. + * @param params.auto Indicates whether to automatically execute as many steps as possible, based on the workflow configuration. The default is false, to execute only the current step. + * @param params.user The user name of the user executing the step. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ executeSteps(params: WorkflowTaskExecuteStepsParams, requestOptions?: any): IPromise; + /** + * Gets all workflow [steps](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) of a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getAllSteps) + * + * @param jobId The unique id of the job. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getAllSteps(jobId: number, requestOptions?: any): IPromise; + /** + * Gets all current [steps](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) of a job. A workflow will have more than one current step if it is configured to support parallel steps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getCurrentSteps) + * + * @param jobId The unique id of the job. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getCurrentSteps(jobId: number, requestOptions?: any): IPromise; + /** + * Gets a specific workflow [step](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) of a job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getStep) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.stepId The unique id of the step. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getStep(params: WorkflowTaskGetStepParams, requestOptions?: any): IPromise; + /** + * Get the help associated with a workflow step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getStepDescription) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.stepId The unique id of the step. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getStepDescription(params: WorkflowTaskGetStepDescriptionParams, requestOptions?: any): IPromise; + /** + * Gets a URL to access the file content of a file step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getStepFileUrl) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.stepId The unique id of the step. + * + */ getStepFileUrl(params: WorkflowTaskGetStepFileUrlParams): string; + /** + * Get a job's [workflow display details](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowDisplayDetails). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getWorkflowDisplayDetails) + * + * @param jobId The unique id of the job. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ getWorkflowDisplayDetails(jobId: number, requestOptions?: any): IPromise; + /** + * Gets a URL of an image depicting the current state of a job's workflow. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getWorkflowImageUrl) + * + * @param jobId The unique id of the job. + * + */ getWorkflowImageUrl(jobId: number): string; + /** + * Marks the specified steps of a job workflow as completed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#markStepsAsDone) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.stepIds The array of unique step Ids. + * @param params.user The user name of the user marking the step complete. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ markStepsAsDone(params: WorkflowTaskMarkStepsAsDoneParams, requestOptions?: any): IPromise; + /** + * Advances the workflow to the next step based on a return code value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#moveToNextStep) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job Id. + * @param params.stepId The unique id of the step. + * @param params.returnCode A numeric value representing the return code. + * @param params.user The user name of the user advancing the workflow to the next step. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ moveToNextStep(params: WorkflowTaskMoveToNextStepParams, requestOptions?: any): IPromise; + /** + * The job workflow is updated with the latest workflow of job type, after the job has been created. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#recreateWorkflow) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.user The user name of the user recreating the workflow. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ recreateWorkflow(params: WorkflowTaskRecreateWorkflowParams, requestOptions?: any): IPromise; + /** + * Resolves workflow path conflicts resulting from executing or marking as complete a step, which can have two or more next steps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#resolveConflict) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.stepId The unique id of the step. + * @param params.optionReturnCode A numeric value representing the return code from the step where the conflict was encountered. + * @param params.optionStepIds An array of unique step IDs of all the possible next steps. + * @param params.user The user name of the user resolving the conflict. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ resolveConflict(params: WorkflowTaskResolveConflictParams, requestOptions?: any): IPromise; + /** + * Sets a step as the current active step of a job workflow. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#setCurrentStep) + * + * @param params See the object specifications in table below for the structure of the `params` object. + * @param params.jobId The unique id of the job. + * @param params.stepId The unique id of the step. + * @param params.user The user name of the user setting the current step. + * @param requestOptions Additional [options](https://developers.arcgis.com/javascript/latest/api-reference/esri-request.html#esriRequest) to be used for the data request (will override requestOptions defined during construction). + * + */ setCurrentStep(params: WorkflowTaskSetCurrentStepParams, requestOptions?: any): IPromise; } interface WorkflowTaskConstructor { + /** + * Class to perform operations on Workflow Manager workflows and steps. The workflows are collections of steps that are executed while working on a job. Workflows are designed to organize and simplify tasks to ensure that no step is missed. The steps are the building blocks of your workflows and are connected using paths. Step and path properties determine the flow of the work. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html) + */ + new(properties?: WorkflowTaskProperties): WorkflowTask; } export const WorkflowTask: WorkflowTaskConstructor; interface WorkflowTaskProperties extends TaskProperties { + /** + * URL to the ArcGIS Workflow Manager REST service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#url) + */ url?: string; } - export interface ExecuteInfo { + /** + * ExecuteInfo provides information on whether a step can be executed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) + */ + export interface ExecuteInfo extends Object { + /** + * Information about [conflicts](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowConflicts) in workflow step progression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) + */ conflicts: WorkflowConflicts; + /** + * The error code returned by the steps in the workflow. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) + */ errorCode: number; + /** + * The description for the errors returned by the steps in the workflow. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) + */ errorDescription: string; + /** + * The result of a step execution. **Possible Values:** executed | dependent-on-step | dependent-on-stage | dependent-on-status | job-on-hold | step-depends-on-step | check | step-assigned-to-other-user | step-assigned-to-other-group | job-assigned-to-others | job-closed | invalid-platform | invalid-step | dependent-on-job | not-current-step + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) + */ executionResult: string; + /** + * Indicates whether a step has conflicts. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) + */ hasConflicts: boolean; + /** + * Indicates whether a step has return code. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) + */ hasReturnCode: boolean; + /** + * The unique id of current job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) + */ jobID: number; + /** + * The return code for the current workflow step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) + */ returnCode: number; + /** + * The unique id of the current step in the workflow. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) + */ stepID: number; + /** + * Indicates whether the step threw an error during execution. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#ExecuteInfo) + */ threwError: boolean; } - export interface Step { + /** + * Step retpresents the properties of a step that is used in a job's workflow. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ + export interface Step extends Object { + /** + * Indicates whether the step has already been executed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ hasBeenExecuted: boolean; + /** + * The user or group to whom the step is assigned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ assignedTo: string; + /** + * Indicates whether the step can be run asynchronously. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ async: boolean; + /** + * Indicates whether the step can be automatically executed when reached. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ autoRun: boolean; + /** + * Indicates whether the step can be skipped without executing it. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ canSkip: boolean; + /** + * Indicates whether the step can start parallel execution of other steps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ canSpawnConcurrency: boolean; + /** + * The unique id of step type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ commonId: number; + /** + * The default percentage completion of the job once step is reached. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ defaultPercentComplete: number; + /** + * Indicates whether the job is assigned to a user, group or unassigned. **Possible Values:** none | unassigned | user | group + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ assignedType: string; + /** + * Indicates whether the step has been started. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ hasBeenStarted: boolean; + /** + * The unique id generated as the step Id. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ id: number; + /** + * The name of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ name: string; + /** + * Indicates whether the step will be automatically marked as complete when complete. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ selfCheck: boolean; + /** + * The unique numeric status value configured as the status of the job once step is reached. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ statusId: number; + /** + * The percentage completion of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ stepPercentComplete: number; + /** + * The type of notification that will be sent when the step finishes execution. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ notificationType: string; + /** + * The [step template](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) for current step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#Step) + */ stepType: StepType; } - export interface StepType { + /** + * StepType represents properties of step templates that are available in the Workflow Manager system for authoring workflows. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ + export interface StepType extends Object { + /** + * The program/application/code that will be executed on this step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ program: string; + /** + * The step arguments required at runtime. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ arguments: string; + /** + * The type of execution for the step. **Possible Values:** executable | function | procedural | launch-url | question | open-file + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ executionType: string; + /** + * The unique id for the step type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ id: number; + /** + * The name of the step type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ name: string; + /** + * The description of the step type. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ description: string; + /** + * The path/URL of the step description. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ stepDescriptionLink: string; + /** + * The type of step description. **Possible Values:** none | embedded-html | link + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ stepDescriptionType: string; + /** + * The shape of the step as it will appear in a workflow graphic. **Possible Values:** rounded-rectangle | rectangle | oval | diamond | parallelogram + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ stepIndicatorType: string; + /** + * The platform on which the step can be executed. **Possible Values:** desktop | server | both + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ supportedPlatform: string; + /** + * Indicates whether Workflow Manager will be minimized and hidden during step execution. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#StepType) + */ visible: boolean; } - export interface WorkflowAnnotationDisplayDetails { + /** + * WorkflowAnnotationDisplayDetails represents properties of a workflow annotation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowAnnotationDisplayDetails) + */ + export interface WorkflowAnnotationDisplayDetails extends Object { + /** + * The X coordinate of the annotation object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowAnnotationDisplayDetails) + */ centerX: number; + /** + * The Y coordinate of the annotation object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowAnnotationDisplayDetails) + */ centerY: number; + /** + * The fill color of the annotation object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowAnnotationDisplayDetails) + */ fillColor: Color; + /** + * The height of the annotation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowAnnotationDisplayDetails) + */ height: number; + /** + * The annotation text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowAnnotationDisplayDetails) + */ label: string; + /** + * The color of annotation label text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowAnnotationDisplayDetails) + */ labelColor: Color; + /** + * The outline color. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowAnnotationDisplayDetails) + */ OutlineColor: Color; + /** + * The width of the annotation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowAnnotationDisplayDetails) + */ width: number; } - export interface WorkflowConflicts { + /** + * WorkflowConflicts represents properties for workflows that have a conflicting path or multiple possible paths for progression. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowConflicts) + */ + export interface WorkflowConflicts extends Object { + /** + * The unique id of currently active job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowConflicts) + */ jobID: number; + /** + * The information about the step in the workflow returned as [WorkflowOption](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowOption). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowConflicts) + */ options: WorkflowOption[]; + /** + * Indicates whether the step will begin a concurrent path in the workflow. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowConflicts) + */ spawnsConcurrency: boolean; + /** + * The unique id of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowConflicts) + */ stepId: number; } - export interface WorkflowDisplayDetails { + /** + * WorkflowDisplayDetails represents a collection of properties that constitute a workflow - annotations, steps, and paths. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowDisplayDetails) + */ + export interface WorkflowDisplayDetails extends Object { + /** + * The properties of how the [annotations are displayed](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowAnnotationDisplayDetails). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowDisplayDetails) + */ annotations: WorkflowAnnotationDisplayDetails[]; + /** + * The properties of how the [path are displayed](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowPathDisplayDetails). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowDisplayDetails) + */ paths: WorkflowPathDisplayDetails[]; + /** + * The properties of how the [step are displayed](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowDisplayDetails) + */ steps: WorkflowStepDisplayDetails[]; } - export interface WorkflowOption { + /** + * WorkflowOption represents properties of a workflow that have return codes and step branches. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowOption) + */ + export interface WorkflowOption extends Object { + /** + * The return code generated from a step execution. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowOption) + */ returnCode: number; + /** + * The collection of [descriptions for workflow steps](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepInfo). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowOption) + */ steps: WorkflowStepInfo[]; } - export interface WorkflowPathDisplayDetails { + /** + * WorkflowPathDisplayDetails represents properties of a workflow's path properties like location, destination steps, postion on the workflow canvas. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowPathDisplayDetails) + */ + export interface WorkflowPathDisplayDetails extends Object { + /** + * The unique id of the step to which the path will lead. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowPathDisplayDetails) + */ destStepId: number; + /** + * The unique id of the step just executed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowPathDisplayDetails) + */ sourceStepID: number; + /** + * The label associated with the path. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowPathDisplayDetails) + */ label: string; + /** + * The color of the label on the path. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowPathDisplayDetails) + */ labelColor: Color; + /** + * The X coordinate of the label. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowPathDisplayDetails) + */ labelX: number; + /** + * The Y coordinate of the label. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowPathDisplayDetails) + */ labelY: number; + /** + * The color of the line representing the path. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowPathDisplayDetails) + */ lineColor: Color; + /** + * An object with following properties. + * + * Name | Type | Description + * ---------|--------|------------- + * isDefault | Boolean | Indicates whehter this is the default path(only path) from the source step. + * numReturnValues | Number[] | The number of possible return values for the path. + * returnValueX | Number[] | The return values associated with the path. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowPathDisplayDetails) + */ pathObject: any; } - export interface WorkflowStepDisplayDetails { + /** + * WorkflowStepDisplayDetails represents properties of a workflow step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ + export interface WorkflowStepDisplayDetails extends Object { + /** + * The color of step label text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ labelColor: Color; + /** + * The X coordinate of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ centerX: number; + /** + * The fill color of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ fillColor: Color; + /** + * The height of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ height: number; + /** + * The step text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ label: string; + /** + * The Y coordinate of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ centerY: number; + /** + * The outline color. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ OutlineColor: Color; + /** + * The shape of the step. **Possible Values:** rounded-rectangle | rectangle | oval | diamond | parallelogram + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ shape: string; + /** + * The unique id of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ stepId: number; + /** + * The step execution type. **Possible Values:** executable | function | procedural | launch-url | question | open-file + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ stepType: string; + /** + * The width of the annotation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepDisplayDetails) + */ width: number; } - export interface WorkflowStepInfo { + /** + * WorkflowStepInfo represents collection of descriptions for workflow's steps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepInfo) + */ + export interface WorkflowStepInfo extends Object { + /** + * The unique id of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepInfo) + */ id: number; + /** + * The name of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#WorkflowStepInfo) + */ name: string; } - export interface WorkflowTaskCanRunStepParams { + + export interface WorkflowTaskCanRunStepParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#canRunStep) + */ jobId: number; + /** + * The unique id of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#canRunStep) + */ stepId: number; + /** + * The user name of the user wanting to run the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#canRunStep) + */ user: string; } - export interface WorkflowTaskExecuteStepsParams { + + export interface WorkflowTaskExecuteStepsParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#executeSteps) + */ jobId: number; + /** + * The array of unique step Ids. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#executeSteps) + */ stepIds: number[]; + /** + * Indicates whether to automatically execute as many steps as possible, based on the workflow configuration. The default is false, to execute only the current step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#executeSteps) + */ auto: boolean; + /** + * The user name of the user executing the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#executeSteps) + */ user: string; } - export interface WorkflowTaskGetStepDescriptionParams { + + export interface WorkflowTaskGetStepDescriptionParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getStepDescription) + */ jobId: number; + /** + * The unique id of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getStepDescription) + */ stepId: number; } - export interface WorkflowTaskGetStepFileUrlParams { + + export interface WorkflowTaskGetStepFileUrlParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getStepFileUrl) + */ jobId: number; + /** + * The unique id of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getStepFileUrl) + */ stepId: number; } - export interface WorkflowTaskGetStepParams { + + export interface WorkflowTaskGetStepParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getStep) + */ jobId: number; + /** + * The unique id of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#getStep) + */ stepId: number; } - export interface WorkflowTaskMarkStepsAsDoneParams { + + export interface WorkflowTaskMarkStepsAsDoneParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#markStepsAsDone) + */ jobId: number; + /** + * The array of unique step Ids. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#markStepsAsDone) + */ stepIds: number[]; + /** + * The user name of the user marking the step complete. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#markStepsAsDone) + */ user: string; } - export interface WorkflowTaskMoveToNextStepParams { + + export interface WorkflowTaskMoveToNextStepParams extends Object { + /** + * The unique id of the job Id. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#moveToNextStep) + */ jobId: number; + /** + * The unique id of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#moveToNextStep) + */ stepId: number; + /** + * A numeric value representing the return code. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#moveToNextStep) + */ returnCode: number; + /** + * The user name of the user advancing the workflow to the next step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#moveToNextStep) + */ user: string; } - export interface WorkflowTaskRecreateWorkflowParams { + + export interface WorkflowTaskRecreateWorkflowParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#recreateWorkflow) + */ jobId: number; + /** + * The user name of the user recreating the workflow. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#recreateWorkflow) + */ user: string; } - export interface WorkflowTaskResolveConflictParams { + + export interface WorkflowTaskResolveConflictParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#resolveConflict) + */ jobId: number; + /** + * The unique id of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#resolveConflict) + */ stepId: number; + /** + * A numeric value representing the return code from the step where the conflict was encountered. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#resolveConflict) + */ optionReturnCode: number; + /** + * An array of unique step IDs of all the possible next steps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#resolveConflict) + */ optionStepIds: number[]; + /** + * The user name of the user resolving the conflict. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#resolveConflict) + */ user: string; } - export interface WorkflowTaskSetCurrentStepParams { + + export interface WorkflowTaskSetCurrentStepParams extends Object { + /** + * The unique id of the job. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#setCurrentStep) + */ jobId: number; + /** + * The unique id of the step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#setCurrentStep) + */ stepId: number; + /** + * The user name of the user setting the current step. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-workflow-WorkflowTask.html#setCurrentStep) + */ user: string; } interface Viewpoint extends Accessor, JSONSupport { + /** + * The viewpoint camera (3D only). + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#camera) + */ camera: Camera; + /** + * The rotation of due north in relation to the top of the view in degrees. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#rotation) + * + * @default 0 + */ rotation: number; + /** + * The scale of the viewpoint. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#scale) + */ scale: number; + /** + * The target geometry framed by the viewpoint. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#targetGeometry) + */ targetGeometry: Geometry; + /** + * Create a deep clone of the viewpoint. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#clone) + * + * + */ clone(): Viewpoint; } interface ViewpointConstructor { + + new(properties?: ViewpointProperties): Viewpoint; fromJSON(json: any): Viewpoint; @@ -8208,303 +35265,1164 @@ declare namespace __esri { export const Viewpoint: ViewpointConstructor; interface ViewpointProperties { + /** + * The viewpoint camera (3D only). + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#camera) + */ camera?: CameraProperties; + /** + * The rotation of due north in relation to the top of the view in degrees. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#rotation) + * + * @default 0 + */ rotation?: number; + /** + * The scale of the viewpoint. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#scale) + */ scale?: number; + /** + * The target geometry framed by the viewpoint. + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#targetGeometry) + */ targetGeometry?: GeometryProperties; } interface Draw extends Accessor { - activeAction: PointDrawAction | PolygonDrawAction | PolylineDrawAction; + /** + * A reference to the active draw action. An instance of the draw action is created when [create()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-Draw.html#create) method is called. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-Draw.html#activeAction) + */ + activeAction: PointDrawAction | MultipointDrawAction | PolygonDrawAction | PolylineDrawAction; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). Set this to link the draw to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-Draw.html#view) + */ view: MapView; - create(drawAction: string): PointDrawAction | PolygonDrawAction | PolylineDrawAction; + /** + * Creates an instance of the requested draw action. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-Draw.html#create) + * + * @param drawAction Name of the draw action to create. See the table below for a list of known values and type of draw action it creates. **Known Values:** point | multipoint | polyline | polygon + * + */ + create(drawAction: string): PointDrawAction | MultipointDrawAction | PolylineDrawAction | PolygonDrawAction; + /** + * Resets the drawing by clearing the active action. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-Draw.html#reset) + * + * + */ + reset(): void; } interface DrawConstructor { + /** + * The Draw class provides advanced drawing capabilities for developers who need complete control over creating temporary geometries. For example, if you want to prevent users from drawing self-intersecting lines or overlapping polygons, then you can use this class to implement these rules. The draw experience is built upon draw actions, which use the view events to generate a set of coordinates for creating new geometries. Each geometry type has a corresponding draw action class. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-Draw.html) + */ + new(properties?: DrawProperties): Draw; } export const Draw: DrawConstructor; interface DrawProperties { - activeAction?: PointDrawActionProperties | PolygonDrawActionProperties | PolylineDrawActionProperties; + /** + * A reference to the active draw action. An instance of the draw action is created when [create()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-Draw.html#create) method is called. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-Draw.html#activeAction) + */ + activeAction?: PointDrawActionProperties | MultipointDrawActionProperties | PolygonDrawActionProperties | PolylineDrawActionProperties; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). Set this to link the draw to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-Draw.html#view) + */ view?: MapViewProperties; } - interface PointDrawAction extends Accessor, Evented { + interface MultipointDrawAction extends Accessor, Evented { + /** + * Two-dimensional array of numbers representing the coordinates of each vertex that comprises the drawn geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#vertices) + */ + readonly vertices: number[][]; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#view) + */ view: MapView; + /** + * Indicates if the [redo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#redo) method can be called on the action instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#canRedo) + * + * + */ + canRedo(): boolean; + /** + * Indicates if the [undo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#undo) method can be called on the action instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#canUndo) + * + * + */ + canUndo(): boolean; + /** + * Completes drawing the [multipoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html) geometry and fires the [draw-complete](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#event:draw-complete) event. Call this method if the drawing logic needs to be completed other than by double-clicking or pressing the "C" key. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#complete) + * + * + */ + complete(): void; + /** + * Incrementally redo actions recorded in the stack. Call [canRedo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#canRedo) prior to calling this method to check if this method can be called on the action instance. Calling this method will fire the [vertex-add](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#event:vertex-add) or [vertex-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#event:vertex-remove) event depending on the last action. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#redo) + * + * + */ + redo(): void; + /** + * Incrementally undo actions recorded in the stack. Call [canUndo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#canUndo) prior to calling this method to check if this method can be called on the action instance. Calling this method will fire the [vertex-add](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#event:vertex-add) or [vertex-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#event:vertex-remove) event depending on the last action. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#undo) + * + * + */ + undo(): void; + + + on(name: "cursor-update", eventHandler: MultipointDrawActionCursorUpdateEventHandler): IHandle; + + on(name: "cursor-update", modifiers: string[], eventHandler: MultipointDrawActionCursorUpdateEventHandler): IHandle; + + on(name: "vertex-add", eventHandler: MultipointDrawActionVertexAddEventHandler): IHandle; + + on(name: "vertex-add", modifiers: string[], eventHandler: MultipointDrawActionVertexAddEventHandler): IHandle; + + on(name: "vertex-remove", eventHandler: MultipointDrawActionVertexRemoveEventHandler): IHandle; + + on(name: "vertex-remove", modifiers: string[], eventHandler: MultipointDrawActionVertexRemoveEventHandler): IHandle; + + on(name: "draw-complete", eventHandler: MultipointDrawActionDrawCompleteEventHandler): IHandle; + + on(name: "draw-complete", modifiers: string[], eventHandler: MultipointDrawActionDrawCompleteEventHandler): IHandle; + } + + interface MultipointDrawActionConstructor { + + + new(properties?: MultipointDrawActionProperties): MultipointDrawAction; + } + + export const MultipointDrawAction: MultipointDrawActionConstructor; + + interface MultipointDrawActionProperties { + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-MultipointDrawAction.html#view) + */ + view?: MapViewProperties; + } + + export interface MultipointDrawActionCursorUpdateEvent { + + defaultPrevented: boolean; + + preventDefault: Function; + + type: string; + + vertexIndex: number; + + vertices: number[][]; + } + + export interface MultipointDrawActionDrawCompleteEvent { + + defaultPrevented: boolean; + + preventDefault: Function; + + type: string; + + vertices: number[][]; + } + + export interface MultipointDrawActionVertexAddEvent { + + defaultPrevented: boolean; + + preventDefault: Function; + + type: string; + + vertexIndex: number; + + vertices: number[][]; + } + + export interface MultipointDrawActionVertexRemoveEvent { + + defaultPrevented: boolean; + + preventDefault: Function; + + type: string; + + vertexIndex: number; + + vertices: number[][]; + } + + interface PointDrawAction extends Accessor, Evented { + /** + * An array of x,y coordinates for the [point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PointDrawAction.html#coordinates) + */ + coordinates: number[]; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PointDrawAction.html#view) + */ + view: MapView; + + /** + * Completes drawing the [point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometry and fires the [draw-complete](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PointDrawAction.html#event:draw-complete) event. Call this method if the drawing logic needs to be completed other than by double-clicking or pressing the "C" key. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PointDrawAction.html#complete) + * + * + */ complete(): void; + on(name: "cursor-update", eventHandler: PointDrawActionCursorUpdateEventHandler): IHandle; + on(name: "cursor-update", modifiers: string[], eventHandler: PointDrawActionCursorUpdateEventHandler): IHandle; + on(name: "draw-complete", eventHandler: PointDrawActionDrawCompleteEventHandler): IHandle; + on(name: "draw-complete", modifiers: string[], eventHandler: PointDrawActionDrawCompleteEventHandler): IHandle; } interface PointDrawActionConstructor { + + new(properties?: PointDrawActionProperties): PointDrawAction; } export const PointDrawAction: PointDrawActionConstructor; interface PointDrawActionProperties { + /** + * An array of x,y coordinates for the [point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PointDrawAction.html#coordinates) + */ + coordinates?: number[]; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PointDrawAction.html#view) + */ view?: MapViewProperties; } export interface PointDrawActionCursorUpdateEvent { + coordinates: number[]; + defaultPrevented: boolean; + preventDefault: Function; + type: string; } export interface PointDrawActionDrawCompleteEvent { + coordinates: number[]; + defaultPrevented: boolean; + preventDefault: Function; + type: string; } interface PolygonDrawAction extends Accessor, Evented { - vertices: number[][]; + /** + * Two-dimensional array of numbers representing the coordinates of each vertex comprising the geometry being drawn. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#vertices) + */ + readonly vertices: number[][]; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#view) + */ view: MapView; + /** + * Indicates if the [redo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#redo) method can be called on the action instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#canRedo) + * + * + */ canRedo(): boolean; + /** + * Indicates if the [undo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#undo) method can be called on the action instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#canUndo) + * + * + */ canUndo(): boolean; + /** + * Completes drawing the polygon geometry and fires the [draw-complete](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#event:draw-complete) event. Call this method if the drawing logic needs to be completed other than by double-clicking or pressing the "C" key. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#complete) + * + * + */ complete(): void; + /** + * Incrementally redo actions recorded in the stack. Call [canRedo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#canRedo) prior to calling this method to check if this method can be called on the action instance. Calling this method will fire the [vertex-add](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#event:vertex-add) or [vertex-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#event:vertex-remove) events depending on the last action. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#redo) + * + * + */ redo(): void; + /** + * Incrementally undo actions recorded in the stack. Call [canUndo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#canUndo) prior to calling this method to check if this method can be called on the action instance. Calling this method will fire the [vertex-add](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#event:vertex-add) or [vertex-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#event:vertex-remove) events depending on the last action. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#undo) + * + * + */ undo(): void; + on(name: "cursor-update", eventHandler: PolygonDrawActionCursorUpdateEventHandler): IHandle; + on(name: "cursor-update", modifiers: string[], eventHandler: PolygonDrawActionCursorUpdateEventHandler): IHandle; + on(name: "vertex-add", eventHandler: PolygonDrawActionVertexAddEventHandler): IHandle; + on(name: "vertex-add", modifiers: string[], eventHandler: PolygonDrawActionVertexAddEventHandler): IHandle; + on(name: "vertex-remove", eventHandler: PolygonDrawActionVertexRemoveEventHandler): IHandle; + on(name: "vertex-remove", modifiers: string[], eventHandler: PolygonDrawActionVertexRemoveEventHandler): IHandle; + on(name: "draw-complete", eventHandler: PolygonDrawActionDrawCompleteEventHandler): IHandle; + on(name: "draw-complete", modifiers: string[], eventHandler: PolygonDrawActionDrawCompleteEventHandler): IHandle; } interface PolygonDrawActionConstructor { + + new(properties?: PolygonDrawActionProperties): PolygonDrawAction; } export const PolygonDrawAction: PolygonDrawActionConstructor; interface PolygonDrawActionProperties { - vertices?: number[][]; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolygonDrawAction.html#view) + */ view?: MapViewProperties; } export interface PolygonDrawActionCursorUpdateEvent { + defaultPrevented: boolean; + preventDefault: Function; + type: string; + vertexIndex: number; + vertices: number[][]; } export interface PolygonDrawActionDrawCompleteEvent { + defaultPrevented: boolean; + preventDefault: Function; + type: string; + vertices: number[][]; } export interface PolygonDrawActionVertexAddEvent { + defaultPrevented: boolean; + preventDefault: Function; + type: string; + vertexIndex: number; + vertices: number[][]; } export interface PolygonDrawActionVertexRemoveEvent { + defaultPrevented: boolean; + preventDefault: Function; + type: string; + vertexIndex: number; + vertices: number[][]; } interface PolylineDrawAction extends Accessor, Evented { - vertices: number[][]; + /** + * Two-dimensional array of numbers representing the coordinates of each vertex that comprising the drawn geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#vertices) + */ + readonly vertices: number[][]; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#view) + */ view: MapView; + /** + * Indicates if the [redo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#redo) method can be called on the action instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#canRedo) + * + * + */ canRedo(): boolean; + /** + * Indicates if the [undo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#undo) method can be called on the action instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#canUndo) + * + * + */ canUndo(): boolean; + /** + * Completes drawing the polyline geometry and fires the [draw-complete](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#event:draw-complete) event. Call this method if the drawing logic needs to be completed other than by double-clicking or pressing the "C" key. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#complete) + * + * + */ complete(): void; + /** + * Incrementally redo actions recorded in the stack. Call [canRedo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#canRedo) prior to calling this method to check if this method can be called on the action instance. Calling this method will fire the [vertex-add](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#event:vertex-add) or [vertex-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#event:vertex-remove) event depending on the last action. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#redo) + * + * + */ redo(): void; + /** + * Incrementally undo actions recorded in the stack. Call [canUndo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#canUndo) prior to calling this method to check if this method can be called on the action instance. Calling this method will fire the [vertex-add](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#event:vertex-add) or [vertex-remove](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#event:vertex-remove) event depending on the last action. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#undo) + * + * + */ undo(): void; + on(name: "cursor-update", eventHandler: PolylineDrawActionCursorUpdateEventHandler): IHandle; + on(name: "cursor-update", modifiers: string[], eventHandler: PolylineDrawActionCursorUpdateEventHandler): IHandle; + on(name: "vertex-add", eventHandler: PolylineDrawActionVertexAddEventHandler): IHandle; + on(name: "vertex-add", modifiers: string[], eventHandler: PolylineDrawActionVertexAddEventHandler): IHandle; + on(name: "vertex-remove", eventHandler: PolylineDrawActionVertexRemoveEventHandler): IHandle; + on(name: "vertex-remove", modifiers: string[], eventHandler: PolylineDrawActionVertexRemoveEventHandler): IHandle; + on(name: "draw-complete", eventHandler: PolylineDrawActionDrawCompleteEventHandler): IHandle; + on(name: "draw-complete", modifiers: string[], eventHandler: PolylineDrawActionDrawCompleteEventHandler): IHandle; } interface PolylineDrawActionConstructor { + + new(properties?: PolylineDrawActionProperties): PolylineDrawAction; } export const PolylineDrawAction: PolylineDrawActionConstructor; interface PolylineDrawActionProperties { - vertices?: number[][]; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-PolylineDrawAction.html#view) + */ view?: MapViewProperties; } export interface PolylineDrawActionCursorUpdateEvent { + defaultPrevented: boolean; + preventDefault: Function; + type: string; + vertexIndex: number; + vertices: number[][]; } export interface PolylineDrawActionDrawCompleteEvent { + defaultPrevented: boolean; + preventDefault: Function; + type: string; + vertices: number[][]; } export interface PolylineDrawActionVertexAddEvent { + defaultPrevented: boolean; + preventDefault: Function; + type: string; + vertexIndex: number; + vertices: number[][]; } export interface PolylineDrawActionVertexRemoveEvent { + defaultPrevented: boolean; + preventDefault: Function; + type: string; + vertexIndex: number; + vertices: number[][]; } + /** + * map/scene on screen. The ArcGIS API for JavaScript offers a low-level interface to access the SceneView's WebGL context, and thus enables creating custom visualizations that interact with the scene the same way as built-in layers. Developers can either write WebGL code directly, or integrate with third-party WebGL libraries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html) + */ interface externalRenderers { + /** + * Adds an external renderer to the view. The external renderer is defined by an object that contains certain methods and properties, as defined by [ExternalRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#ExternalRenderer). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#add) + * + * @param view The view to which to attach the external renderer. + * @param renderer The external renderer. + * + */ add(view: SceneView, renderer: ExternalRenderer): void; - fromRenderCoordinates(view: SceneView, srcCoordinates: number[] | any, srcStart: number, destCoordinates: number[] | any, destStart: number, destSpatialReference: SpatialReference, count: number): number[] | any; + /** + * Transforms positions from the internal rendering coordinate system to the output spatial reference. The allowable output spatial reference is limited and depends on the [viewingMode](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode): + * * In `global` mode, it can either be Web Mercator or WGS84. + * * In `local` mode, it has to match [view.spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#spatialReference), and the call to this function simply copies the coordinates from `srcCoordinates` to `destCoordinates`. + * + * + * If these conditions are not met, nothing is written to `destCoordinates` and the function returns `null`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#fromRenderCoordinates) + * + * @param view The view related to the input coordinates. + * @param srcCoordinates A linear array of one or more vectors that are interpreted as XYZ coordinates. For example, two position vectors would be represented as `[x1, y1, z1, x2, y2, z2]`. This must contain at least `srcStart + 3 * count` elements. + * @param srcStart An index in `srcCoordinates` from which the coordinates will start being read. + * @param destCoordinates A reference to an array in which the results will be written. + * @param destStart An index in `destCoordinates` in which the coordinates will start to be written. + * @param destSpatialReference The spatial reference of the output coordinates. When `null`, `view.spatialReference` is used instead. + * @param count The number of vertices to be transformed. + * + */ + fromRenderCoordinates(view: SceneView, srcCoordinates: number[] | Float32Array, srcStart: number, destCoordinates: number[] | Float32Array, destStart: number, destSpatialReference: SpatialReference, count: number): number[] | Float32Array; + /** + * Removes an external renderer from the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#remove) + * + * @param view The view from which to remove the external renderer. + * @param renderer The external renderer. + * + */ remove(view: SceneView, renderer: ExternalRenderer): void; - renderCoordinateTransformAt(view: SceneView, origin: number[] | any, srcSpatialReference?: SpatialReference, dest?: number[] | any): number[] | any; + /** + * Computes a 4x4 affine transformation matrix that constitutes a linear coordinate transformation from a local Cartesian coordinate system to the virtual world coordinate system. For example, this matrix can be used to transform the vertices of a 3D model to the rendering coordinate system. The local Cartesian system is defined by its origin and the following axis definition: + * * X: Easting + * * Y: Northing + * * Z: Elevation + * + * + * ![externalRenderers-renderCoordinateTransformAt](https://developers.arcgis.com/javascript/latest/assets/img/apiref/views/3d/externalRenderers-renderCoordinateTransformAt.png) When [view.viewingMode](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode) is `global`, a linear transformation does not take the curvature of the globe or other non-linear projection aspects into account. Thus, the resulting coordinates will only appear correct within a small region around the origin of the local Cartesian system. The allowable spatial reference of `origin` depends on the [viewingMode](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode): + * * In `global` mode, it can either be Web Mercator or WGS84. + * * In `local` mode, it has to match [view.spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#spatialReference). + * + * + * If these conditions are not met, nothing will be written to `dest` and the function will return `null`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#renderCoordinateTransformAt) + * + * @param view The view for which the transformation will be used. + * @param origin The global coordinates of the origin in the local Cartesian coordinate system. + * @param srcSpatialReference The spatial reference of the origin coordinates. If undefined, `view.spatialReference` is used instead. + * @param dest A reference to an array where the 16 matrix elements will be stored. The resulting matrix follows OpenGL conventions where the translation components occupy the 13th, 14th and 15th elements. If undefined, a newly created matrix returned. + * + */ + renderCoordinateTransformAt(view: SceneView, origin: number[] | Float32Array, srcSpatialReference?: SpatialReference, dest?: number[] | Float32Array): number[] | Float32Array; + /** + * Requests the view to be redrawn. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#requestRender) + * + * @param view The view to which the external renderer is attached. + * + */ requestRender(view: SceneView): void; - toRenderCoordinates(view: SceneView, srcCoordinates: number[] | any, srcStart: number, srcSpatialReference: SpatialReference, destCoordinates: number[] | any, destStart: number, count: number): number[] | any; + /** + * Transforms positions from the given spatial reference to the internal rendering coordinate system. The allowable input spatial reference is limited and depends on the [viewingMode](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode): + * * In `global` mode, it can either be Web Mercator or WGS84. + * * In `local` mode, it has to match [view.spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#spatialReference); the call to this function simply copies the coordinates from `srcCoordinates` to `destCoordinates`. + * + * + * If these conditions are not met, nothing is written to `destCoordinates` and the function returns `null`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#toRenderCoordinates) + * + * @param view The view in which the coordinates will be used. + * @param srcCoordinates A linear array of one or more vectors which are interpreted as XYZ coordinates. For example, two position vectors would be represented as `[x1, y1, z1, x2, y2, z2]`. This must contain at least `srcStart + 3 * count` elements. + * @param srcStart An index in `srcCoordinates` from which the coordinates start to be read. + * @param srcSpatialReference The spatial reference of the input coordinates. When `null`, `view.spatialReference` is used instead. + * @param destCoordinates A reference to an array where the results will be written. + * @param destStart An index in `destCoordinates` to which the coordinates will start to be written. + * @param count The number of vertices to be transformed. + * + */ + toRenderCoordinates(view: SceneView, srcCoordinates: number[] | Float32Array, srcStart: number, srcSpatialReference: SpatialReference, destCoordinates: number[] | Float32Array, destStart: number, count: number): number[] | Float32Array; } export const externalRenderers: externalRenderers; - export interface ColorAndIntensity { + /** + * Tuple of an RGB color value and an intensity value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#ColorAndIntensity) + */ + export interface ColorAndIntensity extends Object { + /** + * RGB color with values between 0 and 1. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#ColorAndIntensity) + */ color: any; + /** + * Scalar intensity value by which the color should be scaled for compositing. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#ColorAndIntensity) + */ intensity: number; } - export interface ExternalRenderer { + /** + * Defines an external renderer using callbacks and properties. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#ExternalRenderer) + */ + export interface ExternalRenderer extends Object { + /** + * Typically called once after adding the external renderer to a view, or whenever the [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) becomes [ready](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#ready). It may be called again if the ready state cycles, for example when a different [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) is assigned to the view. Receives a single parameter of type [RenderContext](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderContext). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#ExternalRenderer) + * + * + */ setup(): void; + /** + * Called in every frame to execute the state update and draw calls. Receives a single parameter of type [RenderContext](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderContext). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#ExternalRenderer) + * + * + */ render(): void; + /** + * Called when the external renderer is removed from a view, or when the [ready](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#ready) state of the view turns false. Receives a single parameter of type [RenderContext](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderContext). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#ExternalRenderer) + * + * + */ dispose(): void; } - export interface RenderCamera { + /** + * The camera object passed to renderer callbacks in [RenderContext](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderContext). This is not the same as [Camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html). All properties are read-only and defined in terms of the internal rendering coordinate system (see the [section on coordinate systems](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#coordinate-systems) at the top of this page). Vectors (`Vec3`) are presented as arrays with 3 elements (x, y, z). Matrices (`Mat4`) are presented as linear arrays with 16 elements following the OpenGL conventions where the translation components occupy the 13th, 14th, and 15th elements. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderCamera) + */ + export interface RenderCamera extends Object { + /** + * A 4x4 matrix that transforms coordinates from world space to camera space. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderCamera) + */ viewMatrix: any; + /** + * The inverse transpose of `viewMatrix`, used to transform normals from world space to camera space. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderCamera) + */ viewInverseTransposeMatrix: any; + /** + * A 4x4 matrix that defines the perspective projection transformation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderCamera) + */ projectionMatrix: any; + /** + * The position of the camera in the internal Cartesian rendering coordinate system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderCamera) + */ eye: any; + /** + * The camera target ("look at") position in the internal Cartesian rendering coordinate system. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderCamera) + */ center: any; + /** + * The camera up vector. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderCamera) + */ up: any; + /** + * The distance to the near plane. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderCamera) + */ near: number; + /** + * The distance to the far plane. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderCamera) + */ far: number; + /** + * The horizontal field of view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderCamera) + */ fovX: number; + /** + * The vertical field of view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderCamera) + */ fovY: number; } - export interface RenderContext { + /** + * The object passed as a parameter to every call to `setup` and `render` the external renderer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderContext) + */ + export interface RenderContext extends Object { + /** + * The WebGL rendering context. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderContext) + */ gl: any; + /** + * The camera used to render the current frame. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderContext) + */ camera: RenderCamera; + /** + * The lighting used by [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) to render the current frame. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderContext) + */ sunLight: SunLight; + /** + * A convenience function provided to completely reset the WebGL state after using it. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderContext) + * + * + */ resetWebGLState(): void; + /** + * Binds the color and depth buffers an external renderer is supposed to render into. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#RenderContext) + * + * + */ bindRenderTarget(): void; } - export interface SunLight { + /** + * Describes the lighting used by [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html), derived from its sun lighting model. It consists of a directional Lambertian (`diffuse`) and a constant (`ambient`) term, which should be treated in the sense of the [Phong Reflection Model](https://en.wikipedia.org/wiki/Phong_reflection_model). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#SunLight) + */ + export interface SunLight extends Object { + /** + * The incident light direction in render coordinates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#SunLight) + */ direction: any; + /** + * The diffuse light color and intensity. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#SunLight) + */ diffuse: ColorAndIntensity; + /** + * The ambient light color and intensity. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-externalRenderers.html#SunLight) + */ ambient: ColorAndIntensity; } interface BreakpointsOwner { + /** + * A convenience property used for defining the breakpoints on the [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) and [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view. The sizes specified here determine the values of the [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) and [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint) properties depending on the view's size. Setting up breakpoints can aid in responsive app design. It does this by watching width and height breakpoints. This is helpful as it removes the need for multiple [`@media` calls](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries). Instead of listening for the view's size and/or resizes property, you can set up a watch handler for either the [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) or [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint) properties of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints) + */ breakpoints: BreakpointsOwnerBreakpoints; + /** + * A convenience property indicating the general size of the view's height. This value is determined based on where the view's [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) falls in the ranges defined in the [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints) property. See the table below for a list of possible values. + * > Please refer to the [styling guide](https://developers.arcgis.com/javascript/latest/guide/styling/index.html#view-size-css-classes) for additional information on working with this. + * + * Possible Value | Description + * ---------------|------------ + * xsmall | The [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) of the view is smaller than the value set in the `xsmall` [breakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * small | The [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) of the view is between the values set in the `xsmall` and `small` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * medium | The [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) of the view is between the values set in the `small` and `medium` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * large | The [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) of the view is between the values set in the `medium` and `large` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * xlarge | The [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) of the view is larger than the value set in the `large` [breakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint) + */ heightBreakpoint: string; - orientation: string; + /** + * A convenience property indicating the view's orientation. See the table below for a list of possible values. + * > Please refer to the [styling guide](https://developers.arcgis.com/javascript/latest/guide/styling/index.html#view-size-css-classes) for additional information on working with this. + * + * Possible Value | Description + * ---------------|------------ + * landscape | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is greater than its [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height). + * portrait | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is equal to or smaller than its [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#orientation) + */ + readonly orientation: string; + /** + * A convenience property indicating the general size of the view's width. This value is determined based on where the view's [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) falls in the ranges defined in the [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints) property. See the table below for a list of possible values. + * > Please refer to the [styling guide](https://developers.arcgis.com/javascript/latest/guide/styling/index.html#view-size-css-classes) for additional information on working with this. + * + * Possible Value | Description + * ---------------|------------ + * xsmall | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is smaller than the value set in the `xsmall` [breakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * small | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is between the values set in the `xsmall` and `small` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * medium | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is between the values set in the `small` and `medium` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * large | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is between the values set in the `medium` and `large` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * xlarge | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is larger than the value set in the `large` [breakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) + */ widthBreakpoint: string; } interface BreakpointsOwnerConstructor { + + new(): BreakpointsOwner; } export const BreakpointsOwner: BreakpointsOwnerConstructor; interface BreakpointsOwnerProperties { + /** + * A convenience property used for defining the breakpoints on the [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) and [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view. The sizes specified here determine the values of the [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) and [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint) properties depending on the view's size. Setting up breakpoints can aid in responsive app design. It does this by watching width and height breakpoints. This is helpful as it removes the need for multiple [`@media` calls](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries). Instead of listening for the view's size and/or resizes property, you can set up a watch handler for either the [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) or [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint) properties of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints) + */ breakpoints?: BreakpointsOwnerBreakpoints; + /** + * A convenience property indicating the general size of the view's height. This value is determined based on where the view's [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) falls in the ranges defined in the [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints) property. See the table below for a list of possible values. + * > Please refer to the [styling guide](https://developers.arcgis.com/javascript/latest/guide/styling/index.html#view-size-css-classes) for additional information on working with this. + * + * Possible Value | Description + * ---------------|------------ + * xsmall | The [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) of the view is smaller than the value set in the `xsmall` [breakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * small | The [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) of the view is between the values set in the `xsmall` and `small` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * medium | The [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) of the view is between the values set in the `small` and `medium` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * large | The [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) of the view is between the values set in the `medium` and `large` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * xlarge | The [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) of the view is larger than the value set in the `large` [breakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint) + */ heightBreakpoint?: string; - orientation?: string; + /** + * A convenience property indicating the general size of the view's width. This value is determined based on where the view's [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) falls in the ranges defined in the [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints) property. See the table below for a list of possible values. + * > Please refer to the [styling guide](https://developers.arcgis.com/javascript/latest/guide/styling/index.html#view-size-css-classes) for additional information on working with this. + * + * Possible Value | Description + * ---------------|------------ + * xsmall | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is smaller than the value set in the `xsmall` [breakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * small | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is between the values set in the `xsmall` and `small` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * medium | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is between the values set in the `small` and `medium` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * large | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is between the values set in the `medium` and `large` [breakpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * xlarge | The [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) of the view is larger than the value set in the `large` [breakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints). + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) + */ widthBreakpoint?: string; } - export interface BreakpointsOwnerBreakpoints { - xsmall: number; - small: number; - medium: number; - large: number; + + export interface BreakpointsOwnerBreakpoints extends Object { + /** + * Sets the `xsmall` breakpoint in pixels used by [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) and [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint). If the view's [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) or [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) is smaller than this value, then the value of [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) or [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint) will be `xsmall`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints) + * + * @default 544 + */ + xsmall?: number; + /** + * Sets the `small` breakpoint in pixels used by [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) and [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint). If the view's [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) or [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) is between this value and the value of the `xsmall` property, then the value of [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) or [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint) will be `small`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints) + * + * @default 768 + */ + small?: number; + /** + * Sets the `medium` breakpoint in pixels used by [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) and [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint). If the view's [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) or [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) is between this value and the value of the `small` property, then the value of [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) or [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint) will be `medium`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints) + * + * @default 992 + */ + medium?: number; + /** + * Sets the `large` breakpoint in pixels used by [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) and [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint). If the view's [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#height) or [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#width) is between this value and the value of the `medium` property, then the value of [widthBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#widthBreakpoint) or [heightBreakpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#heightBreakpoint) will be `large`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-BreakpointsOwner.html#breakpoints) + * + * @default 1200 + */ + large?: number; } interface DOMContainer { + /** + * The `id` or node representing the DOM element containing the view. This is typically set in the view's constructor. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#container) + */ container: HTMLDivElement | string; - height: number; + /** + * The height of the view in pixels read from the view container element. The view container needs to have a height greater than 0 to be displayed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#height) + * + * @default 0 + */ + readonly height: number; + /** + * A Popup object that displays general content or attributes from [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers) in the [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#map). The view has a default instance of [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) with predefined styles and a template for defining content. The content in this default instance may be modified directly in the [popup's content](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#content) or in a layer's [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). You may create a new [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) instance and set it to this property to customize the style, positioning, and content of the popup in favor of using the default popup instance on the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#popup) + */ popup: Popup; - resizing: boolean; - size: number[]; - suspended: boolean; + /** + * Indicates if the view is being resized. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#resizing) + * + * @default false + */ + readonly resizing: boolean; + /** + * An array containing the width and height of the view in pixels, e.g. `[width, height]`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#size) + */ + readonly size: number[]; + /** + * Indicates if the view is visible on the page. Is `true` if the view has no [container](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#container), a [height](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#height) or [width](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#width) equal to 0, or the CSS `visibility` is `hidden`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#suspended) + * + * @default true + */ + readonly suspended: boolean; + /** + * Exposes the default widgets available in the view and allows you to toggle them on and off. See [DefaultUI](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-DefaultUI.html) for more details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#ui) + */ ui: DefaultUI; - width: number; + /** + * The width of the view in pixels read from the view container element. The view container needs to have a width greater than 0 to be displayed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#width) + * + * @default 0 + */ + readonly width: number; } interface DOMContainerConstructor { + + new(): DOMContainer; } export const DOMContainer: DOMContainerConstructor; interface DOMContainerProperties { + /** + * The `id` or node representing the DOM element containing the view. This is typically set in the view's constructor. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#container) + */ container?: HTMLDivElement | string; - height?: number; + /** + * A Popup object that displays general content or attributes from [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers) in the [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#map). The view has a default instance of [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) with predefined styles and a template for defining content. The content in this default instance may be modified directly in the [popup's content](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#content) or in a layer's [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). You may create a new [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) instance and set it to this property to customize the style, positioning, and content of the popup in favor of using the default popup instance on the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#popup) + */ popup?: PopupProperties; - resizing?: boolean; - size?: number[]; - suspended?: boolean; + /** + * Exposes the default widgets available in the view and allows you to toggle them on and off. See [DefaultUI](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-DefaultUI.html) for more details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-DOMContainer.html#ui) + */ ui?: DefaultUIProperties; - width?: number; } interface CSVLayerView extends LayerView { + /** + * Highlights the given feature(s). + * > **Known Limitations** Currently the highlight method is only supported in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-CSVLayerView.html#highlight) + * + * @param target The feature(s) to highlight. + * + */ highlight(target?: Graphic | Graphic[]): any; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features available for drawing in the layer view and returns the [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) of features that satisfy the query. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-CSVLayerView.html#queryExtent) + * + * @param params Specifies the attributes and spatial filter of the query. Only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. If query parameters are not provided, the extent and count of all features available for drawing are returned. + * + */ queryExtent(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features available for drawing in the layer view and returns the number of features that satisfy the query. If query parameters are not provided, the count of all features available for drawing is returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-CSVLayerView.html#queryFeatureCount) + * + * @param params Specifies the attributes and spatial filter of the query. Only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. If query parameters are not provided, the count of all features available for drawing is returned. + * + */ queryFeatureCount(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features available for drawing in the layer view and returns an array of [Graphic[]](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). If query parameters are not provided, all features available for drawing are returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-CSVLayerView.html#queryFeatures) + * + * @param params Specifies the attributes and spatial filter of the query. Only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. If specifying a [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry) parameter, note that [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) is the only supported geometry. If query parameters are not provided, all features available for drawing are returned. + * + */ queryFeatures(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features available for drawing in the layer view and returns array of the ObjectIDs of features that satisfy the input query. If query parameters are not provided, the ObjectIDs of all features available for drawing are returned. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-CSVLayerView.html#queryObjectIds) + * + * @param params Specifies the attributes and spatial filter of the query. Only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. If query parameters are not provided, the ObjectIDs of all features available for drawing are returned. + * + */ queryObjectIds(params?: Query): IPromise; } interface CSVLayerViewConstructor { + + new(properties?: CSVLayerViewProperties): CSVLayerView; } @@ -8515,14 +36433,65 @@ declare namespace __esri { } interface FeatureLayerView extends LayerView { + /** + * Highlights the given feature(s). + * > **Known Limitations** In 2D [MapViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) this method is only supported for [FeatureLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) that have opted in to [WebGL rendering](esri-layers-FeatureLayer.html#webgl-rendering). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#highlight) + * + * @param target The feature(s) to highlight. When passing a graphic or array of graphics, each feature must have a valid `objectID`. You may alternatively pass one or more objectIDs as a single number or an array. + * + */ highlight(target?: Graphic | Graphic[] | number | number[]): any; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features available for drawing in the layer view and returns the [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) of features that satisfy the query. Valid only for [hosted feature services](http://doc.arcgis.com/en/arcgis-online/share-maps/hosted-web-layers.htm) on [arcgis.com](http://arcgis.com) and for ArcGIS Server 10.3.1 and later. If query parameters are not provided, the extent and count of all features available for drawing are returned. + * > To query for the extent of features directly from a Feature Service rather than those visible in the view, you must use the [FeatureLayer.queryExtent()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryExtent) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryExtent) + * + * @param params Specifies the attributes and spatial filter of the query. Only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. If query parameters are not provided, the extent and count of all features available for drawing are returned. + * + */ queryExtent(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features available for drawing in the layer view and returns the number of features that satisfy the query. If query parameters are not provided, the count of all features available for drawing is returned. + * > To query for the count of features directly from a Feature Service rather than those visible in the view, you must use the [FeatureLayer.queryFeatureCount()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryFeatureCount) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatureCount) + * + * @param params Specifies the attributes and spatial filter of the query. Only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. If query parameters are not provided, the count of all features available for drawing is returned. + * + */ queryFeatureCount(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features available for drawing in the layer view and returns an array of [Graphic[]](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). If query parameters are not provided, all features available for drawing are returned. + * > To execute a query against all the features in a Feature Service rather than only those visible in the view, you must use the [FeatureLayer.queryFeatures()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryFeatures) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatures) + * + * @param params Specifies the attributes and spatial filter of the query. Only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. If specifying a [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry) parameter, note that [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) is the only supported geometry. If query parameters are not provided, all features available for drawing are returned. + * + */ queryFeatures(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features available for drawing in the layer view and returns array of the ObjectIDs of features that satisfy the input query. If query parameters are not provided, the ObjectIDs of all features available for drawing are returned. + * > To query for ObjectIDs of features directly from a Feature Service rather than those visible in the view, you must use the [FeatureLayer.queryObjectIds()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryObjectIds) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryObjectIds) + * + * @param params Specifies the attributes and spatial filter of the query. Only the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#geometry), [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds), and [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#spatialRelationship) properties should be specified. Adding any other properties will return an error. If specifying a spatialRelationship, note that `intersects` is the only supported operation. If query parameters are not provided, the ObjectIDs of all features available for drawing are returned. + * + */ queryObjectIds(params?: Query): IPromise; } interface FeatureLayerViewConstructor { + /** + * Represents the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) of a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) after it has been added to a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) in either a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html) + */ + new(properties?: FeatureLayerViewProperties): FeatureLayerView; } @@ -8533,11 +36502,33 @@ declare namespace __esri { } interface GraphicsLayerView extends LayerView { + /** + * Highlights the given feature(s). + * > **Known Limitations** Currently the highlight method is only supported in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-GraphicsLayerView.html#highlight) + * + * @param target The feature(s) to highlight. When passing a graphic or array of graphics, each feature must have a valid `objectID`. You may alternatively pass one or more objectIDs as a single number or an array. + * + */ highlight(target?: Graphic | Graphic[] | number | number[]): any; + /** + * Returns all graphics available for drawing in the layer view as an array of [Graphic[]](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-GraphicsLayerView.html#queryGraphics) + * + * + */ queryGraphics(): IPromise; } interface GraphicsLayerViewConstructor { + /** + * Represents the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) of a [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html) after it has been added to a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) in either a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-GraphicsLayerView.html) + */ + new(properties?: GraphicsLayerViewProperties): GraphicsLayerView; } @@ -8548,53 +36539,231 @@ declare namespace __esri { } interface ImageryLayerView extends LayerView { + /** + * An object that provides the user access to [pixels](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) and their values in the layer. See the object specifications table below for details about each property. This object is used as input in the [pixelFilter()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#pixelFilter) function for filtering and processing each pixel in the block. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-ImageryLayerView.html#pixelData) + */ pixelData: ImageryLayerViewPixelData; } interface ImageryLayerViewConstructor { + /** + * Represents the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) of an [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html) after it has been added to a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) in either a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-ImageryLayerView.html) + */ + new(properties?: ImageryLayerViewProperties): ImageryLayerView; } export const ImageryLayerView: ImageryLayerViewConstructor; interface ImageryLayerViewProperties extends LayerViewProperties { + /** + * An object that provides the user access to [pixels](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-PixelBlock.html#pixels) and their values in the layer. See the object specifications table below for details about each property. This object is used as input in the [pixelFilter()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#pixelFilter) function for filtering and processing each pixel in the block. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-ImageryLayerView.html#pixelData) + */ pixelData?: ImageryLayerViewPixelData; } - export interface ImageryLayerViewPixelData { + + export interface ImageryLayerViewPixelData extends Object { + /** + * The extent of the `pixelBlock`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-ImageryLayerView.html#pixelData) + */ extent?: Extent; + /** + * An object representing the pixels in the view. This provides the user access to each pixel on the client via the `pixels` property of this object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-ImageryLayerView.html#pixelData) + */ pixelBlock: PixelBlock; } + interface KMLLayerView extends LayerView { + /** + * A collection of all the [MapImages](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-KMLLayerView.html#MapImage) from visible sublayers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-KMLLayerView.html#allVisibleMapImages) + */ + readonly allVisibleMapImages: Collection; + /** + * A collection of all the points from visible sublayers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-KMLLayerView.html#allVisiblePoints) + */ + readonly allVisiblePoints: Collection; + /** + * A collection of all the polygons from visible sublayers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-KMLLayerView.html#allVisiblePolygons) + */ + readonly allVisiblePolygons: Collection; + /** + * A collection of all the polylines from visible sublayers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-KMLLayerView.html#allVisiblePolylines) + */ + readonly allVisiblePolylines: Collection; + } + + interface KMLLayerViewConstructor { + + + new(properties?: KMLLayerViewProperties): KMLLayerView; + } + + export const KMLLayerView: KMLLayerViewConstructor; + + interface KMLLayerViewProperties extends LayerViewProperties { + + } + + /** + * **MapImage** represents an image overlay draped onto the terrain. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-KMLLayerView.html#MapImage) + */ + export interface KMLLayerViewMapImage extends Object { + /** + * Map image id. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-KMLLayerView.html#MapImage) + */ + id: number; + /** + * URL to the map image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-KMLLayerView.html#MapImage) + */ + href: string; + /** + * The [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) of the map image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-KMLLayerView.html#MapImage) + */ + Extent: Extent; + /** + * Rotation of the map image about its center, in degrees. Values can be ±180. The default is 0 (north). Rotations are specified in a counterclockwise direction. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-KMLLayerView.html#MapImage) + */ + rotation: number; + } + interface LayerView extends Accessor, corePromise { - layer: Layer; - suspended: boolean; - updating: boolean; + /** + * The layer being viewed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html#layer) + */ + readonly layer: Layer; + /** + * Value is `true` if the layer is suspended (i.e., layer will not redraw or update itself when the extent changes). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html#suspended) + */ + readonly suspended: boolean; + /** + * Value is `true` when the layer is updating; for example, if it is in the process of fetching data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html#updating) + * + * @default false + */ + readonly updating: boolean; + /** + * When `true`, the layer is visible in the view. Set this property to `false` to hide the layer from the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html#visible) + * + * @default true + */ visible: boolean; } interface LayerViewConstructor { + + new(properties?: LayerViewProperties): LayerView; } export const LayerView: LayerViewConstructor; interface LayerViewProperties { - layer?: LayerProperties; - suspended?: boolean; - updating?: boolean; + /** + * When `true`, the layer is visible in the view. Set this property to `false` to hide the layer from the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html#visible) + * + * @default true + */ visible?: boolean; } interface SceneLayerView extends LayerView { + /** + * Highlights the given feature(s). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-SceneLayerView.html#highlight) + * + * @param target The feature(s) to highlight. When passing a graphic or array of graphics, each feature must have a valid `objectID`. You may alternatively pass one or more objectIDs as a single number or an array. + * + */ highlight(target?: Graphic | Graphic[] | number | number[]): any; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features in the layer view and returns the 3D [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) of features that satisfy the query. If query parameters are not provided, the extent and count of all loaded features are returned. This method is not yet supported when the associated scene layer has a [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#geometryType) of `point`. Read more about queries in the Query section of the [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) class description. + * > To query for the extent of features directly from a Scene Service rather than those loaded for the current view, you must use the [SceneLayer.queryExtent()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#queryExtent) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-SceneLayerView.html#queryExtent) + * + * @param params Specifies the attributes of the query. Only the [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds) property should be specified. Adding any other properties will return an error. If query parameters are not provided, the extent and count of all loaded features are returned. + * + */ queryExtent(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features in the layer view and returns the number of features that satisfy the query. If query parameters are not provided, the count of all loaded features is returned. Read more about queries in the Query section of the [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) class description. This method is not yet supported when the associated scene layer has a [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#geometryType) of `point`. + * > To query for the count of features directly from a Scene Service rather than those loaded for the current view, you must use the [SceneLayer.queryFeatureCount()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#queryFeatureCount) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-SceneLayerView.html#queryFeatureCount) + * + * @param params Specifies the attributes of the query. Only the [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds) property should be specified. Adding any other properties will return an error. If query parameters are not provided, the count of all loaded features is returned. + * + */ queryFeatureCount(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features in the layer view and returns a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-FeatureSet.html). If query parameters are not provided, all loaded features are returned. This method is not yet supported when the associated scene layer has a [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#geometryType) of `point`. Read more about queries in the Query section of the [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) class description. + * > To execute a query against all the features in a Scene Service rather than only those loaded for the current view, you must use the [SceneLayer.queryFeatures()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#queryFeatures) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-SceneLayerView.html#queryFeatures) + * + * @param params Specifies the attributes of the query. Only the [outFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#outFields) and [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds) properties should be specified. Adding any other properties will return an error. If query parameters are not provided, all loaded features are returned. + * + */ queryFeatures(params?: Query): IPromise; + /** + * Executes a [Query](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) against features in the layer view and returns an array of the ObjectIDs of features that satisfy the input query. If query parameters are not provided, the ObjectIDs of all loaded features are returned. This method is not yet supported when the associated scene layer has a [geometryType](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#geometryType) of `point`. Read more about queries in the Query section of the [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) class description. + * > To query for ObjectIDs of features directly from a Scene Service rather than those loaded for the current view, you must use the [SceneLayer.queryObjectIds()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#queryObjectIds) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-SceneLayerView.html#queryObjectIds) + * + * @param params Specifies the attributes of the query. Only the [objectIds](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html#objectIds) property should be specified. Adding any other properties will return an error. If query parameters are not provided, the ObjectIDs of all loaded features are returned. + * + */ queryObjectIds(params?: Query): IPromise; } interface SceneLayerViewConstructor { + /** + * Represents the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) of a [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) after it has been added to a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-SceneLayerView.html) + */ + new(properties?: SceneLayerViewProperties): SceneLayerView; } @@ -8605,1941 +36774,8717 @@ declare namespace __esri { } interface StreamLayerView extends LayerView, Evented { - connectionError: Error; - connectionStatus: string; - filter: StreamLayerViewFilter; + /** + * The error that explains an unsuccessful attempt to connect to the stream service or an unexpected disconnection from the stream service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#connectionError) + */ + readonly connectionError: Error; + /** + * The status of the Web Socket connection with the stream service. This property can be watched to see if the connection is lost unexpectedly. **Possible Values:** connected | disconnected + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#connectionStatus) + */ + readonly connectionStatus: string; + /** + * Contains the attribute and spatial filters used to filter messages sent to the given layer view by a stream service. To change the filter for only a single layer view, use the [updateFilter()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#updateFilter) method. The layer view's filter is always updated when the [updateFilter()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#updateFilter) method of the associated stream layer instance is called. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#filter) + */ + readonly filter: StreamLayerViewFilter; + /** + * Contains the collection of [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) visible in the layer view for the live stream. Graphics may be removed from the layer view by calling the [removeAll()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#removeAll) method from [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#graphics) + */ graphics: Collection; + /** + * Opens a web socket connection with the stream service to start receiving messages. This is called internally when the StreamLayer is added to a view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#connect) + * + * + */ connect(): IPromise; + /** + * Closes the web socket connection with the stream service. This is called internally when the StreamLayer is removed from a view. To verify when the connection is closed, watch the [connectionStatus](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#property:connectionStatus) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#disconnect) + * + * + */ disconnect(): void; + /** + * Updates the [filter](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#filter) on the StreamLayerView. The filter is updated only on the layer view from which it is called. To update the filter on all layer views generated from a common layer, use the [StreamLayer.updateFilter()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html#updateFilter) method. If the input `filter` object is `undefined` or `null`, the spatial and attribute filters are removed. Filter changes only apply to incoming features. Features already displayed in the view are not filtered. Therefore, you may want to clear the graphics in the layer view prior to applying a new filter. To do so, get the layer view then call [removeAll()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#removeAll) on the [StreamLayerView.graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#graphics). You may also filter features already present in the view using the [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) methods. See the examples below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#updateFilter) + * + * @param filter Updates the spatial and attribute [filters](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#filter). If `null`, all filters are cleared. + * @param filter.geometry A spatial filter for filtering features. Only features that intersect the given geometry are displayed in the view. If `null`, the spatial filter is cleared. + * @param filter.where A SQL where clause used to filter features by attributes. If `null`, the attribute filter is cleared. + * + */ updateFilter(filter: StreamLayerViewUpdateFilterFilter): IPromise; + on(name: "data-received", eventHandler: StreamLayerViewDataReceivedEventHandler): IHandle; + on(name: "data-received", modifiers: string[], eventHandler: StreamLayerViewDataReceivedEventHandler): IHandle; } interface StreamLayerViewConstructor { + /** + * The StreamLayerView provides methods for connecting, disconnecting, and filtering data received from a stream service for a layer view associated with a [StreamLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html) + */ + new(properties?: StreamLayerViewProperties): StreamLayerView; } export const StreamLayerView: StreamLayerViewConstructor; interface StreamLayerViewProperties extends LayerViewProperties { - connectionError?: Error; - connectionStatus?: string; - filter?: StreamLayerViewFilter; + /** + * Contains the collection of [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) visible in the layer view for the live stream. Graphics may be removed from the layer view by calling the [removeAll()](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html#removeAll) method from [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#graphics) + */ graphics?: CollectionProperties; } export interface StreamLayerViewDataReceivedEvent { } - export interface StreamLayerViewFilter { + + export interface StreamLayerViewFilter extends Object { + /** + * A spatial filter for filtering features. Only features that intersect the given geometry are displayed in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#filter) + */ geometry?: Extent; + /** + * A SQL where clause used to filter features by attributes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#filter) + */ where?: string; } - export interface StreamLayerViewUpdateFilterFilter { + + export interface StreamLayerViewUpdateFilterFilter extends Object { + /** + * A spatial filter for filtering features. Only features that intersect the given geometry are displayed in the view. If `null`, the spatial filter is cleared. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#updateFilter) + */ geometry?: Extent; + /** + * A SQL where clause used to filter features by attributes. If `null`, the attribute filter is cleared. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-StreamLayerView.html#updateFilter) + */ where?: string; } interface MapView extends View, BreakpointsOwner { + /** + * Represents the view's center point; when setting the center, you may pass a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) instance or an array of numbers representing a longitude/latitude pair (`[-100.4593, 36.9014]`). Setting the center immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). If set in the constructor, this property will be ignored if the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#viewpoint) or [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#extent) properties are also set in the constructor. The returned [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) object is always in the spatial reference of the [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#map) and may be modified internally. To persist the returned object, create a clone using [Point.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#clone). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center) + */ center: Point; + /** + * Specifies constraints to [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale), [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#zoom), and [rotation](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#rotation) that may be applied to the MapView. See object specification below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ constraints: MapViewConstraints; + /** + * The extent represents the visible portion of a [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) within the view as an instance of [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html). Setting the extent immediately changes the view without animation. To animate the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). The returned [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) object is an internal reference which may be modified internally. To persist the returned object, create a copy using [Extent.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#extent) + * + * @default null + */ extent: Extent; + /** + * Options for configuring the highlight. Use the highlight method on the appropriate [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) to highlight a feature. + * > **Known Limitations** Only [FeatureLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) renderered with [WebGL](esri-layers-FeatureLayer.html#webgl-rendering) support highlight. See [FeatureLayerView.highlight()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#highlight) for details of how to highlight features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#highlightOptions) + */ highlightOptions: MapViewHighlightOptions; + /** + * Defines which anchor stays still while resizing the browser window. The default, `center`, ensures the view's center point remains constantly visible as the window size changes. The other options allow the respective portion of the view to remain visible when the window's size is changed. **Possible values:** center | left | right | top | bottom | top-left | top-right | bottom-left | bottom-right + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#resizeAlign) + * + * @default center + */ resizeAlign: string; + /** + * The clockwise rotation of due north in relation to the top of the view in degrees. The view may be rotated by directly setting the rotation or by using the following mouse event: `Right-click + Drag`. Map rotation may be disabled by setting the `rotationEnabled` property in [constraints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) to `false`. See the code snippet below for an example of this. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#rotation) + * + * @default 0 + */ rotation: number; + /** + * Represents the map scale at the center of the view. Setting the scale immediately changes the view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale) + */ scale: number; + /** + * Represents the current view as a [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) or point of observation on the view. Setting the viewpoint immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). The returned [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) object is an internal reference which may be modified internally. To persist the returned object, create a copy using [Viewpoint.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#clone). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#viewpoint) + */ viewpoint: Viewpoint; + /** + * Represents the level of detail (LOD) at the center of the view. Setting the zoom immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). Setting this property in conjunction with [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center) is a convenient way to set the initial extent of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#zoom) + */ zoom: number; + /** + * Sets the focus on the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#focus) + * + * + */ focus(): void; - goTo(target: number[] | Geometry | Geometry[] | Graphic | Graphic[] | Viewpoint | MapViewGoToTarget, options?: MapViewGoToOptions): IPromise; + /** + * Sets the view to a given target. The target parameter can be one of the following: + * * `[longitude, latitude]` pair of coordinates + * * [Geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) (or array of [Geometry[]](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html)) + * * [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) (or array of [Graphic[]](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html)) + * * [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) + * * Object with a combination of `target`, `center` and `scale` properties (with `target` being any of the types listed above). The `center` property is provided as a convenience to animate the [MapView.center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center) and is equivalent to specifying the `target` with the center [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html). + * + * + * This function returns a promise which resolves as soon as the new view has been set to the target. If the transition is animated, then the ongoing animation can be obtained using [MapView.animation](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#animation). Take note that if you pass in an [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) as the `target` geometry, the `goTo` method will zoom to the nearest LOD of the basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo) + * + * @param target The target location/viewpoint to animate to. When using an object for `target`, use the properties in the table below. + * @param target.target The target of the animation. + * @param target.center The [MapView.center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center) to go to. + * @param target.scale The [MapView.scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale) to go to. + * @param target.zoom The [MapView.zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#zoom) to go to. + * @param options Animation options. See properties below for object specifications. + * @param options.animate Indicates if the transition to the new view should be animated. + * @param options.duration The duration of the animation in milliseconds. + * @param options.easing The easing function used for the animation. **Possible Values:** linear | ease | ease-in | ease-out | ease-in-out + * + */ + goTo(target: number[] | Geometry | Geometry[] | Graphic | Graphic[] | Viewpoint | MapViewGoToTarget, options?: MapViewGoToOptions): IPromise; + /** + * Indicates whether there is an event listener on the instance that matches the provided event name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hasEventListener) + * + * @param type The name of the event. + * + */ hasEventListener(type: string): boolean; + /** + * Returns the topmost feature from each layer that intersects the specified screen coordinates. The following layer types will return a result if a hit is made on an intersecting feature: [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html), [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), [CSVLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html), [GeoRSSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html), [KMLLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html), and [StreamLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html). At 4.6 and later, a hit test will always return a result from [VectorTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html). However, the result will only indicate the ID and the name of the layer within the [vector tile style](https://doc.arcgis.com/en/arcgis-online/reference/tile-layers.htm#ESRI_SECTION1_8F68399EB47B48FF9EF46719FCC96978) that intersects the screen point. Detailed attribute and spatial information about the actual feature represented in the layer is not returned. HitTest results returned from VectorTileLayers are primarily used for [Vector tile style editor applications](https://maps.esri.com/jg/VectorBasemapStyleEditor/index.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest) + * + * @param screenPoint The screen coordinates of the click on the view. + * @param screenPoint.x The horizontal screen coordinate of the click on the view. + * @param screenPoint.y The vertical screen coordinate of the click on the view. + * + */ hitTest(screenPoint: MapViewHitTestScreenPoint): IPromise; + /** + * Registers an event handler on the instance. Call this method to hook an event with a listener. See the [Events summary table](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#events-summary) for a list of listened events. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#on) + * + * @param type The name of the event or the events to listen for. + * @param modifiersOrHandler Additional modifier keys to filter the events by. Alternatively, if no modifiers are required, the function to call when the event is fired. + * @param handler? The function to call when the event is fired, if modifiers were specified. + * + */ on(type: string | string[], modifiersOrHandler: string[] | EventHandler, handler?: EventHandler): IHandle; + /** + * Converts the given screen point to a [map point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#toMap) + * + * @param screenPoint The screen coordinates to convert. + * @param screenPoint.x The horizontal screen coordinate to convert. + * @param screenPoint.y The vertical screen coordinate to convert. + * + */ toMap(screenPoint: MapViewToMapScreenPoint): Point; + /** + * Converts the given [map point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) to a [screen point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-ScreenPoint.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#toScreen) + * + * @param point A point geometry. + * @param screenPoint ScreenPoint object that will reference the result. + * + */ toScreen(point: Point, screenPoint?: ScreenPoint): ScreenPoint; + on(name: "resize", eventHandler: MapViewResizeEventHandler): IHandle; + on(name: "resize", modifiers: string[], eventHandler: MapViewResizeEventHandler): IHandle; + on(name: "layerview-create", eventHandler: MapViewLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: MapViewLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: MapViewLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: MapViewLayerviewDestroyEventHandler): IHandle; + on(name: "click", eventHandler: MapViewClickEventHandler): IHandle; + on(name: "click", modifiers: string[], eventHandler: MapViewClickEventHandler): IHandle; + on(name: "double-click", eventHandler: MapViewDoubleClickEventHandler): IHandle; + on(name: "double-click", modifiers: string[], eventHandler: MapViewDoubleClickEventHandler): IHandle; + on(name: "hold", eventHandler: MapViewHoldEventHandler): IHandle; + on(name: "hold", modifiers: string[], eventHandler: MapViewHoldEventHandler): IHandle; + on(name: "drag", eventHandler: MapViewDragEventHandler): IHandle; + on(name: "drag", modifiers: string[], eventHandler: MapViewDragEventHandler): IHandle; + on(name: "mouse-wheel", eventHandler: MapViewMouseWheelEventHandler): IHandle; + on(name: "mouse-wheel", modifiers: string[], eventHandler: MapViewMouseWheelEventHandler): IHandle; + on(name: "key-down", eventHandler: MapViewKeyDownEventHandler): IHandle; + on(name: "key-down", modifiers: string[], eventHandler: MapViewKeyDownEventHandler): IHandle; + on(name: "key-up", eventHandler: MapViewKeyUpEventHandler): IHandle; + on(name: "key-up", modifiers: string[], eventHandler: MapViewKeyUpEventHandler): IHandle; + on(name: "pointer-down", eventHandler: MapViewPointerDownEventHandler): IHandle; + on(name: "pointer-down", modifiers: string[], eventHandler: MapViewPointerDownEventHandler): IHandle; + on(name: "pointer-move", eventHandler: MapViewPointerMoveEventHandler): IHandle; + on(name: "pointer-move", modifiers: string[], eventHandler: MapViewPointerMoveEventHandler): IHandle; + on(name: "pointer-up", eventHandler: MapViewPointerUpEventHandler): IHandle; + on(name: "pointer-up", modifiers: string[], eventHandler: MapViewPointerUpEventHandler): IHandle; + + on(name: "pointer-enter", eventHandler: MapViewPointerEnterEventHandler): IHandle; + + on(name: "pointer-enter", modifiers: string[], eventHandler: MapViewPointerEnterEventHandler): IHandle; + + on(name: "pointer-leave", eventHandler: MapViewPointerLeaveEventHandler): IHandle; + + on(name: "pointer-leave", modifiers: string[], eventHandler: MapViewPointerLeaveEventHandler): IHandle; } interface MapViewConstructor { + /** + * A MapView displays a 2D view of a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) instance. An instance of MapView must be created to render a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) (along with its operational and base layers) in 2D. To render a map and its layers in 3D, see the documentation for [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). For a general overview of views, see [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) + */ + new(properties?: MapViewProperties): MapView; } export const MapView: MapViewConstructor; interface MapViewProperties extends ViewProperties, BreakpointsOwnerProperties { - center?: PointProperties; + /** + * Represents the view's center point; when setting the center, you may pass a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) instance or an array of numbers representing a longitude/latitude pair (`[-100.4593, 36.9014]`). Setting the center immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). If set in the constructor, this property will be ignored if the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#viewpoint) or [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#extent) properties are also set in the constructor. The returned [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) object is always in the spatial reference of the [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#map) and may be modified internally. To persist the returned object, create a clone using [Point.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#clone). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center) + */ + center?: PointProperties | number[]; + /** + * Specifies constraints to [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale), [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#zoom), and [rotation](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#rotation) that may be applied to the MapView. See object specification below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ constraints?: MapViewConstraints; + /** + * The extent represents the visible portion of a [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) within the view as an instance of [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html). Setting the extent immediately changes the view without animation. To animate the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). The returned [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) object is an internal reference which may be modified internally. To persist the returned object, create a copy using [Extent.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#extent) + * + * @default null + */ extent?: ExtentProperties; - highlightOptions?: MapViewHighlightOptions; + /** + * Options for configuring the highlight. Use the highlight method on the appropriate [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) to highlight a feature. + * > **Known Limitations** Only [FeatureLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) renderered with [WebGL](esri-layers-FeatureLayer.html#webgl-rendering) support highlight. See [FeatureLayerView.highlight()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#highlight) for details of how to highlight features. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#highlightOptions) + */ + highlightOptions?: MapViewHighlightOptionsProperties; + /** + * Defines which anchor stays still while resizing the browser window. The default, `center`, ensures the view's center point remains constantly visible as the window size changes. The other options allow the respective portion of the view to remain visible when the window's size is changed. **Possible values:** center | left | right | top | bottom | top-left | top-right | bottom-left | bottom-right + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#resizeAlign) + * + * @default center + */ resizeAlign?: string; + /** + * The clockwise rotation of due north in relation to the top of the view in degrees. The view may be rotated by directly setting the rotation or by using the following mouse event: `Right-click + Drag`. Map rotation may be disabled by setting the `rotationEnabled` property in [constraints](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) to `false`. See the code snippet below for an example of this. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#rotation) + * + * @default 0 + */ rotation?: number; + /** + * Represents the map scale at the center of the view. Setting the scale immediately changes the view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale) + */ scale?: number; + /** + * Represents the current view as a [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) or point of observation on the view. Setting the viewpoint immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). The returned [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) object is an internal reference which may be modified internally. To persist the returned object, create a copy using [Viewpoint.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#clone). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#viewpoint) + */ viewpoint?: ViewpointProperties; + /** + * Represents the level of detail (LOD) at the center of the view. Setting the zoom immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). Setting this property in conjunction with [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center) is a convenient way to set the initial extent of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#zoom) + */ zoom?: number; } export interface MapViewClickEvent { + button: number; + mapPoint: Point; + native: any; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface MapViewDoubleClickEvent { + button: number; + mapPoint: Point; + native: any; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface MapViewDragEvent { + action: string; + native: any; + origin: MapViewDragEventOrigin; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } - export interface HitTestResult { + /** + * Object specification for the result of the [hitTest()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#HitTestResult) + */ + export interface HitTestResult extends Object { + /** + * An array of result objects returned from the [hitTest()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest). Results are returned when the location of the input screen coordinates intersect a [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) in the view. See the table below for the specification of each object in this array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#HitTestResult) + */ results: HitTestResultResults[]; } export interface MapViewHoldEvent { + button: number; + mapPoint: Point; + native: any; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface MapViewKeyDownEvent { + key: string; + native: any; + repeat: boolean; + stopPropagation: Function; + timestamp: number; + type: string; } export interface MapViewKeyUpEvent { + native: any; + stopPropagation: Function; + timestamp: number; + type: string; } export interface MapViewLayerviewCreateEvent { + layer: Layer; + layerView: LayerView; } export interface MapViewLayerviewDestroyEvent { + layer: Layer; + layerView: LayerView; } - export interface MapViewConstraints { + + export interface MapViewConstraints extends Object { + /** + * An array of [LODs](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-LOD.html). If not specified, this value is read from the [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html). This property may be [autocast](https://developers.arcgis.com/javascript/latest/guide/autocasting/index.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ lods?: LOD[]; + /** + * The minimum [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale) the user is allowed to zoom to within the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ minScale?: number; + /** + * The maximum [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale) the user is allowed to zoom to within the view. Setting this value to `0` allows the user to overzoom layer tiles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ maxScale?: number; + /** + * The minimum [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#zoom) level the user is allowed to zoom to within the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ minZoom?: number; + /** + * The maximum [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#zoom) level the user is allowed to zoom to within the view. Setting this value to `0` allows the user to overzoom layer tiles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ maxZoom?: number; + /** + * When `true`, the view snaps to the next LOD when zooming in or out. When `false`, the zoom is continuous. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + * + * @default true + */ snapToZoom?: boolean; + /** + * Indicates whether the user can rotate the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + * + * @default true + */ rotationEnabled?: boolean; + /** + * A read-only property that specifies the levels of detail (LODs) read from the [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ effectiveLODs?: LOD[]; + /** + * A read-only property that specifies the minimum [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#zoom) level the user is allowed to zoom to within the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ effectiveMinZoom?: number; + /** + * A read-only property that specifies the maximum [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#zoom) level the user is allowed to zoom to within the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ effectiveMaxZoom?: number; + /** + * A read-only property that specifies the minimum [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale) the user is allowed to zoom to within the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ effectiveMinScale?: number; + /** + * A read-only property that specifies the maximum [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale) the user is allowed to zoom to within the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#constraints) + */ effectiveMaxScale?: number; } - export interface MapViewGoToOptions { + + export interface MapViewGoToOptions extends Object { + /** + * Indicates if the transition to the new view should be animated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo) + * + * @default true + */ animate?: boolean; + /** + * The duration of the animation in milliseconds. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo) + */ duration?: number; + /** + * The easing function used for the animation. **Possible Values:** linear | ease | ease-in | ease-out | ease-in-out + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo) + * + * @default ease + */ easing?: string | Function; } - export interface MapViewGoToTarget { + + export interface MapViewGoToTarget extends Object { + /** + * The target of the animation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo) + */ target?: number[] | Geometry | Geometry[] | Graphic | Graphic[] | Viewpoint; + /** + * The [MapView.center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center) to go to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo) + */ center?: number[]; + /** + * The [MapView.scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#scale) to go to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo) + */ scale?: number; + /** + * The [MapView.zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#zoom) to go to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo) + */ zoom?: number; } - export interface MapViewHighlightOptions { - color?: Color; + + export interface MapViewHighlightOptionsProperties extends Object { + /** + * The color of the highlight. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#highlightOptions) + * + * @default #00ffff + */ + color?: Color | number[] | string; + /** + * The opacity of the highlight halo. This will be multiplied with the opacity specified in `color`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#highlightOptions) + * + * @default 1 + */ haloOpacity?: number; + /** + * The opacity of the fill (area within the halo). This will be multiplied with the opacity specified in `color`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#highlightOptions) + * + * @default 0.25 + */ fillOpacity?: number; } - export interface MapViewHitTestScreenPoint { + export interface MapViewHighlightOptions extends AnonymousAccessor { + /** + * The color of the highlight. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#highlightOptions) + * + * @default #00ffff + */ + color?: Color; + /** + * The opacity of the highlight halo. This will be multiplied with the opacity specified in `color`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#highlightOptions) + * + * @default 1 + */ + haloOpacity?: number; + /** + * The opacity of the fill (area within the halo). This will be multiplied with the opacity specified in `color`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#highlightOptions) + * + * @default 0.25 + */ + fillOpacity?: number; + } + + + export interface MapViewHitTestScreenPoint extends Object { + /** + * The horizontal screen coordinate of the click on the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest) + */ x: number; + /** + * The vertical screen coordinate of the click on the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#hitTest) + */ y: number; } - export interface MapViewToMapScreenPoint { + + export interface MapViewToMapScreenPoint extends Object { + /** + * The horizontal screen coordinate to convert. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#toMap) + */ x: number; + /** + * The vertical screen coordinate to convert. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#toMap) + */ y: number; } export interface MapViewMouseWheelEvent { + deltaY: number; + native: any; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface MapViewPointerDownEvent { + native: any; + pointerId: number; + pointerType: string; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + + y: number; + } + + export interface MapViewPointerEnterEvent { + + native: any; + + pointerId: number; + + pointerType: string; + + stopPropagation: Function; + + timestamp: number; + + type: string; + + x: number; + + y: number; + } + + export interface MapViewPointerLeaveEvent { + + native: any; + + pointerId: number; + + pointerType: string; + + stopPropagation: Function; + + timestamp: number; + + type: string; + + x: number; + y: number; } export interface MapViewPointerMoveEvent { + native: any; + pointerId: number; + pointerType: string; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface MapViewPointerUpEvent { + native: any; + pointerId: number; + pointerType: string; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface MapViewResizeEvent { + height: number; + oldHeight: number; + oldWidth: number; + width: number; } - export interface MapViewDragEventOrigin { + + export interface MapViewDragEventOrigin extends Object { + x: number; + y: number; } - export interface HitTestResultResults { + + export interface HitTestResultResults extends Object { + /** + * A graphic representing a feature in the view that intersects the input screen coordinates. If the graphic comes from a layer with an applied [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html), then the [symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#symbol) property will be empty. Other properties may be empty based on the context in which the graphic is fetched. If the result comes from a [VectorTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-VectorTileLayer.html) then a static graphic is returned with two `attributes`: `layerId` and `layerName`. These correspond to the name and id of the style-layer in the [vector tile style](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Vector_Tile_Style/02r3000002nv000000/). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#HitTestResult) + */ graphic: Graphic; + /** + * The point geometry in the spatial reference of the view corresponding with the input screen coordinates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#HitTestResult) + */ mapPoint: Point; } interface SceneView extends View, BreakpointsOwner { + /** + * The observation point from which the visible portion (or perspective) of the SceneView is determined. Contains properties including the elevation, tilt, and heading (in degrees) of the current view. Setting the camera immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo). When set in the constructor, this property overrides the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint), [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent), [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center), [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale), and [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) properties. The camera property contains an internal reference which may be modified in the future. To persist or modify the camera, create a clone using [camera.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#clone). + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera) + */ camera: Camera; + /** + * Represents the view's center point; when setting the center you may pass a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) instance or an array of numbers representing at longitude/latitude pair (`[-100.4593, 36.9014]`). Setting the center immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo). If set in the constructor, this property will be ignored if the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint), [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera), or [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent) properties are also set in the constructor. The center property contains an internal reference which may be modified in the future. To persist or modify the center, create a clone using [center.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#clone). + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center) + */ center: Point; + /** + * Represents an optional clipping area used to define the visible [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) of a local scene. If defined, only data (including the basemap) within the area will be displayed. The `clippingArea` property only applies to [local](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode) scenes. ![scene-clipping-area](https://developers.arcgis.com/javascript/latest/assets/img/apiref/views/scene-clipping-area.png%20%22Local%20scene%20with%20clippingArea%22) The clippingArea property contains an internal reference which may be modified in the future. To persist or modify the clippingArea, create a clone using [clippingArea.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#clippingArea) + */ clippingArea: Extent; + /** + * Specifies constraints for [Camera tilt](esri-Camera.html#tilt) and altitude that may be applied to the SceneView. See the object specification table below for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ constraints: SceneViewConstraints; + /** + * Specifies various properties of the environment's visualization in the view. The SceneView will redraw automatically when any property of environment changes. + * ```js + * var view = new SceneView({ + * map: map, + * container: "viewDiv" + * }); + * + * // Set the sun position to reflect the current time + * view.environment.lighting.date = Date.now(); + * + * // Disable automatic lighting updates by camera tracking + * view.environment.lighting.cameraTrackingEnabled = true; + * ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + */ environment: SceneViewEnvironment; + /** + * The extent represents the visible portion of a [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) within the view as an instance of [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html). Setting the extent immediately changes the view without animation. To animate the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). Rather than using extent to change the visible portion of the [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) in a SceneView, you should use [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera) since it easily allows you to define the heading, elevation and tilt of the observation point from which the view's perspective is created. When set in the constructor, this property overrides the [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center), [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale), and [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) properties. This property will be ignored if the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint) or [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera) are also set in the constructor. The extent property contains an internal reference which may be modified in the future. To persist or modify the extent, create a clone using [extent.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone). + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent) + * + * @default null + */ extent: Extent; + /** + * Options for configuring the highlight. Use the highlight method on the appropriate [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) to highlight a feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) + */ highlightOptions: SceneViewHighlightOptions; + /** + * SceneView can draw scenes in two different quality modes: `high` and `low`. Using the `low` quality profile significantly increases performance on slower browsers and devices by reducing the visual quality in the following aspects: + * * Map resolution + * * Scene layer detail level + * * Anti-aliasing (edge smoothing) + * + * + * The default value is based on the detected browser: + * * `low` for Internet Explorer 11 and Safari + * * `high` for any other browser + * + * + * Overriding the default value is best done in the constructor (see example below). If the value is modified after construction, only a subset of the quality aspects are affected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#qualityProfile) + */ qualityProfile: string; + /** + * Represents an approximation of the map scale at the center of the view. Setting the scale immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo). When set in the constructor, this property overrides the [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) property. This property will be ignored if the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint), [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera), or [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent) properties are also set in the constructor. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale) + */ scale: number; + /** + * The viewing mode (`local` or `global`). Global scenes render the earth as a sphere. Local scenes render the earth on a flat plane and allow for navigation and feature display in a localized or [clipped](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#clippingArea) area. Users may also navigate the camera of a local scene below the surface of a basemap. + * + * Value | Example | Description + * ------|-------|------------ + * global | ![scene-global](https://developers.arcgis.com/javascript/latest/assets/img/apiref/views/scene-global.png) | Global scenes allow the entire globe to render in the view, showing the curvature of the earth. + * local | ![scene-local](https://developers.arcgis.com/javascript/latest/assets/img/apiref/views/scene-local.png) | Local scenes render the earth on a flat surface. They can be constrained to only show a "local" area by setting the [clippingArea](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#clipplingArea) property. Local scenes also allow for displaying and exploring data that would otherwise be hidden by the surface of the earth. + * + * Depending on the viewing mode different [supported coordinate systems](esri-views-SceneView.html#supported-coordinate-systems) are available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode) + * + * @default global + */ viewingMode: string; + /** + * Represents the current view as a [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) or point of observation on the view. In SceneViews, [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera) should be used in favor of viewpoint for watching or changing the point of view. Setting the viewpoint immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo). When set in the constructor, this property overrides the [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent), [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center), [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale), and [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) properties. This property will be ignored if [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera) is also set in the constructor. The viewpoint property contains an internal reference which may be modified in the future. To persist or modify the viewpoint, create a clone using [viewpoint.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#clone). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint) + */ viewpoint: Viewpoint; + /** + * Represents the level of detail (LOD) at the center of the view. Setting the zoom immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo). Setting this property in conjunction with [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center) is a convenient way to set the initial extent of the view. If set in the constructor, this property will be ignored if the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint), [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera), [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent), or [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale) properties are also set in the constructor. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) + */ zoom: number; + /** + * Sets the focus on the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#focus) + * + * + */ focus(): void; + /** + * Sets the view to a given target. The target parameter can be one of the following: + * * `[longitude, latitude]` pair of coordinates + * * [Geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) (or array of [Geometry[]](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html)) + * * [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) (or array of [Graphic[]](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html)) + * * [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) + * * [Camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html) + * * Object with a combination of `target`, `center`, `scale`, `position`, `heading` and `tilt` properties (with `target` being any of the types listed above). The `center` property is provided as a convenience to animate the [SceneView.center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center) and is the equivalent of specifying the `target` with the center [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html). The target must be provided in the spatial reference of the view. + * + * + * This function returns a promise which resolves as soon as the new view has been set to the target. If the transition is animated, then the ongoing animation can be obtained using [SceneView.animation](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#animation). If the given target is far away from the current camera position, then heading and tilt will be automatically set to their neutral values (facing north, looking top down). Tilt and heading can always be explicitly set to override this behavior. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + * + * @param target The target location/viewpoint to go to. When using an object for `target`, use the properties in the table below. + * @param target.target The target of the animation. + * @param target.center The [SceneView.center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center) to go to. + * @param target.scale The [SceneView.scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale) to go to. + * @param target.zoom The final [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) value to go to. + * @param target.heading The [Camera.heading](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading) to go to. + * @param target.tilt The [Camera.tilt](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#position) to go to. + * @param target.position The [Camera.position](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#position) to go to. + * @param options View transition options. + * @param options.animate Indicates if the transition to the new view should be animated. + * @param options.speedFactor Increases or decreases the animation speed by the specified factor. A speedFactor of 2 will make the animation twice as fast, while a speedFactor of 0.5 will make the animation half as fast. Setting the speed factor will automatically adapt the default maxDuration accordingly. + * @param options.duration Set the exact duration (in milliseconds) of the animation. Note that by default, animation duration is calculated based on the time required to reach the target at a constant speed. Setting duration overrides the speedFactor option. Note that the resulting duration is still limited to the maxDuration. + * @param options.maxDuration The maximum allowed duration (in milliseconds) of the animation. The default maxDuration value takes the specified speedFactor into account. + * @param options.easing The easing function to use for the animation. This may either be a preset (named) function, or a user specified function. Supported named presets are: `linear`, `in-cubic`, `out-cubic`, `in-out-cubic`, `in-expo`, `out-expo`, `in-out-expo` By default, animations that are less than 1000 ms use an out easing function; longer animations use an in-out function. + * + */ goTo(target: number[] | Geometry | Geometry[] | Graphic | Graphic[] | Viewpoint | Camera | SceneViewGoToTarget, options?: SceneViewGoToOptions): IPromise; + /** + * Indicates whether there is an event listener on the instance that matches the provided event name. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#hasEventListener) + * + * @param type The name of the event. + * + */ hasEventListener(type: string): boolean; + /** + * Returns the topmost feature from each layer that intersects the specified screen coordinates. The following layer types will return a result if a hit is made on an intersecting feature: [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html), [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), [CSVLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html), [GeoRSSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoRSSLayer.html), [KMLLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html), and [StreamLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-StreamLayer.html). Draped graphics (i.e. graphics in layers where the [elevation mode](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#elevationInfo) is `on-the-ground`) are currently **not** returned from this method, even when they intersect the input screen point. When the ground surface is hit, but no graphic is found, then the result of hitTest will be a single object with its mapPoint set to the point on the surface that was hit, but its graphic will be set to `null`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#hitTest) + * + * @param screenPoint The screen coordinates of the click on the view. + * @param screenPoint.x The horizontal screen coordinate of the click on the view. + * @param screenPoint.y The vertical screen coordinate of the click on the view. + * + */ hitTest(screenPoint: SceneViewHitTestScreenPoint): IPromise; + /** + * Registers an event handler on the instance. Call this method to hook an event with a listener. See the [Events summary table](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#events-summary) for a list of listened events. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#on) + * + * @param type The name of the event or the events to listen for. + * @param modifiersOrHandler Additional modifier keys to filter the events by. Alternatively, if no modifiers are required, the function to call when the event is fired. + * @param handler? The function to call when the event is fired, if modifiers were specified. + * + */ on(type: string | string[], modifiersOrHandler: string[] | EventHandler, handler?: EventHandler): IHandle; + /** + * Converts the given screen point to a [map point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#toMap) + * + * @param screenPoint The screen coordinates to convert. + * @param screenPoint.x The horizontal screen coordinate to convert. + * @param screenPoint.y The vertical screen coordinate to convert. + * @param mapPoint The point object that will reference the result. + * + */ toMap(screenPoint: SceneViewToMapScreenPoint, mapPoint?: Point): Point; + /** + * Converts the given [map point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) to a [screen point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-ScreenPoint.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#toScreen) + * + * @param point A point geometry. + * @param screenPoint ScreenPoint object that will reference the result. + * + */ toScreen(point: Point, screenPoint?: ScreenPoint): ScreenPoint; + on(name: "resize", eventHandler: SceneViewResizeEventHandler): IHandle; + on(name: "resize", modifiers: string[], eventHandler: SceneViewResizeEventHandler): IHandle; + on(name: "layerview-create", eventHandler: SceneViewLayerviewCreateEventHandler): IHandle; + on(name: "layerview-create", modifiers: string[], eventHandler: SceneViewLayerviewCreateEventHandler): IHandle; + on(name: "layerview-destroy", eventHandler: SceneViewLayerviewDestroyEventHandler): IHandle; + on(name: "layerview-destroy", modifiers: string[], eventHandler: SceneViewLayerviewDestroyEventHandler): IHandle; + on(name: "click", eventHandler: SceneViewClickEventHandler): IHandle; + on(name: "click", modifiers: string[], eventHandler: SceneViewClickEventHandler): IHandle; + on(name: "double-click", eventHandler: SceneViewDoubleClickEventHandler): IHandle; + on(name: "double-click", modifiers: string[], eventHandler: SceneViewDoubleClickEventHandler): IHandle; + on(name: "hold", eventHandler: SceneViewHoldEventHandler): IHandle; + on(name: "hold", modifiers: string[], eventHandler: SceneViewHoldEventHandler): IHandle; + on(name: "drag", eventHandler: SceneViewDragEventHandler): IHandle; + on(name: "drag", modifiers: string[], eventHandler: SceneViewDragEventHandler): IHandle; + on(name: "mouse-wheel", eventHandler: SceneViewMouseWheelEventHandler): IHandle; + on(name: "mouse-wheel", modifiers: string[], eventHandler: SceneViewMouseWheelEventHandler): IHandle; + on(name: "key-down", eventHandler: SceneViewKeyDownEventHandler): IHandle; + on(name: "key-down", modifiers: string[], eventHandler: SceneViewKeyDownEventHandler): IHandle; + on(name: "key-up", eventHandler: SceneViewKeyUpEventHandler): IHandle; + on(name: "key-up", modifiers: string[], eventHandler: SceneViewKeyUpEventHandler): IHandle; + on(name: "pointer-down", eventHandler: SceneViewPointerDownEventHandler): IHandle; + on(name: "pointer-down", modifiers: string[], eventHandler: SceneViewPointerDownEventHandler): IHandle; + on(name: "pointer-move", eventHandler: SceneViewPointerMoveEventHandler): IHandle; + on(name: "pointer-move", modifiers: string[], eventHandler: SceneViewPointerMoveEventHandler): IHandle; + on(name: "pointer-up", eventHandler: SceneViewPointerUpEventHandler): IHandle; + on(name: "pointer-up", modifiers: string[], eventHandler: SceneViewPointerUpEventHandler): IHandle; + + on(name: "pointer-enter", eventHandler: SceneViewPointerEnterEventHandler): IHandle; + + on(name: "pointer-enter", modifiers: string[], eventHandler: SceneViewPointerEnterEventHandler): IHandle; + + on(name: "pointer-leave", eventHandler: SceneViewPointerLeaveEventHandler): IHandle; + + on(name: "pointer-leave", modifiers: string[], eventHandler: SceneViewPointerLeaveEventHandler): IHandle; } interface SceneViewConstructor { + /** + * A SceneView displays a 3D view of a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) or [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html) instance using WebGL. To render a map and its layers in 2D, see the documentation for [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). For a general overview of views, see [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) + */ + new(properties?: SceneViewProperties): SceneView; } export const SceneView: SceneViewConstructor; interface SceneViewProperties extends ViewProperties, BreakpointsOwnerProperties { + /** + * The observation point from which the visible portion (or perspective) of the SceneView is determined. Contains properties including the elevation, tilt, and heading (in degrees) of the current view. Setting the camera immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo). When set in the constructor, this property overrides the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint), [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent), [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center), [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale), and [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) properties. The camera property contains an internal reference which may be modified in the future. To persist or modify the camera, create a clone using [camera.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#clone). + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera) + */ camera?: CameraProperties; - center?: PointProperties; + /** + * Represents the view's center point; when setting the center you may pass a [Point](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html) instance or an array of numbers representing at longitude/latitude pair (`[-100.4593, 36.9014]`). Setting the center immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo). If set in the constructor, this property will be ignored if the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint), [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera), or [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent) properties are also set in the constructor. The center property contains an internal reference which may be modified in the future. To persist or modify the center, create a clone using [center.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#clone). + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center) + */ + center?: PointProperties | number[]; + /** + * Represents an optional clipping area used to define the visible [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) of a local scene. If defined, only data (including the basemap) within the area will be displayed. The `clippingArea` property only applies to [local](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode) scenes. ![scene-clipping-area](https://developers.arcgis.com/javascript/latest/assets/img/apiref/views/scene-clipping-area.png%20%22Local%20scene%20with%20clippingArea%22) The clippingArea property contains an internal reference which may be modified in the future. To persist or modify the clippingArea, create a clone using [clippingArea.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#clippingArea) + */ clippingArea?: ExtentProperties; + /** + * Specifies constraints for [Camera tilt](esri-Camera.html#tilt) and altitude that may be applied to the SceneView. See the object specification table below for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ constraints?: SceneViewConstraintsProperties; + /** + * Specifies various properties of the environment's visualization in the view. The SceneView will redraw automatically when any property of environment changes. + * ```js + * var view = new SceneView({ + * map: map, + * container: "viewDiv" + * }); + * + * // Set the sun position to reflect the current time + * view.environment.lighting.date = Date.now(); + * + * // Disable automatic lighting updates by camera tracking + * view.environment.lighting.cameraTrackingEnabled = true; + * ``` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + */ environment?: SceneViewEnvironmentProperties; + /** + * The extent represents the visible portion of a [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) within the view as an instance of [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html). Setting the extent immediately changes the view without animation. To animate the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). Rather than using extent to change the visible portion of the [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) in a SceneView, you should use [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera) since it easily allows you to define the heading, elevation and tilt of the observation point from which the view's perspective is created. When set in the constructor, this property overrides the [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center), [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale), and [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) properties. This property will be ignored if the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint) or [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera) are also set in the constructor. The extent property contains an internal reference which may be modified in the future. To persist or modify the extent, create a clone using [extent.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html#clone). + * > **Z-values** defined in a geographic or metric coordinate system are expressed in meters. However, in local scenes that use a projected coordinate system, vertical units are assumed to be the same as the horizontal units specified by the service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent) + * + * @default null + */ extent?: ExtentProperties; - highlightOptions?: SceneViewHighlightOptions; + /** + * Options for configuring the highlight. Use the highlight method on the appropriate [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) to highlight a feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) + */ + highlightOptions?: SceneViewHighlightOptionsProperties; + /** + * SceneView can draw scenes in two different quality modes: `high` and `low`. Using the `low` quality profile significantly increases performance on slower browsers and devices by reducing the visual quality in the following aspects: + * * Map resolution + * * Scene layer detail level + * * Anti-aliasing (edge smoothing) + * + * + * The default value is based on the detected browser: + * * `low` for Internet Explorer 11 and Safari + * * `high` for any other browser + * + * + * Overriding the default value is best done in the constructor (see example below). If the value is modified after construction, only a subset of the quality aspects are affected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#qualityProfile) + */ qualityProfile?: string; + /** + * Represents an approximation of the map scale at the center of the view. Setting the scale immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo). When set in the constructor, this property overrides the [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) property. This property will be ignored if the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint), [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera), or [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent) properties are also set in the constructor. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale) + */ scale?: number; + /** + * The viewing mode (`local` or `global`). Global scenes render the earth as a sphere. Local scenes render the earth on a flat plane and allow for navigation and feature display in a localized or [clipped](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#clippingArea) area. Users may also navigate the camera of a local scene below the surface of a basemap. + * + * Value | Example | Description + * ------|-------|------------ + * global | ![scene-global](https://developers.arcgis.com/javascript/latest/assets/img/apiref/views/scene-global.png) | Global scenes allow the entire globe to render in the view, showing the curvature of the earth. + * local | ![scene-local](https://developers.arcgis.com/javascript/latest/assets/img/apiref/views/scene-local.png) | Local scenes render the earth on a flat surface. They can be constrained to only show a "local" area by setting the [clippingArea](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#clipplingArea) property. Local scenes also allow for displaying and exploring data that would otherwise be hidden by the surface of the earth. + * + * Depending on the viewing mode different [supported coordinate systems](esri-views-SceneView.html#supported-coordinate-systems) are available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode) + * + * @default global + */ viewingMode?: string; + /** + * Represents the current view as a [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) or point of observation on the view. In SceneViews, [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera) should be used in favor of viewpoint for watching or changing the point of view. Setting the viewpoint immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo). When set in the constructor, this property overrides the [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent), [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center), [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale), and [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) properties. This property will be ignored if [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera) is also set in the constructor. The viewpoint property contains an internal reference which may be modified in the future. To persist or modify the viewpoint, create a clone using [viewpoint.clone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html#clone). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint) + */ viewpoint?: ViewpointProperties; + /** + * Represents the level of detail (LOD) at the center of the view. Setting the zoom immediately changes the current view. For animating the view, see [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo). Setting this property in conjunction with [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center) is a convenient way to set the initial extent of the view. If set in the constructor, this property will be ignored if the [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewpoint), [camera](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#camera), [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#extent), or [scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale) properties are also set in the constructor. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) + */ zoom?: number; } export interface SceneViewClickEvent { + button: number; + mapPoint: Point; + native: any; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface SceneViewDoubleClickEvent { + button: number; + mapPoint: Point; + native: any; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface SceneViewDragEvent { + action: string; + native: any; + origin: SceneViewDragEventOrigin; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export type EasingFunction = (t: number, duration: number) => number; - export interface SceneViewHitTestResult { + /** + * Object specification for the result of the [hitTest()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#hitTest) method. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#HitTestResult) + */ + export interface SceneViewHitTestResult extends Object { + /** + * An array of result objects returned from the [hitTest()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#hitTest). Results are returned when the location of the input screen coordinates intersect a [Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) in the view. See the table below for the specification of each object in this array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#HitTestResult) + */ results: SceneViewHitTestResultResults[]; } export interface SceneViewHoldEvent { + button: number; + mapPoint: Point; + native: any; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface SceneViewKeyDownEvent { + key: string; + native: any; + repeat: boolean; + stopPropagation: Function; + timestamp: number; + type: string; } export interface SceneViewKeyUpEvent { + native: any; + stopPropagation: Function; + timestamp: number; + type: string; } export interface SceneViewLayerviewCreateEvent { + layer: Layer; + layerView: LayerView; } export interface SceneViewLayerviewDestroyEvent { + layer: Layer; + layerView: LayerView; } export interface SceneViewMouseWheelEvent { + deltaY: number; + native: any; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface SceneViewPointerDownEvent { + native: any; + pointerId: number; + pointerType: string; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + + y: number; + } + + export interface SceneViewPointerEnterEvent { + + native: any; + + pointerId: number; + + pointerType: string; + + stopPropagation: Function; + + timestamp: number; + + type: string; + + x: number; + + y: number; + } + + export interface SceneViewPointerLeaveEvent { + + native: any; + + pointerId: number; + + pointerType: string; + + stopPropagation: Function; + + timestamp: number; + + type: string; + + x: number; + y: number; } export interface SceneViewPointerMoveEvent { + native: any; + pointerId: number; + pointerType: string; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface SceneViewPointerUpEvent { + native: any; + pointerId: number; + pointerType: string; + stopPropagation: Function; + timestamp: number; + type: string; + x: number; + y: number; } export interface SceneViewResizeEvent { + height: number; + oldHeight: number; + oldWidth: number; + width: number; } - export interface SceneViewConstraintsProperties { + + export interface SceneViewConstraintsProperties extends Object { + /** + * Specifies a constraint on the minimum and maximum allowed camera altitude. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ altitude?: SceneViewConstraintsAltitudeProperties; + /** + * Specifies the near and far webgl clip distances. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ clipDistance?: SceneViewConstraintsClipDistanceProperties; + /** + * When enabled, prevents the user from navigating below the surface in a local SceneView. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ collision?: SceneViewConstraintsCollision; + /** + * Specifies a constraint on the amount of allowed tilting of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ tilt?: SceneViewConstraintsTiltProperties; } - export interface SceneViewConstraints extends Accessor { + + export interface SceneViewConstraints extends AnonymousAccessor { + /** + * Specifies a constraint on the minimum and maximum allowed camera altitude. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ altitude?: SceneViewConstraintsAltitude; + /** + * Specifies the near and far webgl clip distances. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ clipDistance?: SceneViewConstraintsClipDistance; + /** + * When enabled, prevents the user from navigating below the surface in a local SceneView. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ collision?: SceneViewConstraintsCollision; + /** + * Specifies a constraint on the amount of allowed tilting of the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ tilt?: SceneViewConstraintsTilt; } - export interface SceneViewConstraintsAltitudeProperties { - min?: number; - max?: number; - } - export interface SceneViewConstraintsAltitude extends Accessor { + + export interface SceneViewConstraintsAltitudeProperties extends Object { + /** + * The minimum allowed camera altitude (in meters). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + * + * @default -∞ + */ min?: number; + /** + * The maximum allowed camera altitude (in meters). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + * + * @default EARTH_RADIUS * 4 + */ max?: number; } - export interface SceneViewConstraintsClipDistanceProperties { - near?: number; - far?: number; - mode?: string; + export interface SceneViewConstraintsAltitude extends AnonymousAccessor { + /** + * The minimum allowed camera altitude (in meters). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + * + * @default -∞ + */ + min?: number; + /** + * The maximum allowed camera altitude (in meters). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + * + * @default EARTH_RADIUS * 4 + */ + max?: number; } - export interface SceneViewConstraintsClipDistance extends Accessor { + + + export interface SceneViewConstraintsClipDistanceProperties extends Object { + /** + * The near clip distance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ near?: number; + /** + * The far clip distance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ far?: number; + /** + * Specifies the mode of the constraint which is either `auto` or `manual`. In `auto` mode, the near and far clip distance values are automatically determined. In `manual` mode, the near and far clip distance values are user defined, constant values. Note that the mode automatically changes to `manual` whenever the `near` or `far` property is set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + * + * @default auto + */ mode?: string; } - export interface SceneViewConstraintsCollision { + export interface SceneViewConstraintsClipDistance extends AnonymousAccessor { + /** + * The near clip distance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ + near?: number; + /** + * The far clip distance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ + far?: number; + /** + * Specifies the mode of the constraint which is either `auto` or `manual`. In `auto` mode, the near and far clip distance values are automatically determined. In `manual` mode, the near and far clip distance values are user defined, constant values. Note that the mode automatically changes to `manual` whenever the `near` or `far` property is set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + * + * @default auto + */ + mode?: string; + } + + + export interface SceneViewConstraintsCollision extends Object { + /** + * Set to `false` to permit the user to navigate below the surface in a local SceneView. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + * + * @default true + */ enabled?: boolean; } - export interface SceneViewConstraintsTiltProperties { - max?: number; - mode?: string; - } - export interface SceneViewConstraintsTilt extends Accessor { + + export interface SceneViewConstraintsTiltProperties extends Object { + /** + * Specifies the maximum amount of tilt (in degrees) allowed in the view and may range from 0.5 to 179.5 degrees. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ max?: number; + /** + * Specifies the mode of the constraint. There are two possible values: `auto` or `manual`. In `auto` mode, the maximum tilt value is automatically determined based on the altitude of the view camera. In `manual` mode, the maximum tilt value is a user defined, constant value. **Note:** The mode automatically changes to `manual` whenever the `max` property is set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + * + * @default auto + */ mode?: string; } - export interface SceneViewEnvironmentProperties { + export interface SceneViewConstraintsTilt extends AnonymousAccessor { + /** + * Specifies the maximum amount of tilt (in degrees) allowed in the view and may range from 0.5 to 179.5 degrees. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + */ + max?: number; + /** + * Specifies the mode of the constraint. There are two possible values: `auto` or `manual`. In `auto` mode, the maximum tilt value is automatically determined based on the altitude of the view camera. In `manual` mode, the maximum tilt value is a user defined, constant value. **Note:** The mode automatically changes to `manual` whenever the `max` property is set. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#constraints) + * + * @default auto + */ + mode?: string; + } + + + export interface SceneViewEnvironmentProperties extends Object { + /** + * Lighting conditions of the scene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + */ lighting?: SceneViewEnvironmentLightingProperties; + /** + * Indicates whether atmosphere visualization is enabled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + */ atmosphereEnabled?: boolean; + /** + * Atmosphere conditions of the scene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + */ atmosphere?: SceneViewEnvironmentAtmosphereProperties; + /** + * Indicates whether stars visualization is enabled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default true + */ starsEnabled?: boolean; } - export interface SceneViewEnvironment extends Accessor { + + export interface SceneViewEnvironment extends AnonymousAccessor { + /** + * Lighting conditions of the scene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + */ lighting?: SceneViewEnvironmentLighting; + /** + * Indicates whether atmosphere visualization is enabled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + */ atmosphereEnabled?: boolean; + /** + * Atmosphere conditions of the scene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + */ atmosphere?: SceneViewEnvironmentAtmosphere; + /** + * Indicates whether stars visualization is enabled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default true + */ starsEnabled?: boolean; } - export interface SceneViewEnvironmentAtmosphereProperties { - quality?: string; - } - export interface SceneViewEnvironmentAtmosphere extends Accessor { + + export interface SceneViewEnvironmentAtmosphereProperties extends Object { + /** + * Indicates the quality of the atmosphere visualization. The quality of the atmosphere may have a significant impact on performance. This setting does not have any effect in [local scenes](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode). + * + * Known Value | Example + * ------------|--------- + * low | ![scene-atmosphere](https://developers.arcgis.com/javascript/latest/assets/img/apiref/views/scene-atmosphere.png) + * high | ![scene-atmosphere](https://developers.arcgis.com/javascript/latest/assets/img/apiref/views/scene-atmosphere-realistic.png) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default low + */ quality?: string; } - export interface SceneViewEnvironmentLightingProperties { + export interface SceneViewEnvironmentAtmosphere extends AnonymousAccessor { + /** + * Indicates the quality of the atmosphere visualization. The quality of the atmosphere may have a significant impact on performance. This setting does not have any effect in [local scenes](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#viewingMode). + * + * Known Value | Example + * ------------|--------- + * low | ![scene-atmosphere](https://developers.arcgis.com/javascript/latest/assets/img/apiref/views/scene-atmosphere.png) + * high | ![scene-atmosphere](https://developers.arcgis.com/javascript/latest/assets/img/apiref/views/scene-atmosphere-realistic.png) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default low + */ + quality?: string; + } + + + export interface SceneViewEnvironmentLightingProperties extends Object { + /** + * The current date and time of the simulated sun. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default new Date("March 15, 2015 12:00:00") + */ date?: DateProperties; + /** + * Indicates whether to show shadows cast by the sun + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default false + */ directShadowsEnabled?: boolean; + /** + * Indicates whether to show ambient occlusion shading. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default false + */ ambientOcclusionEnabled?: boolean; - cameraTrackingEnabled?: boolean; - } - export interface SceneViewEnvironmentLighting extends Accessor { - date?: Date; - directShadowsEnabled?: boolean; - ambientOcclusionEnabled?: boolean; + /** + * Indicates whether the date and time of the simulated sun is automatically updated to maintain the current time of day while the camera changes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default true + */ cameraTrackingEnabled?: boolean; } - export interface SceneViewGoToOptions { + export interface SceneViewEnvironmentLighting extends AnonymousAccessor { + /** + * The current date and time of the simulated sun. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default new Date("March 15, 2015 12:00:00") + */ + date?: Date; + /** + * Indicates whether to show shadows cast by the sun + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default false + */ + directShadowsEnabled?: boolean; + /** + * Indicates whether to show ambient occlusion shading. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default false + */ + ambientOcclusionEnabled?: boolean; + /** + * Indicates whether the date and time of the simulated sun is automatically updated to maintain the current time of day while the camera changes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#environment) + * + * @default true + */ + cameraTrackingEnabled?: boolean; + } + + + export interface SceneViewGoToOptions extends Object { + /** + * Indicates if the transition to the new view should be animated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + * + * @default true + */ animate?: boolean; + /** + * Increases or decreases the animation speed by the specified factor. A speedFactor of 2 will make the animation twice as fast, while a speedFactor of 0.5 will make the animation half as fast. Setting the speed factor will automatically adapt the default maxDuration accordingly. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + * + * @default 1 + */ speedFactor?: number; + /** + * Set the exact duration (in milliseconds) of the animation. Note that by default, animation duration is calculated based on the time required to reach the target at a constant speed. Setting duration overrides the speedFactor option. Note that the resulting duration is still limited to the maxDuration. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + */ duration?: number; + /** + * The maximum allowed duration (in milliseconds) of the animation. The default maxDuration value takes the specified speedFactor into account. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + * + * @default 8000 + */ maxDuration?: number; + /** + * The easing function to use for the animation. This may either be a preset (named) function, or a user specified function. Supported named presets are: `linear`, `in-cubic`, `out-cubic`, `in-out-cubic`, `in-expo`, `out-expo`, `in-out-expo` By default, animations that are less than 1000 ms use an out easing function; longer animations use an in-out function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + */ easing?: string | EasingFunction; } - export interface SceneViewGoToTarget { + + export interface SceneViewGoToTarget extends Object { + /** + * The target of the animation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + */ target?: number[] | Geometry | Geometry[] | Graphic | Graphic[] | Viewpoint | Camera; + /** + * The [SceneView.center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#center) to go to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + */ center?: number[]; + /** + * The [SceneView.scale](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#scale) to go to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + */ scale?: number; + /** + * The final [zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#zoom) value to go to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + */ zoom?: number; + /** + * The [Camera.heading](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading) to go to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + */ heading?: number; + /** + * The [Camera.tilt](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#position) to go to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + */ tilt?: number; + /** + * The [Camera.position](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#position) to go to. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#goTo) + */ position?: number; } - export interface SceneViewHighlightOptions { - color?: Color; + + export interface SceneViewHighlightOptionsProperties extends Object { + /** + * The color of the highlight. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) + * + * @default #00ffff + */ + color?: Color | number[] | string; + /** + * The opacity of the highlight halo. This will be multiplied with the opacity specified in `color`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) + * + * @default 1 + */ haloOpacity?: number; + /** + * The opacity of the fill (area within the halo). This will be multiplied with the opacity specified in `color`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) + * + * @default 0.25 + */ fillOpacity?: number; } - export interface SceneViewHitTestScreenPoint { + export interface SceneViewHighlightOptions extends AnonymousAccessor { + /** + * The color of the highlight. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) + * + * @default #00ffff + */ + color?: Color; + /** + * The opacity of the highlight halo. This will be multiplied with the opacity specified in `color`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) + * + * @default 1 + */ + haloOpacity?: number; + /** + * The opacity of the fill (area within the halo). This will be multiplied with the opacity specified in `color`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) + * + * @default 0.25 + */ + fillOpacity?: number; + } + + + export interface SceneViewHitTestScreenPoint extends Object { + /** + * The horizontal screen coordinate of the click on the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#hitTest) + */ x: number; + /** + * The vertical screen coordinate of the click on the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#hitTest) + */ y: number; } - export interface SceneViewToMapScreenPoint { + + export interface SceneViewToMapScreenPoint extends Object { + /** + * The horizontal screen coordinate to convert. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#toMap) + */ x: number; + /** + * The vertical screen coordinate to convert. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#toMap) + */ y: number; } - export interface SceneViewDragEventOrigin { + + export interface SceneViewDragEventOrigin extends Object { + x: number; + y: number; } - export interface SceneViewHitTestResultResults { + + export interface SceneViewHitTestResultResults extends Object { + /** + * A graphic present in the view that intersects the input screen coordinates. If the graphic comes from a layer with an applied [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html), then the [symbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#symbol) property will be empty. Other properties will be empty based on the context in which the graphic is fetched. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#HitTestResult) + */ graphic: Graphic; + /** + * The point geometry in the spatial reference of the view corresponding with the input screen coordinates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#HitTestResult) + */ mapPoint: Point; } interface DefaultUI extends UI { + /** + * An array of strings representing the default widgets visible when a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) is created. The default widgets differ between MapView and SceneView. The following are the default components in each view: **MapView:** `["attribution", "zoom"]` **SceneView:** `["attribution", "navigation-toggle", "compass", "zoom"]` + * > Esri requires that when you use an ArcGIS Online basemap in your app, the map must include Esri attribution and you must be licensed to use the content. For detailed guidelines on working with attribution, please visit the official [attribution in your app](https://developers.arcgis.com/terms/attribution/) documentation. For information on terms of use, see the [Terms of Use FAQ](https://developers.arcgis.com/terms/faq/). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-DefaultUI.html#components) + */ components: string[]; } interface DefaultUIConstructor { + /** + * The DefaultUI class exposes the default [widget](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html) [components](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-DefaultUI.html#components) available in either a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). This class also provides a simple API for [adding](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-DefaultUI.html#add), [moving](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-DefaultUI.html#move) and [removing](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-DefaultUI.html#remove) [widgets](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html) and other HTML components from the view's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-DefaultUI.html) + */ + new(properties?: DefaultUIProperties): DefaultUI; } export const DefaultUI: DefaultUIConstructor; interface DefaultUIProperties extends UIProperties { + /** + * An array of strings representing the default widgets visible when a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) is created. The default widgets differ between MapView and SceneView. The following are the default components in each view: **MapView:** `["attribution", "zoom"]` **SceneView:** `["attribution", "navigation-toggle", "compass", "zoom"]` + * > Esri requires that when you use an ArcGIS Online basemap in your app, the map must include Esri attribution and you must be licensed to use the content. For detailed guidelines on working with attribution, please visit the official [attribution in your app](https://developers.arcgis.com/terms/attribution/) documentation. For information on terms of use, see the [Terms of Use FAQ](https://developers.arcgis.com/terms/faq/). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-DefaultUI.html#components) + */ components?: string[]; } interface UI extends Accessor { + /** + * The HTML Element that contains the the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#container) + */ container: HTMLElement; - height: number; + /** + * The height of the UI container. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#height) + */ + readonly height: number; + /** + * Defines the padding for the UI from the top, left, right, and bottom sides of the container or [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). If the value is a number, it will be used to pad all sides of the container. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#padding) + * + * @default { left: 15, top: 15, right: 15, bottom: 15 } + */ padding: any | number; + /** + * The view associated with the UI components. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#view) + */ view: MapView | SceneView; - width: number; + /** + * The width of the UI container. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#width) + */ + readonly width: number; + /** + * Adds one or more HTML component(s) or [widgets](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html) to the UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#add) + * + * @param component The component(s) to add to the UI. This can be a widget instance, HTML element, a string value representing a DOM node ID, or an array containing a combination of any of those types. See the example snippets below for code examples. Alternatively, you can pass an array of objects with the following specification. + * @param component.component The component to add to the UI. This can be a widget instance, HTML element, a string value representing a DOM node ID. + * @param component.position The position in the view at which to add the component. If not specified, `manual` is used by default. **Known Values:** top-left | top-right | bottom-left | bottom-right | manual + * @param component.index The placement index of the component. This index shows where to place the component relative to other components. For example a value of `0` would place it topmost when position is top-*, leftmost for bottom-left and right most for bottom-right. + * @param position The position in the view at which to add the component. If not specified, `manual` is used by default. **Known Values:** top-left | top-right | bottom-left | bottom-right | manual + * @param position.position The position in the view at which to add the component(s). If not specified, `manual` is used by default. **Known Values:** top-left | top-right | bottom-left | bottom-right | manual + * @param position.index The placement index of the component(s). This index shows where to place the component relative to other components. For example a value of `0` would place it topmost when position is top-*, leftmost for bottom-left and right most for bottom-right. + * + */ add(component: Widget | HTMLElement | string | any[] | UIAddComponent, position?: string | UIAddPosition): void; + /** + * Removes all components from a given position. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#empty) + * + * @param position The position from which to remove all components. If not specified, `manual` is used by default. **Known Values:** top-left | top-right | bottom-left | bottom-right | manual + * + */ empty(position?: string): void; + /** + * Moves one or more UI component(s) to the specified position. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#move) + * + * @param component The component(s) to move. This value can be a widget instance, HTML element, a string value representing a DOM node ID, or an array containing a combination of any of those types. See the example snippets below for code examples. Alternatively, you can pass an array of objects with the following specification. + * @param component.component The component to move. This can be a widget instance, HTML element, a string value representing a DOM node ID. + * @param component.position The destination position. The component will be placed in the UI [container](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#container) when not provided. If not specified, `manual` is used by default. **Known Values:** top-left | top-right | bottom-left | bottom-right | manual + * @param position The destination position. The component will be placed in the UI [container](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#container) when not provided. **Known Values:** top-left | top-right | bottom-left | bottom-right | manual + * + */ move(component: Widget | HTMLElement | string | any[] | UIMoveComponent, position?: string): void; + /** + * Removes one or more HTML component(s) or [widgets](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html) from the UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#remove) + * + * @param component The component(s) to remove from the UI. This can be a widget instance, HTML element, a string value representing a DOM node ID, or an array containing a combination of any of those types. See the example snippets below for code examples. + * + */ remove(component: Widget | HTMLElement | string | any[]): void; } interface UIConstructor { + /** + * This class provides a simple interface for [adding](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#add), [moving](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#move) and [removing](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#remove) components from a view's user interface (UI). In most cases, you will work with the view's [DefaultUI](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-DefaultUI.html) which places default [widgets](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html), such as [Zoom](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom.html) and [Attribution](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution.html) in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html) + */ + new(properties?: UIProperties): UI; } export const UI: UIConstructor; interface UIProperties { + /** + * The HTML Element that contains the the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#container) + */ container?: HTMLElement; - height?: number; + /** + * Defines the padding for the UI from the top, left, right, and bottom sides of the container or [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). If the value is a number, it will be used to pad all sides of the container. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#padding) + * + * @default { left: 15, top: 15, right: 15, bottom: 15 } + */ padding?: any | number; + /** + * The view associated with the UI components. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#view) + */ view?: MapViewProperties | SceneViewProperties; - width?: number; } - export interface UIAddComponent { + + export interface UIAddComponent extends Object { + /** + * The component to add to the UI. This can be a widget instance, HTML element, a string value representing a DOM node ID. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#add) + */ component: Widget | HTMLElement | string; + /** + * The position in the view at which to add the component. If not specified, `manual` is used by default. **Known Values:** top-left | top-right | bottom-left | bottom-right | manual + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#add) + */ position?: string; + /** + * The placement index of the component. This index shows where to place the component relative to other components. For example a value of `0` would place it topmost when position is top-*, leftmost for bottom-left and right most for bottom-right. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#add) + */ index?: number; } - export interface UIAddPosition { + + export interface UIAddPosition extends Object { + /** + * The position in the view at which to add the component(s). If not specified, `manual` is used by default. **Known Values:** top-left | top-right | bottom-left | bottom-right | manual + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#add) + */ position?: string; + /** + * The placement index of the component(s). This index shows where to place the component relative to other components. For example a value of `0` would place it topmost when position is top-*, leftmost for bottom-left and right most for bottom-right. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#add) + */ index: number; } - export interface UIMoveComponent { + + export interface UIMoveComponent extends Object { + /** + * The component to move. This can be a widget instance, HTML element, a string value representing a DOM node ID. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#move) + */ component: Widget | HTMLElement | string; + /** + * The destination position. The component will be placed in the UI [container](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#container) when not provided. If not specified, `manual` is used by default. **Known Values:** top-left | top-right | bottom-left | bottom-right | manual + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-UI.html#move) + */ position?: string; } interface View extends Accessor, corePromise, DOMContainer { + /** + * Collection containing a flat list of all the created [LayerViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) related to the basemap, operational layers, and group layers in this view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#allLayerViews) + */ allLayerViews: Collection; + /** + * Represents an ongoing view animation initialized by [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). You may [watch](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html#watch) this property to be notified when the view's extent changes . + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#animation) + */ animation: ViewAnimation; + /** + * Allows for adding [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) directly to the default graphics in the View. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#graphics) + */ graphics: Collection; - interacting: boolean; + /** + * Indication whether the view is being interacted with (for example when panning). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#interacting) + * + * @default false + */ + readonly interacting: boolean; + /** + * A collection containing a hierarchical list of all the created [LayerViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) of the [operational layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers) in the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#layerViews) + */ layerViews: Collection; + /** + * An instance of a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) object to display in the view. A view may only display one map at a time. On the other hand, one [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) may be viewed by multiple [MapViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) and/or [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) simultaneously. This property is typically set in the constructor of the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). See the [class description](#) for examples demonstrating the relationship between the map and the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) + */ map: Map; + /** + * Use the padding property to make the [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center), and [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#extent), etc. work off a subsection of the full view. This is particularly useful when layering UI elements or semi-transparent content on top of portions of the view. See the [view padding sample](https://developers.arcgis.com/javascript/latest/sample-code/view-padding/index.html) for an example of how this works. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#padding) + * + * @default {left: 0, top: 0, right: 0, bottom: 0} + */ padding: ViewPadding; - ready: boolean; + /** + * When `true`, this property indicates whether the view successfully satisfied all dependencies, signaling that the following conditions are met. + * * The view has a [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map). If [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) is a [WebMap](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html) or a [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html), then the map or scene must be [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#loaded). + * * The view has a [container](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#container) with a size greater than `0`. + * * The view has a [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#spatialReference). + * + * + * When a view becomes ready it will resolve itself and invoke the callback defined in [when()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#when) where code can execute on a working view. Subsequent changes to a view's readiness would typically be handled by watching `view.ready` and providing logic for cases where the [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) or [container](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#container) change. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#ready) + * + * @default false + */ + readonly ready: boolean; + /** + * The spatial reference of the view. This indicates the [Projected Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/) or the [Geographic Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) used to locate geographic features in the map. In a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) the following [supported coordinate systems](esri-views-SceneView.html#supported-coordinate-systems) are available. The spatial reference can either be set explicitly or automatically derived from the following: + * * In the case of a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html), if the [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#map) is a [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html) instance, the [WebScene.initialViewProperties.spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#initialViewProperties) is used. + * * In all other cases, the spatial reference is derived from the first layer that loads in this order: + * * [map.basemap.baseLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#baseLayers) + * * [map.layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers) + * * [map.ground.layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#layers) + * + * + * When using an [Esri basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap), the default spatial reference is Web Mercator Auxiliary Sphere. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#spatialReference) + * + * @default null + */ spatialReference: SpatialReference; - stationary: boolean; - type: string; - updating: boolean; + /** + * Indication whether the view is animating, being interacted with or resizing. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#stationary) + * + * @default true + */ + readonly stationary: boolean; + /** + * The type of the view is either `2d` (indicating a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html)) or `3d` (indicating a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html)). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#type) + */ + readonly type: string; + /** + * Indicates whether the view is being updated by additional data requests to the network, or by processing received data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#updating) + * + * @default false + */ + readonly updating: boolean; + /** + * Gets the [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) created on the view for the given layer. The returned promise resolves when the layer view for the given layer has been created, or rejects with an error (for example if the layer is not part of the view, or if the layer type is not supported in this view). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#whenLayerView) + * + * @param layer The layer for which to obtain its LayerView. + * + */ whenLayerView(layer: Layer): IPromise; } interface ViewConstructor { + /** + * A view provides the means of viewing and interacting with the components of a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html). The [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) is merely a container, storing the geographic information contained in base layers and operational layers. The View renders the [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) and its various [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers), making them visible to the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) + */ + new(properties?: ViewProperties): View; } export const View: ViewConstructor; interface ViewProperties extends DOMContainerProperties { + /** + * Collection containing a flat list of all the created [LayerViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) related to the basemap, operational layers, and group layers in this view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#allLayerViews) + */ allLayerViews?: CollectionProperties; + /** + * Represents an ongoing view animation initialized by [goTo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#goTo). You may [watch](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Accessor.html#watch) this property to be notified when the view's extent changes . + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#animation) + */ animation?: ViewAnimationProperties; + /** + * Allows for adding [graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html) directly to the default graphics in the View. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#graphics) + */ graphics?: CollectionProperties; - interacting?: boolean; + /** + * A collection containing a hierarchical list of all the created [LayerViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) of the [operational layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers) in the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#layerViews) + */ layerViews?: CollectionProperties; + /** + * An instance of a [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) object to display in the view. A view may only display one map at a time. On the other hand, one [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html) may be viewed by multiple [MapViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) and/or [SceneViews](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) simultaneously. This property is typically set in the constructor of the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). See the [class description](#) for examples demonstrating the relationship between the map and the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) + */ map?: MapProperties; + /** + * Use the padding property to make the [center](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#center), and [extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#extent), etc. work off a subsection of the full view. This is particularly useful when layering UI elements or semi-transparent content on top of portions of the view. See the [view padding sample](https://developers.arcgis.com/javascript/latest/sample-code/view-padding/index.html) for an example of how this works. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#padding) + * + * @default {left: 0, top: 0, right: 0, bottom: 0} + */ padding?: ViewPadding; - ready?: boolean; + /** + * The spatial reference of the view. This indicates the [Projected Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/) or the [Geographic Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) used to locate geographic features in the map. In a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) the following [supported coordinate systems](esri-views-SceneView.html#supported-coordinate-systems) are available. The spatial reference can either be set explicitly or automatically derived from the following: + * * In the case of a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html), if the [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#map) is a [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html) instance, the [WebScene.initialViewProperties.spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#initialViewProperties) is used. + * * In all other cases, the spatial reference is derived from the first layer that loads in this order: + * * [map.basemap.baseLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#baseLayers) + * * [map.layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#layers) + * * [map.ground.layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#layers) + * + * + * When using an [Esri basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap), the default spatial reference is Web Mercator Auxiliary Sphere. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#spatialReference) + * + * @default null + */ spatialReference?: SpatialReferenceProperties; - stationary?: boolean; - type?: string; - updating?: boolean; } - export interface ViewPadding { + + export interface ViewPadding extends Object { + /** + * The left padding (in pixels). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#padding) + */ left?: number; + /** + * The top padding (in pixels). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#padding) + */ top?: number; + /** + * The right padding (in pixels). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#padding) + */ right?: number; + /** + * The bottom padding (in pixels). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#padding) + */ bottom?: number; } interface ViewAnimation extends Accessor, corePromise { - state: string; + /** + * The state of the animation. The animation terminates when the state is either `finished` or `stopped` and cannot transition again to `running`. The `finished` state indicates the animation has successfully ended, while the `stopped` state indicates that the animation was interrupted before it reached its final target. **Known Values:** running | finished | stopped + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ViewAnimation.html#state) + * + * @default running + */ + readonly state: string; + /** + * The target of the animation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ViewAnimation.html#target) + */ target: Viewpoint; + /** + * Finishes the view animation by immediately going to the target and sets the state of the animation to `finished`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ViewAnimation.html#finish) + * + * + */ finish(): void; + /** + * Stops the view animation at its current state and sets the state of the animation to `stopped`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ViewAnimation.html#stop) + * + * + */ stop(): void; } interface ViewAnimationConstructor { + /** + * Contains a [state](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ViewAnimation.html#state) property used for checking the state of the animation. The view animation is resolved when the animation has `finished` and is rejected if it is `stopped`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ViewAnimation.html) + */ + new(properties?: ViewAnimationProperties): ViewAnimation; } export const ViewAnimation: ViewAnimationConstructor; interface ViewAnimationProperties { - state?: string; + /** + * The target of the animation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ViewAnimation.html#target) + */ target?: ViewpointProperties; } interface WebMap extends Map, corePromise { + /** + * Object responsible for containing the viewing and editing properties of the WebMap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#applicationProperties) + */ applicationProperties: any; + /** + * An array of saved geographic extents that allow end users to quickly navigate to a particular area of interest. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#bookmarks) + */ bookmarks: any[]; + /** + * The initial view of the WebMap. This object contains properties such as [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-webmap-InitialViewProperties.html#viewpoint), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-webmap-InitialViewProperties.html#spatialReference), that should be applied to the view when the WebMap loads. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#initialViewProperties) + */ initialViewProperties: InitialViewProperties; - loaded: boolean; - loadError: Error; - loadStatus: string; + /** + * Indicates whether the instance has loaded. When `true`, the properties of the object can be accessed. A WebMap is considered loaded when its [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#layers) and [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#basemap) are created, but not yet loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#loaded) + * + * @default false + */ + readonly loaded: boolean; + /** + * The Error object returned if an error occurred while loading. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#loadError) + * + * @default null + */ + readonly loadError: Error; + /** + * Represents the status of a [load](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#load) operation. + * + * Value | Description + * ------|------------ + * not-loaded | The object's resources have not loaded. + * loading | The object's resources are currently loading. + * loaded | The object's resources have loaded without errors. + * failed | The object's resources failed to load. See [loadError](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#loadError) for more details. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#loadStatus) + * + * @default not-loaded + */ + readonly loadStatus: string; + /** + * The portal item from which the WebMap is loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#portalItem) + */ portalItem: PortalItem; + /** + * Provides multiple slides. Each slide has a different "title", "extent", "basemap", "layers" etc. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#presentation) + */ presentation: any; - sourceVersion: WebMapSourceVersion; + /** + * The version of the source document from which the WebMap was read. The WebMap must be version 2.x to load into an app. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#sourceVersion) + */ + readonly sourceVersion: WebMapSourceVersion; + /** + * An array of table objects in the WebMap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#tables) + */ tables: any[]; + /** + * The widgets object contains widgets that should be exposed to the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#widgets) + */ widgets: any; + /** + * Triggers the loading of the WebMap instance. A WebMap is considered [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#loaded) when its [operational layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#layers) and [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#basemap) are fully created. When created with a [portalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#portalItem), `load()` will first fetch its data to create the content, otherwise it resolves immediately. The [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) automatically calls the `load()` method when a WebMap instance is added to its [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#map) property so it can display in the view and load each individual layer. If the WebMap is used outside of a view, for example to preload it, you must call `load()` explicitly to interact with its resources. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#load) + * + * + */ load(): IPromise; } interface WebMapConstructor { + /** + * Loads a [WebMap](https://doc.arcgis.com/en/arcgis-online/create-maps/make-your-first-map.htm) from [ArcGIS Online](https://www.arcgis.com/home/) or [Portal for ArcGIS](http://server.arcgis.com/en/portal/) into a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html) + */ + new(properties?: WebMapProperties): WebMap; } export const WebMap: WebMapConstructor; interface WebMapProperties extends MapProperties { + /** + * Object responsible for containing the viewing and editing properties of the WebMap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#applicationProperties) + */ applicationProperties?: any; + /** + * An array of saved geographic extents that allow end users to quickly navigate to a particular area of interest. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#bookmarks) + */ bookmarks?: any[]; + /** + * The initial view of the WebMap. This object contains properties such as [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-webmap-InitialViewProperties.html#viewpoint), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-webmap-InitialViewProperties.html#spatialReference), that should be applied to the view when the WebMap loads. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#initialViewProperties) + */ initialViewProperties?: InitialViewPropertiesProperties; - loaded?: boolean; - loadError?: Error; - loadStatus?: string; + /** + * The portal item from which the WebMap is loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#portalItem) + */ portalItem?: PortalItemProperties; + /** + * Provides multiple slides. Each slide has a different "title", "extent", "basemap", "layers" etc. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#presentation) + */ presentation?: any; - sourceVersion?: WebMapSourceVersion; + /** + * An array of table objects in the WebMap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#tables) + */ tables?: any[]; + /** + * The widgets object contains widgets that should be exposed to the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#widgets) + */ widgets?: any; } interface InitialViewProperties extends Accessor, corePromise { + /** + * The spatial reference of the [WebMap](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html). This indicates the [Projected Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/) or the [Geographic Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) used to locate geographic features in the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webmap-InitialViewProperties.html#spatialReference) + */ spatialReference: SpatialReference; + /** + * The initial viewpoint of the [WebMap](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webmap-InitialViewProperties.html#viewpoint) + */ viewpoint: Viewpoint; + /** + * Creates a deep clone of this object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webmap-InitialViewProperties.html#clone) + * + * + */ clone(): InitialViewProperties; } interface InitialViewPropertiesConstructor { + + new(properties?: InitialViewPropertiesProperties): InitialViewProperties; } export const InitialViewProperties: InitialViewPropertiesConstructor; interface InitialViewPropertiesProperties { + /** + * The spatial reference of the [WebMap](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html). This indicates the [Projected Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/) or the [Geographic Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) used to locate geographic features in the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webmap-InitialViewProperties.html#spatialReference) + */ spatialReference?: SpatialReferenceProperties; + /** + * The initial viewpoint of the [WebMap](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webmap-InitialViewProperties.html#viewpoint) + */ viewpoint?: ViewpointProperties; } - export interface WebMapSourceVersion { + + export interface WebMapSourceVersion extends Object { + /** + * The major version of the WebMap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#sourceVersion) + */ major: number; + /** + * The minor version of the WebMap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebMap.html#sourceVersion) + */ minor: number; } interface WebScene extends Map, corePromise { + /** + * *This property only applies to local scenes.* Represents an optional clipping area used to define the bounds or [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) of a local scene. If defined, only data (including the basemap) within the area will be displayed. Set the [clippingEnabled](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#clippingEnabled) property to `true` to apply the specified clippingArea to the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#clippingArea) + */ clippingArea: Extent; + /** + * *This property only applies to local scenes.* Determines whether clipping using the [clippingArea](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#clippingArea) is enabled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#clippingEnabled) + * + * @default false + */ clippingEnabled: boolean; + /** + * The height model info of the [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html). This object defines the characteristics of the vertical coordinate system used by the scene. In a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html), the height model info is used to avoid combining layers that have incompatible vertical coordinate systems. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#heightModelInfo) + */ heightModelInfo: HeightModelInfo; + /** + * The initial view of the WebScene. This object contains properties such as [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#viewpoint), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#spatialReference), [viewingMode](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#viewingMode), and [environment](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#environment) that should be applied to the [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) when the scene loads. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#initialViewProperties) + */ initialViewProperties: websceneInitialViewProperties; - loaded: boolean; - loadError: Error; - loadStatus: string; + /** + * Indicates whether the instance has loaded. When `true`, the properties of the object can be accessed. A WebScene is considered loaded when its [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#layers) and [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#basemap) are fully created, but not yet loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#loaded) + * + * @default false + */ + readonly loaded: boolean; + /** + * The Error object returned if an error occurred while loading. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#loadError) + * + * @default null + */ + readonly loadError: Error; + /** + * Represents the status of a [load](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#load) operation. + * + * Value | Description + * ------|------------ + * not-loaded | The object's resources have not loaded. + * loading | The object's resources are currently loading. + * loaded | The object's resources have loaded without errors. + * failed | The object's resources failed to load. See [loadError](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#loadError) for more details. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#loadStatus) + * + * @default not-loaded + */ + readonly loadStatus: string; + /** + * The portal item from which the WebScene is loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#portalItem) + */ portalItem: PortalItem; + /** + * Provides a [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of slides that act as bookmarks for saving predefined [viewpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) and visible layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#presentation) + */ presentation: Presentation; - sourceVersion: WebSceneSourceVersion; + /** + * The version of the source document from which the WebScene was read. The WebScene must be version 1.x to load into an app. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#sourceVersion) + */ + readonly sourceVersion: WebSceneSourceVersion; + /** + * Triggers the loading of the WebScene instance. A WebScene is considered [loaded](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#loaded) when its [operational layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#layers), [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#basemap) and [ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#ground) are fully created. When created with a [portalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#portalItem), `load()` will first fetch its data to create the content, otherwise it resolves immediately. The [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) automatically calls the `load()` method when a WebScene instance is added to its [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#map) property so it can display in the view and load each individual layer. If the WebScene is used outside of a view, for example to preload it, you must call `load()` explicitly to interact with its resources. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#load) + * + * + */ load(): IPromise; + /** + * Saves the webscene to its associated portal item. The portal item to save to must already exist and be valid. This is a convenience method that will use [PortalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html#update) to store the webscene in the item. The web scene is saved according to [web scene specification](https://developers.arcgis.com/web-scene-specification/) standards. Use [updateFrom](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#updateFrom) to store the current view properties in the webscene before saving it. Note that this saves the webscene to its existing item. Depending on how the scene is shared, users that do not own the scene may modify it. To save an existing scene as a new item owned by the user signed into the portal instance, use [saveAs()](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#saveAs). The webscene will be automatically loaded if it is not already before saving. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#save) + * + * @param options Additional options. + * @param options.ignoreUnsupported When `true`, the scene will save even if it contains unsupported content (layers, renderers, symbols). Any content that is not supported will not be saved and the scene may appear different when reloaded from its portal item. + * + */ save(options?: WebSceneSaveOptions): IPromise; - saveAs(portalItem: PortalItem, options?: WebSceneSaveAsOptions): IPromise; + /** + * Saves the webscene to a new portal item. If saving has completed successfully, then the saved portal item will be set in the portalItem property of the WebScene. This is a convenience method that will create a new [PortalItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalItem.html) and use [PortalUser.addItem()](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-PortalUser.html#addItem) to store the webscene in a [Portal](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html). Use [updateFrom](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#updateFrom) to store the current view properties in the webscene before saving it. Note that this always saves the webscene as a new portal item owned by the user performing the edits and executing the `saveAs()` method. If you want to modify the existing item without changing its ownership use [save()](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#save). The webscene will be automatically loaded if it is not already before saving. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#saveAs) + * + * @param portalItem The new portal item to which the scene will be saved. Portal item properties such as the title or description need to be explicitly set on the item and will not be automatically copied from the current associated scene portal item (if any). + * @param options additional save options. + * @param options.folder the folder in which to save the item. + * @param options.ignoreUnsupported allow the scene to be saved even in the case it contains unsupported content (layers, renderers, symbols). Any content that is not supported will not be saved and the scene may appear different when reloaded from its portal item. + * + */ + saveAs(portalItem: PortalItem | PortalItemProperties, options?: WebSceneSaveAsOptions): IPromise; + /** + * Converts an instance of [this class]() to its ArcGIS Portal JSON representation. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide and the [web scene specification](https://developers.arcgis.com/web-scene-specification/) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#toJSON) + * + * + */ toJSON(): any; + /** + * Update properties of the WebScene related to the view. This should usually be called just before saving a scene. The following properties are updated from the view: 1. `initialViewProperties.spatialReference` 2. `initialViewProperties.viewingMode` 3. `clippingArea` 4. `heightModelInfo` Depending on the provided options, the following properties are also updated: 1. `initialViewProperties.environment` 1. `initialViewProperties.viewpoint` + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#updateFrom) + * + * @param view the view to update from. + * @param options update options. + * @param options.environmentExcluded update the initial environment from the view, defaults to false. + * @param options.viewpointExcluded update the initial viewpoint from the view, defaults to false. + * + */ updateFrom(view: SceneView, options?: WebSceneUpdateFromOptions): void; } interface WebSceneConstructor { + /** + * The web scene is the core element of 3D mapping across the ArcGIS platform. It defines the content, style, environment, and slides of your scene and it can be shared across multiple ArcGIS web and desktop applications. Web scenes can be created, published, and consumed in [ArcGIS Pro](http://pro.arcgis.com/en/pro-app/help/mapping/map-authoring/author-a-web-scene.htm) and ArcGIS Online with the [Scene Viewer](http://server.arcgis.com/en/portal/latest/use/make-your-first-scene.htm). The web scene is saved as a JSON document that can be consumed by the ArcGIS API for JavaScript via the WebScene class to easily create compelling 3D applications. The JSON document is written according to the [web scene specification](https://developers.arcgis.com/web-scene-specification/). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html) + */ + new(properties?: WebSceneProperties): WebScene; + /** + * Creates a new instance of [this class]() and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input `json` parameter often comes from a response to a query operation in the REST API or a [toJSON()](http://pro.arcgis.com/en/pro-app/tool-reference/conversion/features-to-json.htm) method from another ArcGIS product. If the [WebScene]() is used outside of a view, you must call [load()](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#load) explicitly to interact with its resources. See the [Using fromJSON()](https://developers.arcgis.com/javascript/latest/guide/using-fromjson/index.html) topic in the Guide for details and examples of when and how to use this function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#fromJSON) + * + * @param json A JSON representation of the instance in the ArcGIS format. See the [web scene specification](https://developers.arcgis.com/web-scene-specification/) for more detailed information on serializing web scenes to JSON. + * + */ fromJSON(json: any): any; } export const WebScene: WebSceneConstructor; interface WebSceneProperties extends MapProperties { + /** + * *This property only applies to local scenes.* Represents an optional clipping area used to define the bounds or [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) of a local scene. If defined, only data (including the basemap) within the area will be displayed. Set the [clippingEnabled](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#clippingEnabled) property to `true` to apply the specified clippingArea to the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#clippingArea) + */ clippingArea?: ExtentProperties; + /** + * *This property only applies to local scenes.* Determines whether clipping using the [clippingArea](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#clippingArea) is enabled. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#clippingEnabled) + * + * @default false + */ clippingEnabled?: boolean; + /** + * The height model info of the [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html). This object defines the characteristics of the vertical coordinate system used by the scene. In a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html), the height model info is used to avoid combining layers that have incompatible vertical coordinate systems. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#heightModelInfo) + */ heightModelInfo?: HeightModelInfoProperties; + /** + * The initial view of the WebScene. This object contains properties such as [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#viewpoint), [spatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#spatialReference), [viewingMode](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#viewingMode), and [environment](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#environment) that should be applied to the [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) when the scene loads. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#initialViewProperties) + */ initialViewProperties?: websceneInitialViewPropertiesProperties; - loaded?: boolean; - loadError?: Error; - loadStatus?: string; + /** + * The portal item from which the WebScene is loaded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#portalItem) + */ portalItem?: PortalItemProperties; + /** + * Provides a [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of slides that act as bookmarks for saving predefined [viewpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) and visible layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#presentation) + */ presentation?: PresentationProperties; - sourceVersion?: WebSceneSourceVersion; } interface Environment extends Accessor { + /** + * Settings for defining the lighting of the scene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Environment.html#lighting) + */ lighting: Lighting; + /** + * Creates a deep clone of this object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Environment.html#clone) + * + * + */ clone(): Environment; } interface EnvironmentConstructor { + + new(properties?: EnvironmentProperties): Environment; } export const Environment: EnvironmentConstructor; interface EnvironmentProperties { + /** + * Settings for defining the lighting of the scene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Environment.html#lighting) + */ lighting?: LightingProperties; } interface websceneInitialViewProperties extends Accessor, corePromise { + /** + * The initial environment settings of the [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#environment) + */ environment: Environment; + /** + * The spatial reference of the [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html). This indicates the [Projected Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/) or the [Geographic Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) used to locate geographic features in the map. In a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) the following [supported coordinate systems](esri-views-SceneView.html#supported-coordinate-systems) are available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#spatialReference) + */ spatialReference: SpatialReference; + /** + * The viewing mode of the scene. Global scenes allow the user to navigate the globe. Local scenes allow for navigation and feature display in a particular "localized" area. Users may also navigate the view's camera below the surface of a basemap in local scenes. **Known Values:** global | local + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#viewingMode) + * + * @default global + */ viewingMode: string; + /** + * The initial viewpoint of the [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#viewpoint) + */ viewpoint: Viewpoint; + /** + * Creates a deep clone of this object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#clone) + * + * + */ clone(): websceneInitialViewProperties; } interface websceneInitialViewPropertiesConstructor { + + new(properties?: websceneInitialViewPropertiesProperties): websceneInitialViewProperties; } export const websceneInitialViewProperties: websceneInitialViewPropertiesConstructor; interface websceneInitialViewPropertiesProperties { + /** + * The initial environment settings of the [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#environment) + */ environment?: EnvironmentProperties; + /** + * The spatial reference of the [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html). This indicates the [Projected Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Projected_coordinate_systems/02r3000000vt000000/) or the [Geographic Coordinate System](http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Geographic_coordinate_systems/02r300000105000000/) used to locate geographic features in the map. In a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) the following [supported coordinate systems](esri-views-SceneView.html#supported-coordinate-systems) are available. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#spatialReference) + */ spatialReference?: SpatialReferenceProperties; + /** + * The viewing mode of the scene. Global scenes allow the user to navigate the globe. Local scenes allow for navigation and feature display in a particular "localized" area. Users may also navigate the view's camera below the surface of a basemap in local scenes. **Known Values:** global | local + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#viewingMode) + * + * @default global + */ viewingMode?: string; + /** + * The initial viewpoint of the [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-InitialViewProperties.html#viewpoint) + */ viewpoint?: ViewpointProperties; } interface Lighting extends Accessor, corePromise { + /** + * The time and date for which the sun position and light direction is computed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Lighting.html#date) + * + * @default null + */ date: Date; + /** + * The type of direct shadows. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Lighting.html#directShadowsEnabled) + * + * @default false + */ directShadowsEnabled: boolean; + /** + * The UTC timezone offset in hours that should be displayed in the UI to represent the date. This value does not have an impact on the actual lighting of the scene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Lighting.html#displayUTCOffset) + * + * @default null + */ displayUTCOffset: number; + /** + * Creates a deep clone of this object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Lighting.html#clone) + * + * + */ clone(): Lighting; } interface LightingConstructor { + + new(properties?: LightingProperties): Lighting; } export const Lighting: LightingConstructor; interface LightingProperties { + /** + * The time and date for which the sun position and light direction is computed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Lighting.html#date) + * + * @default null + */ date?: DateProperties; + /** + * The type of direct shadows. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Lighting.html#directShadowsEnabled) + * + * @default false + */ directShadowsEnabled?: boolean; + /** + * The UTC timezone offset in hours that should be displayed in the UI to represent the date. This value does not have an impact on the actual lighting of the scene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Lighting.html#displayUTCOffset) + * + * @default null + */ displayUTCOffset?: number; } interface Presentation extends Accessor { + /** + * A collection of [slides](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html) that bookmark [viewpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html), visible layers, and other settings previously defined in a [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Presentation.html#slides) + */ slides: Collection; + /** + * Creates a deep clone of this object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Presentation.html#clone) + * + * + */ clone(): Presentation; } interface PresentationConstructor { + + new(properties?: PresentationProperties): Presentation; } export const Presentation: PresentationConstructor; interface PresentationProperties { + /** + * A collection of [slides](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html) that bookmark [viewpoints](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html), visible layers, and other settings previously defined in a [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Presentation.html#slides) + */ slides?: CollectionProperties; } interface Slide extends Accessor { - basemap: Basemap | string; + /** + * The basemap of the scene. Only the [base](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#baseLayers) and [reference](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#referenceLayers) layers of the basemap are stored in a slide. This value can be an instance of [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) or one of the strings listed in the table below. + * + * Value | Description + * ------|------------ + * streets | ![basemap-streets](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets.jpg) + * satellite | ![basemap-satellite](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/satellite.jpg) + * hybrid | ![basemap-hybrid](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/hybrid.jpg) + * topo | ![basemap-topo](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/topo.jpg) + * gray | ![basemap-gray](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/gray.jpg) + * dark-gray | ![basemap-dark-gray](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/dark-gray.jpg) + * oceans | ![basemap-oceans](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/oceans.jpg) + * national-geographic | ![basemap-national-geographic](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/national-geographic.jpg) + * terrain | ![basemap-terrain](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/terrain.jpg) + * osm | ![basemap-osm](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/osm.jpg) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#basemap) + */ + basemap: Basemap; + /** + * The description of the slide. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#description) + */ description: SlideDescription; + /** + * Represents settings that affect the environment in which the WebScene is displayed (such as lighting). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#environment) + */ environment: Environment; + /** + * The unique id of a slide within the [slides property](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Presentation.html#slides) of a [Presentation](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Presentation.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#id) + */ id: string; + /** + * A data URI encoded thumbnail. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#thumbnail) + */ thumbnail: SlideThumbnail; + /** + * The title of the slide. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#title) + */ title: SlideTitle; + /** + * The viewpoint of the slide. This acts like a bookmark, saving a predefined location or point of view from which to view the scene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#viewpoint) + */ viewpoint: Viewpoint; + /** + * The visible layers of the scene. This is a collection of objects that stores references (by ID) to the [scene layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#layers) and [ground layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#layers) that are set as `visible` when a slide is applied to a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). When assigning visible layers, the following types of values will be automatically casted: + * * Array (or [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html)) of [Layer instances](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html): `[layerInstance, layerInstance]` + * * Array (or [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html)) of [Layer IDs](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#id): `["layer-1", "layer-2"]` + * + * + * The specification for each object in the collection is outlined in the table below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#visibleLayers) + */ visibleLayers: Collection; + /** + * Applies a slide's settings to a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#applyTo) + * + * @param view The SceneView the slide should be applied to. + * @param options Animation options. See properties below for object specifications. + * @param options.animate Indicates whether to animate the slide transition. + * @param options.speedFactor Increases or decreases the animation speed by the specified factor. A speedFactor of 2 will make the animation twice as fast, while a speedFactor of 0.5 will make the animation half as fast. Setting the speed factor will automatically adapt the default maxDuration accordingly. + * @param options.duration Set the exact duration (in milliseconds) of the animation. Note that by default, animation duration is calculated based on the time required to reach the target at a constant speed. Setting duration overrides the speedFactor option. Note that the resulting duration is still limited to the maxDuration. + * @param options.maxDuration The maximum allowed duration (in milliseconds) of the animation. The default maxDuration value takes the specified speedFactor into account. + * @param options.easing The easing function to use for the animation. This may either be a preset (named) function, or a user specified function. Supported named presets are: `linear`, `in-cubic`, `out-cubic`, `in-out-cubic`, `in-expo`, `out-expo`, `in-out-expo` By default, animations that are less than 1000 ms use an out easing function; longer animations use an in-out function. + * + */ applyTo(view: SceneView, options?: SlideApplyToOptions): IPromise; + /** + * Creates a deep clone of this object. Note that the basemap instance is cloned, but the layers within the basemap are copied. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#clone) + * + * + */ clone(): Slide; + /** + * Updates a slide from a [WebScene's slides](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Presentation.html#slides). Updating the slide is asynchronous and a snapshot of the view is only complete once the returned promise has resolved. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#updateFrom) + * + * @param view The SceneView from which the slide should update. + * @param options Update options. See properties below for object specifications. + * @param options.screenshot Screenshot options to use. See properties below for object specifications. + * + */ updateFrom(view: SceneView, options?: SlideUpdateFromOptions): IPromise; } interface SlideConstructor { + /** + * A slide stores a snapshot of several pre-set properties of the [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html) and [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html), such as the [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#basemap), [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#viewpoint) and [visible layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#visibleLayers). The [visible layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#visibleLayers) may contain references (by [Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#id)) to both operational layers from the [scene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#layers) as well as elevation layers from the [ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#layers), which affect the surface elevation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html) + */ + new(properties?: SlideProperties): Slide; + /** + * Creates a slide from a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html), which may be added to the [slides](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Presentation.html#slides) in the WebScene's [presentation](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#presentation). Updating the slide is asynchronous and a snapshot of the view is only complete once the returned promise has resolved. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#createFrom) + * + * @param view The SceneView from which the slide should be created. + * @param options Creation options. See properties below for object specifications. + * @param options.screenshot Screenshot options to use. See properties below for object specifications. + * + */ createFrom(view: SceneView, options?: SlideCreateFromOptions): IPromise; } export const Slide: SlideConstructor; interface SlideProperties { + /** + * The basemap of the scene. Only the [base](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#baseLayers) and [reference](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html#referenceLayers) layers of the basemap are stored in a slide. This value can be an instance of [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) or one of the strings listed in the table below. + * + * Value | Description + * ------|------------ + * streets | ![basemap-streets](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/streets.jpg) + * satellite | ![basemap-satellite](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/satellite.jpg) + * hybrid | ![basemap-hybrid](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/hybrid.jpg) + * topo | ![basemap-topo](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/topo.jpg) + * gray | ![basemap-gray](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/gray.jpg) + * dark-gray | ![basemap-dark-gray](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/dark-gray.jpg) + * oceans | ![basemap-oceans](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/oceans.jpg) + * national-geographic | ![basemap-national-geographic](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/national-geographic.jpg) + * terrain | ![basemap-terrain](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/terrain.jpg) + * osm | ![basemap-osm](https://developers.arcgis.com/javascript/latest/assets/img/apiref/basemap/osm.jpg) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#basemap) + */ basemap?: BasemapProperties | string; + /** + * The description of the slide. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#description) + */ description?: SlideDescriptionProperties; + /** + * Represents settings that affect the environment in which the WebScene is displayed (such as lighting). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#environment) + */ environment?: EnvironmentProperties; + /** + * The unique id of a slide within the [slides property](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Presentation.html#slides) of a [Presentation](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Presentation.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#id) + */ id?: string; + /** + * A data URI encoded thumbnail. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#thumbnail) + */ thumbnail?: SlideThumbnailProperties; + /** + * The title of the slide. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#title) + */ title?: SlideTitleProperties; + /** + * The viewpoint of the slide. This acts like a bookmark, saving a predefined location or point of view from which to view the scene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#viewpoint) + */ viewpoint?: ViewpointProperties; + /** + * The visible layers of the scene. This is a collection of objects that stores references (by ID) to the [scene layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#layers) and [ground layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#layers) that are set as `visible` when a slide is applied to a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). When assigning visible layers, the following types of values will be automatically casted: + * * Array (or [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html)) of [Layer instances](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html): `[layerInstance, layerInstance]` + * * Array (or [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html)) of [Layer IDs](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#id): `["layer-1", "layer-2"]` + * + * + * The specification for each object in the collection is outlined in the table below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#visibleLayers) + */ visibleLayers?: CollectionProperties; } - export interface SlideApplyToOptions { - animate: boolean; + + export interface SlideApplyToOptions extends Object { + /** + * Indicates whether to animate the slide transition. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#applyTo) + * + * @default true + */ + animate?: boolean; + /** + * Increases or decreases the animation speed by the specified factor. A speedFactor of 2 will make the animation twice as fast, while a speedFactor of 0.5 will make the animation half as fast. Setting the speed factor will automatically adapt the default maxDuration accordingly. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#applyTo) + * + * @default 1 + */ speedFactor?: number; + /** + * Set the exact duration (in milliseconds) of the animation. Note that by default, animation duration is calculated based on the time required to reach the target at a constant speed. Setting duration overrides the speedFactor option. Note that the resulting duration is still limited to the maxDuration. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#applyTo) + */ duration?: number; + /** + * The maximum allowed duration (in milliseconds) of the animation. The default maxDuration value takes the specified speedFactor into account. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#applyTo) + * + * @default 8000 + */ maxDuration?: number; + /** + * The easing function to use for the animation. This may either be a preset (named) function, or a user specified function. Supported named presets are: `linear`, `in-cubic`, `out-cubic`, `in-out-cubic`, `in-expo`, `out-expo`, `in-out-expo` By default, animations that are less than 1000 ms use an out easing function; longer animations use an in-out function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#applyTo) + */ easing?: string | EasingFunction; } - export interface SlideCreateFromOptions { - screenshot: SlideCreateFromOptionsScreenshot; + + export interface SlideCreateFromOptions extends Object { + /** + * Screenshot options to use. See properties below for object specifications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#createFrom) + */ + screenshot?: SlideCreateFromOptionsScreenshot; } - export interface SlideCreateFromOptionsScreenshot { - format: string; - quality: number; - width: number; - height: number; + + export interface SlideCreateFromOptionsScreenshot extends Object { + /** + * The image format. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#createFrom) + * + * @default jpeg + */ + format?: string; + /** + * The image quality (due to compression). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#createFrom) + * + * @default 80 + */ + quality?: number; + /** + * The image width. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#createFrom) + * + * @default 112 + */ + width?: number; + /** + * The image height. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#createFrom) + * + * @default 61 + */ + height?: number; } - export interface SlideDescriptionProperties { - text?: string; - } - export interface SlideDescription extends Accessor { + + export interface SlideDescriptionProperties extends Object { + /** + * The description. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#description) + */ text?: string; } - export interface SlideThumbnailProperties { - url?: string; + export interface SlideDescription extends AnonymousAccessor { + /** + * The description. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#description) + */ + text?: string; } - export interface SlideThumbnail extends Accessor { + + + export interface SlideThumbnailProperties extends Object { + /** + * The URI pointing to the thumbnail image representing the slide. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#thumbnail) + */ url?: string; } - export interface SlideTitleProperties { - text?: string; + export interface SlideThumbnail extends AnonymousAccessor { + /** + * The URI pointing to the thumbnail image representing the slide. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#thumbnail) + */ + url?: string; } - export interface SlideTitle extends Accessor { + + + export interface SlideTitleProperties extends Object { + /** + * The title. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#title) + */ text?: string; } - export interface SlideUpdateFromOptions { + export interface SlideTitle extends AnonymousAccessor { + /** + * The title. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#title) + */ + text?: string; + } + + + export interface SlideUpdateFromOptions extends Object { + /** + * Screenshot options to use. See properties below for object specifications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#updateFrom) + */ screenshot: SlideUpdateFromOptionsScreenshot; } - export interface SlideUpdateFromOptionsScreenshot { - format: string; - quality: number; - width: number; - height: number; + + export interface SlideUpdateFromOptionsScreenshot extends Object { + /** + * The image format. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#updateFrom) + * + * @default jpeg + */ + format?: string; + /** + * The image quality (due to compression). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#updateFrom) + * + * @default 80 + */ + quality?: number; + /** + * The image width. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#updateFrom) + * + * @default 120 + */ + width?: number; + /** + * The image height. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#updateFrom) + * + * @default 75 + */ + height?: number; } - export interface SlideVisibleLayersProperties { + + export interface SlideVisibleLayersProperties extends Object { + /** + * The ID of a [layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#id) in the [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#layers) or [Ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#layers) that is made `visible` in the [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) when the slide is applied to the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#visibleLayers) + */ id?: string; } - export interface SlideVisibleLayers extends Accessor { + + export interface SlideVisibleLayers extends AnonymousAccessor { + /** + * The ID of a [layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#id) in the [WebScene](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#layers) or [Ground](https://developers.arcgis.com/javascript/latest/api-reference/esri-Ground.html#layers) that is made `visible` in the [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) when the slide is applied to the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-webscene-Slide.html#visibleLayers) + */ id: string; } - export interface WebSceneSaveAsOptions { + + export interface WebSceneSaveAsOptions extends Object { + /** + * the folder in which to save the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#saveAs) + */ folder?: PortalFolder; + /** + * allow the scene to be saved even in the case it contains unsupported content (layers, renderers, symbols). Any content that is not supported will not be saved and the scene may appear different when reloaded from its portal item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#saveAs) + */ ignoreUnsupported?: boolean; } - export interface WebSceneSaveOptions { + + export interface WebSceneSaveOptions extends Object { + /** + * When `true`, the scene will save even if it contains unsupported content (layers, renderers, symbols). Any content that is not supported will not be saved and the scene may appear different when reloaded from its portal item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#save) + */ ignoreUnsupported?: boolean; } - export interface WebSceneSourceVersion { + + export interface WebSceneSourceVersion extends Object { + /** + * The major version of the WebScene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#sourceVersion) + */ major: number; + /** + * The minor version of the WebScene. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#sourceVersion) + */ minor: number; } - export interface WebSceneUpdateFromOptions { + + export interface WebSceneUpdateFromOptions extends Object { + /** + * update the initial environment from the view, defaults to false. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#updateFrom) + */ environmentExcluded?: boolean; + /** + * update the initial viewpoint from the view, defaults to false. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-WebScene.html#updateFrom) + */ viewpointExcluded?: boolean; } interface Attribution extends Widget { + /** + * Full attribution text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution.html#attributionText) + */ + readonly attributionText: string; + /** + * Text used to split attribution by [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution.html#itemDelimiter) + * + * @default | + */ + itemDelimiter: string; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution.html#view) + */ view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [AttributionViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution-AttributionViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution.html#viewModel) + */ viewModel: AttributionViewModel; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution.html#render) + * + * + */ render(): any; } interface AttributionConstructor { + /** + * The Attribution displays attribution text for the layers in a map. The text displayed for the layers is either a list of data providers or sources as defined in the layer's custom attribution data, or the copyright text. This widget automatically updates based on layer visibility and map extent and displays a single line of attribution that can be expanded with a single click to view all data sources. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution.html) + */ + new(properties?: AttributionProperties): Attribution; } export const Attribution: AttributionConstructor; interface AttributionProperties extends WidgetProperties { + /** + * Text used to split attribution by [layers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution.html#itemDelimiter) + * + * @default | + */ + itemDelimiter?: string; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [AttributionViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution-AttributionViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution.html#viewModel) + */ viewModel?: AttributionViewModel; } interface AttributionViewModel { - attributionText: string; - itemDelimiter: string; - state: string; + /** + * Array of attribution items. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution-AttributionViewModel.html#items) + */ + readonly items: AttributionItem[]; + /** + * The view model's state. **Known Values:** ready | disabled + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution-AttributionViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The view from which the view model will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution-AttributionViewModel.html#view) + */ view: MapView | SceneView; } interface AttributionViewModelConstructor { + /** + * Provides the logic for the [Attribution](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution.html) widget. Displays attribution text for the layers in a map. The text displayed for the layers is either a list of data providers or sources as defined in the layer's custom attribution data, or the copyright text. The attribution is automatically updated based on layer visibility and map extent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution-AttributionViewModel.html) + */ + + new(properties?: any): AttributionViewModel; } export const AttributionViewModel: AttributionViewModelConstructor; + /** + * The following properties define an attribution item that contains the attribution text for a set of layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution-AttributionViewModel.html#AttributionItem) + */ + export interface AttributionItem extends Object { + /** + * The attribution text for one or more layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution-AttributionViewModel.html#AttributionItem) + */ + text: boolean; + /** + * The associated layers that share the attribution text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attribution-AttributionViewModel.html#AttributionItem) + */ + layers: Layer[]; + } + interface BasemapGallery extends Widget { + /** + * The map's [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#activeBasemap) + */ activeBasemap: Basemap; + /** + * The source for basemaps that the widget will display. This property can be autocast with an array or [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html)s, a [Portal](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html) instance, or a URL to a portal instance. The default source is a [PortalBasemapsSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-PortalBasemapsSource.html) that points to the default portal instance set in [esriConfig.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#source) + */ source: LocalBasemapsSource | PortalBasemapsSource; + /** + * The view from which the widget will operate. This view provides access to the active [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) via the view's [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#view) + */ view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [BasemapGalleryViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#viewModel) + */ viewModel: BasemapGalleryViewModel; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#render) + * + * + */ render(): any; } interface BasemapGalleryConstructor { + /** + * The BasemapGallery widget displays a collection images representing basemaps from ArcGIS.com or a user-defined set of map or image services. When a new basemap is selected from the BasemapGallery, the map's basemap layers are removed and replaced with the basemap layers of the associated basemap selected in the gallery. By default, the BasemapGallery widget looks like the following image. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html) + */ + new(properties?: BasemapGalleryProperties): BasemapGallery; } export const BasemapGallery: BasemapGalleryConstructor; interface BasemapGalleryProperties extends WidgetProperties { + /** + * The map's [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#activeBasemap) + */ activeBasemap?: BasemapProperties; - source?: LocalBasemapsSource | PortalBasemapsSource; + /** + * The source for basemaps that the widget will display. This property can be autocast with an array or [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html)s, a [Portal](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html) instance, or a URL to a portal instance. The default source is a [PortalBasemapsSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-PortalBasemapsSource.html) that points to the default portal instance set in [esriConfig.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#source) + */ + source?: LocalBasemapsSourceProperties | PortalBasemapsSourceProperties; + /** + * The view from which the widget will operate. This view provides access to the active [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) via the view's [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [BasemapGalleryViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html#viewModel) + */ viewModel?: BasemapGalleryViewModelProperties; } - interface BasemapGalleryItem { - basemap: Basemap; - error: Error; - state: string; - view: MapView | SceneView; - } - - export const BasemapGalleryItem: BasemapGalleryItem; - interface BasemapGalleryViewModel extends Accessor { + /** + * The map's [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#activeBasemap) + */ activeBasemap: Basemap; + /** + * A collection of [BasemapGalleryItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-BasemapGalleryItem.html)s representing basemaps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#items) + */ items: Collection; + /** + * The source for basemaps that the widget will display. This property can be autocast with an array or [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html)s, a [Portal](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html) instance or a URL to a portal instance. The default source is a [PortalBasemapsSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-PortalBasemapsSource.html) that points to the default portal instance set in [esriConfig.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#source) + */ source: LocalBasemapsSource | PortalBasemapsSource; - state: string; + /** + * The view model's state. **Known Values:** ready | disabled + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The view from which the widget will operate. This view provides access to the active [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) via the view's [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#view) + */ view: MapView | SceneView; + /** + * A convenience function to check basemap equality. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#basemapEquals) + * + * @param basemap1 The basemap to compare against `basemap2`. + * @param basemap2 The basemap to compare against `basemap1`. + * + */ basemapEquals(basemap1: Basemap, basemap2: Basemap): boolean; } interface BasemapGalleryViewModelConstructor { + + new(properties?: BasemapGalleryViewModelProperties): BasemapGalleryViewModel; } export const BasemapGalleryViewModel: BasemapGalleryViewModelConstructor; interface BasemapGalleryViewModelProperties { + /** + * The map's [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#activeBasemap) + */ activeBasemap?: BasemapProperties; + /** + * A collection of [BasemapGalleryItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-BasemapGalleryItem.html)s representing basemaps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#items) + */ items?: CollectionProperties; - source?: LocalBasemapsSource | PortalBasemapsSource; - state?: string; + /** + * The source for basemaps that the widget will display. This property can be autocast with an array or [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html)s, a [Portal](https://developers.arcgis.com/javascript/latest/api-reference/esri-portal-Portal.html) instance or a URL to a portal instance. The default source is a [PortalBasemapsSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-PortalBasemapsSource.html) that points to the default portal instance set in [esriConfig.portalUrl](https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#portalUrl). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#source) + */ + source?: LocalBasemapsSourceProperties | PortalBasemapsSourceProperties; + /** + * The view from which the widget will operate. This view provides access to the active [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) via the view's [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-BasemapGalleryViewModel.html#view) + */ view?: MapViewProperties | SceneViewProperties; } - interface LocalBasemapsSource { - basemaps: Collection; - state: string; + + interface BasemapGalleryItem { + /** + * The item's associated basemap. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-BasemapGalleryItem.html#basemap) + */ + basemap: Basemap; + /** + * The Error object returned if an error occurred. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-BasemapGalleryItem.html#error) + */ + readonly error: Error; + /** + * The item's state. **Known Values:** loading | ready | error + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-BasemapGalleryItem.html#state) + * + * @default loading + */ + readonly state: string; + /** + * The view associated with this item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-BasemapGalleryItem.html#view) + */ + view: MapView | SceneView; } - export const LocalBasemapsSource: LocalBasemapsSource; + export const BasemapGalleryItem: BasemapGalleryItem; - interface PortalBasemapsSource { + interface LocalBasemapsSource extends Accessor { + /** + * A collection of [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html)s. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-LocalBasemapsSource.html#basemaps) + */ basemaps: Collection; + /** + * The source's state. The state is always `ready`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-LocalBasemapsSource.html#state) + */ + readonly state: string; + + /** + * Refreshes the source basemaps. Note: `refresh` will not affect LocalBasemapsSource. Modify basemaps directly instead. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-LocalBasemapsSource.html#refresh) + * + * + */ + refresh(): void; + } + + interface LocalBasemapsSourceConstructor { + + + new(properties?: LocalBasemapsSourceProperties): LocalBasemapsSource; + } + + export const LocalBasemapsSource: LocalBasemapsSourceConstructor; + + interface LocalBasemapsSourceProperties { + /** + * A collection of [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html)s. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-LocalBasemapsSource.html#basemaps) + */ + basemaps?: CollectionProperties; + } + + interface PortalBasemapsSource extends LocalBasemapsSource { + /** + * Function used to filter basemaps after being fetched from the Portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-PortalBasemapsSource.html#filterFunction) + */ filterFunction: Function; + /** + * The Portal from which to fetch basemaps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-PortalBasemapsSource.html#portal) + */ portal: Portal; + /** + * An object with key-value pairs used to create a custom basemap gallery group query. Note that all parameters will be joined using the `AND` operator. A query string can also be provided for more advanced use cases. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-PortalBasemapsSource.html#query) + */ query: any | string; - state: string; } - export const PortalBasemapsSource: PortalBasemapsSource; + interface PortalBasemapsSourceConstructor { + + + new(properties?: PortalBasemapsSourceProperties): PortalBasemapsSource; + } + + export const PortalBasemapsSource: PortalBasemapsSourceConstructor; + + interface PortalBasemapsSourceProperties extends LocalBasemapsSourceProperties { + /** + * Function used to filter basemaps after being fetched from the Portal. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-PortalBasemapsSource.html#filterFunction) + */ + filterFunction?: Function; + /** + * The Portal from which to fetch basemaps. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-PortalBasemapsSource.html#portal) + */ + portal?: PortalProperties; + /** + * An object with key-value pairs used to create a custom basemap gallery group query. Note that all parameters will be joined using the `AND` operator. A query string can also be provided for more advanced use cases. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-PortalBasemapsSource.html#query) + */ + query?: any | string; + } interface BasemapToggle extends Widget { - activeBasemap: Basemap; - nextBasemap: Basemap | string; + /** + * The map's [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#activeBasemap) + */ + readonly activeBasemap: Basemap; + /** + * The next basemap for toggling. One of the following values may be set to this property: + * * The [string ID](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of any Esri basemap. + * * A custom [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) object. Since this property may be [autocast](https://developers.arcgis.com/javascript/latest/guide/autocasting/index.html), the [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) module does not need to be included in the `require()` function in most applications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#nextBasemap) + */ + nextBasemap: Basemap; + /** + * Indicates if the title of the basemap is visible in the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#titleVisible) + * + * @default false + */ titleVisible: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). This view provides the BasemapToggle widget with access to the initial [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) to toggle from via the view's [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#view) + */ view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [BasemapToggleViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle-BasemapToggleViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#viewModel) + */ viewModel: BasemapToggleViewModel; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#render) + * + * + */ render(): any; + /** + * Toggles to the [next basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#nextBasemap). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#toggle) + * + * + */ toggle(): void; } interface BasemapToggleConstructor { + /** + * The BasemapToggle provides a widget which allows an end-user to switch between two basemaps. The toggled basemap is set inside the [view's](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#view) [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html) + */ + new(properties?: BasemapToggleProperties): BasemapToggle; } export const BasemapToggle: BasemapToggleConstructor; interface BasemapToggleProperties extends WidgetProperties { - activeBasemap?: BasemapProperties; + /** + * The next basemap for toggling. One of the following values may be set to this property: + * * The [string ID](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of any Esri basemap. + * * A custom [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) object. Since this property may be [autocast](https://developers.arcgis.com/javascript/latest/guide/autocasting/index.html), the [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) module does not need to be included in the `require()` function in most applications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#nextBasemap) + */ nextBasemap?: BasemapProperties | string; + /** + * Indicates if the title of the basemap is visible in the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#titleVisible) + * + * @default false + */ titleVisible?: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). This view provides the BasemapToggle widget with access to the initial [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) to toggle from via the view's [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [BasemapToggleViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle-BasemapToggleViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle.html#viewModel) + */ viewModel?: BasemapToggleViewModelProperties; } interface BasemapToggleViewModel extends Accessor, Evented { - activeBasemap: Basemap; - nextBasemap: Basemap | string; - state: string; + /** + * The map's [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle-BasemapToggleViewModel.html#activeBasemap) + */ + readonly activeBasemap: Basemap; + /** + * The next basemap for toggling. One of the following values may be set to this property: + * * The [string ID](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of any Esri basemap. + * * A custom [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) object. Since this property may be [autocast](https://developers.arcgis.com/javascript/latest/guide/autocasting/index.html), the [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) module does not need to be included in the `require()` function in most applications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle-BasemapToggleViewModel.html#nextBasemap) + */ + nextBasemap: Basemap; + /** + * The view model's state. **Known Values:** ready | disabled + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle-BasemapToggleViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The view from which the widget will operate. This view provides access to the initial [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) to toggle from via the view's [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle-BasemapToggleViewModel.html#view) + */ view: MapView | SceneView; + /** + * Toggles to the [next basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle-BasemapToggleViewModel.html#nextBasemap). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle-BasemapToggleViewModel.html#toggle) + * + * + */ toggle(): void; } interface BasemapToggleViewModelConstructor { + + new(properties?: BasemapToggleViewModelProperties): BasemapToggleViewModel; + /** + * Helper method to find a basemap's thumbnail URL. If the basemap does not have a thumbnail URL defined, this utility will try to find a thumbnail URL from the best matching well-known basemap. If no match is found, a thumbnail URL from the basemap's base layers will be used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle-BasemapToggleViewModel.html#getThumbnailUrl) + * + * @param basemap The basemap used to retrieve the thumbnail URL. + * + */ getThumbnailUrl(basemap: Basemap): string; } export const BasemapToggleViewModel: BasemapToggleViewModelConstructor; interface BasemapToggleViewModelProperties { - activeBasemap?: BasemapProperties; + /** + * The next basemap for toggling. One of the following values may be set to this property: + * * The [string ID](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) of any Esri basemap. + * * A custom [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) object. Since this property may be [autocast](https://developers.arcgis.com/javascript/latest/guide/autocasting/index.html), the [Basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Basemap.html) module does not need to be included in the `require()` function in most applications. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle-BasemapToggleViewModel.html#nextBasemap) + */ nextBasemap?: BasemapProperties | string; - state?: string; + /** + * The view from which the widget will operate. This view provides access to the initial [basemap](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#basemap) to toggle from via the view's [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#map) property. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapToggle-BasemapToggleViewModel.html#view) + */ view?: MapViewProperties | SceneViewProperties; } interface ColorSlider extends Accessor, Widgette { + /** + * Indicates whether to show the handles of the slider that may be dragged by the user. See the image in the [class description](#) to see where handles are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#handlesVisible) + * + * @default true + */ handlesVisible: boolean; + /** + * The histogram associated with the data represented on the slider. This may be generated using the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html) statistics function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#histogram) + */ histogram: HistogramResult; + /** + * Indicates whether to show the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#histogram) in the slider UI. See the image in the [class description](#) to see where the histogram is typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#histogramVisible) + * + * @default true + */ histogramVisible: boolean; + /** + * The width of the histogram in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#histogramWidth) + * + * @default 100 + */ histogramWidth: number; + /** + * Indicates whether to show labels in the slider UI. See the image in the [class description](#) to see where labels are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#labelsVisible) + * + * @default true + */ labelsVisible: boolean; + /** + * The maximum value or upper bound of the slider. This value overrides the `max` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statistics), but may not be less than the value of the maximum stop of the [color visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#visualVariable). This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#maxValue) + */ maxValue: number; + /** + * The minimum value or lower bound of the slider. This value overrides the `min` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statistics), but may not be greater than the value of the minimum stop of the [color visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#visualVariable). This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#minValue) + */ minValue: number; + /** + * Indicates the number of handles to show on the slider. Acceptable values are `2` or `3`. If `3` handles are specified, then the [syncedHandles](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#syncedHandles) property may be enabled to sync the movement of the outside handles with the middle, or primary, handle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#numHandles) + * + * @default {"value":2,"set":""} + */ numHandles: number; + /** + * The summary statistics of the data represented in the slider. This is an object that may be generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) statistics function. The `min` and `max` values in this object determine the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#minValue) and [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#maxValue) of the slider if values for those properties are not already provided. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statistics) + */ statistics: ColorSliderStatistics; + /** + * Indicates whether to show the average in the slider UI. See the image in the [class description](#) to see where this symbol is typically placed. Hover over this symbol to view the average in the tooltip. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statisticsVisible) + * + * @default true + */ statisticsVisible: boolean; + /** + * Only applicable when [numHandles](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#numHandles) is set to `3`. This property indicates whether the outside handles are synced with the middle, or primary, handle. If the primary handle is dragged then the outside handles are dragged while maintaining the same distance from the primary handle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#syncedHandles) + * + * @default false + */ syncedHandles: boolean; + /** + * Indicates whether to show tick marks next to the slider handles. See the image in the [class description](#) to see where ticks are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#ticksVisible) + * + * @default true + */ ticksVisible: boolean; - values: ColorSliderValues[]; + /** + * Each object in this array represents a stop in the [color visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#visualVariable) associated with the slider. The properties of each object describe whether the stop has a slider handle, the value of the handle and its associated color. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#values) + */ + readonly values: ColorSliderValues[]; + /** + * The color visual variable represented by the slider. This must be set initially on the slider for it to render in the view. This may be created manually (see snippet below) or generated from the [colorRendererCreator](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html) helper methods. A new color visual variable is created each time the user slides handles or changes the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#minValue) or the [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#maxValue). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#visualVariable) + */ visualVariable: ColorVisualVariable; } interface ColorSliderConstructor { + /** + * The ColorSlider is a widget intended for authoring and exploring data-driven visualizations in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) using color. To display properly, this slider requires a [color visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#visualVariable) and a [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statistics) object. Other optional properties may be used, including adding a [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#histogram). Most of the various options that affect the UI of the slider are labeled in the image below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html) + */ + new(properties?: ColorSliderProperties): ColorSlider; } export const ColorSlider: ColorSliderConstructor; interface ColorSliderProperties extends WidgetteProperties { + /** + * Indicates whether to show the handles of the slider that may be dragged by the user. See the image in the [class description](#) to see where handles are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#handlesVisible) + * + * @default true + */ handlesVisible?: boolean; + /** + * The histogram associated with the data represented on the slider. This may be generated using the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html) statistics function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#histogram) + */ histogram?: HistogramResult; + /** + * Indicates whether to show the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#histogram) in the slider UI. See the image in the [class description](#) to see where the histogram is typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#histogramVisible) + * + * @default true + */ histogramVisible?: boolean; + /** + * The width of the histogram in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#histogramWidth) + * + * @default 100 + */ histogramWidth?: number; + /** + * Indicates whether to show labels in the slider UI. See the image in the [class description](#) to see where labels are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#labelsVisible) + * + * @default true + */ labelsVisible?: boolean; + /** + * The maximum value or upper bound of the slider. This value overrides the `max` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statistics), but may not be less than the value of the maximum stop of the [color visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#visualVariable). This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#maxValue) + */ maxValue?: number; + /** + * The minimum value or lower bound of the slider. This value overrides the `min` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statistics), but may not be greater than the value of the minimum stop of the [color visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#visualVariable). This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#minValue) + */ minValue?: number; + /** + * Indicates the number of handles to show on the slider. Acceptable values are `2` or `3`. If `3` handles are specified, then the [syncedHandles](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#syncedHandles) property may be enabled to sync the movement of the outside handles with the middle, or primary, handle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#numHandles) + * + * @default {"value":2,"set":""} + */ numHandles?: number; + /** + * The summary statistics of the data represented in the slider. This is an object that may be generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) statistics function. The `min` and `max` values in this object determine the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#minValue) and [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#maxValue) of the slider if values for those properties are not already provided. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statistics) + */ statistics?: ColorSliderStatistics; + /** + * Indicates whether to show the average in the slider UI. See the image in the [class description](#) to see where this symbol is typically placed. Hover over this symbol to view the average in the tooltip. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statisticsVisible) + * + * @default true + */ statisticsVisible?: boolean; + /** + * Only applicable when [numHandles](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#numHandles) is set to `3`. This property indicates whether the outside handles are synced with the middle, or primary, handle. If the primary handle is dragged then the outside handles are dragged while maintaining the same distance from the primary handle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#syncedHandles) + * + * @default false + */ syncedHandles?: boolean; + /** + * Indicates whether to show tick marks next to the slider handles. See the image in the [class description](#) to see where ticks are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#ticksVisible) + * + * @default true + */ ticksVisible?: boolean; - values?: ColorSliderValues[]; + /** + * The color visual variable represented by the slider. This must be set initially on the slider for it to render in the view. This may be created manually (see snippet below) or generated from the [colorRendererCreator](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-color.html) helper methods. A new color visual variable is created each time the user slides handles or changes the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#minValue) or the [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#maxValue). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#visualVariable) + */ visualVariable?: ColorVisualVariable; } - export interface ColorSliderStatistics { + + export interface ColorSliderStatistics extends Object { + /** + * The average of all data values represented in the color visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statistics) + */ avg: number; + /** + * The maximum of all data values represented in the color visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statistics) + */ max: number; + /** + * The minimum of all data values represented in the color visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statistics) + */ min: number; + /** + * The standard deviation calculated from all data values represented in the color visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#statistics) + */ stddev: number; } - export interface ColorSliderValues { + + export interface ColorSliderValues extends Object { + /** + * The color used to represent features with values at the associated stop. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#values) + */ color: Color; + /** + * The value of the stop for the associated handle. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#values) + */ value: number; + /** + * The label used to display the value to the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ColorSlider.html#values) + */ label: string; } interface Compass extends Widget { + /** + * The view in which the Compass obtains and indicates camera [heading](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading), using a (SceneView) or rotation (MapView). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass.html#view) + */ view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [CompassViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass-CompassViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass.html#viewModel) + */ viewModel: CompassViewModel; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass.html#render) + * + * + */ render(): any; + /** + * If working in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html), sets the view's [rotation](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#rotation) to `0`. If working in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html), sets the camera's [heading](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading) to `0`. This method is executed each time the [Compass](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass.html) is clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass.html#reset) + * + * + */ reset(): void; } interface CompassConstructor { + /** + * The Compass widget indicates where north is in relation to the current view [rotation](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#rotation) or [camera heading](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading). Clicking the Compass widget rotates the view to face north (heading = 0). This widget is added to a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass.html) + */ + new(properties?: CompassProperties): Compass; } export const Compass: CompassConstructor; interface CompassProperties extends WidgetProperties { + /** + * The view in which the Compass obtains and indicates camera [heading](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading), using a (SceneView) or rotation (MapView). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [CompassViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass-CompassViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass.html#viewModel) + */ viewModel?: CompassViewModelProperties; } interface CompassViewModel extends Accessor { + /** + * The orientation axes (x, y, z). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass-CompassViewModel.html#orientation) + * + * @default { x: 0, y: 0, z: 0 } + */ orientation: any; - state: string; + /** + * The view model's state. **Known Values:** compass | rotation | disabled + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass-CompassViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The view in which the Compass obtains and indicates camera [heading](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading), using a (SceneView) or rotation (MapView). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass-CompassViewModel.html#view) + */ view: MapView | SceneView; + /** + * If working in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html), sets the view's [rotation](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html#rotation) is to `0`. If working in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html), sets the camera's [heading](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading) to `0`. This method is executed each time the [Compass](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass.html) is clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass-CompassViewModel.html#reset) + * + * + */ reset(): void; } interface CompassViewModelConstructor { + /** + * Provides the logic for the [Compass](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass.html) widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass-CompassViewModel.html) + */ + new(properties?: CompassViewModelProperties): CompassViewModel; } export const CompassViewModel: CompassViewModelConstructor; interface CompassViewModelProperties { + /** + * The orientation axes (x, y, z). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass-CompassViewModel.html#orientation) + * + * @default { x: 0, y: 0, z: 0 } + */ orientation?: any; - state?: string; + /** + * The view in which the Compass obtains and indicates camera [heading](https://developers.arcgis.com/javascript/latest/api-reference/esri-Camera.html#heading), using a (SceneView) or rotation (MapView). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Compass-CompassViewModel.html#view) + */ view?: MapViewProperties | SceneViewProperties; } - interface Expand extends Widget { - autoCollapse: boolean; - collapseIconClass: string; - collapseTooltip: string; - content: Node | string | Widget; - expanded: boolean; - expandIconClass: string; - expandTooltip: string; - iconNumber: string; + interface Directions extends Widget { + /** + * The maximum number of stops allowed for routing. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#maxStops) + * + * @default 50 + */ + maxStops: number; + /** + * The URL of the REST endpoint of the Route service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#routeServiceUrl) + * + * @default "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World" + */ + routeServiceUrl: string; + /** + * Defines the symbol used to draw the route on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#routeSymbol) + */ + routeSymbol: SimpleLineSymbol; + /** + * This property controls the default properties for [Searching](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html). These properties can be configured per application. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#searchProperties) + */ + searchProperties: DirectionsSearchProperties; + /** + * The default stop symbols used to display locations between the origin and final destination. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#stopSymbols) + */ + stopSymbols: DirectionsStopSymbols; + /** + * The view from which the widget will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#view) + */ view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [DirectionsViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#viewModel) + */ + viewModel: DirectionsViewModel; + + /** + * Calculate the route to the input locations and display the list of directions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#getDirections) + * + * + */ + getDirections(): IPromise; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#render) + * + * + */ + render(): any; + /** + * Zoom so that the full route is displayed within the current map extent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#zoomToRoute) + * + * + */ + zoomToRoute(): void; + } + + interface DirectionsConstructor { + /** + * The Directions Widget provides a way to build driving and walking directions using ArcGIS online and custom Network Analysis Route services. Similar to how the [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html) works, this widget generates a route finding a least-cost path between multiple points using a specified network. The resulting directions are displayed with detailed turn-by-turn instructions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html) + */ + + new(properties?: DirectionsProperties): Directions; + } + + export const Directions: DirectionsConstructor; + + interface DirectionsProperties extends WidgetProperties { + /** + * The maximum number of stops allowed for routing. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#maxStops) + * + * @default 50 + */ + maxStops?: number; + /** + * The URL of the REST endpoint of the Route service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#routeServiceUrl) + * + * @default "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World" + */ + routeServiceUrl?: string; + /** + * Defines the symbol used to draw the route on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#routeSymbol) + */ + routeSymbol?: SimpleLineSymbolProperties; + /** + * This property controls the default properties for [Searching](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html). These properties can be configured per application. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#searchProperties) + */ + searchProperties?: DirectionsSearchProperties; + /** + * The default stop symbols used to display locations between the origin and final destination. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#stopSymbols) + */ + stopSymbols?: DirectionsStopSymbols; + /** + * The view from which the widget will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#view) + */ + view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [DirectionsViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#viewModel) + */ + viewModel?: DirectionsViewModelProperties; + } + + interface DirectionsViewModel extends Accessor { + /** + * The network attribute name to be used as the impedance attribute in the analysis. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attribute names listed in the Service Directory under `Network Dataset -> Network Attributes` as `Usage Type: esriNAUTCost`. You can also specify a value of `none` to indicate that no network attributes should be used for impedance. If you specify an empty array, it will default to the default of the service. For example, set `impedanceAttribute = "Time"` for the quickest route and `impedanceAttribute = "Length"` for shortest drive, assuming the service has those two esriNAUTCost attributes. For more information, see [Understanding the network attribute](http://resources.arcgis.com/en/help/main/10.2/index.html#//00470000000m000000). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#impedanceAttribute) + */ + impedanceAttribute: string; + /** + * The most recent route result. Returns an object containing properties for any barriers used when generating the route, messages that may arise when solving the route, and finally an array of returned [RouteResults](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#lastRoute) + * + * @default null + */ + readonly lastRoute: DirectionsViewModelLastRoute; + /** + * The maximum number of stops allowed for routing. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#maxStops) + * + * @default 50 + */ + maxStops: number; + /** + * Route Parameters object used to call the service. Please refer to the [RouteParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html) documentation for the list of available settings. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#routeParameters) + */ + routeParameters: RouteParameters; + /** + * The URL of the REST endpoint of the Route service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#routeServiceUrl) + * + * @default "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World" + */ + routeServiceUrl: string; + /** + * Defines the symbol used to draw the route on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#routeSymbol) + */ + routeSymbol: SimpleLineSymbol; + /** + * The selected travel mode. More information can be found in the [ArcGIS Online documentation](https://doc.arcgis.com/en/arcgis-online/reference/travel-modes.htm#GUID-96DF7F50-E0B2-4BF3-8271-EB515D3F0107). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#selectedTravelMode) + * + * @default null | 'Driving Time' + */ + readonly selectedTravelMode: DirectionsViewModelSelectedTravelMode; + /** + * The Service Description object returned by the Route REST Endpoint. This object contains service specific details like available Cost attributes, supported Restrictions, default Attribute Parameter Values, Service Limits (like maximum input stop count), default Impedance Attribute, etc. This information is useful when implementing complex logistics scenarios operating with limitations or preferences on vehicle or stop properties, for example avoiding toll roads, dealing with hazardous materials, working with stop service times, etc. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#serviceDescription) + * + * @default null + */ + readonly serviceDescription: any; + /** + * The current state of the view model. **Possible Values:** disabled | ready + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * An array of graphics that define the stop locations along the route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#stops) + */ + stops: Collection; + /** + * The default stop symbols used to display locations between the origin and final destination. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#stopSymbols) + */ + stopSymbols: DirectionsViewModelStopSymbols; + /** + * The name of the network attribute to use for the drive time when computing directions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#timeAttribute) + */ + timeAttribute: DirectionsViewModelTimeAttribute; + /** + * Array of objects containing properties specific to either an ArcGIS service or organization's travel modes. More information can be found in the [ArcGIS Online documentation](https://doc.arcgis.com/en/arcgis-online/reference/travel-modes.htm#GUID-96DF7F50-E0B2-4BF3-8271-EB515D3F0107). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#travelModes) + */ + readonly travelModes: TravelMode[]; + /** + * The view from which the widget will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#view) + */ + view: MapView | SceneView; + + /** + * Centers the map at the specified maneuver or stop. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#centerAt) + * + * @param stopOrManeuver The stop or maneuver where the map should be centered. + * + */ + centerAt(stopOrManeuver: Graphic): void; + /** + * Clears any highlighted route segments. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#clearHighlights) + * + * + */ + clearHighlights(): void; + /** + * Removes the route directions from the directions list, leaving the inputs untouched. The route and locations persist on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#clearResults) + * + * + */ + clearResults(): void; + /** + * Returns cost attribute name specific to a particular route service. This can be used as a [travel mode impedance](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#TravelMode). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#getCostAttribute) + * + * @param attributeName The attribute name specifying the cost attribute used as an impedance. + * + */ + getCostAttribute(attributeName: string): string; + /** + * Calculate the route to the input locations and display the list of directions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#getDirections) + * + * + */ + getDirections(): IPromise; + /** + * Highlights the specified route segment on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#highlightSegment) + * + * @param maneuver The route segment to highlight. + * + */ + highlightSegment(maneuver: Graphic): void; + /** + * Resets the state of the ViewModel, clearing off all the input stops, and results in the widget. The results persist in the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#reset) + * + * + */ + reset(): void; + /** + * Zoom so that the full route is displayed within the current map extent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#zoomToRoute) + * + * + */ + zoomToRoute(): void; + } + + interface DirectionsViewModelConstructor { + /** + * Provides the communication and data manipulation logic for the [Directions](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html) widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html) + */ + + new(properties?: DirectionsViewModelProperties): DirectionsViewModel; + } + + export const DirectionsViewModel: DirectionsViewModelConstructor; + + interface DirectionsViewModelProperties { + /** + * The network attribute name to be used as the impedance attribute in the analysis. The default is as defined in the specific routing network layer used in your [RouteTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-RouteTask.html). You can specify any attribute names listed in the Service Directory under `Network Dataset -> Network Attributes` as `Usage Type: esriNAUTCost`. You can also specify a value of `none` to indicate that no network attributes should be used for impedance. If you specify an empty array, it will default to the default of the service. For example, set `impedanceAttribute = "Time"` for the quickest route and `impedanceAttribute = "Length"` for shortest drive, assuming the service has those two esriNAUTCost attributes. For more information, see [Understanding the network attribute](http://resources.arcgis.com/en/help/main/10.2/index.html#//00470000000m000000). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#impedanceAttribute) + */ + impedanceAttribute?: string; + /** + * The maximum number of stops allowed for routing. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#maxStops) + * + * @default 50 + */ + maxStops?: number; + /** + * Route Parameters object used to call the service. Please refer to the [RouteParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteParameters.html) documentation for the list of available settings. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#routeParameters) + */ + routeParameters?: RouteParametersProperties; + /** + * The URL of the REST endpoint of the Route service. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#routeServiceUrl) + * + * @default "https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World" + */ + routeServiceUrl?: string; + /** + * Defines the symbol used to draw the route on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#routeSymbol) + */ + routeSymbol?: SimpleLineSymbolProperties; + /** + * An array of graphics that define the stop locations along the route. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#stops) + */ + stops?: CollectionProperties; + /** + * The default stop symbols used to display locations between the origin and final destination. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#stopSymbols) + */ + stopSymbols?: DirectionsViewModelStopSymbols; + /** + * The name of the network attribute to use for the drive time when computing directions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#timeAttribute) + */ + timeAttribute?: DirectionsViewModelTimeAttribute; + /** + * The view from which the widget will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#view) + */ + view?: MapViewProperties | SceneViewProperties; + } + + + export interface DirectionsViewModelLastRoute extends Object { + /** + * Array of graphics representing the point barriers. For a list of properties returned for each barrier, see the [barriers](https://desktop.arcgis.com/en/arcmap/latest/extensions/network-analyst/barriers.htm) help documentation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#lastRoute) + */ + barriers: Graphic[]; + /** + * An array of messages serialized to JSON. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#lastRoute) + */ + messages: DirectionsViewModelLastRouteMessages[]; + /** + * Array of graphics representing the polygon barriers. For a list of properties returned for each barrier, see the [barriers](https://desktop.arcgis.com/en/arcmap/latest/extensions/network-analyst/barriers.htm) help documentation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#lastRoute) + */ + polygonBarriers: Graphic[]; + /** + * Array of graphics representing the polygon barriers. For a list of properties returned for each barrier, see the [barriers](https://desktop.arcgis.com/en/arcmap/latest/extensions/network-analyst/barriers.htm) help documentation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#lastRoute) + */ + polylineBarriers: Graphic[]; + /** + * An array of [RouteResults](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-RouteResult.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#lastRoute) + */ + routeResults: RouteResult; + } + + + export interface DirectionsViewModelLastRouteMessages extends Object { + /** + * A descriptive message of the returned mesage. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#lastRoute) + */ + description: string; + /** + * Number indicating the message type returned from the service. This number correlates to one of the known values listed below. + * + * Number | Value + * ------|------------ + * 0 | informative + * 1 | process-definition + * 2 | process-start + * 3 | process-stop + * 50 | warning + * 100 | error + * 101 | empty + * 200 | abort + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#lastRoute) + */ + type: number; + } + + + export interface DirectionsViewModelSelectedTravelMode extends TravelMode { + /** + * The description explaining the selected travel mode. A listing of these descriptions can be found in the [ArcGIS Online documentation](https://doc.arcgis.com/en/arcgis-online/reference/travel-modes.htm#GUID-96DF7F50-E0B2-4BF3-8271-EB515D3F0107). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#selectedTravelMode) + */ + description: string; + /** + * The unique identifier specific for this travel mode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#selectedTravelMode) + */ + id: string; + /** + * The cost attribute on which to optimize the analysis. For example `Miles`, `Minutes`, `Travel Time`, `Kilometers`, `TimeAt1KPH`, `WalkTime`, and `TruckTravelTime`. Take note that attribute names are specific to the network dataset. They may be different if using another Network Analysis service besides the one hosted via ArcGIS Online. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#selectedTravelMode) + */ + impedanceAttributeName: string; + /** + * Name of the travel mode. Users of ArcGIS Online or Portal for ArcGIS can define custom travel modes inside their Organization settings. Authors of stand alone Network Analysis Services can define their own travel modes inside a network dataset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#selectedTravelMode) + */ + name: string; + /** + * The time-based cost attribute for reporting directions. For example, `Minutes`, `Travel Time`, `TimeAt1KPH`, `WalkTime`, and `TruckTravelTime`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#selectedTravelMode) + */ + timeAttributeName: string; + } + + + export interface DirectionsViewModelStopSymbols extends Object { + /** + * The first stop symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#stopSymbols) + */ + first?: Symbol; + /** + * The middle stop symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#stopSymbols) + */ + middle?: Symbol; + /** + * The last stop symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#stopSymbols) + */ + last?: Symbol; + /** + * An unlocated stop symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#stopSymbols) + */ + unlocated?: Symbol; + /** + * A waypoint stop symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#stopSymbols) + */ + waypoint?: Symbol; + } + + + export interface DirectionsViewModelTimeAttribute extends Object { + /** + * The name of the network attribute to use for the drive time when computing directions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#timeAttribute) + */ + name: string; + /** + * The units to use when calculating drive time for directions. **Possible Values:** feet | kilometers | meters | miles | nautical-miles | yards + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#timeAttribute) + */ + units?: string; + } + + /** + * Array of objects containing properties specific to either an ArcGIS service or organization's travel modes. More information can be found in the [ArcGIS Online documentation](https://doc.arcgis.com/en/arcgis-online/reference/travel-modes.htm#GUID-96DF7F50-E0B2-4BF3-8271-EB515D3F0107). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#TravelMode) + */ + export interface TravelMode extends Object { + /** + * The description explaining the selected travel mode. A listing of these descriptions can be found in the [ArcGIS Online documentation](https://doc.arcgis.com/en/arcgis-online/reference/travel-modes.htm#GUID-96DF7F50-E0B2-4BF3-8271-EB515D3F0107). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#TravelMode) + */ + description?: string; + /** + * The unique identifier specific for this travel mode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#TravelMode) + */ + id?: string; + /** + * The cost attribute on which to optimize the analysis. For example `Miles`, `Minutes`, `Travel Time`, `Kilometers`, `TimeAt1KPH`, `WalkTime`, and `TruckTravelTime`. Take note that attribute names are specific to the network dataset. They may be different if using another Network Analysis service besides the one hosted via ArcGIS Online. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#TravelMode) + */ + impedanceAttributeName?: string; + /** + * Name of the travel mode. Users of ArcGIS Online or Portal for ArcGIS can define custom travel modes inside their Organization settings. Authors of stand alone Network Analysis Services can define their own travel modes inside a network dataset. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#TravelMode) + */ + name?: string; + /** + * The time-based cost attribute for reporting directions. For example, `Minutes`, `Travel Time`, `TimeAt1KPH`, `WalkTime`, and `TruckTravelTime`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions-DirectionsViewModel.html#TravelMode) + */ + timeAttributeName?: string; + } + + + export interface DirectionsStopSymbols extends Object { + /** + * The first stop symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#stopSymbols) + */ + first?: Symbol; + /** + * The middle stop symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#stopSymbols) + */ + middle?: Symbol; + /** + * The last stop symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#stopSymbols) + */ + last?: Symbol; + /** + * An unlocated stop symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#stopSymbols) + */ + unlocated?: Symbol; + /** + * A waypoint stop symbol. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#stopSymbols) + */ + waypoint?: Symbol; + } + + /** + * Configurable Search properties of the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + export interface DirectionsSearchProperties extends Object { + /** + * Indicates whether to show the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a result is selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + popupOpenOnSelect?: boolean; + /** + * Number index indicating the current selected source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + activeSourceIndex?: number; + /** + * Indicates whether to automatically navigate to the selected result once selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + autoNavigate?: boolean; + /** + * Indicates whether to automatically select and zoom to the first geocoded result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + autoSelect?: boolean; + /** + * Indicates the maximum number of search results to return. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + maxResults?: number; + /** + * Indicates the maximum number of suggestions to return for the widget's input. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + maxSuggestions?: number; + /** + * Indicates the minimum number of characters required before querying for a suggestion. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + minSuggestCharacters?: number; + /** + * Indicates whether to display a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a selected result is clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + popupEnabled?: boolean; + /** + * String value used as a hint for input text when searching on multiple sources. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + allPlaceholder?: string; + /** + * A customized PopupTemplate for the selected feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + popupTemplate?: PopupTemplate; + /** + * Indicates whether to show a graphic on the map for the selected source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + resultGraphicEnabled?: boolean; + /** + * Indicates whether to display the option to search all sources. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + searchAllEnabled?: boolean; + /** + * The value of the search box input text string. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + searchTerm?: string; + /** + * Specifies the sources to search in the [view](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#view). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + sources?: Collection; + /** + * Indicates whether to display suggestions as the user enters input text in the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + suggestionsEnabled?: boolean; + /** + * The view of the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + view?: MapView | SceneView; + /** + * The Search widget's view model. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Directions.html#SearchProperties) + */ + viewModel?: SearchViewModel; + } + + interface DirectLineMeasurement3D extends Widget { + /** + * A reference to the [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-DirectLineMeasurement3D.html#view) + */ + view: SceneView; + + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-DirectLineMeasurement3D.html#render) + * + * + */ + render(): any; + } + + interface DirectLineMeasurement3DConstructor { + /** + * The DirectLineMeasurement3D widget calculates and displays the 3D distance between two points. This widget can be used in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html) to measure the vertical, horizontal, and direct distance between two points. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-DirectLineMeasurement3D.html) + */ + + new(properties?: DirectLineMeasurement3DProperties): DirectLineMeasurement3D; + } + + export const DirectLineMeasurement3D: DirectLineMeasurement3DConstructor; + + interface DirectLineMeasurement3DProperties extends WidgetProperties { + /** + * A reference to the [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-DirectLineMeasurement3D.html#view) + */ + view?: SceneViewProperties; + } + + interface Expand extends Widget { + /** + * Automatically collapses the expand widget instance when the view's viewpoint updates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#autoCollapse) + * + * @default false + */ + autoCollapse: boolean; + /** + * Icon font used to style the Expand button. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#collapseIconClass) + */ + collapseIconClass: string; + /** + * Tooltip to display to indicate Expand widget can be collapsed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#collapseTooltip) + * + * @default "Collapse" (English locale) + */ + collapseTooltip: string; + /** + * The content to display within the expanded Expand widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#content) + */ + content: Node | string | Widget; + /** + * Whether the widget is currently expanded or not. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#expanded) + * + * @default false + */ + readonly expanded: boolean; + /** + * Icon font used to style the Expand button. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#expandIconClass) + */ + expandIconClass: string; + /** + * Tooltip to display to indicate Expand widget can be expanded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#expandTooltip) + * + * @default "Expand" (English locale) + */ + expandTooltip: string; + /** + * This value associates two or more Expand widget instances with each other, allowing one instance to auto collapse when another instance in the same group is expanded. For auto collapsing to take effect, all instances of the group must be included in the [view.ui](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#ui). For example, if you place multiple Expand instances in the top-left of the view's ui, you can assign them to a group called `top-left`. If one Expand instance is expanded and the user clicks on a different instance in the `top-left` group, then the first instance is collapsed, allowing the content of the second instance to be fully visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#group) + */ + group: string; + /** + * A number to display at the corner of the widget to indicate the number of, for example, open issues or unread notices. ![expand widget icon number](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/expand-with-iconnumber.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#iconNumber) + */ + iconNumber: number; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#view) + */ + view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [ExpandViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand-ExpandViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#viewModel) + */ viewModel: ExpandViewModel; + /** + * Collapse the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#collapse) + * + * + */ collapse(): void; + /** + * Expand the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#expand) + * + * + */ expand(): void; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#render) + * + * + */ render(): any; + /** + * Toggle the widget by expanding it if it's collapsed, or collapsing it if it's expanded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#toggle) + * + * + */ toggle(): void; } interface ExpandConstructor { + + new(properties?: ExpandProperties): Expand; } export const Expand: ExpandConstructor; interface ExpandProperties extends WidgetProperties { + /** + * Automatically collapses the expand widget instance when the view's viewpoint updates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#autoCollapse) + * + * @default false + */ autoCollapse?: boolean; + /** + * Icon font used to style the Expand button. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#collapseIconClass) + */ collapseIconClass?: string; + /** + * Tooltip to display to indicate Expand widget can be collapsed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#collapseTooltip) + * + * @default "Collapse" (English locale) + */ collapseTooltip?: string; + /** + * The content to display within the expanded Expand widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#content) + */ content?: Node | string | WidgetProperties; - expanded?: boolean; + /** + * Icon font used to style the Expand button. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#expandIconClass) + */ expandIconClass?: string; + /** + * Tooltip to display to indicate Expand widget can be expanded. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#expandTooltip) + * + * @default "Expand" (English locale) + */ expandTooltip?: string; - iconNumber?: string; + /** + * This value associates two or more Expand widget instances with each other, allowing one instance to auto collapse when another instance in the same group is expanded. For auto collapsing to take effect, all instances of the group must be included in the [view.ui](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#ui). For example, if you place multiple Expand instances in the top-left of the view's ui, you can assign them to a group called `top-left`. If one Expand instance is expanded and the user clicks on a different instance in the `top-left` group, then the first instance is collapsed, allowing the content of the second instance to be fully visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#group) + */ + group?: string; + /** + * A number to display at the corner of the widget to indicate the number of, for example, open issues or unread notices. ![expand widget icon number](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/expand-with-iconnumber.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#iconNumber) + */ + iconNumber?: number; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [ExpandViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand-ExpandViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand.html#viewModel) + */ viewModel?: ExpandViewModelProperties; } interface ExpandViewModel extends Accessor { + /** + * Automatically collapses the expand widget instance when the view's viewpoint updates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand-ExpandViewModel.html#autoCollapse) + * + * @default false + */ autoCollapse: boolean; - expanded: boolean; - state: string; + /** + * Whether the widget is currently expanded or not. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand-ExpandViewModel.html#expanded) + * + * @default false + */ + readonly expanded: boolean; + /** + * This value associates two or more Expand widget instances with each other, allowing one instance to auto collapse when another instance in the same group is expanded. For auto collapsing to take effect, all instances of the group must be included in the [view.ui](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#ui). For example, if you place multiple Expand instances in the top-left of the view's ui, you can assign them to a group called `top-left`. If one Expand instance is expanded and the user clicks on a different instance in the `top-left` group, then the first instance is collapsed, allowing the content of the second instance to be fully visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand-ExpandViewModel.html#group) + */ + group: string; + /** + * The view model's state. **Known Values:** ready | disabled + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand-ExpandViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The view in which the Expand is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand-ExpandViewModel.html#view) + */ view: MapView | SceneView; } interface ExpandViewModelConstructor { + + new(properties?: ExpandViewModelProperties): ExpandViewModel; } export const ExpandViewModel: ExpandViewModelConstructor; interface ExpandViewModelProperties { + /** + * Automatically collapses the expand widget instance when the view's viewpoint updates. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand-ExpandViewModel.html#autoCollapse) + * + * @default false + */ autoCollapse?: boolean; - expanded?: boolean; - state?: string; + /** + * This value associates two or more Expand widget instances with each other, allowing one instance to auto collapse when another instance in the same group is expanded. For auto collapsing to take effect, all instances of the group must be included in the [view.ui](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html#ui). For example, if you place multiple Expand instances in the top-left of the view's ui, you can assign them to a group called `top-left`. If one Expand instance is expanded and the user clicks on a different instance in the `top-left` group, then the first instance is collapsed, allowing the content of the second instance to be fully visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand-ExpandViewModel.html#group) + */ + group?: string; + /** + * The view in which the Expand is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Expand-ExpandViewModel.html#view) + */ + view?: MapViewProperties | SceneViewProperties; + } + + interface Fullscreen extends Widget { + /** + * The [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) to present in fullscreen mode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen.html#element) + */ + element: HTMLElement; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen.html#view) + */ + view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [FullscreenViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen-FullscreenViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen.html#viewModel) + */ + viewModel: FullscreenViewModel; + + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen.html#render) + * + * + */ + render(): any; + } + + interface FullscreenConstructor { + /** + * Provides a simple widget to present the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) or a user-defined [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) using the entire screen. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen.html) + */ + + new(properties?: FullscreenProperties): Fullscreen; + } + + export const Fullscreen: FullscreenConstructor; + + interface FullscreenProperties extends WidgetProperties { + /** + * The [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) to present in fullscreen mode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen.html#element) + */ + element?: HTMLElement; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen.html#view) + */ + view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [FullscreenViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen-FullscreenViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen.html#viewModel) + */ + viewModel?: FullscreenViewModelProperties; + } + + interface FullscreenViewModel extends Accessor { + /** + * The [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) to present in fullscreen mode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen-FullscreenViewModel.html#element) + */ + element: HTMLElement; + /** + * The view model's state. **Known Values:** active | ready | feature-unsupported | disabled + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen-FullscreenViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The view associated with the widget instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen-FullscreenViewModel.html#view) + */ + view: MapView | SceneView; + + /** + * Enter fullscreen + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen-FullscreenViewModel.html#enter) + * + * + */ + enter(): void; + /** + * Exit fullscreen + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen-FullscreenViewModel.html#exit) + * + * + */ + exit(): void; + /** + * Toggle fullscreen + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen-FullscreenViewModel.html#toggle) + * + * + */ + toggle(): void; + } + + interface FullscreenViewModelConstructor { + + + new(properties?: FullscreenViewModelProperties): FullscreenViewModel; + } + + export const FullscreenViewModel: FullscreenViewModelConstructor; + + interface FullscreenViewModelProperties { + /** + * The [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) to present in fullscreen mode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen-FullscreenViewModel.html#element) + */ + element?: HTMLElement; + /** + * The view associated with the widget instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Fullscreen-FullscreenViewModel.html#view) + */ view?: MapViewProperties | SceneViewProperties; } interface Home extends Widget { + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home.html#view) + */ view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [HomeViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home-HomeViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home.html#viewModel) + */ viewModel: HomeViewModel; + /** + * The [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html), or point of view, to zoom to when going home. The initial value is determined a few different ways: + * * If no [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is provided, the value is `null`. + * * If the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is ready, but the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is not defined, the initial value of the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is determined when the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) became ready. + * * If the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is ready and the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is defined by the user, the initial viewpoint value is the user-defined [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home.html#viewpoint) + */ viewpoint: Viewpoint; + /** + * Animates the view to the initial Viewpoint of the view or the value of [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home.html#viewpoint). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home.html#go) + * + * + */ go(): void; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home.html#render) + * + * + */ render(): any; } interface HomeConstructor { + /** + * Provides a simple widget that switches the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) to its initial [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) or a previously defined [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home.html#viewpoint). By default this button looks like the following: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home.html) + */ + new(properties?: HomeProperties): Home; } export const Home: HomeConstructor; interface HomeProperties extends WidgetProperties { + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [HomeViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home-HomeViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home.html#viewModel) + */ viewModel?: HomeViewModelProperties; + /** + * The [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html), or point of view, to zoom to when going home. The initial value is determined a few different ways: + * * If no [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is provided, the value is `null`. + * * If the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is ready, but the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is not defined, the initial value of the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is determined when the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) became ready. + * * If the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is ready and the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is defined by the user, the initial viewpoint value is the user-defined [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home.html#viewpoint) + */ viewpoint?: ViewpointProperties; } interface HomeViewModel extends Accessor, Evented { - state: string; + /** + * The current state of the widget. **Possible Values:** disabled | ready | going-home + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home-HomeViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The view associated with the widget instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home-HomeViewModel.html#view) + */ view: MapView | SceneView; + /** + * The [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html), or point of view, to zoom to when going home. The initial value is determined a few different ways: + * * If no [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is provided, the value is `null`. + * * If the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is ready, but the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is not defined, the initial value of the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is determined when the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) became ready. + * * If the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is ready and the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is defined by the user, the initial viewpoint value is the user-defined [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home-HomeViewModel.html#viewpoint) + * + * @default null + */ viewpoint: Viewpoint; + /** + * Animates the view to the initial [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) of the view or the value of [viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home-HomeViewModel.html#viewpoint). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home-HomeViewModel.html#go) + * + * + */ go(): void; } interface HomeViewModelConstructor { + + new(properties?: HomeViewModelProperties): HomeViewModel; } export const HomeViewModel: HomeViewModelConstructor; interface HomeViewModelProperties { - state?: string; + /** + * The view associated with the widget instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home-HomeViewModel.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html), or point of view, to zoom to when going home. The initial value is determined a few different ways: + * * If no [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is provided, the value is `null`. + * * If the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is ready, but the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is not defined, the initial value of the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is determined when the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) became ready. + * * If the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) is ready and the [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) is defined by the user, the initial viewpoint value is the user-defined [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Home-HomeViewModel.html#viewpoint) + * + * @default null + */ viewpoint?: ViewpointProperties; } interface LayerList extends Widget { + /** + * **Use [listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction) instead.** Specify the function that will create actions for [ListItems](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html). Actions are defined with the properties listed in the [Action class](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html). This function must return a two-dimensional array of [Actions](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#createActionsFunction) + */ createActionsFunction: Function; + /** + * Specifies a function that accesses each [ListItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html). Each list item can be modified according to its modifiable propeties. Actions can be added to list items using the [actionsSections](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#actionsSections) property of the ListItem. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction) + */ listItemCreatedFunction: Function; + /** + * A collection of [ListItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html)s representing operational layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#operationalItems) + */ operationalItems: Collection; + /** + * Option for enabling status indicators, which indicate whether or not each layer is loading resources. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#statusIndicatorsVisible) + * + * @default true + */ statusIndicatorsVisible: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#view) + */ view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [LayerListViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#viewModel) + */ viewModel: LayerListViewModel; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#render) + * + * + */ render(): any; + /** + * Triggers the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#event:trigger-action) event and executes the given [action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#triggerAction) + * + * @param action The action to execute. + * @param item An item associated with the action. + * + */ triggerAction(action: Action, item: ListItem): void; } interface LayerListConstructor { + + new(properties?: LayerListProperties): LayerList; } export const LayerList: LayerListConstructor; interface LayerListProperties extends WidgetProperties { + /** + * **Use [listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction) instead.** Specify the function that will create actions for [ListItems](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html). Actions are defined with the properties listed in the [Action class](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html). This function must return a two-dimensional array of [Actions](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#createActionsFunction) + */ createActionsFunction?: Function; + /** + * Specifies a function that accesses each [ListItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html). Each list item can be modified according to its modifiable propeties. Actions can be added to list items using the [actionsSections](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#actionsSections) property of the ListItem. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction) + */ listItemCreatedFunction?: Function; + /** + * A collection of [ListItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html)s representing operational layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#operationalItems) + */ operationalItems?: CollectionProperties; + /** + * Option for enabling status indicators, which indicate whether or not each layer is loading resources. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#statusIndicatorsVisible) + * + * @default true + */ statusIndicatorsVisible?: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [LayerListViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#viewModel) + */ viewModel?: LayerListViewModelProperties; } interface LayerListViewModel extends Accessor { + /** + * **Use [listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#listItemCreatedFunction) instead.** Specify the function that will create actions for [ListItems](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html). Actions are defined with the properties listed in the [Action class](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#createActionsFunction) + */ createActionsFunction: Function; + /** + * Specifies a function that accesses each [ListItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html). Each list item can be modified according to its modifiable propeties. Actions can be added to list items using the [actionsSections](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#actionsSections) property of the ListItem. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#listItemCreatedFunction) + */ listItemCreatedFunction: Function; - operationalItems: Collection; - state: string; + /** + * A collection of [ListItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html)s representing operational layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#operationalItems) + */ + readonly operationalItems: Collection; + /** + * The view model's state. **Known Values:** ready | disabled + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The view from which the widget will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#view) + */ view: MapView | SceneView; + /** + * Triggers the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#event:trigger-action) event and executes the given [action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#triggerAction) + * + * @param action The action to execute. + * @param item An item associated with the action. + * + */ triggerAction(action: Action, item: ListItem): void; } interface LayerListViewModelConstructor { + + new(properties?: LayerListViewModelProperties): LayerListViewModel; } export const LayerListViewModel: LayerListViewModelConstructor; interface LayerListViewModelProperties { + /** + * **Use [listItemCreatedFunction](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#listItemCreatedFunction) instead.** Specify the function that will create actions for [ListItems](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html). Actions are defined with the properties listed in the [Action class](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#createActionsFunction) + */ createActionsFunction?: Function; + /** + * Specifies a function that accesses each [ListItem](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html). Each list item can be modified according to its modifiable propeties. Actions can be added to list items using the [actionsSections](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#actionsSections) property of the ListItem. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#listItemCreatedFunction) + */ listItemCreatedFunction?: Function; - operationalItems?: CollectionProperties; - state?: string; + /** + * The view from which the widget will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-LayerListViewModel.html#view) + */ view?: MapViewProperties | SceneViewProperties; } interface ListItem { + /** + * Whether the actional panel is open in the LayerList. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#actionsOpen) + * + * @default false + */ actionsOpen: boolean; + /** + * A nested 2-dimensional collection of actions that could be triggered on the item. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#actionsSections) + */ actionsSections: Collection>; + /** + * When a layer contains sublayers, this property is a Collection of ListItem objects belonging to the given layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#children) + */ children: Collection; - error: Error; + /** + * The Error object returned if an error occurred. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#error) + */ + readonly error: Error; + /** + * The layer associated with the triggered action. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#layer) + * + * @default null + */ layer: Layer; - layerView: LayerView; + /** + * The [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) displaying data for the associated [layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#layer). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#layerView) + */ + readonly layerView: LayerView; + /** + * Whether the layer is open in the LayerList. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#open) + * + * @default false + */ open: boolean; + /** + * The parent of this item + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#parent) + * + * @default null + */ parent: ListItem; + /** + * The title of the layer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#title) + */ title: string; - updating: boolean; + /** + * Value is `true` when the layer is updating; for example, if it is in the process of fetching data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#updating) + * + * @default false + */ + readonly updating: boolean; + /** + * The view from which the widget will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#view) + */ view: MapView | SceneView; - visibilityMode: string; + /** + * Indicates how to manage the visibility of the children layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#visibilityMode) + */ + readonly visibilityMode: string; + /** + * Indicates if the ListItem is visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#visible) + * + * @default true + */ visible: boolean; - visibleAtCurrentScale: boolean; + /** + * Whether the layer is visible at the current scale or not. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#visibleAtCurrentScale) + * + * @default true + */ + readonly visibleAtCurrentScale: boolean; + /** + * Creates a deep clone of this object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html#clone) + * + * + */ clone(): ListItem; } interface ListItemConstructor { + + + new(): ListItem; } export const ListItem: ListItemConstructor; interface Legend extends Widget { + /** + * Specifies a subset of the layers to display in the legend. If this property is not set, all layers in the map will display in the legend. Objects in this array are defined with the properties listed below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html#layerInfos) + */ layerInfos: LegendLayerInfos[]; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html#view) + */ view: MapView | SceneView; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html#render) + * + * + */ render(): any; } interface LegendConstructor { + /** + * The Legend widget displays labels and symbols for layers in a map. Labels and their corresponding symbols depend on the values set in the [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html) of the layer. The legend will only display layers and sublayers that are visible in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html) + */ + new(properties?: LegendProperties): Legend; } export const Legend: LegendConstructor; interface LegendProperties extends WidgetProperties { + /** + * Specifies a subset of the layers to display in the legend. If this property is not set, all layers in the map will display in the legend. Objects in this array are defined with the properties listed below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html#layerInfos) + */ layerInfos?: LegendLayerInfos[]; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html#view) + */ view?: MapViewProperties | SceneViewProperties; } - export interface LegendLayerInfos { + + export interface LegendLayerInfos extends Object { + /** + * Specifies a title for the layer to display above its symbols and descriptions. If no title is specified the service name is used. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html#layerInfos) + */ title?: string; + /** + * A layer to display in the legend. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html#layerInfos) + */ layer: Layer; } interface Locate extends Widget { + /** + * The HTML5 Geolocation Position options for locating. Refer to [Geolocation API Specification](http://www.w3.org/TR/geolocation-API/#position-options) for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#geolocationOptions) + * + * @default { maximumAge: 0, timeout: 15000, enableHighAccuracy: true } + */ geolocationOptions: any; + /** + * Indicates whether the widget should navigate the view to the position and scale of the geolocated result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#goToLocationEnabled) + * + * @default true + */ goToLocationEnabled: boolean; + /** + * The graphic used to show the user's location on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#graphic) + */ graphic: Graphic; + /** + * Indicates whether the widget will automatically [rotate to user's direction](https://www.w3.org/TR/geolocation-API/#coordinates_interface). Set to `false` to disable this behavior. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#useHeadingEnabled) + * + * @default true + */ + useHeadingEnabled: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#view) + */ view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [LocateViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate-LocateViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#viewModel) + */ viewModel: LocateViewModel; + /** + * Animates the view to the user's location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#locate) + * + * + */ locate(): IPromise; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#render) + * + * + */ render(): any; } interface LocateConstructor { + /** + * Provides a simple widget that animates the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) to the user's current location. The view rotates according to the direction where the tracked device is heading towards. By default the widget looks like the following: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html) + */ + new(properties?: LocateProperties): Locate; } export const Locate: LocateConstructor; interface LocateProperties extends WidgetProperties { + /** + * The HTML5 Geolocation Position options for locating. Refer to [Geolocation API Specification](http://www.w3.org/TR/geolocation-API/#position-options) for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#geolocationOptions) + * + * @default { maximumAge: 0, timeout: 15000, enableHighAccuracy: true } + */ geolocationOptions?: any; + /** + * Indicates whether the widget should navigate the view to the position and scale of the geolocated result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#goToLocationEnabled) + * + * @default true + */ goToLocationEnabled?: boolean; + /** + * The graphic used to show the user's location on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#graphic) + */ graphic?: GraphicProperties; + /** + * Indicates whether the widget will automatically [rotate to user's direction](https://www.w3.org/TR/geolocation-API/#coordinates_interface). Set to `false` to disable this behavior. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#useHeadingEnabled) + * + * @default true + */ + useHeadingEnabled?: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [LocateViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate-LocateViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html#viewModel) + */ viewModel?: LocateViewModelProperties; } interface LocateViewModel extends Accessor, Evented, GeolocationPositioning { - state: string; + /** + * The current state of the widget. **Possible Values:** disabled | ready | locating + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate-LocateViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * Animates the view to the user's location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate-LocateViewModel.html#locate) + * + * + */ locate(): IPromise; } interface LocateViewModelConstructor { + /** + * Provides the logic for the [Locate](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate.html) widget, which animates the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) to the user's current location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Locate-LocateViewModel.html) + */ + new(properties?: LocateViewModelProperties): LocateViewModel; } export const LocateViewModel: LocateViewModelConstructor; interface LocateViewModelProperties extends GeolocationPositioningProperties { - state?: string; + } interface NavigationToggle extends Widget { + /** + * Sets the layout of the widget to either `horizontal` or `vertical`. See the table below for a list of possible values. + * + * Possible Value | Example + * ---------------|-------- + * vertical | ![navigation-toggle](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/navigation-toggle.png) + * horizontal | ![navigation-toggle-horizontal](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/navigation-toggle-horizontal.png) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle.html#layout) + * + * @default vertical + */ layout: string; + /** + * A reference to the SceneView. Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle.html#view) + */ view: SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [NavigationToggleViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle.html#viewModel) + */ viewModel: NavigationToggleViewModel; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle.html#render) + * + * + */ render(): any; + /** + * Toggles the navigation mode of the [view](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle.html#view) from `pan` to `rotate` or vice versa. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle.html#toggle) + * + * + */ toggle(): void; } interface NavigationToggleConstructor { + /** + * Provides two simple buttons for toggling the [navigation mode](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html#navigationMode) of a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Note that this widget is designed only for 3D mouse interaction in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). It has no effect on touch navigation and it should not be used with 2D mouse interaction in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle.html) + */ + new(properties?: NavigationToggleProperties): NavigationToggle; } export const NavigationToggle: NavigationToggleConstructor; interface NavigationToggleProperties extends WidgetProperties { + /** + * Sets the layout of the widget to either `horizontal` or `vertical`. See the table below for a list of possible values. + * + * Possible Value | Example + * ---------------|-------- + * vertical | ![navigation-toggle](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/navigation-toggle.png) + * horizontal | ![navigation-toggle-horizontal](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/navigation-toggle-horizontal.png) + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle.html#layout) + * + * @default vertical + */ layout?: string; + /** + * A reference to the SceneView. Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle.html#view) + */ view?: SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [NavigationToggleViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle.html#viewModel) + */ viewModel?: NavigationToggleViewModelProperties; } interface NavigationToggleViewModel extends Accessor { + /** + * The navigation mode of the [view](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html#view). See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------- + * pan | The mouse drag gesture pans the view. Right-click + drag allows the user to perform a 3D rotate around the center of the view. + * rotate | The mouse drag gesture performs a 3D rotate around the center of the view and the right-click + drag gesture pans the view. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html#navigationMode) + * + * @default pan + */ navigationMode: string; - state: string; + /** + * The state of the widget. **Possible Values:** disabled | ready + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The view associated with the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html#view) + */ view: SceneView; + /** + * Toggles the navigation mode of the [view](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html#view) from `pan` to `rotate` or vice versa. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html#toggle) + * + * + */ toggle(): void; } interface NavigationToggleViewModelConstructor { + /** + * Provides the logic for the [NavigationToggle](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle.html) widget, which provides two simple buttons for toggling the [navigation mode](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html#navigationMode) of a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Note that this is not designed for 2D mouse interaction in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html), nor for touch navigation. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html) + */ + new(properties?: NavigationToggleViewModelProperties): NavigationToggleViewModel; } export const NavigationToggleViewModel: NavigationToggleViewModelConstructor; interface NavigationToggleViewModelProperties { + /** + * The navigation mode of the [view](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html#view). See the table below for a list of possible values. + * + * Possible Value | Description + * ---------------|------------- + * pan | The mouse drag gesture pans the view. Right-click + drag allows the user to perform a 3D rotate around the center of the view. + * rotate | The mouse drag gesture performs a 3D rotate around the center of the view and the right-click + drag gesture pans the view. + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html#navigationMode) + * + * @default pan + */ navigationMode?: string; - state?: string; + /** + * The view associated with the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-NavigationToggle-NavigationToggleViewModel.html#view) + */ view?: SceneViewProperties; } interface Popup extends Widget, Evented { + /** + * Defines actions that may be executed by clicking the icon or image symbolizing them in the popup. By default, every popup has a `zoom-to` action styled with a magnifying glass icon ![popupTemplate-zoom-action](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/popuptemplate-zoom-action.png). When this icon is clicked, the view zooms in four LODs and centers on the selected feature. You may override this action by removing it from the `actions` array or by setting the [overwriteActions](esri-PopupTemplate.html#overwriteActions) property to `true` in a [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). The order of each action in the popup is the order in which they appear in the array. The [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event:trigger-action) event fires each time an action in the popup is clicked. This event should be used to execute custom code for each action clicked. For example, if you would like to add a `zoom-out` action to the popup that zooms the view out several LODs, you would define the zoom-out code in a separate function. Then you would call the custom `zoom-out` function in the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event:trigger-action) event handler. See the sample code snippet below for more details on how this works. Actions are defined with the properties listed in the [Action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html) class. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#actions) + */ actions: Collection; + /** + * This closes the popup when the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) camera or [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) changes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#autoCloseEnabled) + * + * @default false + */ autoCloseEnabled: boolean; + /** + * Indicates whether the popup displays its content. If `true`, only the header displays. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#collapsed) + * + * @default false + */ collapsed: boolean; - content: string | Node; - currentDockPosition: string; + /** + * Indicates whether to enable collapse functionality for the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#collapseEnabled) + * + * @default true + */ + collapseEnabled: boolean; + /** + * The content of the popup. When set directly on the Popup, this content is static and cannot use fields to set content templates. To set a template for the content based on field or attribute names, see [PopupTemplate.content](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#content) + */ + content: string | HTMLElement | Widget; + /** + * Dock position in the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html). **Known Values:** top-left | top-center | top-right | bottom-left | bottom-center | bottom-right + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#currentDockPosition) + */ + readonly currentDockPosition: string; + /** + * Indicates whether the placement of the popup is docked to the side of the view. Docking the popup allows for a better user experience, particularly when opening popups in apps on mobile devices. When a popup is "dockEnabled" it means the popup no longer points to the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature) or the [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location) assigned to it. Rather it is attached to a side, the top, or the bottom of the view. See [dockOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockOptions) to override default options related to docking the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockEnabled) + * + * @default false + */ dockEnabled: boolean; + /** + * Docking the popup allows for a better user experience, particularly when opening popups in apps on mobile devices. When a popup is "dockEnabled" it means the popup no longer points to the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature) or the [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location) assigned to it. Rather it is placed in one of the corners of the view or to the top or bottom of it. This property allows the developer to set various options for docking the popup. See the object specification table below to override default docking properties on the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockOptions) + */ dockOptions: PopupDockOptions; - featureCount: number; + /** + * The number of selected [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#features) available to the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#featureCount) + * + * @default 0 + */ + readonly featureCount: number; + /** + * An array of features associated with the popup. Each graphic in this array must have a valid [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) set. They may share the same [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) or have unique [PopupTemplates](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) depending on their attributes. The [content](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#content) and [title](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#title) of the poup is set based on the `content` and `title` properties of each graphic's respective [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). When more than one graphic exists in this array, the current content of the Popup is set based on the value of the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature). This value is `null` if no features are associated with the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#features) + */ features: Graphic[]; + /** + * Highlight the selected popup feature using the [highlightOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) set on the [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Currently highlight only works in 3D. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#highlightEnabled) + * + * @default true + */ highlightEnabled: boolean; + /** + * Point used to position the popup. This is automatically set when viewing the popup by selecting a feature. If using the Popup to display content not related to features in the map, such as the results from a task, then you must set this property before making the popup [visible](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#visible) to the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location) + */ location: Point; + /** + * An array of pending Promises that have not yet been fulfilled. If there are no pending promises, the value is `null`. When the pending promises are resolved they are removed from this array and the features they return are pushed into the [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#features) array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#promises) + */ promises: IPromise[]; - selectedFeature: Graphic; + /** + * The selected feature accessed by the popup. The content of the Popup is determined based on the [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) assigned to this feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature) + */ + readonly selectedFeature: Graphic; + /** + * Index of the feature that is [selected](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature). When [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#features) are set, the first index is automatically selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeatureIndex) + */ selectedFeatureIndex: number; + /** + * The title of the popup. This can be set generically on the popup no matter the features that are selected. If the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature) has a [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html), then the title set in the corresponding template is used here. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#title) + */ title: string; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#view) + */ view: MapView | SceneView; + /** + * This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [PopupViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#viewModel) + */ viewModel: PopupViewModel; + /** + * Indicates whether the popup is visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#visible) + */ visible: boolean; + /** + * Use this method to remove focus from the Widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#blur) + * + * + */ + blur(): void; + /** + * Removes [promises](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#promises), [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#features), [content](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#content), [title](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#title) and [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location) from the Popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#clear) + * + * + */ clear(): void; + /** + * Closes the popup by setting its [visible](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#visible) property to `false`. Users can alternatively close the popup by directly setting the [visible](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#visible) property to `false`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#close) + * + * + */ close(): void; + /** + * Use this method to give focus to the Widget if the widget is able to be focused. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#focus) + * + * + */ + focus(): void; + /** + * Selects the feature at the next index in relation to the selected feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#next) + * + * + */ next(): PopupViewModel; + /** + * Opens the popup at the given location with content defined either explicitly with `content` or driven from the [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) of input features. This method sets the popup's [visible](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#visible) property to `true`. Users can alternatively open the popup by directly setting the [visible](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#visible) property to `true`. The popup will only display if the view's size constraints in [dockOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockOptions) are met or the [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location) property is set to a geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#open) + * + * @param options Defines the location and content of the popup when opened. + * @param options.title Sets the [title](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#title) of the popup. + * @param options.content Sets the the [content](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#content) of the popup. + * @param options.location Sets the popup's [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location), which is the geometry used to position the popup. + * @param options.features Sets the popup's [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#features), which populate the title and content of the popup based on each graphic's [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). + * @param options.promises Sets pending [promises](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#promises) on the popup. The popup will display once the promises resolve. Each promise must resolve to an array of [Graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). + * @param options.featureMenuOpen **Since:** 4.5 This property enables multiple features in a popup to display in a list rather than displaying the first selected feature. Setting this to `true` allows the user to scroll through the list of features returned from the query and choose the selection they want to display within the popup. + * @param options.updateLocationEnabled When `true` indicates the popup should update its [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location) for each paginated feature based on the [selected feature's](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature) geometry. + * @param options.collapsed **Since:** 4.5 When `true`, indicates that only the popup header will display. + * + */ open(options?: PopupOpenOptions): void; + /** + * Selects the feature at the previous index in relation to the selected feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#previous) + * + * + */ previous(): PopupViewModel; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#render) + * + * + */ render(): any; + /** + * Positions the popup on the view. Moves the popup into the view's extent if the popup is partially or fully outside the view's extent. If the popup is partially out of view, the view will move to fully show the popup. If the popup is fully out of view, the view will move to the popup's location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#reposition) + * + * + */ reposition(): void; + /** + * Triggers the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event:trigger-action) event and executes the [action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#actions) at the specified index in the [actions](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#actions) array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#triggerAction) + * + * @param actionIndex The index of the [action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#actions) to execute. + * + */ triggerAction(actionIndex: number): void; } interface PopupConstructor { + /** + * The popup widget allows users to view content from feature attributes. Popups enhance web applications by providing users with a simple way to interact with and view attributes in a layer. They play an important role in relaying information to the user, which improves the storytelling capabilities of the application. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) + */ + new(properties?: PopupProperties): Popup; } export const Popup: PopupConstructor; interface PopupProperties extends WidgetProperties { + /** + * Defines actions that may be executed by clicking the icon or image symbolizing them in the popup. By default, every popup has a `zoom-to` action styled with a magnifying glass icon ![popupTemplate-zoom-action](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/popuptemplate-zoom-action.png). When this icon is clicked, the view zooms in four LODs and centers on the selected feature. You may override this action by removing it from the `actions` array or by setting the [overwriteActions](esri-PopupTemplate.html#overwriteActions) property to `true` in a [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). The order of each action in the popup is the order in which they appear in the array. The [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event:trigger-action) event fires each time an action in the popup is clicked. This event should be used to execute custom code for each action clicked. For example, if you would like to add a `zoom-out` action to the popup that zooms the view out several LODs, you would define the zoom-out code in a separate function. Then you would call the custom `zoom-out` function in the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#event:trigger-action) event handler. See the sample code snippet below for more details on how this works. Actions are defined with the properties listed in the [Action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html) class. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#actions) + */ actions?: CollectionProperties; + /** + * This closes the popup when the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) camera or [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) changes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#autoCloseEnabled) + * + * @default false + */ autoCloseEnabled?: boolean; + /** + * Indicates whether the popup displays its content. If `true`, only the header displays. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#collapsed) + * + * @default false + */ collapsed?: boolean; - content?: string | Node; - currentDockPosition?: string; + /** + * Indicates whether to enable collapse functionality for the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#collapseEnabled) + * + * @default true + */ + collapseEnabled?: boolean; + /** + * The content of the popup. When set directly on the Popup, this content is static and cannot use fields to set content templates. To set a template for the content based on field or attribute names, see [PopupTemplate.content](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#content) + */ + content?: string | HTMLElement | WidgetProperties; + /** + * Indicates whether the placement of the popup is docked to the side of the view. Docking the popup allows for a better user experience, particularly when opening popups in apps on mobile devices. When a popup is "dockEnabled" it means the popup no longer points to the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature) or the [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location) assigned to it. Rather it is attached to a side, the top, or the bottom of the view. See [dockOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockOptions) to override default options related to docking the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockEnabled) + * + * @default false + */ dockEnabled?: boolean; + /** + * Docking the popup allows for a better user experience, particularly when opening popups in apps on mobile devices. When a popup is "dockEnabled" it means the popup no longer points to the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature) or the [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location) assigned to it. Rather it is placed in one of the corners of the view or to the top or bottom of it. This property allows the developer to set various options for docking the popup. See the object specification table below to override default docking properties on the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockOptions) + */ dockOptions?: PopupDockOptions; - featureCount?: number; + /** + * An array of features associated with the popup. Each graphic in this array must have a valid [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) set. They may share the same [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) or have unique [PopupTemplates](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) depending on their attributes. The [content](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#content) and [title](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#title) of the poup is set based on the `content` and `title` properties of each graphic's respective [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). When more than one graphic exists in this array, the current content of the Popup is set based on the value of the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature). This value is `null` if no features are associated with the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#features) + */ features?: GraphicProperties[]; + /** + * Highlight the selected popup feature using the [highlightOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) set on the [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Currently highlight only works in 3D. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#highlightEnabled) + * + * @default true + */ highlightEnabled?: boolean; + /** + * Point used to position the popup. This is automatically set when viewing the popup by selecting a feature. If using the Popup to display content not related to features in the map, such as the results from a task, then you must set this property before making the popup [visible](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#visible) to the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location) + */ location?: PointProperties; + /** + * An array of pending Promises that have not yet been fulfilled. If there are no pending promises, the value is `null`. When the pending promises are resolved they are removed from this array and the features they return are pushed into the [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#features) array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#promises) + */ promises?: IPromise[]; - selectedFeature?: GraphicProperties; + /** + * Index of the feature that is [selected](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature). When [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#features) are set, the first index is automatically selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeatureIndex) + */ selectedFeatureIndex?: number; + /** + * The title of the popup. This can be set generically on the popup no matter the features that are selected. If the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature) has a [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html), then the title set in the corresponding template is used here. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#title) + */ title?: string; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [PopupViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#viewModel) + */ viewModel?: PopupViewModelProperties; + /** + * Indicates whether the popup is visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#visible) + */ visible?: boolean; } interface PopupViewModel extends Accessor, Evented { - actions: Collection>; + /** + * [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html) objects. Each action may be executed by clicking the icon or image symbolizing them in the popup. By default, every popup has a `zoom-to` action styled with a magnifying glass icon ![popupTemplate-zoom-action](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/popuptemplate-zoom-action.png). When this icon is clicked, the view zooms in four LODs and centers on the selected feature. You may override this action by removing it from the actions [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) or by setting the [overwriteActions](esri-PopupTemplate.html#overwriteActions) property to `true` in a [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). The order of each action in the popup is the order in which they appear in the actions [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html). The [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#event:trigger-action) event fires each time an action in the popup is clicked. This event should be used to execute custom code for each action clicked. For example, if you would like to add a `zoom-out` action to the popup that zooms the view out several LODs, you would define the zoom-out code in a separate function. Then you would call the custom `zoom-out` function in the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#event:trigger-action) event handler. See the sample code snippet below for more details on how this works. Actions are defined with the properties listed in the [Action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html) class. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#actions) + */ + actions: Collection; + /** + * This closes the popup when the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) camera or [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) changes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#autoCloseEnabled) + * + * @default false + */ autoCloseEnabled: boolean; - content: string | Node; - featureCount: number; + /** + * The content of the popup. When set directly on the Popup, this content may only be static and cannot use fields to set content templates. To set a template for the content based on field or attribute names, see [PopupTemplate.content](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#content) + */ + content: string | HTMLElement | Widget; + /** + * The number of selected [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#features) available to the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#featureCount) + * + * @default 0 + */ + readonly featureCount: number; + /** + * An array of features associated with the popup. Each graphic in this array must have a valid [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) set. They may share the same [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) or have unique [PopupTemplates](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) depending on their attributes. The [content](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#content) and [title](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#title) of the poup is set based on the `content` and `title` properties of each graphic's respective [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). When more than one graphic exists in this array, the current content of the Popup is set based on the value of the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#selectedFeature). This value is `null` if no features are associated with the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#features) + */ features: Graphic[]; + /** + * Highlight the selected popup feature using the [highlightOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) set on the [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Currently highlight only works in 3D. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#highlightEnabled) + * + * @default true + */ highlightEnabled: boolean; + /** + * Geometry used to position the popup. This is automatically set when viewing the popup by selecting a feature. If using the Popup to display content not related to features in the map, such as the results from a task, then you must set this property before making the popup [visible](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#visible) to the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#location) + */ location: Point; - pendingPromisesCount: number; - promiseCount: number; + /** + * The number of [promises](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#promises) remaining to be resolved. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#pendingPromisesCount) + * + * @default 0 + */ + readonly pendingPromisesCount: number; + /** + * The number of selected [promises](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#promises) available to the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#promiseCount) + * + * @default 0 + */ + readonly promiseCount: number; + /** + * An array of pending Promises that have not yet been fulfilled. If there are no pending Promises, the value is `null`. When the pending Promises are resolved they are removed from this array and the features they return are pushed into the [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#features) array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#promises) + */ promises: IPromise[]; - selectedFeature: Graphic; + /** + * The selected feature accessed by the popup. The content of the Popup is determined based on the [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) assigned to this feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#selectedFeature) + */ + readonly selectedFeature: Graphic; + /** + * Index of the feature that is [selected](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#selectedFeature). When [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#features) are set, the first index is automatically selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#selectedFeatureIndex) + */ selectedFeatureIndex: number; - state: string; + /** + * The view model's state. **Known Values:** ready | disabled + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The title of the popup. This can be set generically on the popup no matter the features that are selected. If the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#selectedFeature) has a [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html), then the title set in the corresponding template is used here. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#title) + */ title: string; + /** + * The view associated with the Popup instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#view) + */ view: MapView | SceneView; + /** + * Indicates whether the popup is visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#visible) + */ visible: boolean; + /** + * Removes [promises](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#promises), [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#features), [content](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#content), [title](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#title) and [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#location) from the Popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#clear) + * + * + */ clear(): void; + /** + * Selects the feature at the next index in relation to the selected feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#next) + * + * + */ next(): PopupViewModel; + /** + * Selects the feature at the previous index in relation to the selected feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#previous) + * + * + */ previous(): PopupViewModel; + /** + * Triggers the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#event:trigger-action) event and executes the [action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#actions) at the specified index in the [actions](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#actions) array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#triggerAction) + * + * @param actionIndex The index of the [action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#actions) to execute. + * + */ triggerAction(actionIndex: number): void; + + + on(name: "trigger-action", eventHandler: PopupViewModelTriggerActionEventHandler): IHandle; + + on(name: "trigger-action", modifiers: string[], eventHandler: PopupViewModelTriggerActionEventHandler): IHandle; } interface PopupViewModelConstructor { + /** + * Provides the logic for the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) widget, which allows users to view content from feature attributes. Popups enhance web applications by providing users with a simple way to interact with and view attributes in a layer. They play an important role in relaying information to the user, which improves the storytelling capabilities of the application. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html) + */ + new(properties?: PopupViewModelProperties): PopupViewModel; } export const PopupViewModel: PopupViewModelConstructor; interface PopupViewModelProperties { - actions?: CollectionProperties>; + /** + * [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of [Action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html) objects. Each action may be executed by clicking the icon or image symbolizing them in the popup. By default, every popup has a `zoom-to` action styled with a magnifying glass icon ![popupTemplate-zoom-action](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/popuptemplate-zoom-action.png). When this icon is clicked, the view zooms in four LODs and centers on the selected feature. You may override this action by removing it from the actions [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) or by setting the [overwriteActions](esri-PopupTemplate.html#overwriteActions) property to `true` in a [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). The order of each action in the popup is the order in which they appear in the actions [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html). The [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#event:trigger-action) event fires each time an action in the popup is clicked. This event should be used to execute custom code for each action clicked. For example, if you would like to add a `zoom-out` action to the popup that zooms the view out several LODs, you would define the zoom-out code in a separate function. Then you would call the custom `zoom-out` function in the [trigger-action](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#event:trigger-action) event handler. See the sample code snippet below for more details on how this works. Actions are defined with the properties listed in the [Action](https://developers.arcgis.com/javascript/latest/api-reference/esri-support-Action.html) class. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#actions) + */ + actions?: CollectionProperties; + /** + * This closes the popup when the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) camera or [Viewpoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-Viewpoint.html) changes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#autoCloseEnabled) + * + * @default false + */ autoCloseEnabled?: boolean; - content?: string | Node; - featureCount?: number; + /** + * The content of the popup. When set directly on the Popup, this content may only be static and cannot use fields to set content templates. To set a template for the content based on field or attribute names, see [PopupTemplate.content](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html#content). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#content) + */ + content?: string | HTMLElement | WidgetProperties; + /** + * An array of features associated with the popup. Each graphic in this array must have a valid [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) set. They may share the same [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) or have unique [PopupTemplates](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html) depending on their attributes. The [content](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#content) and [title](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#title) of the poup is set based on the `content` and `title` properties of each graphic's respective [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). When more than one graphic exists in this array, the current content of the Popup is set based on the value of the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#selectedFeature). This value is `null` if no features are associated with the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#features) + */ features?: GraphicProperties[]; + /** + * Highlight the selected popup feature using the [highlightOptions](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#highlightOptions) set on the [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Currently highlight only works in 3D. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#highlightEnabled) + * + * @default true + */ highlightEnabled?: boolean; + /** + * Geometry used to position the popup. This is automatically set when viewing the popup by selecting a feature. If using the Popup to display content not related to features in the map, such as the results from a task, then you must set this property before making the popup [visible](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#visible) to the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#location) + */ location?: PointProperties; - pendingPromisesCount?: number; - promiseCount?: number; + /** + * An array of pending Promises that have not yet been fulfilled. If there are no pending Promises, the value is `null`. When the pending Promises are resolved they are removed from this array and the features they return are pushed into the [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#features) array. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#promises) + */ promises?: IPromise[]; - selectedFeature?: GraphicProperties; + /** + * Index of the feature that is [selected](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#selectedFeature). When [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#features) are set, the first index is automatically selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#selectedFeatureIndex) + */ selectedFeatureIndex?: number; - state?: string; + /** + * The title of the popup. This can be set generically on the popup no matter the features that are selected. If the [selected feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#selectedFeature) has a [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html), then the title set in the corresponding template is used here. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#title) + */ title?: string; + /** + * The view associated with the Popup instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * Indicates whether the popup is visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup-PopupViewModel.html#visible) + */ visible?: boolean; } - export interface PopupDockOptions { + export interface PopupViewModelTriggerActionEvent { + + action: Action; + } + + + export interface PopupDockOptions extends Object { + /** + * Defines the dimensions of the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) at which to dock the popup. Set to `false` to disable docking at a breakpoint. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockOptions) + * + * @default true + */ breakpoint?: boolean | PopupDockOptionsBreakpoint; + /** + * If `true`, displays the dock button. If `false`, hides the dock button from the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockOptions) + */ buttonEnabled?: boolean; + /** + * The position in the view at which to dock the popup. Can be set as either a string or function. See the table below for known string values and their position in the view based on the view's size. + * + * Known Value | View size > breakpoint | View size < breakpoint + * --------------- | ------------------------------- | ------------- + * auto | top-right | bottom 100% + * top-left | top-left | top 100% + * top-center | top-center | top 100% + * top-right | top-right | top 100% + * bottom-left | bottom-left | bottom 100% + * bottom-center | bottom-center | bottom 100% + * bottom-right | bottom-right | bottom 100% + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockOptions) + * + * @default auto + */ position?: string | Function; } - export interface PopupDockOptionsBreakpoint { + + export interface PopupDockOptionsBreakpoint extends Object { + /** + * The maximum width of the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) at which the popup will be set to dockEnabled automatically. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockOptions) + * + * @default 544 + */ width?: number; + /** + * The maximum height of the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) at which the popup will be set to dockEnabled automatically. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#dockOptions) + * + * @default 544 + */ height?: number; } - export interface PopupOpenOptions { + + export interface PopupOpenOptions extends Object { + /** + * Sets the [title](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#title) of the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#open) + */ title?: string; + /** + * Sets the the [content](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#content) of the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#open) + */ content?: string; + /** + * Sets the popup's [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location), which is the geometry used to position the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#open) + */ location?: Geometry; + /** + * Sets the popup's [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#features), which populate the title and content of the popup based on each graphic's [PopupTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-PopupTemplate.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#open) + */ features?: Graphic[]; + /** + * Sets pending [promises](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#promises) on the popup. The popup will display once the promises resolve. Each promise must resolve to an array of [Graphics](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#open) + */ promises?: IPromise[]; + /** + * **Since:** 4.5 This property enables multiple features in a popup to display in a list rather than displaying the first selected feature. Setting this to `true` allows the user to scroll through the list of features returned from the query and choose the selection they want to display within the popup. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#open) + * + * @default false + */ featureMenuOpen?: boolean; + /** + * When `true` indicates the popup should update its [location](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#location) for each paginated feature based on the [selected feature's](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#selectedFeature) geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#open) + * + * @default false + */ updateLocationEnabled?: boolean; + /** + * **Since:** 4.5 When `true`, indicates that only the popup header will display. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html#open) + * + * @default false + */ collapsed?: boolean; } interface Print extends Widget { + /** + * The URL of the REST endpoint of the Export Web Map Task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html#printServiceUrl) + */ printServiceUrl: string; + /** + * Defines the layout template options used by the [Print](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html) widget to generate the print page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html#templateOptions) + */ + templateOptions: TemplateOptions; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html#view) + */ view: MapView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [PrintViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-PrintViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html#viewModel) + */ viewModel: PrintViewModel; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html#render) + * + * + */ render(): any; } interface PrintConstructor { + /** + * The Print widget connects your application with a [printing service](https://server.arcgis.com/en/portal/latest/administer/windows/configure-the-portal-to-print-maps.htm) to allow the map to be printed. It takes advantage of server-side, high-quality, full cartographic print functionality using the ExportWebMap service of ArcGIS, which can be configured with custom layout templates. One is provided that shows the map only, while another provides a layout with legend, etc. The Print widget works with the [PrintTask](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-PrintTask.html) which generates a printer-ready version of the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html) + */ + new(properties?: PrintProperties): Print; } export const Print: PrintConstructor; interface PrintProperties extends WidgetProperties { + /** + * The URL of the REST endpoint of the Export Web Map Task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html#printServiceUrl) + */ printServiceUrl?: string; + /** + * Defines the layout template options used by the [Print](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html) widget to generate the print page. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html#templateOptions) + */ + templateOptions?: TemplateOptionsProperties; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html#view) + */ view?: MapViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [PrintViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-PrintViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print.html#viewModel) + */ viewModel?: PrintViewModelProperties; } interface PrintViewModel extends Accessor { + /** + * The URL of the REST endpoint of the Export Web Map Task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-PrintViewModel.html#printServiceUrl) + */ printServiceUrl: string; + /** + * The time interval in milliseconds between each job status request sent to an asynchronous GP task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-PrintViewModel.html#updateDelay) + * + * @default 1000 + */ updateDelay: number; + /** + * The view from which the widget will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-PrintViewModel.html#view) + */ view: MapView; + /** + * Prints (exports) the current MapView according to selected options. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-PrintViewModel.html#print) + * + * @param printTemplate The [PrintTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-PrintTemplate.html) is used to specify the layout template options which is then used by the PrintTask to generate the print page. + * + */ print(printTemplate: PrintTemplate): IPromise; } interface PrintViewModelConstructor { + + new(properties?: PrintViewModelProperties): PrintViewModel; } export const PrintViewModel: PrintViewModelConstructor; interface PrintViewModelProperties { + /** + * The URL of the REST endpoint of the Export Web Map Task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-PrintViewModel.html#printServiceUrl) + */ printServiceUrl?: string; + /** + * The time interval in milliseconds between each job status request sent to an asynchronous GP task. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-PrintViewModel.html#updateDelay) + * + * @default 1000 + */ updateDelay?: number; + /** + * The view from which the widget will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-PrintViewModel.html#view) + */ view?: MapViewProperties; } + interface TemplateOptions extends Accessor { + /** + * When `false`, the attribution is not displayed on the printout. This only applies when the [layout](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#layout) value is `map-only`. Reference our policies on [Licensing & Attribution](https://developers.arcgis.com/javascript/latest/guide/licensing/) for specific attribution requirements. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#attributionEnabled) + * + * @default true + */ + attributionEnabled: boolean; + /** + * The text used for the author if the specified layout contains an author text element. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#author) + */ + author: string; + /** + * The text used for the copyright if the specified layout contains an copyright text element. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#copyright) + */ + copyright: string; + /** + * The output format for the printed map. **Known Values:** pdf | png32 | png8 | jpg | gif | eps | svg | svgz + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#format) + */ + format: string; + /** + * Map height. This only applies when the [layout](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#layout) value is `map-only`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#height) + */ + height: number; + /** + * The layout used for the print output. When the value is `map-only` or is empty, the output map does not contain any page layout surroundings (for example, title, legend, scale bar and so forth). The print service provides out-of-the-box templates listed in possible values. The server administrator can add additional templates to the print service. Possible values are listed below: + * + * Value | Description + * | --- | --- + * map-only | Map does not contain any layout elements. Only map image is printed. + * a3-landscape | 16.54 x 11.69 in + * a3-portrait | 11.69 x 16.54 in + * a4-landscape | 11.69 x 8.27 in + * a4-portrait | 8.27 × 11.69 in + * letter-ansi-a-landscape | 11.0 x 8.5 in + * letter-ansi-a-portrait | 8.5 x 11.0 in + * tabloid-ansi-b-landscape| 17.0 x 11.0 in + * tabloid-ansi-b-portrait | 11.0 x 17.0 in + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#layout) + */ + layout: string; + /** + * When `false`, the legend is not displayed on the printout. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#legendEnabled) + * + * @default true + */ + legendEnabled: boolean; + /** + * When `true`, scale is used in the printed map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#scaleEnabled) + * + * @default false + */ + scaleEnabled: boolean; + /** + * The text used for the map title if the specified layout contains a title text element. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#title) + */ + title: string; + /** + * Map width. This only applies when the [layout](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#layout) value is `map-only`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#width) + */ + width: number; + } + + interface TemplateOptionsConstructor { + + + new(properties?: TemplateOptionsProperties): TemplateOptions; + } + + export const TemplateOptions: TemplateOptionsConstructor; + + interface TemplateOptionsProperties { + /** + * When `false`, the attribution is not displayed on the printout. This only applies when the [layout](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#layout) value is `map-only`. Reference our policies on [Licensing & Attribution](https://developers.arcgis.com/javascript/latest/guide/licensing/) for specific attribution requirements. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#attributionEnabled) + * + * @default true + */ + attributionEnabled?: boolean; + /** + * The text used for the author if the specified layout contains an author text element. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#author) + */ + author?: string; + /** + * The text used for the copyright if the specified layout contains an copyright text element. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#copyright) + */ + copyright?: string; + /** + * The output format for the printed map. **Known Values:** pdf | png32 | png8 | jpg | gif | eps | svg | svgz + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#format) + */ + format?: string; + /** + * Map height. This only applies when the [layout](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#layout) value is `map-only`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#height) + */ + height?: number; + /** + * The layout used for the print output. When the value is `map-only` or is empty, the output map does not contain any page layout surroundings (for example, title, legend, scale bar and so forth). The print service provides out-of-the-box templates listed in possible values. The server administrator can add additional templates to the print service. Possible values are listed below: + * + * Value | Description + * | --- | --- + * map-only | Map does not contain any layout elements. Only map image is printed. + * a3-landscape | 16.54 x 11.69 in + * a3-portrait | 11.69 x 16.54 in + * a4-landscape | 11.69 x 8.27 in + * a4-portrait | 8.27 × 11.69 in + * letter-ansi-a-landscape | 11.0 x 8.5 in + * letter-ansi-a-portrait | 8.5 x 11.0 in + * tabloid-ansi-b-landscape| 17.0 x 11.0 in + * tabloid-ansi-b-portrait | 11.0 x 17.0 in + * + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#layout) + */ + layout?: string; + /** + * When `false`, the legend is not displayed on the printout. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#legendEnabled) + * + * @default true + */ + legendEnabled?: boolean; + /** + * When `true`, scale is used in the printed map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#scaleEnabled) + * + * @default false + */ + scaleEnabled?: boolean; + /** + * The text used for the map title if the specified layout contains a title text element. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#title) + */ + title?: string; + /** + * Map width. This only applies when the [layout](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#layout) value is `map-only`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Print-TemplateOptions.html#width) + */ + width?: number; + } + interface ScaleBar extends Widget { + /** + * The style for the scale bar. Valid values are `ruler` or `line`. When `unit` is set to `dual`, the style will always be `line`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html#style) + */ style: string; + /** + * Units to use for the scale bar. Valid values are `non-metric`, `metric` or `dual`. When using `dual`, the scale bar displays both metric and non-metric units. Metric values shows either kilometers or meters depending on the scale, and similarly non-metric values shows miles and feet depending on the scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html#unit) + * + * @default non-metric (i.e. miles and feet) + */ unit: string; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html#view) + */ view: MapView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [ScaleBarViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar-ScaleBarViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html#viewModel) + */ viewModel: ScaleBarViewModel; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html#render) + * + * + */ render(): any; } interface ScaleBarConstructor { + /** + * The ScaleBar widget displays a scale bar on the map or in a specified HTML node. The widget respects various coordinate systems and displays units in metric or non-metric values. Metric values shows either kilometers or meters depending on the scale, and likewise non-metric values shows miles and feet depending on the scale. When working with Web Mercator or geographic coordinate systems the scale bar takes into account projection distortion and dynamically adjusts the scale bar. The ScaleBar sample, which uses a map using the Web Mercator projection, shows this behavior. Open the sample and note that as you pan the map south towards the equator the scale bar gets shorter and as you pan north it gets longer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html) + */ + new(properties?: ScaleBarProperties): ScaleBar; } export const ScaleBar: ScaleBarConstructor; interface ScaleBarProperties extends WidgetProperties { + /** + * The style for the scale bar. Valid values are `ruler` or `line`. When `unit` is set to `dual`, the style will always be `line`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html#style) + */ style?: string; + /** + * Units to use for the scale bar. Valid values are `non-metric`, `metric` or `dual`. When using `dual`, the scale bar displays both metric and non-metric units. Metric values shows either kilometers or meters depending on the scale, and similarly non-metric values shows miles and feet depending on the scale. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html#unit) + * + * @default non-metric (i.e. miles and feet) + */ unit?: string; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html#view) + */ view?: MapViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [ScaleBarViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar-ScaleBarViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar.html#viewModel) + */ viewModel?: ScaleBarViewModelProperties; } interface ScaleBarViewModel extends Accessor { + /** + * The view from which the widget will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar-ScaleBarViewModel.html#view) + */ view: MapView; } interface ScaleBarViewModelConstructor { + + new(properties?: ScaleBarViewModelProperties): ScaleBarViewModel; } export const ScaleBarViewModel: ScaleBarViewModelConstructor; interface ScaleBarViewModelProperties { + /** + * The view from which the widget will operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-ScaleBar-ScaleBarViewModel.html#view) + */ view?: MapViewProperties; } interface Search extends Widget { - activeSource: FeatureLayer | Locator; + /** + * The [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#sources) object currently selected. Can be either a [feature layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or a [locator task](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#activeSource) + */ + readonly activeSource: FeatureLayer | Locator; + /** + * The selected source's index. This value is `-1` when all sources are selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#activeSourceIndex) + * + * @default 0 + */ activeSourceIndex: number; + /** + * String value used as a hint for input text when searching on multiple sources. See the image below to view the location and style of this text in the context of the widget. ![search-allPlaceholder](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-allplaceholder.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#allPlaceholder) + * + * @default "Find address or place" + */ allPlaceholder: string; + /** + * Indicates whether to automatically select and zoom to the first geocoded result. If `false`, the [findAddressCandidates](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-find-address-candidates.htm) operation will still geocode the input string, but the top result will not be selected. To work with the geocoded results, you can set up a [search-complete](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#event:search-complete) event handler and get the results through the event object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#autoSelect) + * + * @default true + */ autoSelect: boolean; - defaultSource: LocatorSource | FeatureLayerSource; + /** + * The default source used for the Search widget. These can range from a [Locator Source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) to a [Feature Layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#defaultSource) + */ + readonly defaultSource: LocatorSource | FeatureLayerSource; + /** + * Enables location services within the widget. ![locationEnabled](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-locationEnabled.png) + * > The use of this property is only supported on secure origins. To use it, switch your application to a secure origin, such as HTTPS. Note that localhost is considered "potentially secure" and can be used for easy testing in browsers that supports [Window.isSecureContext](https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext#Browser_compatibility) (currently Chrome and Firefox). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#locationEnabled) + * + * @default true + */ + locationEnabled: boolean; + /** + * The maximum number of results returned by the widget if not specified by the source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#maxResults) + * + * @default 6 + */ maxResults: number; + /** + * The maximum number of suggestions returned by the widget if not specified by the source. If working with the default [ArcGIS Online Geocoding service](https://developers.arcgis.com/rest/geocode/api-reference/overview-world-geocoding-service.htm), the default remains at `5`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#maxSuggestions) + * + * @default 6 + */ maxSuggestions: number; + /** + * The minimum number of characters needed for the search if not specified by the source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#minSuggestCharacters) + * + * @default 1 + */ minSuggestCharacters: number; + /** + * Indicates whether to display the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) on feature click. The graphic can be clicked to display a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html). This is not the same as using [popupOpenOnSelect](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#popupOpenOnSelect) which opens the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) any time a search is performed. It is possible to have `popupOpenOnSelect=false` but `popupEnabled=true` so the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) can be opened by someone but it is not opened by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#popupEnabled) + * + * @default true + */ popupEnabled: boolean; + /** + * Indicates whether to show the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a result is selected. Using `popupOpenOnSelect` opens the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) any time a search is performed. It is possible to have `popupOpenOnSelect=false` but `popupEnabled=true` so the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) can be opened by someone but not opened by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#popupOpenOnSelect) + * + * @default true + */ popupOpenOnSelect: boolean; + /** + * A customized PopupTemplate for the selected feature. Note that specifying a wildcard {*} for the popupTemplate will return all fields in addition to search-specific fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#popupTemplate) + */ popupTemplate: PopupTemplate; - resultGraphic: Graphic; + /** + * The graphic used to highlight the resulting feature or location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#resultGraphic) + */ + readonly resultGraphic: Graphic; + /** + * Indicates if the [resultGraphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#resultGraphic) will display at the location of the selected feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#resultGraphicEnabled) + * + * @default true + */ resultGraphicEnabled: boolean; + /** + * An array of objects, each containing a [SearchResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResult) from the search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#results) + */ results: any[]; + /** + * Indicates whether to display the option to search all sources. When `true`, the "All" option is displayed by default: ![search-searchAllEnabled-true](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-enablesearchingall-true.png) When `false`, no option to search all sources at once is available: ![search-searchAllEnabled-false](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-enablesearchingall-false.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#searchAllEnabled) + * + * @default true + */ searchAllEnabled: boolean; - searching: boolean; + /** + * The value of the search box input text string. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#searchTerm) + */ searchTerm: string; - selectedResult: SearchResult; + /** + * The result selected from a search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#selectedResult) + */ + readonly selectedResult: SearchResult; + /** + * The Search widget may be used to search features in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or geocode locations with a [Locator](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html). The `sources` property defines the sources from which to search for the [view](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#view) specified by the Search widget instance. There are two types of sources: + * * [LocatorSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + * * [FeatureLayerSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + * + * + * Any combination of one or more [Locator](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) and [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) sources may be used together in the same instance of the Search widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#sources) + */ sources: Collection; - suggestions: SuggestResult[]; + /** + * The current state of the widget. **Known Values:** ready | disabled | searching + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#state) + * + * @default ready + */ + readonly state: string; + /** + * An array of results from the [suggest method](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#suggest). This is available if working with a 10.3 geocoding service that has [suggest capability loaded](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) or a 10.3 feature layer that supports pagination, i.e. `supportsPagination = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#suggestions) + */ + readonly suggestions: SuggestResult[]; + /** + * Enable suggestions for the widget. This is only available if working with a 10.3 geocoding service that has [suggest capability loaded](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) or a 10.3 feature layer that supports pagination, i.e. `supportsPagination = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#suggestionsEnabled) + * + * @default true + */ suggestionsEnabled: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#view) + */ view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [SearchViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#viewModel) + */ viewModel: SearchViewModel; + /** + * Unfocuses the widget's text input. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#blur) + * + * + */ blur(): void; + /** + * Clears the current searchTerm, search results, suggest results, graphic, and graphics layer. It also hides any open menus. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#clear) + * + * + */ clear(): void; + /** + * Brings focus to the widget's text input. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#focus) + * + * + */ focus(): void; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#render) + * + * + */ render(): any; + /** + * Depending on the sources specified, search() queries the feature layer(s) and/or performs address matching using any specified [Locator(s)](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html) and returns any applicable results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#search) + * + * @param searchTerm This searchTerm can be a string, geometry, suggest candidate object, or an array of [longitude,latitude] coordinate pairs. If a geometry is supplied, then it will reverse geocode (locator) or findAddressCandidates with geometry instead of text. + * + */ search(searchTerm?: string | Geometry | SuggestResult | number[][]): IPromise; + /** + * Performs a suggest() request on the active Locator. It also uses the current value of the widget or one that is passed in. Suggestions are available if working with a 10.3 geocoding service that has [suggest capability loaded](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) or a 10.3 feature layer that supports pagination, i.e. `supportsPagination = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#suggest) + * + * @param value The string value used to suggest() on an active Locator or feature layer. If nothing is passed in, takes the current value of the widget. + * + */ suggest(value?: string): IPromise; } interface SearchConstructor { + /** + * The Search widget provides a way to perform search operations on [locator service(s)](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html) and/or [map](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html)/[feature](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) service feature layer(s). If using a locator with a geocoding service, the [findAddressCandidates](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-find-address-candidates.htm) operation is used, whereas [queries](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html) are used on feature layers. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html) + */ + new(properties?: SearchProperties): Search; } export const Search: SearchConstructor; interface SearchProperties extends WidgetProperties { - activeSource?: FeatureLayerProperties | LocatorProperties; + /** + * The selected source's index. This value is `-1` when all sources are selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#activeSourceIndex) + * + * @default 0 + */ activeSourceIndex?: number; + /** + * String value used as a hint for input text when searching on multiple sources. See the image below to view the location and style of this text in the context of the widget. ![search-allPlaceholder](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-allplaceholder.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#allPlaceholder) + * + * @default "Find address or place" + */ allPlaceholder?: string; + /** + * Indicates whether to automatically select and zoom to the first geocoded result. If `false`, the [findAddressCandidates](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-find-address-candidates.htm) operation will still geocode the input string, but the top result will not be selected. To work with the geocoded results, you can set up a [search-complete](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#event:search-complete) event handler and get the results through the event object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#autoSelect) + * + * @default true + */ autoSelect?: boolean; - defaultSource?: LocatorSource | FeatureLayerSource; + /** + * Enables location services within the widget. ![locationEnabled](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-locationEnabled.png) + * > The use of this property is only supported on secure origins. To use it, switch your application to a secure origin, such as HTTPS. Note that localhost is considered "potentially secure" and can be used for easy testing in browsers that supports [Window.isSecureContext](https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext#Browser_compatibility) (currently Chrome and Firefox). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#locationEnabled) + * + * @default true + */ + locationEnabled?: boolean; + /** + * The maximum number of results returned by the widget if not specified by the source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#maxResults) + * + * @default 6 + */ maxResults?: number; + /** + * The maximum number of suggestions returned by the widget if not specified by the source. If working with the default [ArcGIS Online Geocoding service](https://developers.arcgis.com/rest/geocode/api-reference/overview-world-geocoding-service.htm), the default remains at `5`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#maxSuggestions) + * + * @default 6 + */ maxSuggestions?: number; + /** + * The minimum number of characters needed for the search if not specified by the source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#minSuggestCharacters) + * + * @default 1 + */ minSuggestCharacters?: number; + /** + * Indicates whether to display the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) on feature click. The graphic can be clicked to display a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html). This is not the same as using [popupOpenOnSelect](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#popupOpenOnSelect) which opens the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) any time a search is performed. It is possible to have `popupOpenOnSelect=false` but `popupEnabled=true` so the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) can be opened by someone but it is not opened by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#popupEnabled) + * + * @default true + */ popupEnabled?: boolean; + /** + * Indicates whether to show the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a result is selected. Using `popupOpenOnSelect` opens the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) any time a search is performed. It is possible to have `popupOpenOnSelect=false` but `popupEnabled=true` so the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) can be opened by someone but not opened by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#popupOpenOnSelect) + * + * @default true + */ popupOpenOnSelect?: boolean; + /** + * A customized PopupTemplate for the selected feature. Note that specifying a wildcard {*} for the popupTemplate will return all fields in addition to search-specific fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#popupTemplate) + */ popupTemplate?: PopupTemplateProperties; - resultGraphic?: GraphicProperties; + /** + * Indicates if the [resultGraphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#resultGraphic) will display at the location of the selected feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#resultGraphicEnabled) + * + * @default true + */ resultGraphicEnabled?: boolean; + /** + * An array of objects, each containing a [SearchResult](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResult) from the search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#results) + */ results?: any[]; + /** + * Indicates whether to display the option to search all sources. When `true`, the "All" option is displayed by default: ![search-searchAllEnabled-true](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-enablesearchingall-true.png) When `false`, no option to search all sources at once is available: ![search-searchAllEnabled-false](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-enablesearchingall-false.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#searchAllEnabled) + * + * @default true + */ searchAllEnabled?: boolean; - searching?: boolean; + /** + * The value of the search box input text string. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#searchTerm) + */ searchTerm?: string; - selectedResult?: SearchResult; + /** + * The Search widget may be used to search features in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or geocode locations with a [Locator](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html). The `sources` property defines the sources from which to search for the [view](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#view) specified by the Search widget instance. There are two types of sources: + * * [LocatorSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + * * [FeatureLayerSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + * + * + * Any combination of one or more [Locator](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) and [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) sources may be used together in the same instance of the Search widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#sources) + */ sources?: CollectionProperties; - suggestions?: SuggestResult[]; + /** + * Enable suggestions for the widget. This is only available if working with a 10.3 geocoding service that has [suggest capability loaded](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) or a 10.3 feature layer that supports pagination, i.e. `supportsPagination = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#suggestionsEnabled) + * + * @default true + */ suggestionsEnabled?: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [SearchViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#viewModel) + */ viewModel?: SearchViewModelProperties; } interface SearchViewModel extends Accessor, Evented { - activeSource: FeatureLayer | Locator; + /** + * The [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#sources) object currently selected. Can be either a [feature layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or a [locator task](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#activeSource) + */ + readonly activeSource: FeatureLayer | Locator; + /** + * The selected source's index. This value is `-1` when all sources are selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#activeSourceIndex) + * + * @default 0 + */ activeSourceIndex: number; + /** + * String value used as a hint for input text when searching on multiple sources. See the image below to view the location and style of this text in the context of the widget. ![search-allPlaceholder](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-allplaceholder.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#allPlaceholder) + * + * @default "Find address or place" + */ allPlaceholder: string; + /** + * Indicates whether to automatically select and zoom to the first geocoded result. If `false`, the [findAddressCandidates](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-find-address-candidates.htm) operation will still geocode the input string, but the top result will not be selected. To work with the geocoded results, you can set up a [search-complete](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#event:search-complete) event handler and get the results through the event object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#autoSelect) + */ autoSelect: boolean; - defaultSource: SearchViewModelFeatureLayerSource | SearchViewModelLocatorSource; + /** + * The default source used for the Search widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#defaultSource) + */ + readonly defaultSource: SearchViewModelFeatureLayerSource | SearchViewModelLocatorSource; + /** + * The maximum character length of the search text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#maxInputLength) + */ maxInputLength: number; + /** + * The maximum number of results returned by the widget if not specified by the source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#maxResults) + */ maxResults: number; + /** + * The maximum number of suggestions returned by the widget if not specified by the source. If working with the default [ArcGIS Online Geocoding service](https://developers.arcgis.com/rest/geocode/api-reference/overview-world-geocoding-service.htm), the default remains at `5`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#maxSuggestions) + */ maxSuggestions: number; + /** + * The minimum number of characters needed for the search if not specified by the source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#minSuggestCharacters) + */ minSuggestCharacters: number; - placeholder: string; + /** + * The placeholder used by the [activeSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#activeSource). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#placeholder) + */ + readonly placeholder: string; + /** + * Indicates whether to display the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) on feature click. The graphic can be clicked to display a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html). This is not the same as using [popupOpenOnSelect](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#popupOpenOnSelect) which opens the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) any time a search is performed. It is possible to have `popupOpenOnSelect=false` but `popupEnabled=true` so the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) can be opened by someone but it is not opened by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#popupEnabled) + */ popupEnabled: boolean; + /** + * Indicates whether to show the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a result is selected. Using `popupOpenOnSelect` opens the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) any time a search is performed. It is possible to have `popupOpenOnSelect=false` but `popupEnabled=true` so the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) can be opened by someone but not opened by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#popupOpenOnSelect) + */ popupOpenOnSelect: boolean; + /** + * A customized PopupTemplate for the selected feature. Note that specifying a wildcard {*} for the popupTemplate will return all fields in addition to search-specific fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#popupTemplate) + */ popupTemplate: PopupTemplate; - resultGraphic: Graphic; + /** + * The graphic used to highlight the resulting feature or location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#resultGraphic) + */ + readonly resultGraphic: Graphic; + /** + * Indicates if the [resultGraphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#resultGraphic) will display at the location of the selected feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#resultGraphicEnabled) + * + * @default true + */ resultGraphicEnabled: boolean; + /** + * An array of current results from the search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#results) + */ results: any[]; + /** + * Indicates whether to display the option to search all sources. When `true`, the "All" option is displayed by default: ![search-searchAllEnabled-true](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-enablesearchingall-true.png) When `false`, no option to search all sources at once is available: ![search-searchAllEnabled-true-false](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-enablesearchingall-false.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#searchAllEnabled) + */ searchAllEnabled: boolean; + /** + * The value of the search box input text string. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#searchTerm) + */ searchTerm: string; - selectedResult: any; + /** + * The result selected from a search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#selectedResult) + */ + readonly selectedResult: any; + /** + * The Search widget may be used to search features in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or geocode locations with a [Locator](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html). The `sources` property defines the sources from which to search for the [view](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#view) specified by the Search widget instance. There are two types of sources: + * * [LocatorSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + * * [FeatureLayerSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + * + * + * Any combination of one or more [Locator](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) and [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) sources may be used together in the same instance of the Search widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#sources) + */ sources: Collection; + /** + * The millisecond delay after keyup and before making a [suggest](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#suggest) network request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#suggestionDelay) + */ suggestionDelay: number; - suggestions: SearchViewModelSuggestResult[]; + /** + * An array of results from the [suggest method](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#suggest). This is available if working with a 10.3 geocoding service that has [suggest capability loaded](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) or a 10.3 feature layer that supports pagination, i.e. `supportsPagination = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#suggestions) + */ + readonly suggestions: SearchViewModelSuggestResult[]; + /** + * Enable suggestions for the widget. This is only available if working with a 10.3 geocoding service that has [suggest capability loaded] (https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) or a 10.3 feature layer that supports pagination, i.e. `supportsPagination = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#suggestionsEnabled) + */ suggestionsEnabled: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#view) + */ view: MapView | SceneView; + /** + * Clears the current value, search results, suggest results, graphic, and graphics layer. It also hides any open menus. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#clear) + * + * + */ clear(): void; + /** + * Depending on the sources specified, `search()` queries the feature layer(s) and/or performs address matching using any specified [Locator(s)](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html) and returns the applicable results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#search) + * + * @param searchTerm This searchTerm can be a string, geometry, suggest candidate object, or an array of [latitude,longitude]. If a geometry is supplied, then it will reverse geocode (locator) or findAddressCandidates with geometry instead of text (featurelayer). + * + */ search(searchTerm?: string | Geometry | SearchViewModelSuggestResult | number[][]): IPromise; + /** + * Performs a suggest() request on the active Locator. It also uses the current value of the widget or one that is passed in. Suggestions are available if working with a 10.3 geocoding service that has [suggest capability loaded](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) or a 10.3 feature layer that supports pagination, i.e.`supportsPagination = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#suggest) + * + * @param value The string value used to suggest() on an active Locator or feature layer. If nothing is passed in, takes the current value of the widget. + * + */ suggest(value?: string): IPromise; + on(name: "search-clear", eventHandler: SearchViewModelSearchClearEventHandler): IHandle; + on(name: "search-clear", modifiers: string[], eventHandler: SearchViewModelSearchClearEventHandler): IHandle; + on(name: "search-start", eventHandler: SearchViewModelSearchStartEventHandler): IHandle; + on(name: "search-start", modifiers: string[], eventHandler: SearchViewModelSearchStartEventHandler): IHandle; + on(name: "suggest-start", eventHandler: SearchViewModelSuggestStartEventHandler): IHandle; + on(name: "suggest-start", modifiers: string[], eventHandler: SearchViewModelSuggestStartEventHandler): IHandle; - on(name: "load", eventHandler: SearchViewModelLoadEventHandler): IHandle; - on(name: "load", modifiers: string[], eventHandler: SearchViewModelLoadEventHandler): IHandle; + on(name: "search-complete", eventHandler: SearchViewModelSearchCompleteEventHandler): IHandle; + on(name: "search-complete", modifiers: string[], eventHandler: SearchViewModelSearchCompleteEventHandler): IHandle; + on(name: "select-result", eventHandler: SearchViewModelSelectResultEventHandler): IHandle; + on(name: "select-result", modifiers: string[], eventHandler: SearchViewModelSelectResultEventHandler): IHandle; + on(name: "suggest-complete", eventHandler: SearchViewModelSuggestCompleteEventHandler): IHandle; + on(name: "suggest-complete", modifiers: string[], eventHandler: SearchViewModelSuggestCompleteEventHandler): IHandle; } interface SearchViewModelConstructor { + + new(properties?: SearchViewModelProperties): SearchViewModel; } export const SearchViewModel: SearchViewModelConstructor; interface SearchViewModelProperties { - activeSource?: FeatureLayerProperties | LocatorProperties; + /** + * The selected source's index. This value is `-1` when all sources are selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#activeSourceIndex) + * + * @default 0 + */ activeSourceIndex?: number; + /** + * String value used as a hint for input text when searching on multiple sources. See the image below to view the location and style of this text in the context of the widget. ![search-allPlaceholder](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-allplaceholder.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#allPlaceholder) + * + * @default "Find address or place" + */ allPlaceholder?: string; + /** + * Indicates whether to automatically select and zoom to the first geocoded result. If `false`, the [findAddressCandidates](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-find-address-candidates.htm) operation will still geocode the input string, but the top result will not be selected. To work with the geocoded results, you can set up a [search-complete](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#event:search-complete) event handler and get the results through the event object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#autoSelect) + */ autoSelect?: boolean; - defaultSource?: SearchViewModelFeatureLayerSource | SearchViewModelLocatorSource; + /** + * The maximum character length of the search text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#maxInputLength) + */ maxInputLength?: number; + /** + * The maximum number of results returned by the widget if not specified by the source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#maxResults) + */ maxResults?: number; + /** + * The maximum number of suggestions returned by the widget if not specified by the source. If working with the default [ArcGIS Online Geocoding service](https://developers.arcgis.com/rest/geocode/api-reference/overview-world-geocoding-service.htm), the default remains at `5`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#maxSuggestions) + */ maxSuggestions?: number; + /** + * The minimum number of characters needed for the search if not specified by the source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#minSuggestCharacters) + */ minSuggestCharacters?: number; - placeholder?: string; + /** + * Indicates whether to display the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) on feature click. The graphic can be clicked to display a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html). This is not the same as using [popupOpenOnSelect](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#popupOpenOnSelect) which opens the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) any time a search is performed. It is possible to have `popupOpenOnSelect=false` but `popupEnabled=true` so the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) can be opened by someone but it is not opened by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#popupEnabled) + */ popupEnabled?: boolean; + /** + * Indicates whether to show the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a result is selected. Using `popupOpenOnSelect` opens the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) any time a search is performed. It is possible to have `popupOpenOnSelect=false` but `popupEnabled=true` so the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) can be opened by someone but not opened by default. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#popupOpenOnSelect) + */ popupOpenOnSelect?: boolean; + /** + * A customized PopupTemplate for the selected feature. Note that specifying a wildcard {*} for the popupTemplate will return all fields in addition to search-specific fields. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#popupTemplate) + */ popupTemplate?: PopupTemplateProperties; - resultGraphic?: GraphicProperties; + /** + * Indicates if the [resultGraphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#resultGraphic) will display at the location of the selected feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#resultGraphicEnabled) + * + * @default true + */ resultGraphicEnabled?: boolean; + /** + * An array of current results from the search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#results) + */ results?: any[]; + /** + * Indicates whether to display the option to search all sources. When `true`, the "All" option is displayed by default: ![search-searchAllEnabled-true](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-enablesearchingall-true.png) When `false`, no option to search all sources at once is available: ![search-searchAllEnabled-true-false](https://developers.arcgis.com/javascript/latest/assets/img/apiref/widgets/search-enablesearchingall-false.png) + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#searchAllEnabled) + */ searchAllEnabled?: boolean; + /** + * The value of the search box input text string. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#searchTerm) + */ searchTerm?: string; - selectedResult?: any; + /** + * The Search widget may be used to search features in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or geocode locations with a [Locator](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html). The `sources` property defines the sources from which to search for the [view](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#view) specified by the Search widget instance. There are two types of sources: + * * [LocatorSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + * * [FeatureLayerSource](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + * + * + * Any combination of one or more [Locator](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) and [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) sources may be used together in the same instance of the Search widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#sources) + */ sources?: CollectionProperties; + /** + * The millisecond delay after keyup and before making a [suggest](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#suggest) network request. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#suggestionDelay) + */ suggestionDelay?: number; - suggestions?: SearchViewModelSuggestResult[]; + /** + * Enable suggestions for the widget. This is only available if working with a 10.3 geocoding service that has [suggest capability loaded] (https://developers.arcgis.com/rest/geocode/api-reference/geocoding-suggest.htm) or a 10.3 feature layer that supports pagination, i.e. `supportsPagination = true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#suggestionsEnabled) + */ suggestionsEnabled?: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#view) + */ view?: MapViewProperties | SceneViewProperties; } - export interface SearchViewModelFeatureLayerSource { + /** + * The following properties define a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html)-based [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#sources) whose features may be searched by the Search widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ + export interface SearchViewModelFeatureLayerSource extends Object { + /** + * The Popup instance used for the selected result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ popup: Popup; - autoNavigate: boolean; - exactMatch: boolean; + /** + * Indicates whether to automatically navigate to the selected result once selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ + autoNavigate?: boolean; + /** + * Indicates to only return results that match the search value exactly. This property only applies to `string` field searches. `exactMatch` is always `true` when searching fields of type `number`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ + exactMatch?: boolean; + /** + * The feature layer queried in the search. This is **required**. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ featureLayer: FeatureLayer; + /** + * As of version 4.4, this property replaces the now deprecated `searchQueryParams`, `suggestQueryParams`, and `searchExtent` properties. Please see the object specification table below for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ filter: SearchViewModelFeatureLayerSourceFilter; - maxResults: number; - maxSuggestions: number; - minSuggestCharacters: number; + /** + * Indicates the maximum number of search results to return. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ + maxResults?: number; + /** + * Indicates the maximum number of suggestions to return for the widget's input. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ + maxSuggestions?: number; + /** + * Indicates the minimum number of characters required before querying for a suggestion. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ + minSuggestCharacters?: number; + /** + * The name of the source for display. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ name: string; + /** + * Specifies the fields returned with the search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ outFields: string[]; + /** + * Used as a hint for the source input text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ placeholder: string; + /** + * The results are displayed using this field. Defaults to the layer's `displayField` or the first string field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ displayField: string; - popupEnabled: boolean; - popupOpenOnSelect: boolean; + /** + * Indicates whether to display a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a selected result is clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ + popupEnabled?: boolean; + /** + * Indicates whether to show the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a result is selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ + popupOpenOnSelect?: boolean; + /** + * Specify this to prefix the input for the search text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ prefix: string; - resultGraphicEnabled: boolean; + /** + * Indicates whether to show a graphic on the map for the selected source using the [resultSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#resultSymbol). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ + resultGraphicEnabled?: boolean; + /** + * The symbol used for the [resultGraphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#resultGraphic). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ resultSymbol: Symbol; + /** + * An array of string values representing the names of fields in the feature layer to search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ searchFields: string[]; + /** + * Specify this to suffix the input for the search value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ suffix: string; + /** + * Indicates whether to display suggestions as the user enters input text in the widget. The default value is `true`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ suggestionsEnabled: boolean; + /** + * A template string used to display multiple fields in a defined order when suggestions are displayed. This takes precedence over `displayField`. Field names in the template must have the following format: `{FieldName}`. An example suggestionTemplate could look something like: `Name: {OWNER}, Parcel: {PARCEL_ID}`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ suggestionTemplate: string; + /** + * Indicates whether to constrain the search results to the view's extent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ withinViewEnabled: boolean; + /** + * Applicable to the specified source. If the result does not have an associated extent, specify this number to use as the zoom scale for the result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ zoomScale: number; } - export interface SearchViewModelLoadEvent { - } - - export interface SearchViewModelLocatorSource { + /** + * The following properties define a [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#sources) pointing to a [Locator](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html) that may be used to geocode locations with the Search widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ + export interface SearchViewModelLocatorSource extends Object { + /** + * Used as a hint for the source input text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ placeholder: string; - autoNavigate: boolean; + /** + * Indicates whether to automatically navigate to the selected result once selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ + autoNavigate?: boolean; + /** + * Constricts search results to a specified country code. For example, `US` for United States or `SE` for Sweden. Only applies to the World Geocode Service. View the [World Geocoding Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ countryCode: string; + /** + * As of version 4.4, this property replaces the now deprecated `searchQueryParams`, `suggestQueryParams`, and `searchExtent` properties. Please see the object specification table below for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ filter: SearchViewModelLocatorSourceFilter; + /** + * Sets the sources for local `distance` and `minScale` for searching. See the object specification table below for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ localSearchOptions: SearchViewModelLocatorSourceLocalSearchOptions; - locationToAddressDistance: number; + /** + * When reverse geocoding a result, use this distance in meters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ + locationToAddressDistance?: number; + /** + * The locator task used to search. This is **required** and defaults to the [World Geocoding Service](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ locator: Locator; - maxResults: number; - maxSuggestions: number; - minSuggestCharacters: number; + /** + * Indicates the maximum number of search results to return. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ + maxResults?: number; + /** + * Indicates the maximum number of suggestions to return for the widget's input. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ + maxSuggestions?: number; + /** + * Indicates the minimum number of characters required before querying for a suggestion. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ + minSuggestCharacters?: number; + /** + * The name of the source for display. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ name: string; + /** + * Specifies the fields returned with the search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ outFields: string[]; + /** + * A string array which limits the results to one or more categories. For example "Populated Place" or "airport". Only applicable when using the World Geocode Service. View the [World Geocoding Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ categories: string[]; + /** + * The Popup instance used for the selected result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ popup: Popup; - popupEnabled: boolean; - popupOpenOnSelect: boolean; + /** + * Indicates whether to display a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a selected result is clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ + popupEnabled?: boolean; + /** + * Indicates whether to show the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a result is selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ + popupOpenOnSelect?: boolean; + /** + * Specify this to prefix the input for the search text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ prefix: string; - resultGraphicEnabled: boolean; + /** + * Indicates whether to show a graphic on the map for the selected source using the [resultSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#resultSymbol). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ + resultGraphicEnabled?: boolean; + /** + * The symbol used for the [resultGraphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#resultGraphic). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ resultSymbol: Symbol; + /** + * A template string used to display multiple fields in a defined order when results are displayed, e.g. `"{Street}, {City}, {ZIP}"`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ searchTemplate: string; + /** + * The field name of the Single Line Address Field in the REST services directory for the locator service. Common values are `SingleLine` and `SingleLineFieldName`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ singleLineFieldName: string; - suggestionsEnabled: boolean; + /** + * Indicates whether to display suggestions as the user enters input text in the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ + suggestionsEnabled?: boolean; + /** + * Specify this to suffix the input for the search value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ suffix: string; + /** + * Indicates whether to constrain the search results to the view's extent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ withinViewEnabled: boolean; + /** + * Applicable to the specified source. If the result does not have an associated extent, specify this number to use as the zoom scale for the result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ zoomScale: number; } @@ -10547,24 +45492,79 @@ declare namespace __esri { } export interface SearchViewModelSearchCompleteEvent { + activeSourceIndex: number; + errors: Error[]; + numResults: number; + results: SearchViewModelSearchCompleteEventResults[]; + searchTerm: string; } - export interface SearchViewModelSearchResponse { + /** + * When resolved, returns this response after calling [search](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#search). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResponse) + */ + export interface SearchViewModelSearchResponse extends Object { + /** + * The index of the source from which the search result was obtained. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResponse) + */ activeSourceIndex: number; + /** + * An array of error objects returned from the search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResponse) + */ errors: Error[]; + /** + * The number of search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResponse) + */ numResults: number; + /** + * The searched expression + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResponse) + */ searchTerm: string; + /** + * An array of objects representing the results of search. See object specification table below for more information about the result object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResponse) + */ results: SearchViewModelSearchResponseResults[]; } - export interface SearchViewModelSearchResult { + /** + * The result object returned from the [search](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#search). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResult) + */ + export interface SearchViewModelSearchResult extends Object { + /** + * The extent, or bounding box, of the returned feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResult) + */ extent: Extent; + /** + * The resulting feature or location obtained from the search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResult) + */ feature: Graphic; + /** + * The name of the result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResult) + */ name: string; } @@ -10572,478 +45572,1959 @@ declare namespace __esri { } export interface SearchViewModelSelectResultEvent { + result: SearchViewModelSelectResultEventResult; + source: any; + sourceIndex: number; } export interface SearchViewModelSuggestCompleteEvent { + activeSourceIndex: number; + errors: Error[]; + numResults: number; + results: SearchViewModelSuggestCompleteEventResults[]; + searchTerm: string; } - export interface SearchViewModelSuggestResponse { + /** + * When resolved, returns this reponse after calling [suggest](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#suggest). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResponse) + */ + export interface SearchViewModelSuggestResponse extends Object { + /** + * The index of the source from which suggestions are obtained. This value is `-1` when all sources are selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResponse) + */ activeSourceIndex: number; + /** + * An array of error objects returned from the suggest results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResponse) + */ errors: Error[]; + /** + * The number of suggest results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResponse) + */ numResults: number; + /** + * The search expression used for the suggest. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResponse) + */ searchTerm: string; + /** + * An array of objects representing the results of suggest. See object specification table below for more information about the result object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResponse) + */ results: SearchViewModelSuggestResponseResults[]; } - export interface SearchViewModelSuggestResult { + /** + * The result object returned from a [suggest](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#suggest). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResult) + */ + export interface SearchViewModelSuggestResult extends Object { + /** + * The key related to the suggest result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResult) + */ key: string; + /** + * The string name of the suggested location to geocode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResult) + */ text: string; + /** + * The index of the currently selected result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResult) + */ sourceIndex: number; } export interface SearchViewModelSuggestStartEvent { } - export interface SearchViewModelFeatureLayerSourceFilter { + + export interface SearchViewModelFeatureLayerSourceFilter extends Object { + /** + * The where clause specified for filtering suggests or search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ where: string; + /** + * The filter geometry for suggests or search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#FeatureLayerSource) + */ geometry: Geometry; } - export interface SearchViewModelLocatorSourceFilter { + + export interface SearchViewModelLocatorSourceFilter extends Object { + /** + * The where clause specified for filtering suggests or search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ where: string; + /** + * The filter geometry for suggests or search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ geometry: Geometry; } - export interface SearchViewModelLocatorSourceLocalSearchOptions { + + export interface SearchViewModelLocatorSourceLocalSearchOptions extends Object { + /** + * The distance to search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ distance: number; + /** + * The minimum scale used to search locally. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#LocatorSource) + */ minScale: number; } - export interface SearchViewModelSearchCompleteEventResults { + + export interface SearchViewModelSearchCompleteEventResults extends Object { + results: SearchResult[]; + sourceIndex: number; + source: any[]; } - export interface SearchViewModelSearchResponseResults { + + export interface SearchViewModelSearchResponseResults extends Object { + /** + * An array of search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResponse) + */ results: SearchViewModelSearchResult[]; + /** + * The index of the currently selected source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResponse) + */ sourceIndex: number; + /** + * The [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#sources) of the selected result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SearchResponse) + */ source: any; } - export interface SearchViewModelSelectResultEventResult { + + export interface SearchViewModelSelectResultEventResult extends Object { + extent: Extent; + feature: Graphic; + name: string; } - export interface SearchViewModelSuggestCompleteEventResults { + + export interface SearchViewModelSuggestCompleteEventResults extends Object { + results: SearchViewModelSuggestResult[]; + sourceIndex: number; + source: any; } - export interface SearchViewModelSuggestResponseResults { + + export interface SearchViewModelSuggestResponseResults extends Object { + /** + * An array of suggest results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResponse) + */ results: SearchViewModelSuggestResult[]; + /** + * The index of the currently selected source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResponse) + */ sourceIndex: number; + /** + * The [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#sources) of the selected result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search-SearchViewModel.html#SuggestResponse) + */ source: any; } - export interface FeatureLayerSource { + /** + * The following properties define a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html)-based [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#sources) whose features may be searched by the Search widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ + export interface FeatureLayerSource extends Object { + /** + * The Popup instance used for the selected result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ popup: Popup; - autoNavigate: boolean; - exactMatch: boolean; + /** + * Indicates whether to automatically navigate to the selected result once selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ + autoNavigate?: boolean; + /** + * Indicates to only return results that match the search value exactly. This property only applies to `string` field searches. `exactMatch` is always `true` when searching fields of type `number`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ + exactMatch?: boolean; + /** + * The feature layer queried in the search. This is **required**. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ featureLayer: FeatureLayer; + /** + * As of version 4.4, this property replaces the now deprecated `searchQueryParams`, `suggestQueryParams`, and `searchExtent` properties. Please see the object specification table below for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ filter: FeatureLayerSourceFilter; - maxResults: number; - maxSuggestions: number; - minSuggestCharacters: number; + /** + * Indicates the maximum number of search results to return. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ + maxResults?: number; + /** + * Indicates the maximum number of suggestions to return for the widget's input. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ + maxSuggestions?: number; + /** + * Indicates the minimum number of characters required before querying for a suggestion. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ + minSuggestCharacters?: number; + /** + * The name of the source for display. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ name: string; + /** + * Specifies the fields returned with the search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ outFields: string[]; + /** + * Used as a hint for the source input text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ placeholder: string; + /** + * The results are displayed using this field. Defaults to the layer's `displayField` or the first string field. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ displayField: string; - popupEnabled: boolean; - popupOpenOnSelect: boolean; + /** + * Indicates whether to display a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a selected result is clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ + popupEnabled?: boolean; + /** + * Indicates whether to show the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a result is selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ + popupOpenOnSelect?: boolean; + /** + * Specify this to prefix the input for the search text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ prefix: string; - resultGraphicEnabled: boolean; + /** + * Indicates whether to show a graphic on the map for the selected source using the [resultSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#resultSymbol). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ + resultGraphicEnabled?: boolean; + /** + * The symbol used for the [resultGraphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#resultGraphic). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ resultSymbol: Symbol; + /** + * An array of string values representing the names of fields in the feature layer to search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ searchFields: string[]; + /** + * Specify this to suffix the input for the search value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ suffix: string; - suggestionsEnabled: boolean; + /** + * Indicates whether to display suggestions as the user enters input text in the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ + suggestionsEnabled?: boolean; + /** + * A template string used to display multiple fields in a defined order when suggestions are displayed. This takes precedence over `displayField`. Field names in the template must have the following format: `{FieldName}`. An example suggestionTemplate could look something like: `Name: {OWNER}, Parcel: {PARCEL_ID}`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ suggestionTemplate: string; + /** + * Indicates whether to constrain the search results to the view's extent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ withinViewEnabled: boolean; + /** + * The set zoom scale for the resulting search result. This scale is automatically honored. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ zoomScale: number; } - export interface LocatorSource { + /** + * The following properties define a [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#sources) pointing to a [Locator](https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html) that may be used to geocode locations with the Search widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + export interface LocatorSource extends Object { + /** + * Used as a hint for the source input text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ placeholder: string; - autoNavigate: boolean; + /** + * Indicates whether to automatically navigate to the selected result once selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + autoNavigate?: boolean; + /** + * Constricts search results to a specified country code. For example, `US` for United States or `SE` for Sweden. Only applies to the World Geocode Service. View the [World Geocoding Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ countryCode: string; + /** + * As of version 4.4, this property replaces the now deprecated `searchQueryParams`, `suggestQueryParams`, and `searchExtent` properties. Please see the object specification table below for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ filter: LocatorSourceFilter; + /** + * Sets the sources for local `distance` and `minScale` for searching. See the object specification table below for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ localSearchOptions: LocatorSourceLocalSearchOptions; - locationToAddressDistance: number; + /** + * When reverse geocoding a result, use this distance in meters. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + locationToAddressDistance?: number; + /** + * The locator task used to search. This is **required** and defaults to the [World Geocoding Service](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ locator: Locator; - maxResults: number; - maxSuggestions: number; - minSuggestCharacters: number; + /** + * Indicates the maximum number of search results to return. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + maxResults?: number; + /** + * Indicates the maximum number of suggestions to return for the widget's input. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + maxSuggestions?: number; + /** + * Indicates the minimum number of characters required before querying for a suggestion. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + minSuggestCharacters?: number; + /** + * The name of the source for display. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ name: string; + /** + * Specifies the fields returned with the search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ outFields: string[]; + /** + * A string array which limits the results to one or more categories. For example "Populated Place" or "airport". Only applicable when using the World Geocode Service. View the [World Geocoding Service documentation](https://developers.arcgis.com/rest/geocode/api-reference/geocoding-category-filtering.htm) for more information. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ categories: string[]; + /** + * The Popup instance used for the selected result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ popup: Popup; - popupEnabled: boolean; - popupOpenOnSelect: boolean; + /** + * Indicates whether to display a [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a selected result is clicked. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + popupEnabled?: boolean; + /** + * Indicates whether to show the [Popup](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Popup.html) when a result is selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + popupOpenOnSelect?: boolean; + /** + * Specify this to prefix the input for the search text. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ prefix: string; - resultGraphicEnabled: boolean; - resultSymbol: Symbol; - searchTemplate: string; + /** + * Indicates whether to show a graphic on the map for the selected source using the [resultSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#resultSymbol). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + resultGraphicEnabled?: boolean; + /** + * The symbol used for the [resultGraphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#resultGraphic). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + resultSymbol?: Symbol; + /** + * A template string used to display multiple fields in a defined order when results are displayed, e.g. `"{Street}, {City}, {ZIP}"`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + searchTemplate?: string; + /** + * The field name of the Single Line Address Field in the REST services directory for the locator service. Common values are `SingleLine` and `SingleLineFieldName`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ singleLineFieldName: string; - suggestionsEnabled: boolean; - suffix: string; - withinViewEnabled: boolean; - zoomScale: number; + /** + * Indicates whether to display suggestions as the user enters input text in the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + suggestionsEnabled?: boolean; + /** + * Specify this to suffix the input for the search value. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + suffix?: string; + /** + * Indicates whether to constrain the search results to the view's extent. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + withinViewEnabled?: boolean; + /** + * The set zoom scale for the resulting search result. This scale is automatically honored. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ + zoomScale?: number; } - export interface SearchResponse { + /** + * When resolved, returns this response after calling [search](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#search). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResponse) + */ + export interface SearchResponse extends Object { + /** + * The index of the source from which the search result was obtained. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResponse) + */ activeSourceIndex: number; + /** + * An array of error objects returned from the search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResponse) + */ errors: Error[]; + /** + * The number of search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResponse) + */ numResults: number; + /** + * The searched expression + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResponse) + */ searchTerm: string; + /** + * An array of objects representing the results of search. See object specification table below for more information about the result object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResponse) + */ results: SearchResponseResults[]; } - export interface SearchResult { + /** + * The result object returned from a [search()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#search). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResult) + */ + export interface SearchResult extends Object { + /** + * The extent, or bounding box, of the returned feature. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResult) + */ extent: Extent; + /** + * The resulting feature or location obtained from the search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResult) + */ feature: Graphic; + /** + * The name of the result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResult) + */ name: string; } - export interface SuggestResponse { + /** + * When resolved, returns this response after calling [suggest](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#suggest). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResponse) + */ + export interface SuggestResponse extends Object { + /** + * The index of the source from which suggestions are obtained. This value is `-1` when all sources are selected. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResponse) + */ activeSourceIndex: number; + /** + * An array of error objects returned from the suggest results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResponse) + */ errors: Error[]; + /** + * The number of suggest results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResponse) + */ numResults: number; + /** + * The search expression used for the suggest. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResponse) + */ searchTerm: string; + /** + * An array of objects representing the results of suggest. See object specification table below for more information about the result object. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResponse) + */ results: SuggestResponseResults[]; } - export interface SuggestResult { + /** + * The result object returned from a [suggest()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#suggest). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResult) + */ + export interface SuggestResult extends Object { + /** + * The key related to the suggest result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResult) + */ key: string; + /** + * The string name of the suggested location to geocode. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResult) + */ text: string; + /** + * The index of the currently selected result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResult) + */ sourceIndex: number; } - export interface FeatureLayerSourceFilter { + + export interface FeatureLayerSourceFilter extends Object { + /** + * The where clause specified for filtering suggests or search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ where: string; + /** + * The filter geometry for suggests or search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#FeatureLayerSource) + */ geometry: Geometry; } - export interface LocatorSourceFilter { + + export interface LocatorSourceFilter extends Object { + /** + * The where clause specified for filtering suggests or search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ where: string; + /** + * The filter geometry for suggests or search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ geometry: Geometry; } - export interface LocatorSourceLocalSearchOptions { + + export interface LocatorSourceLocalSearchOptions extends Object { + /** + * The distance to search. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ distance: number; + /** + * The minimum scale used to search locally. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#LocatorSource) + */ minScale: number; } - export interface SearchResponseResults { + + export interface SearchResponseResults extends Object { + /** + * An array of search results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResponse) + */ results: SearchResult[]; + /** + * The index of the currently selected source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResponse) + */ sourceIndex: number; + /** + * The [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#sources) of the selected result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SearchResponse) + */ source: any; } - export interface SuggestResponseResults { + + export interface SuggestResponseResults extends Object { + /** + * An array of suggest results. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResponse) + */ results: SuggestResult[]; + /** + * The index of the currently selected source. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResponse) + */ sourceIndex: number; + /** + * The [source](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#sources) of the selected result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Search.html#SuggestResponse) + */ source: any; } interface SizeSlider extends Accessor, Widgette { + /** + * Indicates whether to show the handles of the slider that may be dragged by the user. See the image in the [class description](#) to see where handles are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#handlesVisible) + * + * @default true + */ handlesVisible: boolean; + /** + * The histogram associated with the data represented on the slider. This may be generated using the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html) statistics function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#histogram) + */ histogram: HistogramResult; + /** + * Indicates whether to show the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#histogram) in the slider UI. See the image in the [class description](#) to see where the histogram is typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#histogramVisible) + * + * @default true + */ histogramVisible: boolean; + /** + * The width of the histogram in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#histogramWidth) + * + * @default 100 + */ histogramWidth: number; + /** + * Indicates whether to show labels in the slider UI. See the image in the [class description](#) to see where labels are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#labelsVisible) + * + * @default true + */ labelsVisible: boolean; - maxSize: number; + /** + * The size in points or pixels with which features will be represented at or above the [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#maxValue). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#maxSize) + */ + readonly maxSize: number; + /** + * The maximum value or upper bound of the slider. This value overrides the `max` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statistics), but may not be smaller than the upper value of the [values](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#values) array. This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#maxValue) + */ maxValue: number; - minSize: number; + /** + * The size in points or pixels with which features will be represented at or below the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#minValue). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#minSize) + */ + readonly minSize: number; + /** + * The minimum value or lower bound of the slider. This value overrides the `min` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statistics), but may not be greater than the lower value of the [values](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#values) array. This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#minValue) + */ minValue: number; + /** + * The summary statistics of the data represented in the slider. This is an object that may be generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) statistics function. The `min` and `max` values in this object determine the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#minValue) and [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#maxValue) of the slider if values for those properties are not already provided. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statistics) + */ statistics: SizeSliderStatistics; + /** + * Indicates whether to show the average value of features in the dataset in the slider UI. See the image in the [class description](#) to see where this symbol is typically placed. Hover over this symbol to view the average in the tooltip. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statisticsVisible) + * + * @default true + */ statisticsVisible: boolean; + /** + * The symbol on the slider representing the features in the view. This symbol type should match the symbol type of the appropriate features. This can be an instance of [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), which is the default value, or [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#symbol) + */ symbol: SimpleMarkerSymbol | SimpleLineSymbol; + /** + * Indicates whether to show tick marks next to the slider handles. See the image in the [class description](#) to see where ticks are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#ticksVisible) + * + * @default true + */ ticksVisible: boolean; - values: number[]; + /** + * Represents the data values corresponding to the handles on the slider. It is an array of numbers indicating the `minDataValue` and the `maxDataValue` of the [visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html#SizeVisualVariable) represented by the slider. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#values) + */ + readonly values: number[]; + /** + * The size visual variable represented by the slider. This must be set initially on the slider for it to render in the view. This may be created manually (see snippet below) or generated from the sizeRendererCreator helper methods. A new size visual variable is created each time the user slides handles or changes the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#minValue) or the [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#maxValue). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#visualVariable) + */ visualVariable: SizeVisualVariable; } interface SizeSliderConstructor { + /** + * The SizeSlider is a widget intended for authoring and exploring data-driven visualizations in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) using the size of marker symbols or 3D object symbol layers. To display properly, this slider requires a [size visual variable](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#visualVariable) and [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statistics) object. Other optional properties may be used including adding a [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#histogram). Most of the various options that affect the UI of the slider are labeled in the image below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html) + */ + new(properties?: SizeSliderProperties): SizeSlider; } export const SizeSlider: SizeSliderConstructor; interface SizeSliderProperties extends WidgetteProperties { + /** + * Indicates whether to show the handles of the slider that may be dragged by the user. See the image in the [class description](#) to see where handles are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#handlesVisible) + * + * @default true + */ handlesVisible?: boolean; + /** + * The histogram associated with the data represented on the slider. This may be generated using the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html) statistics function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#histogram) + */ histogram?: HistogramResult; + /** + * Indicates whether to show the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#histogram) in the slider UI. See the image in the [class description](#) to see where the histogram is typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#histogramVisible) + * + * @default true + */ histogramVisible?: boolean; + /** + * The width of the histogram in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#histogramWidth) + * + * @default 100 + */ histogramWidth?: number; + /** + * Indicates whether to show labels in the slider UI. See the image in the [class description](#) to see where labels are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#labelsVisible) + * + * @default true + */ labelsVisible?: boolean; - maxSize?: number; + /** + * The maximum value or upper bound of the slider. This value overrides the `max` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statistics), but may not be smaller than the upper value of the [values](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#values) array. This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#maxValue) + */ maxValue?: number; - minSize?: number; + /** + * The minimum value or lower bound of the slider. This value overrides the `min` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statistics), but may not be greater than the lower value of the [values](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#values) array. This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#minValue) + */ minValue?: number; + /** + * The summary statistics of the data represented in the slider. This is an object that may be generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) statistics function. The `min` and `max` values in this object determine the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#minValue) and [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#maxValue) of the slider if values for those properties are not already provided. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statistics) + */ statistics?: SizeSliderStatistics; + /** + * Indicates whether to show the average value of features in the dataset in the slider UI. See the image in the [class description](#) to see where this symbol is typically placed. Hover over this symbol to view the average in the tooltip. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statisticsVisible) + * + * @default true + */ statisticsVisible?: boolean; + /** + * The symbol on the slider representing the features in the view. This symbol type should match the symbol type of the appropriate features. This can be an instance of [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleMarkerSymbol.html), which is the default value, or [SimpleLineSymbol](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-SimpleLineSymbol.html). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#symbol) + */ symbol?: SimpleMarkerSymbolProperties | SimpleLineSymbolProperties; + /** + * Indicates whether to show tick marks next to the slider handles. See the image in the [class description](#) to see where ticks are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#ticksVisible) + * + * @default true + */ ticksVisible?: boolean; - values?: number[]; + /** + * The size visual variable represented by the slider. This must be set initially on the slider for it to render in the view. This may be created manually (see snippet below) or generated from the sizeRendererCreator helper methods. A new size visual variable is created each time the user slides handles or changes the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#minValue) or the [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#maxValue). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#visualVariable) + */ visualVariable?: SizeVisualVariable; } - export interface SizeSliderStatistics { + + export interface SizeSliderStatistics extends Object { + /** + * The average of all data values represented in the size visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statistics) + */ avg?: number; + /** + * The maximum of all data values represented in the size visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statistics) + */ max: number; + /** + * The minimum of all data values represented in the size visual variable. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-SizeSlider.html#statistics) + */ min: number; } interface SketchViewModel extends Accessor, Evented { + /** + * Graphic representing the temporary geometry that is being drawn on the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#graphic) + */ graphic: Graphic; + /** + * GraphicsLayer associated with the SketchViewModel. It allows you to organize where temporary graphics are placed when the drawing is completed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#layer) + */ + layer: GraphicsLayer; + /** + * A simple marker symbol used for drawing point geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#pointSymbol) + */ pointSymbol: SimpleMarkerSymbol; + /** + * A simple fill symbol used for drawing polygon geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#polygonSymbol) + */ polygonSymbol: SimpleFillSymbol; + /** + * A simple line symbol used for drawing polyline geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#polylineSymbol) + */ polylineSymbol: SimpleLineSymbol; - state: string; + /** + * The view model's state. **Known Values:** ready | disabled + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The view in which geometries will be sketched by the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#view) + */ view: MapView; + /** + * Completes the active drawing and fires the [draw-complete](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#event:draw-complete) event. If called mid-drawing, `complete()` finishes the active drawing and keeps the valid geometry. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#complete) + * + * + */ + complete(): void; + /** + * Creates an instance of the requested draw action type. **Known Values:** point | multipoint | polyline | polygon + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#create) + * + * @param drawAction Name of the draw action tool. + * + */ create(drawAction: string): void; + /** + * Resets SketchViewModel to prepare for another create operation. Reset discards the current drawing, if called mid drawing. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#reset) + * + * + */ reset(): void; } interface SketchViewModelConstructor { + /** + * SketchViewModel simplifies the process of adding temporary geometries to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html). It saves the effort of writing lots of code for sketching different geometry types. SketchViewModel is intended for basic usage, without advanced features such as preventing self-intersecting lines or overlapping polygons. If more control is required for creating temporary geometries, then use the [Draw](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-2d-draw-Draw.html) class instead. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html) + */ + new(properties?: SketchViewModelProperties): SketchViewModel; } export const SketchViewModel: SketchViewModelConstructor; interface SketchViewModelProperties { + /** + * Graphic representing the temporary geometry that is being drawn on the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#graphic) + */ graphic?: GraphicProperties; + /** + * GraphicsLayer associated with the SketchViewModel. It allows you to organize where temporary graphics are placed when the drawing is completed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#layer) + */ + layer?: GraphicsLayerProperties; + /** + * A simple marker symbol used for drawing point geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#pointSymbol) + */ pointSymbol?: SimpleMarkerSymbolProperties; + /** + * A simple fill symbol used for drawing polygon geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#polygonSymbol) + */ polygonSymbol?: SimpleFillSymbolProperties; + /** + * A simple line symbol used for drawing polyline geometries. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#polylineSymbol) + */ polylineSymbol?: SimpleLineSymbolProperties; - state?: string; + /** + * The view in which geometries will be sketched by the user. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#view) + */ view?: MapViewProperties; } interface GeolocationPositioning { + /** + * The HTML5 Geolocation Position options for locating. Refer to [Geolocation API Specification](http://www.w3.org/TR/geolocation-API/#position-options) for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-GeolocationPositioning.html#geolocationOptions) + * + * @default { maximumAge: 0, timeout: 15000, enableHighAccuracy: true } + */ geolocationOptions: any; + /** + * Indicates whether to navigate the view to the position and scale of the geolocated result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-GeolocationPositioning.html#goToLocationEnabled) + * + * @default true + */ goToLocationEnabled: boolean; + /** + * The graphic used to show the user's location on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-GeolocationPositioning.html#graphic) + */ graphic: Graphic; + /** + * The view associated with the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-GeolocationPositioning.html#view) + */ view: MapView | SceneView; } interface GeolocationPositioningConstructor { + + new(): GeolocationPositioning; } export const GeolocationPositioning: GeolocationPositioningConstructor; interface GeolocationPositioningProperties { + /** + * The HTML5 Geolocation Position options for locating. Refer to [Geolocation API Specification](http://www.w3.org/TR/geolocation-API/#position-options) for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-GeolocationPositioning.html#geolocationOptions) + * + * @default { maximumAge: 0, timeout: 15000, enableHighAccuracy: true } + */ geolocationOptions?: any; + /** + * Indicates whether to navigate the view to the position and scale of the geolocated result. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-GeolocationPositioning.html#goToLocationEnabled) + * + * @default true + */ goToLocationEnabled?: boolean; + /** + * The graphic used to show the user's location on the map. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-GeolocationPositioning.html#graphic) + */ graphic?: GraphicProperties; + /** + * The view associated with the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-GeolocationPositioning.html#view) + */ view?: MapViewProperties | SceneViewProperties; } + interface widget { + /** + * This convenience decorator is used to help simplify accessibility within the widget keyboard events. For example, it can be used to execute a method when the `space` or `enter` keys are pressed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-widget.html#accessibleHandler) + * + * + */ accessibleHandler(): Function; + /** + * Utility method used for joining CSS classes. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-widget.html#join) + * + * @param classNames The class names to join. + * + */ join(...classNames: string[]): string; + /** + * This convenience decorator marks a property for automatic rendering. It is useful when you want rendering to be scheduled whenever the decorated property changes. Many times this decorator is used in conjunction with the [@property](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-accessorSupport-decorators.html) decorator. Rendering on deep properties is also supported by providing a path to a property deeper in the instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-widget.html#renderable) + * + * @param propertyName Names of nested renderable properties. + * + */ renderable(propertyName?: string | string[]): Function; + /** + * This convenience method is used to assign an [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) DOM node reference to a variable. It does this by taking a [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement) passed from either the [afterUpdate](https://developers.arcgis.com/javascript/latest/guide/custom-widget/index.html#widget-rendering) or [afterCreate](https://developers.arcgis.com/javascript/latest/guide/custom-widget/index.html#widget-rendering) callbacks. In order to use this, the element must have a set [data-node-ref](https://developers.arcgis.com/javascript/latest/guide/custom-widget/index.html#widget-rendering) attribute. In addition, it must also be bound to the widget instance, e.g. `bind={this}`. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-widget.html#storeNode) + * + * @param node The referenced DOM node. + * + */ + storeNode(node: HTMLElement): void; + /** + * This convenience method is used to render the JSX in the [widget.render()](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#render) method. It is required to import `tsx` even though it is not explicitly called. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-widget.html#tsx) + * + * @param selector The element to create. + * @param properties The element's properties. + * @param children The element's children. + * + */ tsx(selector: string, properties?: any, children?: any): any; + /** + * This convenience decorator helps dispatch view model events on the widget instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-support-widget.html#vmEvent) + * + * @param eventNames The event names to re-dispatch. + * + */ vmEvent(eventNames: string | string[]): Function; } export const widget: widget; interface Track extends Widget { + /** + * The HTML5 Geolocation Position options for locating. Refer to [Geolocation API Specification](http://www.w3.org/TR/geolocation-API/#position-options) for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#geolocationOptions) + * + * @default { maximumAge: 0, timeout: 15000, enableHighAccuracy: true } + */ geolocationOptions: any; + /** + * Indicates whether the widget will automatically navigate the view to the user's position when a geolocation result is found. Set to `false` to disable this behavior, leaving full control to the developer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#goToLocationEnabled) + * + * @default true + */ goToLocationEnabled: boolean; + /** + * The graphic used to show the user's location in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#graphic) + */ graphic: Graphic; - tracking: boolean; + /** + * Indicates whether the widget is watching for new positions. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#tracking) + * + * @default false + */ + readonly tracking: boolean; + /** + * Indicates whether the widget will automatically [rotate to user's direction](https://www.w3.org/TR/geolocation-API/#coordinates_interface). Set to `false` to disable this behavior. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#useHeadingEnabled) + * + * @default true + */ + useHeadingEnabled: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#view) + */ view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [TrackViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track-TrackViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#viewModel) + */ viewModel: TrackViewModel; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#render) + * + * + */ render(): any; + /** + * When executed, the widget will start [tracking](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#tracking) the user's location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#start) + * + * + */ start(): void; + /** + * Stops tracking the user's location when executed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#stop) + * + * + */ stop(): void; } interface TrackConstructor { + /** + * Provides a simple button that animates the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) to the user's location when clicked. The view rotates according to the direction where the tracked device is heading towards. While tracking, the default button looks like the following: + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html) + */ + new(properties?: TrackProperties): Track; } export const Track: TrackConstructor; interface TrackProperties extends WidgetProperties { + /** + * The HTML5 Geolocation Position options for locating. Refer to [Geolocation API Specification](http://www.w3.org/TR/geolocation-API/#position-options) for details. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#geolocationOptions) + * + * @default { maximumAge: 0, timeout: 15000, enableHighAccuracy: true } + */ geolocationOptions?: any; + /** + * Indicates whether the widget will automatically navigate the view to the user's position when a geolocation result is found. Set to `false` to disable this behavior, leaving full control to the developer. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#goToLocationEnabled) + * + * @default true + */ goToLocationEnabled?: boolean; + /** + * The graphic used to show the user's location in the view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#graphic) + */ graphic?: GraphicProperties; - tracking?: boolean; + /** + * Indicates whether the widget will automatically [rotate to user's direction](https://www.w3.org/TR/geolocation-API/#coordinates_interface). Set to `false` to disable this behavior. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#useHeadingEnabled) + * + * @default true + */ + useHeadingEnabled?: boolean; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [TrackViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track-TrackViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html#viewModel) + */ viewModel?: TrackViewModelProperties; } interface TrackViewModel extends Accessor, Evented, GeolocationPositioning { - state: string; - tracking: boolean; + /** + * The current state of the widget. **Possible Values:** disabled | ready | tracking | waiting + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track-TrackViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * Indicates whether new positions are being watched. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track-TrackViewModel.html#tracking) + * + * @default false + */ + readonly tracking: boolean; + /** + * When executed, [tracking](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track-TrackViewModel.html#tracking) starts at the user's location. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track-TrackViewModel.html#start) + * + * + */ start(): void; + /** + * Stops tracking the user's location when executed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track-TrackViewModel.html#stop) + * + * + */ stop(): void; } interface TrackViewModelConstructor { + /** + * Provides the logic for the [Track](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track.html) widget, which animates the [View](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-View.html) to the user's location when clicked and tracks it as the location is updated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Track-TrackViewModel.html) + */ + new(properties?: TrackViewModelProperties): TrackViewModel; } export const TrackViewModel: TrackViewModelConstructor; interface TrackViewModelProperties extends GeolocationPositioningProperties { - state?: string; - tracking?: boolean; + } interface UnivariateColorSizeSlider extends Accessor, Widgette { + /** + * Indicates whether to show the handles of the slider that may be dragged by the user. See the image in the [class description](#) to see where handles are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#handlesVisible) + * + * @default true + */ handlesVisible: boolean; + /** + * The histogram associated with the data represented on the slider. This may be generated using the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html) statistics function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#histogram) + */ histogram: HistogramResult; + /** + * Indicates whether to show the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#histogram) in the slider UI. See the image in the [class description](#) to see where the histogram is typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#histogramVisible) + * + * @default true + */ histogramVisible: boolean; + /** + * The width of the histogram in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#histogramWidth) + * + * @default 100 + */ histogramWidth: number; + /** + * Indicates whether to show labels in the slider UI. See the image in the [class description](#) to see where labels are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#labelsVisible) + * + * @default true + */ labelsVisible: boolean; - maxSize: number; + /** + * The size in points or pixels with which features will be represented at or above the [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#maxValue). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#maxSize) + */ + readonly maxSize: number; + /** + * The maximum value or upper bound of the slider. This value overrides the `max` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statistics), but may not be smaller than the upper value of the [values](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#values) array. This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#maxValue) + */ maxValue: number; - minSize: number; + /** + * The size in points or pixels with which features will be represented at or below the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#minValue). + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#minSize) + */ + readonly minSize: number; + /** + * The minimum value or lower bound of the slider. This value overrides the `min` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statistics), but may not be greater than the lower value of the [values](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#values) array. This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#minValue) + */ minValue: number; + /** + * The summary statistics of the data represented in the slider. This is an object that may be generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) statistics function. The `min` and `max` values in this object determine the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#minValue) and [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#maxValue) of the slider if values for those properties are not already provided. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statistics) + */ statistics: UnivariateColorSizeSliderStatistics; + /** + * Indicates whether to show the average of the dataset in the slider UI. See the image in the [class description](#) to see where this symbol is typically placed. Hover over this symbol to view the average in the tooltip. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statisticsVisible) + * + * @default true + */ statisticsVisible: boolean; + /** + * Indicates whether to show tick marks next to the slider handles. See the image in the [class description](#) to see where ticks are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#ticksVisible) + * + * @default true + */ ticksVisible: boolean; - values: number[]; + /** + * Represents the data values corresponding to the handles on the slider. It is an array of numbers indicating the `minDataValue` and the `maxDataValue` of the visual variables represented by the slider. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#values) + */ + readonly values: number[]; + /** + * The size and color visual variables represented by the slider. Since this slider represents univariate visualizations, both color and size visual variables must represent data from the same field or expression and be conicident. In other words, the lower stop or bound of the color visual variable must match the lower bound (or `minDataValue`) of the size visual variable. The same is true of the upper bounds of both visual variables. These must be set initially on the slider for it to render in the view. Both visual variables may be created manually (see snippet below) or generated from the [univariateColorSize](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html) helper methods. New coincident color and size visual variables are created each time the user slides the handles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#visualVariables) + */ visualVariables: any[]; } interface UnivariateColorSizeSliderConstructor { + /** + * The UnivariateColorSizeSlider is a widget intended for authoring and exploring data-driven univariate visualizations in a [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html) or [SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html) using color and size. To display properly, this slider requires [color and size visual variables](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#visualVariables) and a [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statistics) object. Other optional properties may be used including adding a [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#histogram). Most of the various options that affect the UI of the slider are labeled in the image below. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html) + */ + new(properties?: UnivariateColorSizeSliderProperties): UnivariateColorSizeSlider; } export const UnivariateColorSizeSlider: UnivariateColorSizeSliderConstructor; interface UnivariateColorSizeSliderProperties extends WidgetteProperties { + /** + * Indicates whether to show the handles of the slider that may be dragged by the user. See the image in the [class description](#) to see where handles are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#handlesVisible) + * + * @default true + */ handlesVisible?: boolean; + /** + * The histogram associated with the data represented on the slider. This may be generated using the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-histogram.html) statistics function. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#histogram) + */ histogram?: HistogramResult; + /** + * Indicates whether to show the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#histogram) in the slider UI. See the image in the [class description](#) to see where the histogram is typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#histogramVisible) + * + * @default true + */ histogramVisible?: boolean; + /** + * The width of the histogram in pixels. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#histogramWidth) + * + * @default 100 + */ histogramWidth?: number; + /** + * Indicates whether to show labels in the slider UI. See the image in the [class description](#) to see where labels are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#labelsVisible) + * + * @default true + */ labelsVisible?: boolean; - maxSize?: number; + /** + * The maximum value or upper bound of the slider. This value overrides the `max` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statistics), but may not be smaller than the upper value of the [values](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#values) array. This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#maxValue) + */ maxValue?: number; - minSize?: number; + /** + * The minimum value or lower bound of the slider. This value overrides the `min` property of the [statistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statistics), but may not be greater than the lower value of the [values](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#values) array. This property may be set programmatically or by the user in the widget's UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#minValue) + */ minValue?: number; + /** + * The summary statistics of the data represented in the slider. This is an object that may be generated from the [summaryStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-statistics-summaryStatistics.html) statistics function. The `min` and `max` values in this object determine the [minValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#minValue) and [maxValue](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#maxValue) of the slider if values for those properties are not already provided. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statistics) + */ statistics?: UnivariateColorSizeSliderStatistics; + /** + * Indicates whether to show the average of the dataset in the slider UI. See the image in the [class description](#) to see where this symbol is typically placed. Hover over this symbol to view the average in the tooltip. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statisticsVisible) + * + * @default true + */ statisticsVisible?: boolean; + /** + * Indicates whether to show tick marks next to the slider handles. See the image in the [class description](#) to see where ticks are typically placed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#ticksVisible) + * + * @default true + */ ticksVisible?: boolean; - values?: number[]; + /** + * The size and color visual variables represented by the slider. Since this slider represents univariate visualizations, both color and size visual variables must represent data from the same field or expression and be conicident. In other words, the lower stop or bound of the color visual variable must match the lower bound (or `minDataValue`) of the size visual variable. The same is true of the upper bounds of both visual variables. These must be set initially on the slider for it to render in the view. Both visual variables may be created manually (see snippet below) or generated from the [univariateColorSize](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-smartMapping-creators-univariateColorSize.html) helper methods. New coincident color and size visual variables are created each time the user slides the handles. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#visualVariables) + */ visualVariables?: any[]; } - export interface UnivariateColorSizeSliderStatistics { + + export interface UnivariateColorSizeSliderStatistics extends Object { + /** + * The average of all data values represented in the size and color visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statistics) + */ avg: number; + /** + * The maximum of all data values represented in the size and color visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statistics) + */ max: number; + /** + * The minimum of all all data values represented in the size and color visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statistics) + */ min: number; + /** + * The standard deviation calculated from all data values represented in the size and color visual variables. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-UnivariateColorSizeSlider.html#statistics) + */ stddev: number; } interface Widget extends Accessor, Evented { + /** + * The ID or node representing the DOM element containing the widget. This property can only be set once. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#container) + */ container: string | HTMLElement; + /** + * When `true`, this property indicates whether the widget has been destroyed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#destroyed) + */ destroyed: boolean; + /** + * The unique ID assigned to the widget when the widget is created. If not set by the developer, it will default to the container ID, or if that is not present then it will be automatically generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#id) + */ id: string; + /** + * Destroys the widget instance. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#destroy) + * + * + */ destroy(): void; + /** + * Widget teardown helper. Any handles added to it will be automatically removed when the widget is destroyed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#own) + * + * @param handles Handles marked for removal once the widget is destroyed. + * + */ own(handles: WatchHandle | WatchHandle[]): void; + /** + * *This method is primarily used by developers when implementing custom widgets.* Executes after widget is ready for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#postInitialize) + * + * + */ postInitialize(): void; + /** + * Renders widget to the DOM immediately. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#renderNow) + * + * + */ renderNow(): void; + /** + * *This method is primarily used by developers when implementing custom widgets.* Schedules widget rendering. This method is useful for changes affecting the UI. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#scheduleRender) + * + * + */ scheduleRender(): void; + /** + * Finalizes the creation of the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#startup) + * + * + */ startup(): void; } interface WidgetConstructor { + /** + * The base class for widgets. Each widget's presentation is separate from its properties, methods, and data. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html) + */ + new(properties?: WidgetProperties): Widget; } export const Widget: WidgetConstructor; interface WidgetProperties { + /** + * The ID or node representing the DOM element containing the widget. This property can only be set once. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#container) + */ container?: string | HTMLElement; + /** + * When `true`, this property indicates whether the widget has been destroyed. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#destroyed) + */ destroyed?: boolean; + /** + * The unique ID assigned to the widget when the widget is created. If not set by the developer, it will default to the container ID, or if that is not present then it will be automatically generated. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widget.html#id) + */ id?: string; } interface Widgette { + /** + * The ID or node representing the DOM element containing the widget. Note that once set, this property cannot be modified afterwards. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widgette.html#container) + */ container: string | HTMLElement; + /** + * Indicates whether the widget is visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widgette.html#visible) + * + * @default true + */ visible: boolean; + /** + * Destroys the widget instance. Call this method when the widget is no longer needed by the application. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widgette.html#destroy) + * + * + */ destroy(): void; + /** + * Registers an event handler on the widget instance. Call this method to hook an event with a listener. See the [Events summary table](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widgette.html#events-summary) for a list of supported events. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widgette.html#on) + * + * @param type The name of the event. + * @param listener The function to call when the event is fired. + * + */ on(type: string, listener: Function): any; } interface WidgetteConstructor { + + new(): Widgette; } export const Widgette: WidgetteConstructor; interface WidgetteProperties { + /** + * The ID or node representing the DOM element containing the widget. Note that once set, this property cannot be modified afterwards. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widgette.html#container) + */ container?: string | HTMLElement; + /** + * Indicates whether the widget is visible. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Widgette.html#visible) + * + * @default true + */ visible?: boolean; } interface Zoom extends Widget { + /** + * Determines the layout/orientation of the Zoom widget. **Known Values:** vertical | horizontal + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom.html#layout) + * + * @default vertical + */ layout: string; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom.html#view) + */ view: MapView | SceneView; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [ZoomViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom-ZoomViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom.html#viewModel) + */ viewModel: ZoomViewModel; + /** + * *This method is primarily used by developers when implementing custom widgets.* It must be implemented by subclasses for rendering. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom.html#render) + * + * + */ render(): any; + /** + * Zooms the view in by an LOD factor of 0.5. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom.html#zoomIn) + * + * + */ zoomIn(): void; + /** + * Zooms the view out by an LOD factor of 2. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom.html#zoomOut) + * + * + */ zoomOut(): void; } interface ZoomConstructor { + /** + * The Zoom widget allows users to zoom in/out within a view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom.html) + */ + new(properties?: ZoomProperties): Zoom; } export const Zoom: ZoomConstructor; interface ZoomProperties extends WidgetProperties { + /** + * Determines the layout/orientation of the Zoom widget. **Known Values:** vertical | horizontal + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom.html#layout) + * + * @default vertical + */ layout?: string; + /** + * A reference to the [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) or [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html). Set this to link the widget to a specific view. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom.html#view) + */ view?: MapViewProperties | SceneViewProperties; + /** + * The view model for this widget. This is a class that contains all the logic (properties and methods) that controls this widget's behavior. See the [ZoomViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom-ZoomViewModel.html) class to access all properties and methods on the widget. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom.html#viewModel) + */ viewModel?: ZoomViewModelProperties; } interface ZoomViewModel extends Accessor { + /** + * Indicates if the view can zoom in. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom-ZoomViewModel.html#canZoomIn) + */ canZoomIn: boolean; + /** + * Indicates if the view can zoom out. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom-ZoomViewModel.html#canZoomOut) + */ canZoomOut: boolean; - state: string; + /** + * The current state of the widget. **Possible Values:** disabled | ready + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom-ZoomViewModel.html#state) + * + * @default disabled + */ + readonly state: string; + /** + * The view from which to operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom-ZoomViewModel.html#view) + */ view: MapView | SceneView; + /** + * Zooms the view in by an LOD factor of 0.5. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom-ZoomViewModel.html#zoomIn) + * + * + */ zoomIn(): void; + /** + * Zooms the view out by an LOD factor of 2. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom-ZoomViewModel.html#zoomOut) + * + * + */ zoomOut(): void; } interface ZoomViewModelConstructor { + + new(properties?: ZoomViewModelProperties): ZoomViewModel; } export const ZoomViewModel: ZoomViewModelConstructor; interface ZoomViewModelProperties { + /** + * Indicates if the view can zoom in. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom-ZoomViewModel.html#canZoomIn) + */ canZoomIn?: boolean; + /** + * Indicates if the view can zoom out. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom-ZoomViewModel.html#canZoomOut) + */ canZoomOut?: boolean; - state?: string; + /** + * The view from which to operate. + * + * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Zoom-ZoomViewModel.html#view) + */ view?: MapViewProperties | SceneViewProperties; } + export type MultipointDrawActionCursorUpdateEventHandler = (event: MultipointDrawActionCursorUpdateEvent) => void; + + export type MultipointDrawActionDrawCompleteEventHandler = (event: MultipointDrawActionDrawCompleteEvent) => void; + + export type MultipointDrawActionVertexAddEventHandler = (event: MultipointDrawActionVertexAddEvent) => void; + + export type MultipointDrawActionVertexRemoveEventHandler = (event: MultipointDrawActionVertexRemoveEvent) => void; + export type OpenStreetMapLayerLayerviewCreateEventHandler = (event: OpenStreetMapLayerLayerviewCreateEvent) => void; export type OpenStreetMapLayerLayerviewDestroyEventHandler = (event: OpenStreetMapLayerLayerviewDestroyEvent) => void; @@ -11072,6 +47553,8 @@ declare namespace __esri { export type PolylineDrawActionVertexRemoveEventHandler = (event: PolylineDrawActionVertexRemoveEvent) => void; + export type PopupViewModelTriggerActionEventHandler = (event: PopupViewModelTriggerActionEvent) => void; + export type SceneLayerLayerviewCreateEventHandler = (event: SceneLayerLayerviewCreateEvent) => void; export type SceneLayerLayerviewDestroyEventHandler = (event: SceneLayerLayerviewDestroyEvent) => void; @@ -11096,14 +47579,16 @@ declare namespace __esri { export type SceneViewPointerDownEventHandler = (event: SceneViewPointerDownEvent) => void; + export type SceneViewPointerEnterEventHandler = (event: SceneViewPointerEnterEvent) => void; + + export type SceneViewPointerLeaveEventHandler = (event: SceneViewPointerLeaveEvent) => void; + export type SceneViewPointerMoveEventHandler = (event: SceneViewPointerMoveEvent) => void; export type SceneViewPointerUpEventHandler = (event: SceneViewPointerUpEvent) => void; export type SceneViewResizeEventHandler = (event: SceneViewResizeEvent) => void; - export type SearchViewModelLoadEventHandler = (event: SearchViewModelLoadEvent) => void; - export type SearchViewModelSearchClearEventHandler = (event: SearchViewModelSearchClearEvent) => void; export type SearchViewModelSearchCompleteEventHandler = (event: SearchViewModelSearchCompleteEvent) => void; @@ -11616,6 +48101,16 @@ declare module "esri/renderers/PointCloudUniqueValueRenderer" { export = PointCloudUniqueValueRenderer; } +declare module "esri/renderers/support/AuthoringInfo" { + import AuthoringInfo = __esri.AuthoringInfo; + export = AuthoringInfo; +} + +declare module "esri/renderers/support/AuthoringInfoVisualVariable" { + import AuthoringInfoVisualVariable = __esri.AuthoringInfoVisualVariable; + export = AuthoringInfoVisualVariable; +} + declare module "esri/support/Action" { import Action = __esri.Action; export = Action; @@ -12096,6 +48591,11 @@ declare module "esri/views/layers/ImageryLayerView" { export = ImageryLayerView; } +declare module "esri/views/layers/KMLLayerView" { + import KMLLayerView = __esri.KMLLayerView; + export = KMLLayerView; +} + declare module "esri/views/layers/SceneLayerView" { import SceneLayerView = __esri.SceneLayerView; export = SceneLayerView; @@ -12136,6 +48636,11 @@ declare module "esri/views/2d/draw/PolygonDrawAction" { export = PolygonDrawAction; } +declare module "esri/views/2d/draw/MultipointDrawAction" { + import MultipointDrawAction = __esri.MultipointDrawAction; + export = MultipointDrawAction; +} + declare module "esri/webmap/InitialViewProperties" { import InitialViewProperties = __esri.InitialViewProperties; export = InitialViewProperties; @@ -12191,11 +48696,26 @@ declare module "esri/widgets/Compass" { export = Compass; } +declare module "esri/widgets/Directions" { + import Directions = __esri.Directions; + export = Directions; +} + +declare module "esri/widgets/DirectLineMeasurement3D" { + import DirectLineMeasurement3D = __esri.DirectLineMeasurement3D; + export = DirectLineMeasurement3D; +} + declare module "esri/widgets/Expand" { import Expand = __esri.Expand; export = Expand; } +declare module "esri/widgets/Fullscreen" { + import Fullscreen = __esri.Fullscreen; + export = Fullscreen; +} + declare module "esri/widgets/Home" { import Home = __esri.Home; export = Home; @@ -12276,6 +48796,16 @@ declare module "esri/widgets/BasemapGallery/BasemapGalleryViewModel" { export = BasemapGalleryViewModel; } +declare module "esri/widgets/BasemapGallery/support/LocalBasemapsSource" { + import LocalBasemapsSource = __esri.LocalBasemapsSource; + export = LocalBasemapsSource; +} + +declare module "esri/widgets/BasemapGallery/support/PortalBasemapsSource" { + import PortalBasemapsSource = __esri.PortalBasemapsSource; + export = PortalBasemapsSource; +} + declare module "esri/widgets/BasemapToggle/BasemapToggleViewModel" { import BasemapToggleViewModel = __esri.BasemapToggleViewModel; export = BasemapToggleViewModel; @@ -12286,11 +48816,21 @@ declare module "esri/widgets/Compass/CompassViewModel" { export = CompassViewModel; } +declare module "esri/widgets/Directions/DirectionsViewModel" { + import DirectionsViewModel = __esri.DirectionsViewModel; + export = DirectionsViewModel; +} + declare module "esri/widgets/Expand/ExpandViewModel" { import ExpandViewModel = __esri.ExpandViewModel; export = ExpandViewModel; } +declare module "esri/widgets/Fullscreen/FullscreenViewModel" { + import FullscreenViewModel = __esri.FullscreenViewModel; + export = FullscreenViewModel; +} + declare module "esri/widgets/Home/HomeViewModel" { import HomeViewModel = __esri.HomeViewModel; export = HomeViewModel; @@ -12321,6 +48861,11 @@ declare module "esri/widgets/Print/PrintViewModel" { export = PrintViewModel; } +declare module "esri/widgets/Print/TemplateOptions" { + import TemplateOptions = __esri.TemplateOptions; + export = TemplateOptions; +} + declare module "esri/widgets/Popup/PopupViewModel" { import PopupViewModel = __esri.PopupViewModel; export = PopupViewModel; @@ -12406,6 +48951,11 @@ declare module "esri/layers/mixins/PortalLayer" { export = PortalLayer; } +declare module "esri/layers/mixins/RefreshableLayer" { + import RefreshableLayer = __esri.RefreshableLayer; + export = RefreshableLayer; +} + declare module "esri/layers/mixins/ScaleRangeLayer" { import ScaleRangeLayer = __esri.ScaleRangeLayer; export = ScaleRangeLayer; @@ -12491,16 +49041,16 @@ declare module "esri/core/watchUtils" { export = watchUtils; } -declare module "esri/core/accessorSupport/decorators" { - import decorators = __esri.decorators; - export = decorators; -} - declare module "esri/core/workers" { import workers = __esri.workers; export = workers; } +declare module "esri/core/accessorSupport/decorators" { + import decorators = __esri.decorators; + export = decorators; +} + declare module "esri/geometry/geometryEngine" { import geometryEngine = __esri.geometryEngine; export = geometryEngine; @@ -12536,6 +49086,11 @@ declare module "esri/renderers/smartMapping/creators/location" { export = location; } +declare module "esri/renderers/smartMapping/creators/opacity" { + import opacity = __esri.opacity; + export = opacity; +} + declare module "esri/renderers/smartMapping/creators/size" { import size = __esri.size; export = size; @@ -12601,6 +49156,11 @@ declare module "esri/symbols/support/jsonUtils" { export = symbolsSupportJsonUtils; } +declare module "esri/symbols/support/symbolPreview" { + import symbolPreview = __esri.symbolPreview; + export = symbolPreview; +} + declare module "esri/views/3d/externalRenderers" { import externalRenderers = __esri.externalRenderers; export = externalRenderers; @@ -12611,17 +49171,20 @@ declare module "esri/widgets/support/widget" { export = widget; } -declare module "esri/widgets/BasemapGallery/BasemapGalleryItem" { +declare module "esri/widgets/BasemapGallery/support/BasemapGalleryItem" { import BasemapGalleryItem = __esri.BasemapGalleryItem; export = BasemapGalleryItem; } -declare module "esri/widgets/BasemapGallery/support/LocalBasemapsSource" { - import LocalBasemapsSource = __esri.LocalBasemapsSource; - export = LocalBasemapsSource; -} -declare module "esri/widgets/BasemapGallery/support/PortalBasemapsSource" { - import PortalBasemapsSource = __esri.PortalBasemapsSource; - export = PortalBasemapsSource; -} \ No newline at end of file +declare module "esri/geometry" { + export import Extent = __esri.Extent; + export import Multipoint = __esri.Multipoint; + export import Point = __esri.Point; + export import Polygon = __esri.Polygon; + export import Polyline = __esri.Polyline; + export import SpatialReference = __esri.SpatialReference; + export import ScreenPoint = __esri.ScreenPoint; + + export type Geometry = Extent | Multipoint | Point | Polygon | Polyline; +} From 9d988b0f457249091e84e12fcd5a5f8e1d8815dd Mon Sep 17 00:00:00 2001 From: Robert Kuykendall Date: Thu, 14 Dec 2017 15:23:28 -0500 Subject: [PATCH 167/298] [react-bootstrap] Update FormGroup validationState As shown in spec: https://react-bootstrap.github.io/components.html#forms-props-form-group and source: https://github.com/react-bootstrap/react-bootstrap/blob/0e93f934e426685c6570ac63aacd8fae6cacafda/src/FormGroup.js#L16 --- types/react-bootstrap/lib/FormGroup.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-bootstrap/lib/FormGroup.d.ts b/types/react-bootstrap/lib/FormGroup.d.ts index aef2d19f1d..6b7207c215 100644 --- a/types/react-bootstrap/lib/FormGroup.d.ts +++ b/types/react-bootstrap/lib/FormGroup.d.ts @@ -6,7 +6,7 @@ declare namespace FormGroup { bsClass?: string; bsSize?: Sizes; controlId?: string; - validationState?: "success" | "warning" | "error"; + validationState?: "success" | "warning" | "error" | null; } } declare class FormGroup extends React.Component { } From 03764c9c394dc55efc1cb463cd9aa0a71717cb8f Mon Sep 17 00:00:00 2001 From: DanStach Date: Thu, 14 Dec 2017 14:31:09 -0600 Subject: [PATCH 168/298] updated the return type of page.select, to match docs updated the return type of page.select, to match docs at puppeteer link to puppeteer https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pageselectselector-values --- types/puppeteer/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/puppeteer/index.d.ts b/types/puppeteer/index.d.ts index b89d41bbba..41ba1c0cba 100644 --- a/types/puppeteer/index.d.ts +++ b/types/puppeteer/index.d.ts @@ -968,7 +968,7 @@ export interface Page extends EventEmitter, FrameBase { * @param values Values of options to select. If the `` has the `multiple` attribute, * all values are considered, otherwise only the first one is taken into account. */ - select(selector: string, ...values: string[]): Promise>; + select(selector: string, ...values: string[]): Promise; /** * Sets the page content. From c693da26678828accdb6e02bbef2ee511dc35c9a Mon Sep 17 00:00:00 2001 From: DovidM Date: Thu, 14 Dec 2017 15:49:23 -0500 Subject: [PATCH 170/298] Added typing --- types/word-list-json/index.d.ts | 40 +++++++-------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/types/word-list-json/index.d.ts b/types/word-list-json/index.d.ts index 0dec6547e2..4c9ffb751f 100644 --- a/types/word-list-json/index.d.ts +++ b/types/word-list-json/index.d.ts @@ -1,39 +1,15 @@ // Type definitions for word-list-json 0.2 // Project: https://github.com/sindresorhus/word-list -// Definitions by: My Self +// Definitions by: Dovid Meiseles // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/*~ If this module is a UMD module that exposes a global variable 'myLib' when - *~ loaded outside a module loader environment, declare that global here. - *~ Otherwise, delete this declaration. - */ -export as namespace myLib; - -/*~ If this module has methods, declare them as functions like so. - */ -export function myMethod(a: string): string; -export function myOtherMethod(a: number): number; - /*~ You can declare types that are available via importing the module */ -export interface someType { - name: string; - length: number; - extras?: string[]; +interface Lengths { + [key: string]: number; } +export const words: string[]; +export const lengths: Lengths; -/*~ You can declare properties of the module using const, let, or var */ -export const myField: number; - -/*~ If there are types, properties, or methods inside dotted names - *~ of the module, declare them inside a 'namespace'. - */ -export namespace subProp { - /*~ For example, given this definition, someone could write: - *~ import { subProp } from 'yourModule'; - *~ subProp.foo(); - *~ or - *~ import * as yourMod from 'yourModule'; - *~ yourMod.subProp.foo(); - */ - export function foo(): void; -} \ No newline at end of file +export default interface Words { + words: typeof words & typeof lengths; +} From a0472cd4d802d75033178a450726d5a02c2cc1f4 Mon Sep 17 00:00:00 2001 From: Technion Date: Thu, 14 Dec 2017 21:05:56 +0000 Subject: [PATCH 171/298] Disable style check on jest. --- types/jest/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 0c595a5b82..5e27577d3c 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -1046,6 +1046,7 @@ declare namespace jest { path: Path; } + // tslint:disable-next-line:no-empty-interface interface Set {} // To allow non-ES6 users the Set below interface Reporter { onTestResult?(test: Test, testResult: TestResult, aggregatedResult: AggregatedResult): void; From 1490613596547e46114d5a268f6b63fd123807c7 Mon Sep 17 00:00:00 2001 From: DovidM Date: Thu, 14 Dec 2017 16:12:45 -0500 Subject: [PATCH 172/298] Made types clearer, added example --- types/word-list-json/index.d.ts | 11 ++++++----- types/word-list-json/word-list-json-tests.ts | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/word-list-json/index.d.ts b/types/word-list-json/index.d.ts index 4c9ffb751f..a9435519ce 100644 --- a/types/word-list-json/index.d.ts +++ b/types/word-list-json/index.d.ts @@ -4,12 +4,13 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /*~ You can declare types that are available via importing the module */ + interface Lengths { [key: string]: number; } -export const words: string[]; -export const lengths: Lengths; -export default interface Words { - words: typeof words & typeof lengths; -} +type words = string[]; + +export default interface Words extends words { + lengths: Lengths; +} \ No newline at end of file diff --git a/types/word-list-json/word-list-json-tests.ts b/types/word-list-json/word-list-json-tests.ts index e69de29bb2..2198e4396e 100644 --- a/types/word-list-json/word-list-json-tests.ts +++ b/types/word-list-json/word-list-json-tests.ts @@ -0,0 +1,3 @@ +import wordListJson from 'word-list-json'; + +const words: wordListJson['lengths'] = { '123': 123 }; From ac8197d94979c00e707d9f58e0c283312201013b Mon Sep 17 00:00:00 2001 From: DovidM Date: Thu, 14 Dec 2017 16:36:54 -0500 Subject: [PATCH 173/298] Nothing to test --- types/word-list-json/word-list-json-tests.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/types/word-list-json/word-list-json-tests.ts b/types/word-list-json/word-list-json-tests.ts index 2198e4396e..e69de29bb2 100644 --- a/types/word-list-json/word-list-json-tests.ts +++ b/types/word-list-json/word-list-json-tests.ts @@ -1,3 +0,0 @@ -import wordListJson from 'word-list-json'; - -const words: wordListJson['lengths'] = { '123': 123 }; From 07968972fea72f30f66a021f006d39dd0d472ae9 Mon Sep 17 00:00:00 2001 From: Xavier Lozinguez Date: Thu, 14 Dec 2017 18:14:36 -0500 Subject: [PATCH 174/298] Adjusted RequestedDeviceOptions type definition to indicate that either `filters` or `acceptAllDevices` should be specified. --- types/web-bluetooth/index.d.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/types/web-bluetooth/index.d.ts b/types/web-bluetooth/index.d.ts index ea01176c38..d2f92309ed 100644 --- a/types/web-bluetooth/index.d.ts +++ b/types/web-bluetooth/index.d.ts @@ -16,11 +16,13 @@ interface BluetoothRequestDeviceFilter { serviceDataUUID?: BluetoothServiceUUID; } -interface RequestDeviceOptions { - filters?: BluetoothRequestDeviceFilter[]; +type RequestDeviceOptions = { + filters: BluetoothRequestDeviceFilter[]; optionalServices?: BluetoothServiceUUID[]; - acceptAllDevices?: boolean; -} +} | { + acceptAllDevices: boolean; + optionalServices?: BluetoothServiceUUID[]; +}; interface BluetoothRemoteGATTDescriptor { readonly characteristic: BluetoothRemoteGATTCharacteristic; @@ -99,11 +101,9 @@ interface BluetoothDevice extends EventTarget, BluetoothDeviceEventHandlers, Cha readonly name?: string; readonly gatt?: BluetoothRemoteGATTServer; readonly uuids?: string[]; - watchAdvertisements(): Promise; unwatchAdvertisements(): void; readonly watchingAdvertisements: boolean; - addEventListener(type: "gattserverdisconnected", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "advertisementreceived", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -114,7 +114,6 @@ interface Bluetooth extends EventTarget, BluetoothDeviceEventHandlers, Character onavailabilitychanged: (this: this, ev: Event) => any; readonly referringDevice?: BluetoothDevice; requestDevice(options?: RequestDeviceOptions): Promise; - addEventListener(type: "availabilitychanged", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } From 6da8269d521add60d99349f3180fef19d0e01ebc Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 10:09:26 +0900 Subject: [PATCH 175/298] cleanup simple style ignore lint errors --- types/vinyl/index.d.ts | 4 +- types/vinyl/tslint.json | 6 +- types/vinyl/vinyl-tests.ts | 365 ++++++++++++++++++------------------- 3 files changed, 176 insertions(+), 199 deletions(-) diff --git a/types/vinyl/index.d.ts b/types/vinyl/index.d.ts index f6cd0c8609..5239147517 100644 --- a/types/vinyl/index.d.ts +++ b/types/vinyl/index.d.ts @@ -9,8 +9,8 @@ import * as fs from 'fs'; interface ConstructorOptions { /** - * The current working directory of the file. Default: process.cwd() - */ + * The current working directory of the file. Default: process.cwd() + */ cwd?: string; /** diff --git a/types/vinyl/tslint.json b/types/vinyl/tslint.json index 537285c84b..e4f0f9f640 100644 --- a/types/vinyl/tslint.json +++ b/types/vinyl/tslint.json @@ -1,17 +1,13 @@ { "extends": "dtslint/dt.json", "rules": { - "comment-format": false, "dt-header": false, - "jsdoc-format": false, "no-conditional-assignment": false, "no-construct": false, - "no-padding": false, "no-var-keyword": false, "no-var-requires": false, "object-literal-shorthand": false, "only-arrow-functions": false, - "prefer-const": false, - "space-before-function-paren": false + "prefer-const": false } } diff --git a/types/vinyl/vinyl-tests.ts b/types/vinyl/vinyl-tests.ts index 2fe95e9404..e2b2507d7b 100644 --- a/types/vinyl/vinyl-tests.ts +++ b/types/vinyl/vinyl-tests.ts @@ -31,48 +31,46 @@ var isCloneable: (obj: any) => boolean = cloneable.isCloneable; var isWin = (process.platform === 'win32'); -describe('File', function () { - - describe('isVinyl()', function () { - - it('returns true for a Vinyl object', function (done) { +describe('File', function() { + describe('isVinyl()', function() { + it('returns true for a Vinyl object', function(done) { var file = new File(); var result = File.isVinyl(file); expect(result).toEqual(true); done(); }); - it('returns false for a normal object', function (done) { + it('returns false for a normal object', function(done) { var result = File.isVinyl({}); expect(result).toEqual(false); done(); }); - it('returns false for null', function (done) { + it('returns false for null', function(done) { var result = File.isVinyl(null); expect(result).toEqual(false); done(); }); - it('returns false for a string', function (done) { + it('returns false for a string', function(done) { var result = File.isVinyl('foobar'); expect(result).toEqual(false); done(); }); - it('returns false for a String object', function (done) { + it('returns false for a String object', function(done) { var result = File.isVinyl(new String('foobar')); expect(result).toEqual(false); done(); }); - it('returns false for a number', function (done) { + it('returns false for a number', function(done) { var result = File.isVinyl(1); expect(result).toEqual(false); done(); }); - it('returns false for a Number object', function (done) { + it('returns false for a Number object', function(done) { var result = File.isVinyl(new Number(1)); expect(result).toEqual(false); done(); @@ -81,55 +79,54 @@ describe('File', function () { // This is based on current implementation // A test was added to document and make aware during internal changes // TODO: decide if this should be leak-able - it('returns true for a mocked object', function (done) { + it('returns true for a mocked object', function(done) { var result = File.isVinyl({ _isVinyl: true }); expect(result).toEqual(true); done(); }); }); - describe('defaults', function () { - - it('defaults cwd to process.cwd', function (done) { + describe('defaults', function() { + it('defaults cwd to process.cwd', function(done) { var file = new File(); expect(file.cwd).toEqual(process.cwd()); done(); }); - it('defaults base to process.cwd', function (done) { + it('defaults base to process.cwd', function(done) { var file = new File(); expect(file.base).toEqual(process.cwd()); done(); }); - it('defaults base to cwd property', function (done) { + it('defaults base to cwd property', function(done) { var cwd = path.normalize('/'); var file = new File({ cwd: cwd }); expect(file.base).toEqual(cwd); done(); }); - it('defaults path to null', function (done) { + it('defaults path to null', function(done) { var file = new File(); expect(file.path).toNotExist(); expect(file.path).toEqual(null); done(); }); - it('defaults history to an empty array', function (done) { + it('defaults history to an empty array', function(done) { var file = new File(); expect(file.history).toEqual([]); done(); }); - it('defaults stat to null', function (done) { + it('defaults stat to null', function(done) { var file = new File(); expect(file.stat).toNotExist(); expect(file.stat).toEqual(null); done(); }); - it('defaults contents to null', function (done) { + it('defaults contents to null', function(done) { var file = new File(); expect(file.contents).toNotExist(); expect(file.contents).toEqual(null); @@ -137,23 +134,22 @@ describe('File', function () { }); }); - describe('constructor()', function () { - - it('sets base', function (done) { + describe('constructor()', function() { + it('sets base', function(done) { var val = path.normalize('/'); var file = new File({ base: val }); expect(file.base).toEqual(val); done(); }); - it('sets cwd', function (done) { + it('sets cwd', function(done) { var val = path.normalize('/'); var file = new File({ cwd: val }); expect(file.cwd).toEqual(val); done(); }); - it('sets path (and history)', function (done) { + it('sets path (and history)', function(done) { var val = path.normalize('/test.coffee'); var file = new File({ path: val }); expect(file.path).toEqual(val); @@ -161,7 +157,7 @@ describe('File', function () { done(); }); - it('sets history (and path)', function (done) { + it('sets history (and path)', function(done) { var val = path.normalize('/test.coffee'); var file = new File({ history: [val] }); expect(file.path).toEqual(val); @@ -169,28 +165,28 @@ describe('File', function () { done(); }); - it('sets stat', function (done) { + it('sets stat', function(done) { var val = {}; var file = new File({ stat: val as any as fs.Stats }); expect(file.stat).toEqual(val); done(); }); - it('sets contents', function (done) { + it('sets contents', function(done) { var val = new Buffer('test'); var file = new File({ contents: val }); expect(file.contents).toEqual(val); done(); }); - it('sets custom properties', function (done) { + it('sets custom properties', function(done) { var sourceMap = {}; var file = new File({ sourceMap: sourceMap }) as TestFile; expect(file.sourceMap).toEqual(sourceMap); done(); }); - it('normalizes path', function (done) { + it('normalizes path', function(done) { var val = '/test/foo/../test.coffee'; var expected = path.normalize(val); var file = new File({ path: val }); @@ -199,7 +195,7 @@ describe('File', function () { done(); }); - it('normalizes and removes trailing separator from path', function (done) { + it('normalizes and removes trailing separator from path', function(done) { var val = '/test/foo/../foo/'; var expected = path.normalize(val.slice(0, -1)); var file = new File({ path: val }); @@ -207,12 +203,12 @@ describe('File', function () { done(); }); - it('normalizes history', function (done) { + it('normalizes history', function(done) { var val = [ '/test/bar/../bar/test.coffee', '/test/foo/../test.coffee', ]; - var expected = val.map(function (p) { + var expected = val.map(function(p) { return path.normalize(p); }); var file = new File({ history: val }); @@ -221,12 +217,12 @@ describe('File', function () { done(); }); - it('normalizes and removes trailing separator from history', function (done) { + it('normalizes and removes trailing separator from history', function(done) { var val = [ '/test/foo/../foo/', '/test/bar/../bar/', ]; - var expected = val.map(function (p) { + var expected = val.map(function(p) { return path.normalize(p.slice(0, -1)); }); var file = new File({ history: val }); @@ -234,7 +230,7 @@ describe('File', function () { done(); }); - it('appends path to history if both exist and different from last', function (done) { + it('appends path to history if both exist and different from last', function(done) { var val = path.normalize('/test/baz/test.coffee'); var history = [ path.normalize('/test/bar/test.coffee'), @@ -249,7 +245,7 @@ describe('File', function () { done(); }); - it('does not append path to history if both exist and same as last', function (done) { + it('does not append path to history if both exist and same as last', function(done) { var val = path.normalize('/test/baz/test.coffee'); var history = [ path.normalize('/test/bar/test.coffee'), @@ -263,7 +259,7 @@ describe('File', function () { done(); }); - it('does not mutate history array passed in', function (done) { + it('does not mutate history array passed in', function(done) { var val = path.normalize('/test/baz/test.coffee'); var history = [ path.normalize('/test/bar/test.coffee'), @@ -281,158 +277,154 @@ describe('File', function () { }); }); - describe('isBuffer()', function () { - - it('returns true when the contents are a Buffer', function (done) { + describe('isBuffer()', function() { + it('returns true when the contents are a Buffer', function(done) { var val = new Buffer('test'); var file = new File({ contents: val }); expect(file.isBuffer()).toEqual(true); done(); }); - it('returns false when the contents are a Stream', function (done) { + it('returns false when the contents are a Stream', function(done) { var val = from([]); var file = new File({ contents: val }); expect(file.isBuffer()).toEqual(false); done(); }); - it('returns false when the contents are null', function (done) { + it('returns false when the contents are null', function(done) { var file = new File({ contents: null }); expect(file.isBuffer()).toEqual(false); done(); }); }); - describe('isStream()', function () { - - it('returns false when the contents are a Buffer', function (done) { + describe('isStream()', function() { + it('returns false when the contents are a Buffer', function(done) { var val = new Buffer('test'); var file = new File({ contents: val }); expect(file.isStream()).toEqual(false); done(); }); - it('returns true when the contents are a Stream', function (done) { + it('returns true when the contents are a Stream', function(done) { var val = from([]); var file = new File({ contents: val }); expect(file.isStream()).toEqual(true); done(); }); - it('returns false when the contents are null', function (done) { + it('returns false when the contents are null', function(done) { var file = new File({ contents: null }); expect(file.isStream()).toEqual(false); done(); }); }); - describe('isNull()', function () { - - it('returns false when the contents are a Buffer', function (done) { + describe('isNull()', function() { + it('returns false when the contents are a Buffer', function(done) { var val = new Buffer('test'); var file = new File({ contents: val }); expect(file.isNull()).toEqual(false); done(); }); - it('returns false when the contents are a Stream', function (done) { + it('returns false when the contents are a Stream', function(done) { var val = from([]); var file = new File({ contents: val }); expect(file.isNull()).toEqual(false); done(); }); - it('returns true when the contents are null', function (done) { + it('returns true when the contents are null', function(done) { var file = new File({ contents: null }); expect(file.isNull()).toEqual(true); done(); }); }); - describe('isDirectory()', function () { + describe('isDirectory()', function() { var fakeStat = { - isDirectory: function () { + isDirectory: function() { return true; }, } as any as fs.Stats; - it('returns false when the contents are a Buffer', function (done) { + it('returns false when the contents are a Buffer', function(done) { var val = new Buffer('test'); var file = new File({ contents: val, stat: fakeStat }); expect(file.isDirectory()).toEqual(false); done(); }); - it('returns false when the contents are a Stream', function (done) { + it('returns false when the contents are a Stream', function(done) { var val = from([]); var file = new File({ contents: val, stat: fakeStat }); expect(file.isDirectory()).toEqual(false); done(); }); - it('returns true when the contents are null & stat.isDirectory is true', function (done) { + it('returns true when the contents are null & stat.isDirectory is true', function(done) { var file = new File({ contents: null, stat: fakeStat }); expect(file.isDirectory()).toEqual(true); done(); }); - it('returns false when stat exists but does not contain an isDirectory method', function (done) { + it('returns false when stat exists but does not contain an isDirectory method', function(done) { var file = new File({ contents: null, stat: {} as any as fs.Stats }); expect(file.isDirectory()).toEqual(false); done(); }); - it('returns false when stat does not exist', function (done) { + it('returns false when stat does not exist', function(done) { var file = new File({ contents: null }); expect(file.isDirectory()).toEqual(false); done(); }); }); - describe('isSymbolic()', function () { + describe('isSymbolic()', function() { var fakeStat = { - isSymbolicLink: function () { + isSymbolicLink: function() { return true; }, } as any as fs.Stats; - it('returns false when the contents are a Buffer', function (done) { + it('returns false when the contents are a Buffer', function(done) { var val = new Buffer('test'); var file = new File({ contents: val, stat: fakeStat }); expect(file.isSymbolic()).toEqual(false); done(); }); - it('returns false when the contents are a Stream', function (done) { + it('returns false when the contents are a Stream', function(done) { var val = from([]); var file = new File({ contents: val, stat: fakeStat }); expect(file.isSymbolic()).toEqual(false); done(); }); - it('returns true when the contents are null & stat.isSymbolicLink is true', function (done) { + it('returns true when the contents are null & stat.isSymbolicLink is true', function(done) { var file = new File({ contents: null, stat: fakeStat }); expect(file.isSymbolic()).toEqual(true); done(); }); - it('returns false when stat exists but does not contain an isSymbolicLink method', function (done) { + it('returns false when stat exists but does not contain an isSymbolicLink method', function(done) { var file = new File({ contents: null, stat: {} as any as fs.Stats }); expect(file.isSymbolic()).toEqual(false); done(); }); - it('returns false when stat does not exist', function (done) { + it('returns false when stat does not exist', function(done) { var file = new File({ contents: null }); expect(file.isSymbolic()).toEqual(false); done(); }); }); - describe('clone()', function () { - - it('copies all attributes over with Buffer contents', function (done) { + describe('clone()', function() { + it('copies all attributes over with Buffer contents', function(done) { var options = { cwd: '/', base: '/test/', @@ -451,7 +443,7 @@ describe('File', function () { done(); }); - it('assigns Buffer content reference when contents option is false', function (done) { + it('assigns Buffer content reference when contents option is false', function(done) { var options = { cwd: '/', base: '/test/', @@ -467,12 +459,12 @@ describe('File', function () { expect(copy2.contents).toNotBe(file.contents); // TypeScript: expected compilation error - //var copy3 = file.clone({ contents: 'invalid' }); - //expect(copy3.contents).toNotBe(file.contents); - //done(); + // var copy3 = file.clone({ contents: 'invalid' }); + // expect(copy3.contents).toNotBe(file.contents); + // done(); }); - it('copies all attributes over with Stream contents', function (done) { + it('copies all attributes over with Stream contents', function(done) { var options = { cwd: '/', base: '/test/', @@ -507,20 +499,20 @@ describe('File', function () { pipe([ file.contents, - concat(function (d) { + concat(function(d) { data = d; }), ], assert); pipe([ file2.contents, - concat(function (d) { + concat(function(d) { data2 = d; }), ], assert); }); - it('does not start flowing until all clones flows (data)', function (done) { + it('does not start flowing until all clones flows (data)', function(done) { var options = { cwd: '/', base: '/test/', @@ -542,17 +534,17 @@ describe('File', function () { } // Start flowing file2 - file2.contents.on('data', function (chunk: Buffer) { + file2.contents.on('data', function(chunk: Buffer) { data2 += chunk.toString('utf8'); }); - process.nextTick(function () { + process.nextTick(function() { // Nothing was written yet expect(data).toEqual(''); expect(data2).toEqual(''); // Starts flowing file - file.contents.on('data', function (chunk: Buffer) { + file.contents.on('data', function(chunk: Buffer) { data += chunk.toString('utf8'); }); }); @@ -561,7 +553,7 @@ describe('File', function () { file.contents.on('end', assert); }); - it('does not start flowing until all clones flows (readable)', function (done) { + it('does not start flowing until all clones flows (readable)', function(done) { var options = { cwd: '/', base: '/test/', @@ -578,7 +570,7 @@ describe('File', function () { } // Start flowing file2 - file2.contents.on('readable', function (this: NodeJS.ReadableStream) { + file2.contents.on('readable', function(this: NodeJS.ReadableStream) { var chunk: string | Buffer; while ((chunk = this.read()) !== null) { data2 += chunk.toString(); @@ -591,7 +583,7 @@ describe('File', function () { ], done); }); - it('copies all attributes over with null contents', function (done) { + it('copies all attributes over with null contents', function(done) { var options = { cwd: '/', base: '/test/', @@ -609,7 +601,7 @@ describe('File', function () { done(); }); - it('properly clones the `stat` property', function (done) { + it('properly clones the `stat` property', function(done) { var options = { cwd: '/', base: '/test/', @@ -631,7 +623,7 @@ describe('File', function () { done(); }); - it('properly clones the `history` property', function (done) { + it('properly clones the `history` property', function(done) { var options = { cwd: path.normalize('/'), base: path.normalize('/test/'), @@ -648,7 +640,7 @@ describe('File', function () { done(); }); - it('copies custom properties', function (done) { + it('copies custom properties', function(done) { var options = { cwd: '/', base: '/test/', @@ -670,7 +662,7 @@ describe('File', function () { done(); }); - it('copies history', function (done) { + it('copies history', function(done) { var options = { cwd: '/', base: '/test/', @@ -694,7 +686,7 @@ describe('File', function () { done(); }); - it('supports deep & shallow copy of all attributes', function (done) { + it('supports deep & shallow copy of all attributes', function(done) { var options = { cwd: '/', base: '/test/', @@ -755,22 +747,21 @@ describe('File', function () { // }); }); - describe('inspect()', function () { - - it('returns correct format when no contents and no path', function (done) { + describe('inspect()', function() { + it('returns correct format when no contents and no path', function(done) { var file = new File(); expect(file.inspect()).toEqual(''); done(); }); - it('returns correct format when Buffer contents and no path', function (done) { + it('returns correct format when Buffer contents and no path', function(done) { var val = new Buffer('test'); var file = new File({ contents: val }); expect(file.inspect()).toEqual('>'); done(); }); - it('returns correct format when Buffer contents and relative path', function (done) { + it('returns correct format when Buffer contents and relative path', function(done) { var val = new Buffer('test'); var file = new File({ cwd: '/', @@ -782,7 +773,7 @@ describe('File', function () { done(); }); - it('returns correct format when Stream contents and relative path', function (done) { + it('returns correct format when Stream contents and relative path', function(done) { var file = new File({ cwd: '/', base: '/test/', @@ -793,7 +784,7 @@ describe('File', function () { done(); }); - it('returns correct format when null contents and relative path', function (done) { + it('returns correct format when null contents and relative path', function(done) { var file = new File({ cwd: '/', base: '/test/', @@ -805,9 +796,8 @@ describe('File', function () { }); }); - describe('contents get/set', function () { - - it('returns _contents', function (done) { + describe('contents get/set', function() { + it('returns _contents', function(done) { var val = new Buffer('test'); var file = new File() as TestFile; file._contents = val; @@ -815,7 +805,7 @@ describe('File', function () { done(); }); - it('sets _contents', function (done) { + it('sets _contents', function(done) { var val = new Buffer('test'); var file = new File() as TestFile; file.contents = val; @@ -823,7 +813,7 @@ describe('File', function () { done(); }); - it('sets a Buffer', function (done) { + it('sets a Buffer', function(done) { var val = new Buffer('test'); var file = new File(); file.contents = val; @@ -831,7 +821,7 @@ describe('File', function () { done(); }); - it('wraps Stream in Cloneable', function (done) { + it('wraps Stream in Cloneable', function(done) { var val = from([]); var file = new File(); file.contents = val; @@ -839,7 +829,7 @@ describe('File', function () { done(); }); - it('does not double wrap a Cloneable', function (done) { + it('does not double wrap a Cloneable', function(done) { var val = from([]); var clone = cloneable(val); var file = new File(); @@ -848,7 +838,7 @@ describe('File', function () { done(); }); - it('sets null', function (done) { + it('sets null', function(done) { var val = null; var file = new File(); file.contents = val; @@ -868,9 +858,8 @@ describe('File', function () { // }); }); - describe('cwd get/set', function () { - - it('returns _cwd', function (done) { + describe('cwd get/set', function() { + it('returns _cwd', function(done) { var val = '/test'; var file = new File() as TestFile; file._cwd = val; @@ -878,7 +867,7 @@ describe('File', function () { done(); }); - it('sets _cwd', function (done) { + it('sets _cwd', function(done) { var val = '/test'; var file = new File() as TestFile; file.cwd = val; @@ -886,7 +875,7 @@ describe('File', function () { done(); }); - it('normalizes and removes trailing separator on set', function (done) { + it('normalizes and removes trailing separator on set', function(done) { var val = '/test/foo/../foo/'; var expected = path.normalize(val.slice(0, -1)); var file = new File(); @@ -931,15 +920,14 @@ describe('File', function () { // }); }); - describe('base get/set', function () { - - it('proxies cwd when omitted', function (done) { + describe('base get/set', function() { + it('proxies cwd when omitted', function(done) { var file = new File({ cwd: '/test' }); expect(file.base).toEqual(file.cwd); done(); }); - it('proxies cwd when same', function (done) { + it('proxies cwd when same', function(done) { var file = new File({ cwd: '/test', base: '/test', @@ -972,7 +960,7 @@ describe('File', function () { // done(); // }); - it('returns _base', function (done) { + it('returns _base', function(done) { var val = '/test/'; var file = new File() as TestFile; file._base = val; @@ -980,7 +968,7 @@ describe('File', function () { done(); }); - it('sets _base', function (done) { + it('sets _base', function(done) { var val = '/test/foo'; var file = new File() as TestFile; file.base = val; @@ -988,7 +976,7 @@ describe('File', function () { done(); }); - it('normalizes and removes trailing separator on set', function (done) { + it('normalizes and removes trailing separator on set', function(done) { var val = '/test/foo/../foo/'; var expected = path.normalize(val.slice(0, -1)); var file = new File(); @@ -1032,9 +1020,8 @@ describe('File', function () { // }); }); - describe('relative get/set', function () { - - it('throws on set', function (done) { + describe('relative get/set', function() { + it('throws on set', function(done) { var file = new File(); function invalid() { @@ -1045,7 +1032,7 @@ describe('File', function () { done(); }); - it('throws on get with no path', function (done) { + it('throws on get with no path', function(done) { var file = new File(); function invalid() { @@ -1056,7 +1043,7 @@ describe('File', function () { done(); }); - it('returns a relative path from base', function (done) { + it('returns a relative path from base', function(done) { var file = new File({ base: '/test/', path: '/test/test.coffee', @@ -1066,7 +1053,7 @@ describe('File', function () { done(); }); - it('returns a relative path from cwd', function (done) { + it('returns a relative path from cwd', function(done) { var file = new File({ cwd: '/', path: '/test/test.coffee', @@ -1076,12 +1063,12 @@ describe('File', function () { done(); }); - it('does not append separator when directory', function (done) { + it('does not append separator when directory', function(done) { var file = new File({ base: '/test', path: '/test/foo/bar', stat: { - isDirectory: function () { + isDirectory: function() { return true; }, } as any as fs.Stats, @@ -1091,12 +1078,12 @@ describe('File', function () { done(); }); - it('does not append separator when symlink', function (done) { + it('does not append separator when symlink', function(done) { var file = new File({ base: '/test', path: '/test/foo/bar', stat: { - isSymbolicLink: function () { + isSymbolicLink: function() { return true; }, } as any as fs.Stats, @@ -1106,15 +1093,15 @@ describe('File', function () { done(); }); - it('does not append separator when directory & symlink', function (done) { + it('does not append separator when directory & symlink', function(done) { var file = new File({ base: '/test', path: '/test/foo/bar', stat: { - isDirectory: function () { + isDirectory: function() { return true; }, - isSymbolicLink: function () { + isSymbolicLink: function() { return true; }, } as any as fs.Stats, @@ -1125,9 +1112,8 @@ describe('File', function () { }); }); - describe('dirname get/set', function () { - - it('throws on get with no path', function (done) { + describe('dirname get/set', function() { + it('throws on get with no path', function(done) { var file = new File(); function invalid() { @@ -1138,7 +1124,7 @@ describe('File', function () { done(); }); - it('returns the dirname without trailing separator', function (done) { + it('returns the dirname without trailing separator', function(done) { var file = new File({ cwd: '/', base: '/test', @@ -1149,7 +1135,7 @@ describe('File', function () { done(); }); - it('throws on set with no path', function (done) { + it('throws on set with no path', function(done) { var file = new File(); function invalid() { @@ -1160,7 +1146,7 @@ describe('File', function () { done(); }); - it('replaces the dirname of the path', function (done) { + it('replaces the dirname of the path', function(done) { var file = new File({ cwd: '/', base: '/test/', @@ -1173,9 +1159,8 @@ describe('File', function () { }); }); - describe('basename get/set', function () { - - it('throws on get with no path', function (done) { + describe('basename get/set', function() { + it('throws on get with no path', function(done) { var file = new File(); function invalid() { @@ -1186,7 +1171,7 @@ describe('File', function () { done(); }); - it('returns the basename of the path', function (done) { + it('returns the basename of the path', function(done) { var file = new File({ cwd: '/', base: '/test/', @@ -1197,11 +1182,11 @@ describe('File', function () { done(); }); - it('does not append trailing separator when directory', function (done) { + it('does not append trailing separator when directory', function(done) { var file = new File({ path: '/test/foo', stat: { - isDirectory: function () { + isDirectory: function() { return true; }, } as any as fs.Stats, @@ -1211,11 +1196,11 @@ describe('File', function () { done(); }); - it('does not append trailing separator when symlink', function (done) { + it('does not append trailing separator when symlink', function(done) { var file = new File({ path: '/test/foo', stat: { - isSymbolicLink: function () { + isSymbolicLink: function() { return true; }, } as any as fs.Stats, @@ -1225,14 +1210,14 @@ describe('File', function () { done(); }); - it('does not append trailing separator when directory & symlink', function (done) { + it('does not append trailing separator when directory & symlink', function(done) { var file = new File({ path: '/test/foo', stat: { - isDirectory: function () { + isDirectory: function() { return true; }, - isSymbolicLink: function () { + isSymbolicLink: function() { return true; }, } as any as fs.Stats, @@ -1242,7 +1227,7 @@ describe('File', function () { done(); }); - it('removes trailing separator', function (done) { + it('removes trailing separator', function(done) { var file = new File({ path: '/test/foo/', }); @@ -1251,11 +1236,11 @@ describe('File', function () { done(); }); - it('removes trailing separator when directory', function (done) { + it('removes trailing separator when directory', function(done) { var file = new File({ path: '/test/foo/', stat: { - isDirectory: function () { + isDirectory: function() { return true; }, } as any as fs.Stats, @@ -1265,11 +1250,11 @@ describe('File', function () { done(); }); - it('removes trailing separator when symlink', function (done) { + it('removes trailing separator when symlink', function(done) { var file = new File({ path: '/test/foo/', stat: { - isSymbolicLink: function () { + isSymbolicLink: function() { return true; }, } as any as fs.Stats, @@ -1279,14 +1264,14 @@ describe('File', function () { done(); }); - it('removes trailing separator when directory & symlink', function (done) { + it('removes trailing separator when directory & symlink', function(done) { var file = new File({ path: '/test/foo/', stat: { - isDirectory: function () { + isDirectory: function() { return true; }, - isSymbolicLink: function () { + isSymbolicLink: function() { return true; }, } as any as fs.Stats, @@ -1296,7 +1281,7 @@ describe('File', function () { done(); }); - it('throws on set with no path', function (done) { + it('throws on set with no path', function(done) { var file = new File(); function invalid() { @@ -1307,7 +1292,7 @@ describe('File', function () { done(); }); - it('replaces the basename of the path', function (done) { + it('replaces the basename of the path', function(done) { var file = new File({ cwd: '/', base: '/test/', @@ -1320,9 +1305,8 @@ describe('File', function () { }); }); - describe('stem get/set', function () { - - it('throws on get with no path', function (done) { + describe('stem get/set', function() { + it('throws on get with no path', function(done) { var file = new File(); function invalid() { @@ -1333,7 +1317,7 @@ describe('File', function () { done(); }); - it('returns the stem of the path', function (done) { + it('returns the stem of the path', function(done) { var file = new File({ cwd: '/', base: '/test/', @@ -1344,7 +1328,7 @@ describe('File', function () { done(); }); - it('throws on set with no path', function (done) { + it('throws on set with no path', function(done) { var file = new File(); function invalid() { @@ -1355,7 +1339,7 @@ describe('File', function () { done(); }); - it('replaces the stem of the path', function (done) { + it('replaces the stem of the path', function(done) { var file = new File({ cwd: '/', base: '/test/', @@ -1368,9 +1352,8 @@ describe('File', function () { }); }); - describe('extname get/set', function () { - - it('throws on get with no path', function (done) { + describe('extname get/set', function() { + it('throws on get with no path', function(done) { var file = new File(); function invalid() { @@ -1381,7 +1364,7 @@ describe('File', function () { done(); }); - it('returns the extname of the path', function (done) { + it('returns the extname of the path', function(done) { var file = new File({ cwd: '/', base: '/test/', @@ -1392,7 +1375,7 @@ describe('File', function () { done(); }); - it('throws on set with no path', function (done) { + it('throws on set with no path', function(done) { var file = new File(); function invalid() { @@ -1403,7 +1386,7 @@ describe('File', function () { done(); }); - it('replaces the extname of the path', function (done) { + it('replaces the extname of the path', function(done) { var file = new File({ cwd: '/', base: '/test/', @@ -1416,9 +1399,8 @@ describe('File', function () { }); }); - describe('path get/set', function () { - - it('records path in history upon instantiation', function (done) { + describe('path get/set', function() { + it('records path in history upon instantiation', function(done) { var file = new File({ cwd: '/', path: '/test/test.coffee', @@ -1432,7 +1414,7 @@ describe('File', function () { done(); }); - it('records path in history when set', function (done) { + it('records path in history when set', function(done) { var val = path.normalize('/test/test.js'); var file = new File({ cwd: '/', @@ -1456,7 +1438,7 @@ describe('File', function () { done(); }); - it('does not record path in history when set to the current path', function (done) { + it('does not record path in history when set to the current path', function(done) { var val = path.normalize('/test/test.coffee'); var file = new File({ cwd: '/', @@ -1473,7 +1455,7 @@ describe('File', function () { done(); }); - it('does not record path in history when set to empty string', function (done) { + it('does not record path in history when set to empty string', function(done) { var val = path.normalize('/test/test.coffee'); var file = new File({ cwd: '/', @@ -1504,7 +1486,7 @@ describe('File', function () { // done(); // }); - it('normalizes the path upon set', function (done) { + it('normalizes the path upon set', function(done) { var val = '/test/foo/../test.coffee'; var expected = path.normalize(val); var file = new File(); @@ -1516,7 +1498,7 @@ describe('File', function () { done(); }); - it('removes the trailing separator upon set', function (done) { + it('removes the trailing separator upon set', function(done) { var file = new File(); file.path = '/test/'; @@ -1525,10 +1507,10 @@ describe('File', function () { done(); }); - it('removes the trailing separator upon set when directory', function (done) { + it('removes the trailing separator upon set when directory', function(done) { var file = new File({ stat: { - isDirectory: function () { + isDirectory: function() { return true; }, } as any as fs.Stats, @@ -1540,10 +1522,10 @@ describe('File', function () { done(); }); - it('removes the trailing separator upon set when symlink', function (done) { + it('removes the trailing separator upon set when symlink', function(done) { var file = new File({ stat: { - isSymbolicLink: function () { + isSymbolicLink: function() { return true; }, } as any as fs.Stats, @@ -1555,13 +1537,13 @@ describe('File', function () { done(); }); - it('removes the trailing separator upon set when directory & symlink', function (done) { + it('removes the trailing separator upon set when directory & symlink', function(done) { var file = new File({ stat: { - isDirectory: function () { + isDirectory: function() { return true; }, - isSymbolicLink: function () { + isSymbolicLink: function() { return true; }, } as any as fs.Stats, @@ -1574,16 +1556,15 @@ describe('File', function () { }); }); - describe('symlink get/set', function () { - - it('return null on get with no symlink', function (done) { + describe('symlink get/set', function() { + it('return null on get with no symlink', function(done) { var file = new File(); expect(file.symlink).toEqual(null); done(); }); - it('returns _symlink', function (done) { + it('returns _symlink', function(done) { var val = '/test/test.coffee'; var file = new File() as TestFile; file._symlink = val; @@ -1592,7 +1573,7 @@ describe('File', function () { done(); }); - it('throws on set with non-string', function (done) { + it('throws on set with non-string', function(done) { var file = new File(); function invalid() { @@ -1603,7 +1584,7 @@ describe('File', function () { done(); }); - it('sets _symlink', function (done) { + it('sets _symlink', function(done) { var val = '/test/test.coffee'; var expected = path.normalize(val); var file = new File() as TestFile; @@ -1613,7 +1594,7 @@ describe('File', function () { done(); }); - it('allows relative symlink', function (done) { + it('allows relative symlink', function(done) { var val = 'test.coffee'; var file = new File(); file.symlink = val; @@ -1622,7 +1603,7 @@ describe('File', function () { done(); }); - it('normalizes and removes trailing separator upon set', function (done) { + it('normalizes and removes trailing separator upon set', function(done) { var val = '/test/foo/../bar/'; var expected = path.normalize(val.slice(0, -1)); var file = new File(); From 62f093e09c6eef3ef1edfee04f877971b8546fe5 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Sat, 9 Dec 2017 17:55:49 -0600 Subject: [PATCH 176/298] Support passing function only in Node writable.end() --- types/node/index.d.ts | 6 +++--- types/node/v0/index.d.ts | 6 +++--- types/node/v4/index.d.ts | 6 +++--- types/node/v6/index.d.ts | 6 +++--- types/node/v7/index.d.ts | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/types/node/index.d.ts b/types/node/index.d.ts index c9dfcf3915..d715be540d 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -354,7 +354,7 @@ declare namespace NodeJS { writable: boolean; write(buffer: Buffer | string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; + end(cb?: Function): void; end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; @@ -5280,7 +5280,7 @@ declare module "stream" { write(chunk: any, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean; setDefaultEncoding(encoding: string): this; - end(): void; + end(cb?: Function): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; cork(): void; @@ -5371,7 +5371,7 @@ declare module "stream" { write(chunk: any, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean; setDefaultEncoding(encoding: string): this; - end(): void; + end(cb?: Function): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; cork(): void; diff --git a/types/node/v0/index.d.ts b/types/node/v0/index.d.ts index ccf2e5e207..03671db5a3 100644 --- a/types/node/v0/index.d.ts +++ b/types/node/v0/index.d.ts @@ -221,7 +221,7 @@ declare namespace NodeJS { writable: boolean; write(buffer: Buffer|string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; + end(cb?: Function): void; end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; @@ -1804,7 +1804,7 @@ declare module "stream" { write(chunk: any, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean; setDefaultEncoding(encoding: string): this; - end(): void; + end(cb?: Function): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; } @@ -1821,7 +1821,7 @@ declare module "stream" { write(chunk: any, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean; setDefaultEncoding(encoding: string): this; - end(): void; + end(cb?: Function): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; } diff --git a/types/node/v4/index.d.ts b/types/node/v4/index.d.ts index 5658d4e05e..f257c3b917 100644 --- a/types/node/v4/index.d.ts +++ b/types/node/v4/index.d.ts @@ -291,7 +291,7 @@ declare namespace NodeJS { writable: boolean; write(buffer: Buffer|string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; + end(cb?: Function): void; end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; @@ -2271,7 +2271,7 @@ declare module "stream" { write(chunk: any, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean; setDefaultEncoding(encoding: string): this; - end(): void; + end(cb?: Function): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; } @@ -2290,7 +2290,7 @@ declare module "stream" { write(chunk: any, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean; setDefaultEncoding(encoding: string): this; - end(): void; + end(cb?: Function): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; } diff --git a/types/node/v6/index.d.ts b/types/node/v6/index.d.ts index e8931e43cf..2e2303e898 100644 --- a/types/node/v6/index.d.ts +++ b/types/node/v6/index.d.ts @@ -301,7 +301,7 @@ declare namespace NodeJS { writable: boolean; write(buffer: Buffer | string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; + end(cb?: Function): void; end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; @@ -3564,7 +3564,7 @@ declare module "stream" { write(chunk: any, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean; setDefaultEncoding(encoding: string): this; - end(): void; + end(cb?: Function): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; @@ -3649,7 +3649,7 @@ declare module "stream" { write(chunk: any, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean; setDefaultEncoding(encoding: string): this; - end(): void; + end(cb?: Function): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; } diff --git a/types/node/v7/index.d.ts b/types/node/v7/index.d.ts index cc87fadd7c..8ce6079614 100644 --- a/types/node/v7/index.d.ts +++ b/types/node/v7/index.d.ts @@ -313,7 +313,7 @@ declare namespace NodeJS { writable: boolean; write(buffer: Buffer | string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; + end(cb?: Function): void; end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; @@ -3713,7 +3713,7 @@ declare module "stream" { write(chunk: any, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean; setDefaultEncoding(encoding: string): this; - end(): void; + end(cb?: Function): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; @@ -3798,7 +3798,7 @@ declare module "stream" { write(chunk: any, cb?: Function): boolean; write(chunk: any, encoding?: string, cb?: Function): boolean; setDefaultEncoding(encoding: string): this; - end(): void; + end(cb?: Function): void; end(chunk: any, cb?: Function): void; end(chunk: any, encoding?: string, cb?: Function): void; } From 1107825556daf7542ea89247cd178b8dbb3a0315 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 10:25:17 +0900 Subject: [PATCH 177/298] cleanup ignore lint errors: no-var-keyword, object-literal-shorthand --- types/vinyl/tslint.json | 2 - types/vinyl/vinyl-tests.ts | 520 ++++++++++++++++++------------------- 2 files changed, 260 insertions(+), 262 deletions(-) diff --git a/types/vinyl/tslint.json b/types/vinyl/tslint.json index e4f0f9f640..4c5f80b2f4 100644 --- a/types/vinyl/tslint.json +++ b/types/vinyl/tslint.json @@ -4,9 +4,7 @@ "dt-header": false, "no-conditional-assignment": false, "no-construct": false, - "no-var-keyword": false, "no-var-requires": false, - "object-literal-shorthand": false, "only-arrow-functions": false, "prefer-const": false } diff --git a/types/vinyl/vinyl-tests.ts b/types/vinyl/vinyl-tests.ts index e2b2507d7b..079588a4e7 100644 --- a/types/vinyl/vinyl-tests.ts +++ b/types/vinyl/vinyl-tests.ts @@ -3,8 +3,8 @@ import * as fs from 'fs'; import * as path from 'path'; import * as expect from 'expect'; -var miss = require('mississippi'); -var cloneable = require('cloneable-readable'); +const miss = require('mississippi'); +const cloneable = require('cloneable-readable'); import File = require('vinyl'); @@ -24,54 +24,54 @@ interface TestFile extends File { _base?: string; } -var pipe: (streams: [NodeJS.ReadableStream, NodeJS.WritableStream], cb: (err?: Error) => void) => void = miss.pipe; -var from: (values: any[]) => NodeJS.ReadableStream = miss.from; -var concat: (fn: (d: Buffer) => void) => NodeJS.WritableStream = miss.concat; -var isCloneable: (obj: any) => boolean = cloneable.isCloneable; +let pipe: (streams: [NodeJS.ReadableStream, NodeJS.WritableStream], cb: (err?: Error) => void) => void = miss.pipe; +let from: (values: any[]) => NodeJS.ReadableStream = miss.from; +let concat: (fn: (d: Buffer) => void) => NodeJS.WritableStream = miss.concat; +let isCloneable: (obj: any) => boolean = cloneable.isCloneable; -var isWin = (process.platform === 'win32'); +let isWin = (process.platform === 'win32'); describe('File', function() { describe('isVinyl()', function() { it('returns true for a Vinyl object', function(done) { - var file = new File(); - var result = File.isVinyl(file); + let file = new File(); + let result = File.isVinyl(file); expect(result).toEqual(true); done(); }); it('returns false for a normal object', function(done) { - var result = File.isVinyl({}); + let result = File.isVinyl({}); expect(result).toEqual(false); done(); }); it('returns false for null', function(done) { - var result = File.isVinyl(null); + let result = File.isVinyl(null); expect(result).toEqual(false); done(); }); it('returns false for a string', function(done) { - var result = File.isVinyl('foobar'); + let result = File.isVinyl('foobar'); expect(result).toEqual(false); done(); }); it('returns false for a String object', function(done) { - var result = File.isVinyl(new String('foobar')); + let result = File.isVinyl(new String('foobar')); expect(result).toEqual(false); done(); }); it('returns false for a number', function(done) { - var result = File.isVinyl(1); + let result = File.isVinyl(1); expect(result).toEqual(false); done(); }); it('returns false for a Number object', function(done) { - var result = File.isVinyl(new Number(1)); + let result = File.isVinyl(new Number(1)); expect(result).toEqual(false); done(); }); @@ -80,7 +80,7 @@ describe('File', function() { // A test was added to document and make aware during internal changes // TODO: decide if this should be leak-able it('returns true for a mocked object', function(done) { - var result = File.isVinyl({ _isVinyl: true }); + let result = File.isVinyl({ _isVinyl: true }); expect(result).toEqual(true); done(); }); @@ -88,46 +88,46 @@ describe('File', function() { describe('defaults', function() { it('defaults cwd to process.cwd', function(done) { - var file = new File(); + let file = new File(); expect(file.cwd).toEqual(process.cwd()); done(); }); it('defaults base to process.cwd', function(done) { - var file = new File(); + let file = new File(); expect(file.base).toEqual(process.cwd()); done(); }); it('defaults base to cwd property', function(done) { - var cwd = path.normalize('/'); - var file = new File({ cwd: cwd }); + let cwd = path.normalize('/'); + let file = new File({ cwd }); expect(file.base).toEqual(cwd); done(); }); it('defaults path to null', function(done) { - var file = new File(); + let file = new File(); expect(file.path).toNotExist(); expect(file.path).toEqual(null); done(); }); it('defaults history to an empty array', function(done) { - var file = new File(); + let file = new File(); expect(file.history).toEqual([]); done(); }); it('defaults stat to null', function(done) { - var file = new File(); + let file = new File(); expect(file.stat).toNotExist(); expect(file.stat).toEqual(null); done(); }); it('defaults contents to null', function(done) { - var file = new File(); + let file = new File(); expect(file.contents).toNotExist(); expect(file.contents).toEqual(null); done(); @@ -136,109 +136,109 @@ describe('File', function() { describe('constructor()', function() { it('sets base', function(done) { - var val = path.normalize('/'); - var file = new File({ base: val }); + let val = path.normalize('/'); + let file = new File({ base: val }); expect(file.base).toEqual(val); done(); }); it('sets cwd', function(done) { - var val = path.normalize('/'); - var file = new File({ cwd: val }); + let val = path.normalize('/'); + let file = new File({ cwd: val }); expect(file.cwd).toEqual(val); done(); }); it('sets path (and history)', function(done) { - var val = path.normalize('/test.coffee'); - var file = new File({ path: val }); + let val = path.normalize('/test.coffee'); + let file = new File({ path: val }); expect(file.path).toEqual(val); expect(file.history).toEqual([val]); done(); }); it('sets history (and path)', function(done) { - var val = path.normalize('/test.coffee'); - var file = new File({ history: [val] }); + let val = path.normalize('/test.coffee'); + let file = new File({ history: [val] }); expect(file.path).toEqual(val); expect(file.history).toEqual([val]); done(); }); it('sets stat', function(done) { - var val = {}; - var file = new File({ stat: val as any as fs.Stats }); + let val = {}; + let file = new File({ stat: val as any as fs.Stats }); expect(file.stat).toEqual(val); done(); }); it('sets contents', function(done) { - var val = new Buffer('test'); - var file = new File({ contents: val }); + let val = new Buffer('test'); + let file = new File({ contents: val }); expect(file.contents).toEqual(val); done(); }); it('sets custom properties', function(done) { - var sourceMap = {}; - var file = new File({ sourceMap: sourceMap }) as TestFile; + let sourceMap = {}; + let file = new File({ sourceMap }) as TestFile; expect(file.sourceMap).toEqual(sourceMap); done(); }); it('normalizes path', function(done) { - var val = '/test/foo/../test.coffee'; - var expected = path.normalize(val); - var file = new File({ path: val }); + let val = '/test/foo/../test.coffee'; + let expected = path.normalize(val); + let file = new File({ path: val }); expect(file.path).toEqual(expected); expect(file.history).toEqual([expected]); done(); }); it('normalizes and removes trailing separator from path', function(done) { - var val = '/test/foo/../foo/'; - var expected = path.normalize(val.slice(0, -1)); - var file = new File({ path: val }); + let val = '/test/foo/../foo/'; + let expected = path.normalize(val.slice(0, -1)); + let file = new File({ path: val }); expect(file.path).toEqual(expected); done(); }); it('normalizes history', function(done) { - var val = [ + let val = [ '/test/bar/../bar/test.coffee', '/test/foo/../test.coffee', ]; - var expected = val.map(function(p) { + let expected = val.map(function(p) { return path.normalize(p); }); - var file = new File({ history: val }); + let file = new File({ history: val }); expect(file.path).toEqual(expected[1]); expect(file.history).toEqual(expected); done(); }); it('normalizes and removes trailing separator from history', function(done) { - var val = [ + let val = [ '/test/foo/../foo/', '/test/bar/../bar/', ]; - var expected = val.map(function(p) { + let expected = val.map(function(p) { return path.normalize(p.slice(0, -1)); }); - var file = new File({ history: val }); + let file = new File({ history: val }); expect(file.history).toEqual(expected); done(); }); it('appends path to history if both exist and different from last', function(done) { - var val = path.normalize('/test/baz/test.coffee'); - var history = [ + let val = path.normalize('/test/baz/test.coffee'); + let history = [ path.normalize('/test/bar/test.coffee'), path.normalize('/test/foo/test.coffee'), ]; - var file = new File({ path: val, history: history }); + let file = new File({ path: val, history }); - var expectedHistory = history.concat(val); + let expectedHistory = history.concat(val); expect(file.path).toEqual(val); expect(file.history).toEqual(expectedHistory); @@ -246,13 +246,13 @@ describe('File', function() { }); it('does not append path to history if both exist and same as last', function(done) { - var val = path.normalize('/test/baz/test.coffee'); - var history = [ + let val = path.normalize('/test/baz/test.coffee'); + let history = [ path.normalize('/test/bar/test.coffee'), path.normalize('/test/foo/test.coffee'), val, ]; - var file = new File({ path: val, history: history }); + let file = new File({ path: val, history }); expect(file.path).toEqual(val); expect(file.history).toEqual(history); @@ -260,15 +260,15 @@ describe('File', function() { }); it('does not mutate history array passed in', function(done) { - var val = path.normalize('/test/baz/test.coffee'); - var history = [ + let val = path.normalize('/test/baz/test.coffee'); + let history = [ path.normalize('/test/bar/test.coffee'), path.normalize('/test/foo/test.coffee'), ]; - var historyCopy = Array.prototype.slice.call(history); - var file = new File({ path: val, history: history }); + let historyCopy = Array.prototype.slice.call(history); + let file = new File({ path: val, history }); - var expectedHistory = history.concat(val); + let expectedHistory = history.concat(val); expect(file.path).toEqual(val); expect(file.history).toEqual(expectedHistory); @@ -279,21 +279,21 @@ describe('File', function() { describe('isBuffer()', function() { it('returns true when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var file = new File({ contents: val }); + let val = new Buffer('test'); + let file = new File({ contents: val }); expect(file.isBuffer()).toEqual(true); done(); }); it('returns false when the contents are a Stream', function(done) { - var val = from([]); - var file = new File({ contents: val }); + let val = from([]); + let file = new File({ contents: val }); expect(file.isBuffer()).toEqual(false); done(); }); it('returns false when the contents are null', function(done) { - var file = new File({ contents: null }); + let file = new File({ contents: null }); expect(file.isBuffer()).toEqual(false); done(); }); @@ -301,21 +301,21 @@ describe('File', function() { describe('isStream()', function() { it('returns false when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var file = new File({ contents: val }); + let val = new Buffer('test'); + let file = new File({ contents: val }); expect(file.isStream()).toEqual(false); done(); }); it('returns true when the contents are a Stream', function(done) { - var val = from([]); - var file = new File({ contents: val }); + let val = from([]); + let file = new File({ contents: val }); expect(file.isStream()).toEqual(true); done(); }); it('returns false when the contents are null', function(done) { - var file = new File({ contents: null }); + let file = new File({ contents: null }); expect(file.isStream()).toEqual(false); done(); }); @@ -323,101 +323,101 @@ describe('File', function() { describe('isNull()', function() { it('returns false when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var file = new File({ contents: val }); + let val = new Buffer('test'); + let file = new File({ contents: val }); expect(file.isNull()).toEqual(false); done(); }); it('returns false when the contents are a Stream', function(done) { - var val = from([]); - var file = new File({ contents: val }); + let val = from([]); + let file = new File({ contents: val }); expect(file.isNull()).toEqual(false); done(); }); it('returns true when the contents are null', function(done) { - var file = new File({ contents: null }); + let file = new File({ contents: null }); expect(file.isNull()).toEqual(true); done(); }); }); describe('isDirectory()', function() { - var fakeStat = { - isDirectory: function() { + let fakeStat = { + isDirectory() { return true; }, } as any as fs.Stats; it('returns false when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var file = new File({ contents: val, stat: fakeStat }); + let val = new Buffer('test'); + let file = new File({ contents: val, stat: fakeStat }); expect(file.isDirectory()).toEqual(false); done(); }); it('returns false when the contents are a Stream', function(done) { - var val = from([]); - var file = new File({ contents: val, stat: fakeStat }); + let val = from([]); + let file = new File({ contents: val, stat: fakeStat }); expect(file.isDirectory()).toEqual(false); done(); }); it('returns true when the contents are null & stat.isDirectory is true', function(done) { - var file = new File({ contents: null, stat: fakeStat }); + let file = new File({ contents: null, stat: fakeStat }); expect(file.isDirectory()).toEqual(true); done(); }); it('returns false when stat exists but does not contain an isDirectory method', function(done) { - var file = new File({ contents: null, stat: {} as any as fs.Stats }); + let file = new File({ contents: null, stat: {} as any as fs.Stats }); expect(file.isDirectory()).toEqual(false); done(); }); it('returns false when stat does not exist', function(done) { - var file = new File({ contents: null }); + let file = new File({ contents: null }); expect(file.isDirectory()).toEqual(false); done(); }); }); describe('isSymbolic()', function() { - var fakeStat = { - isSymbolicLink: function() { + let fakeStat = { + isSymbolicLink() { return true; }, } as any as fs.Stats; it('returns false when the contents are a Buffer', function(done) { - var val = new Buffer('test'); - var file = new File({ contents: val, stat: fakeStat }); + let val = new Buffer('test'); + let file = new File({ contents: val, stat: fakeStat }); expect(file.isSymbolic()).toEqual(false); done(); }); it('returns false when the contents are a Stream', function(done) { - var val = from([]); - var file = new File({ contents: val, stat: fakeStat }); + let val = from([]); + let file = new File({ contents: val, stat: fakeStat }); expect(file.isSymbolic()).toEqual(false); done(); }); it('returns true when the contents are null & stat.isSymbolicLink is true', function(done) { - var file = new File({ contents: null, stat: fakeStat }); + let file = new File({ contents: null, stat: fakeStat }); expect(file.isSymbolic()).toEqual(true); done(); }); it('returns false when stat exists but does not contain an isSymbolicLink method', function(done) { - var file = new File({ contents: null, stat: {} as any as fs.Stats }); + let file = new File({ contents: null, stat: {} as any as fs.Stats }); expect(file.isSymbolic()).toEqual(false); done(); }); it('returns false when stat does not exist', function(done) { - var file = new File({ contents: null }); + let file = new File({ contents: null }); expect(file.isSymbolic()).toEqual(false); done(); }); @@ -425,14 +425,14 @@ describe('File', function() { describe('clone()', function() { it('copies all attributes over with Buffer contents', function(done) { - var options = { + let options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: new Buffer('test'), }; - var file = new File(options); - var file2 = file.clone(); + let file = new File(options); + let file2 = file.clone(); expect(file2).toNotBe(file); expect(file2.cwd).toEqual(file.cwd); @@ -444,18 +444,18 @@ describe('File', function() { }); it('assigns Buffer content reference when contents option is false', function(done) { - var options = { + let options = { cwd: '/', base: '/test/', path: '/test/test.js', contents: new Buffer('test'), }; - var file = new File(options); + let file = new File(options); - var copy1 = file.clone({ contents: false }); + let copy1 = file.clone({ contents: false }); expect(copy1.contents).toBe(file.contents); - var copy2 = file.clone(); + let copy2 = file.clone(); expect(copy2.contents).toNotBe(file.contents); // TypeScript: expected compilation error @@ -465,14 +465,14 @@ describe('File', function() { }); it('copies all attributes over with Stream contents', function(done) { - var options = { + let options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: from(['wa', 'dup']), }; - var file = new File(options); - var file2 = file.clone(); + let file = new File(options); + let file2 = file.clone(); expect(file2).toNotBe(file); expect(file2.cwd).toEqual(file.cwd); @@ -480,9 +480,9 @@ describe('File', function() { expect(file2.path).toEqual(file.path); expect(file2.contents).toNotBe(file.contents); - var ends = 2; - var data: Buffer; - var data2: Buffer; + let ends = 2; + let data: Buffer; + let data2: Buffer; function assert(err: any) { if (err) { @@ -513,18 +513,18 @@ describe('File', function() { }); it('does not start flowing until all clones flows (data)', function(done) { - var options = { + let options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: from(['wa', 'dup']), }; - var file = new File(options); - var file2 = file.clone(); - var ends = 2; + let file = new File(options); + let file2 = file.clone(); + let ends = 2; - var data = ''; - var data2 = ''; + let data = ''; + let data2 = ''; function assert() { if (--ends === 0) { @@ -554,16 +554,16 @@ describe('File', function() { }); it('does not start flowing until all clones flows (readable)', function(done) { - var options = { + let options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: from(['wa', 'dup']), }; - var file = new File(options); - var file2 = file.clone(); + let file = new File(options); + let file2 = file.clone(); - var data2 = ''; + let data2 = ''; function assert(data: Buffer) { expect(data.toString('utf8')).toEqual(data2); @@ -571,7 +571,7 @@ describe('File', function() { // Start flowing file2 file2.contents.on('readable', function(this: NodeJS.ReadableStream) { - var chunk: string | Buffer; + let chunk: string | Buffer; while ((chunk = this.read()) !== null) { data2 += chunk.toString(); } @@ -584,14 +584,14 @@ describe('File', function() { }); it('copies all attributes over with null contents', function(done) { - var options = { + let options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: null, }; - var file = new File(options); - var file2 = file.clone(); + let file = new File(options); + let file2 = file.clone(); expect(file2).toNotBe(file); expect(file2.cwd).toEqual(file.cwd); @@ -602,7 +602,7 @@ describe('File', function() { }); it('properly clones the `stat` property', function(done) { - var options = { + let options = { cwd: '/', base: '/test/', path: '/test/test.js', @@ -610,8 +610,8 @@ describe('File', function() { stat: fs.statSync(__filename), }; - var file = new File(options); - var copy = file.clone(); + let file = new File(options); + let copy = file.clone(); expect(copy.stat).toExist(); if (copy.stat != null) { @@ -624,15 +624,15 @@ describe('File', function() { }); it('properly clones the `history` property', function(done) { - var options = { + let options = { cwd: path.normalize('/'), base: path.normalize('/test/'), path: path.normalize('/test/test.js'), contents: new Buffer('test'), }; - var file = new File(options); - var copy = file.clone(); + let file = new File(options); + let copy = file.clone(); expect(copy.history[0]).toEqual(options.path); copy.path = 'lol'; @@ -641,7 +641,7 @@ describe('File', function() { }); it('copies custom properties', function(done) { - var options = { + let options = { cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -649,8 +649,8 @@ describe('File', function() { custom: { meta: {} }, }; - var file = new File(options) as TestFile; - var file2 = file.clone(); + let file = new File(options) as TestFile; + let file2 = file.clone(); expect(file2).toNotBe(file); expect(file2.cwd).toEqual(file.cwd); @@ -663,22 +663,22 @@ describe('File', function() { }); it('copies history', function(done) { - var options = { + let options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: null, }; - var history = [ + let history = [ path.normalize('/test/test.coffee'), path.normalize('/test/test.js'), path.normalize('/test/test-938di2s.js'), ]; - var file = new File(options); + let file = new File(options); file.path = history[1]; file.path = history[2]; - var file2 = file.clone(); + let file2 = file.clone(); expect(file2.history).toEqual(history); expect(file2.history).toNotBe(file.history); @@ -687,7 +687,7 @@ describe('File', function() { }); it('supports deep & shallow copy of all attributes', function(done) { - var options = { + let options = { cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -695,33 +695,33 @@ describe('File', function() { custom: { meta: {} }, }; - var file = new File(options) as TestFile; + let file = new File(options) as TestFile; - var file2 = file.clone(); + let file2 = file.clone(); expect(file2.custom).toEqual(file.custom); expect(file2.custom).toNotBe(file.custom); expect(file2.custom.meta).toEqual(file.custom.meta); expect(file2.custom.meta).toNotBe(file.custom.meta); - var file3 = file.clone(true); + let file3 = file.clone(true); expect(file3.custom).toEqual(file.custom); expect(file3.custom).toNotBe(file.custom); expect(file3.custom.meta).toEqual(file.custom.meta); expect(file3.custom.meta).toNotBe(file.custom.meta); - var file4 = file.clone({ deep: true }); + let file4 = file.clone({ deep: true }); expect(file4.custom).toEqual(file.custom); expect(file4.custom).toNotBe(file.custom); expect(file4.custom.meta).toEqual(file.custom.meta); expect(file4.custom.meta).toNotBe(file.custom.meta); - var file5 = file.clone(false); + let file5 = file.clone(false); expect(file5.custom).toEqual(file.custom); expect(file5.custom).toBe(file.custom); expect(file5.custom.meta).toEqual(file.custom.meta); expect(file5.custom.meta).toBe(file.custom.meta); - var file6 = file.clone({ deep: false }); + let file6 = file.clone({ deep: false }); expect(file6.custom).toEqual(file.custom); expect(file6.custom).toBe(file.custom); expect(file6.custom.meta).toEqual(file.custom.meta); @@ -749,21 +749,21 @@ describe('File', function() { describe('inspect()', function() { it('returns correct format when no contents and no path', function(done) { - var file = new File(); + let file = new File(); expect(file.inspect()).toEqual(''); done(); }); it('returns correct format when Buffer contents and no path', function(done) { - var val = new Buffer('test'); - var file = new File({ contents: val }); + let val = new Buffer('test'); + let file = new File({ contents: val }); expect(file.inspect()).toEqual('>'); done(); }); it('returns correct format when Buffer contents and relative path', function(done) { - var val = new Buffer('test'); - var file = new File({ + let val = new Buffer('test'); + let file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -774,7 +774,7 @@ describe('File', function() { }); it('returns correct format when Stream contents and relative path', function(done) { - var file = new File({ + let file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -785,7 +785,7 @@ describe('File', function() { }); it('returns correct format when null contents and relative path', function(done) { - var file = new File({ + let file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -798,49 +798,49 @@ describe('File', function() { describe('contents get/set', function() { it('returns _contents', function(done) { - var val = new Buffer('test'); - var file = new File() as TestFile; + let val = new Buffer('test'); + let file = new File() as TestFile; file._contents = val; expect(file.contents).toEqual(val); done(); }); it('sets _contents', function(done) { - var val = new Buffer('test'); - var file = new File() as TestFile; + let val = new Buffer('test'); + let file = new File() as TestFile; file.contents = val; expect(file._contents).toEqual(val); done(); }); it('sets a Buffer', function(done) { - var val = new Buffer('test'); - var file = new File(); + let val = new Buffer('test'); + let file = new File(); file.contents = val; expect(file.contents).toEqual(val); done(); }); it('wraps Stream in Cloneable', function(done) { - var val = from([]); - var file = new File(); + let val = from([]); + let file = new File(); file.contents = val; expect(isCloneable(file.contents)).toEqual(true); done(); }); it('does not double wrap a Cloneable', function(done) { - var val = from([]); - var clone = cloneable(val); - var file = new File(); + let val = from([]); + let clone = cloneable(val); + let file = new File(); file.contents = clone; expect((file.contents as any)._original).toBe(val); done(); }); it('sets null', function(done) { - var val = null; - var file = new File(); + let val = null; + let file = new File(); file.contents = val; expect(file.contents).toEqual(null); done(); @@ -860,32 +860,32 @@ describe('File', function() { describe('cwd get/set', function() { it('returns _cwd', function(done) { - var val = '/test'; - var file = new File() as TestFile; + let val = '/test'; + let file = new File() as TestFile; file._cwd = val; expect(file.cwd).toEqual(val); done(); }); it('sets _cwd', function(done) { - var val = '/test'; - var file = new File() as TestFile; + let val = '/test'; + let file = new File() as TestFile; file.cwd = val; expect(file._cwd).toEqual(path.normalize(val)); done(); }); it('normalizes and removes trailing separator on set', function(done) { - var val = '/test/foo/../foo/'; - var expected = path.normalize(val.slice(0, -1)); - var file = new File(); + let val = '/test/foo/../foo/'; + let expected = path.normalize(val.slice(0, -1)); + let file = new File(); file.cwd = val; expect(file.cwd).toEqual(expected); - var val2 = '\\test\\foo\\..\\foo\\'; - var expected2 = path.normalize(isWin ? val2.slice(0, -1) : val2); + let val2 = '\\test\\foo\\..\\foo\\'; + let expected2 = path.normalize(isWin ? val2.slice(0, -1) : val2); file.cwd = val2; @@ -922,20 +922,20 @@ describe('File', function() { describe('base get/set', function() { it('proxies cwd when omitted', function(done) { - var file = new File({ cwd: '/test' }); + let file = new File({ cwd: '/test' }); expect(file.base).toEqual(file.cwd); done(); }); it('proxies cwd when same', function(done) { - var file = new File({ + let file = new File({ cwd: '/test', base: '/test', }); file.cwd = '/foo/'; expect(file.base).toEqual(file.cwd); - var file2 = new File({ + let file2 = new File({ cwd: '/test', }); file2.base = '/test/'; @@ -961,32 +961,32 @@ describe('File', function() { // }); it('returns _base', function(done) { - var val = '/test/'; - var file = new File() as TestFile; + let val = '/test/'; + let file = new File() as TestFile; file._base = val; expect(file.base).toEqual(val); done(); }); it('sets _base', function(done) { - var val = '/test/foo'; - var file = new File() as TestFile; + let val = '/test/foo'; + let file = new File() as TestFile; file.base = val; expect(file._base).toEqual(path.normalize(val)); done(); }); it('normalizes and removes trailing separator on set', function(done) { - var val = '/test/foo/../foo/'; - var expected = path.normalize(val.slice(0, -1)); - var file = new File(); + let val = '/test/foo/../foo/'; + let expected = path.normalize(val.slice(0, -1)); + let file = new File(); file.base = val; expect(file.base).toEqual(expected); - var val2 = '\\test\\foo\\..\\foo\\'; - var expected2 = path.normalize(isWin ? val2.slice(0, -1) : val2); + let val2 = '\\test\\foo\\..\\foo\\'; + let expected2 = path.normalize(isWin ? val2.slice(0, -1) : val2); file.base = val2; @@ -1022,7 +1022,7 @@ describe('File', function() { describe('relative get/set', function() { it('throws on set', function(done) { - var file = new File(); + let file = new File(); function invalid() { file.relative = 'test'; @@ -1033,7 +1033,7 @@ describe('File', function() { }); it('throws on get with no path', function(done) { - var file = new File(); + let file = new File(); function invalid() { file.relative; @@ -1044,7 +1044,7 @@ describe('File', function() { }); it('returns a relative path from base', function(done) { - var file = new File({ + let file = new File({ base: '/test/', path: '/test/test.coffee', }); @@ -1054,7 +1054,7 @@ describe('File', function() { }); it('returns a relative path from cwd', function(done) { - var file = new File({ + let file = new File({ cwd: '/', path: '/test/test.coffee', }); @@ -1064,11 +1064,11 @@ describe('File', function() { }); it('does not append separator when directory', function(done) { - var file = new File({ + let file = new File({ base: '/test', path: '/test/foo/bar', stat: { - isDirectory: function() { + isDirectory() { return true; }, } as any as fs.Stats, @@ -1079,11 +1079,11 @@ describe('File', function() { }); it('does not append separator when symlink', function(done) { - var file = new File({ + let file = new File({ base: '/test', path: '/test/foo/bar', stat: { - isSymbolicLink: function() { + isSymbolicLink() { return true; }, } as any as fs.Stats, @@ -1094,14 +1094,14 @@ describe('File', function() { }); it('does not append separator when directory & symlink', function(done) { - var file = new File({ + let file = new File({ base: '/test', path: '/test/foo/bar', stat: { - isDirectory: function() { + isDirectory() { return true; }, - isSymbolicLink: function() { + isSymbolicLink() { return true; }, } as any as fs.Stats, @@ -1114,7 +1114,7 @@ describe('File', function() { describe('dirname get/set', function() { it('throws on get with no path', function(done) { - var file = new File(); + let file = new File(); function invalid() { file.dirname; @@ -1125,7 +1125,7 @@ describe('File', function() { }); it('returns the dirname without trailing separator', function(done) { - var file = new File({ + let file = new File({ cwd: '/', base: '/test', path: '/test/test.coffee', @@ -1136,7 +1136,7 @@ describe('File', function() { }); it('throws on set with no path', function(done) { - var file = new File(); + let file = new File(); function invalid() { file.dirname = '/test'; @@ -1147,7 +1147,7 @@ describe('File', function() { }); it('replaces the dirname of the path', function(done) { - var file = new File({ + let file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1161,7 +1161,7 @@ describe('File', function() { describe('basename get/set', function() { it('throws on get with no path', function(done) { - var file = new File(); + let file = new File(); function invalid() { return file.basename; @@ -1172,7 +1172,7 @@ describe('File', function() { }); it('returns the basename of the path', function(done) { - var file = new File({ + let file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1183,10 +1183,10 @@ describe('File', function() { }); it('does not append trailing separator when directory', function(done) { - var file = new File({ + let file = new File({ path: '/test/foo', stat: { - isDirectory: function() { + isDirectory() { return true; }, } as any as fs.Stats, @@ -1197,10 +1197,10 @@ describe('File', function() { }); it('does not append trailing separator when symlink', function(done) { - var file = new File({ + let file = new File({ path: '/test/foo', stat: { - isSymbolicLink: function() { + isSymbolicLink() { return true; }, } as any as fs.Stats, @@ -1211,13 +1211,13 @@ describe('File', function() { }); it('does not append trailing separator when directory & symlink', function(done) { - var file = new File({ + let file = new File({ path: '/test/foo', stat: { - isDirectory: function() { + isDirectory() { return true; }, - isSymbolicLink: function() { + isSymbolicLink() { return true; }, } as any as fs.Stats, @@ -1228,7 +1228,7 @@ describe('File', function() { }); it('removes trailing separator', function(done) { - var file = new File({ + let file = new File({ path: '/test/foo/', }); @@ -1237,10 +1237,10 @@ describe('File', function() { }); it('removes trailing separator when directory', function(done) { - var file = new File({ + let file = new File({ path: '/test/foo/', stat: { - isDirectory: function() { + isDirectory() { return true; }, } as any as fs.Stats, @@ -1251,10 +1251,10 @@ describe('File', function() { }); it('removes trailing separator when symlink', function(done) { - var file = new File({ + let file = new File({ path: '/test/foo/', stat: { - isSymbolicLink: function() { + isSymbolicLink() { return true; }, } as any as fs.Stats, @@ -1265,13 +1265,13 @@ describe('File', function() { }); it('removes trailing separator when directory & symlink', function(done) { - var file = new File({ + let file = new File({ path: '/test/foo/', stat: { - isDirectory: function() { + isDirectory() { return true; }, - isSymbolicLink: function() { + isSymbolicLink() { return true; }, } as any as fs.Stats, @@ -1282,7 +1282,7 @@ describe('File', function() { }); it('throws on set with no path', function(done) { - var file = new File(); + let file = new File(); function invalid() { file.basename = 'test.coffee'; @@ -1293,7 +1293,7 @@ describe('File', function() { }); it('replaces the basename of the path', function(done) { - var file = new File({ + let file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1307,7 +1307,7 @@ describe('File', function() { describe('stem get/set', function() { it('throws on get with no path', function(done) { - var file = new File(); + let file = new File(); function invalid() { file.stem; @@ -1318,7 +1318,7 @@ describe('File', function() { }); it('returns the stem of the path', function(done) { - var file = new File({ + let file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1329,7 +1329,7 @@ describe('File', function() { }); it('throws on set with no path', function(done) { - var file = new File(); + let file = new File(); function invalid() { file.stem = 'test.coffee'; @@ -1340,7 +1340,7 @@ describe('File', function() { }); it('replaces the stem of the path', function(done) { - var file = new File({ + let file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1354,7 +1354,7 @@ describe('File', function() { describe('extname get/set', function() { it('throws on get with no path', function(done) { - var file = new File(); + let file = new File(); function invalid() { file.extname; @@ -1365,7 +1365,7 @@ describe('File', function() { }); it('returns the extname of the path', function(done) { - var file = new File({ + let file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1376,7 +1376,7 @@ describe('File', function() { }); it('throws on set with no path', function(done) { - var file = new File(); + let file = new File(); function invalid() { file.extname = '.coffee'; @@ -1387,7 +1387,7 @@ describe('File', function() { }); it('replaces the extname of the path', function(done) { - var file = new File({ + let file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1401,11 +1401,11 @@ describe('File', function() { describe('path get/set', function() { it('records path in history upon instantiation', function(done) { - var file = new File({ + let file = new File({ cwd: '/', path: '/test/test.coffee', }); - var history = [ + let history = [ path.normalize('/test/test.coffee'), ]; @@ -1415,12 +1415,12 @@ describe('File', function() { }); it('records path in history when set', function(done) { - var val = path.normalize('/test/test.js'); - var file = new File({ + let val = path.normalize('/test/test.js'); + let file = new File({ cwd: '/', path: '/test/test.coffee', }); - var history = [ + let history = [ path.normalize('/test/test.coffee'), val, ]; @@ -1429,7 +1429,7 @@ describe('File', function() { expect(file.path).toEqual(val); expect(file.history).toEqual(history); - var val2 = path.normalize('/test/test.es6'); + let val2 = path.normalize('/test/test.es6'); history.push(val2); file.path = val2; @@ -1439,12 +1439,12 @@ describe('File', function() { }); it('does not record path in history when set to the current path', function(done) { - var val = path.normalize('/test/test.coffee'); - var file = new File({ + let val = path.normalize('/test/test.coffee'); + let file = new File({ cwd: '/', path: val, }); - var history = [ + let history = [ val, ]; @@ -1456,12 +1456,12 @@ describe('File', function() { }); it('does not record path in history when set to empty string', function(done) { - var val = path.normalize('/test/test.coffee'); - var file = new File({ + let val = path.normalize('/test/test.coffee'); + let file = new File({ cwd: '/', path: val, }); - var history = [ + let history = [ val, ]; @@ -1487,9 +1487,9 @@ describe('File', function() { // }); it('normalizes the path upon set', function(done) { - var val = '/test/foo/../test.coffee'; - var expected = path.normalize(val); - var file = new File(); + let val = '/test/foo/../test.coffee'; + let expected = path.normalize(val); + let file = new File(); file.path = val; @@ -1499,7 +1499,7 @@ describe('File', function() { }); it('removes the trailing separator upon set', function(done) { - var file = new File(); + let file = new File(); file.path = '/test/'; expect(file.path).toEqual(path.normalize('/test')); @@ -1508,9 +1508,9 @@ describe('File', function() { }); it('removes the trailing separator upon set when directory', function(done) { - var file = new File({ + let file = new File({ stat: { - isDirectory: function() { + isDirectory() { return true; }, } as any as fs.Stats, @@ -1523,9 +1523,9 @@ describe('File', function() { }); it('removes the trailing separator upon set when symlink', function(done) { - var file = new File({ + let file = new File({ stat: { - isSymbolicLink: function() { + isSymbolicLink() { return true; }, } as any as fs.Stats, @@ -1538,12 +1538,12 @@ describe('File', function() { }); it('removes the trailing separator upon set when directory & symlink', function(done) { - var file = new File({ + let file = new File({ stat: { - isDirectory: function() { + isDirectory() { return true; }, - isSymbolicLink: function() { + isSymbolicLink() { return true; }, } as any as fs.Stats, @@ -1558,15 +1558,15 @@ describe('File', function() { describe('symlink get/set', function() { it('return null on get with no symlink', function(done) { - var file = new File(); + let file = new File(); expect(file.symlink).toEqual(null); done(); }); it('returns _symlink', function(done) { - var val = '/test/test.coffee'; - var file = new File() as TestFile; + let val = '/test/test.coffee'; + let file = new File() as TestFile; file._symlink = val; expect(file.symlink).toEqual(val); @@ -1574,7 +1574,7 @@ describe('File', function() { }); it('throws on set with non-string', function(done) { - var file = new File(); + let file = new File(); function invalid() { file.symlink = null; @@ -1585,9 +1585,9 @@ describe('File', function() { }); it('sets _symlink', function(done) { - var val = '/test/test.coffee'; - var expected = path.normalize(val); - var file = new File() as TestFile; + let val = '/test/test.coffee'; + let expected = path.normalize(val); + let file = new File() as TestFile; file.symlink = val; expect(file._symlink).toEqual(expected); @@ -1595,8 +1595,8 @@ describe('File', function() { }); it('allows relative symlink', function(done) { - var val = 'test.coffee'; - var file = new File(); + let val = 'test.coffee'; + let file = new File(); file.symlink = val; expect(file.symlink).toEqual(val); @@ -1604,9 +1604,9 @@ describe('File', function() { }); it('normalizes and removes trailing separator upon set', function(done) { - var val = '/test/foo/../bar/'; - var expected = path.normalize(val.slice(0, -1)); - var file = new File(); + let val = '/test/foo/../bar/'; + let expected = path.normalize(val.slice(0, -1)); + let file = new File(); file.symlink = val; expect(file.symlink).toEqual(expected); From 73009cc2d0d42b003c516b9f93d7833e024efa89 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 10:26:43 +0900 Subject: [PATCH 178/298] cleanup ignore lint error: dt-header --- types/vinyl/index.d.ts | 2 +- types/vinyl/tslint.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/types/vinyl/index.d.ts b/types/vinyl/index.d.ts index 5239147517..c62007372e 100644 --- a/types/vinyl/index.d.ts +++ b/types/vinyl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for vinyl 2.0.0 +// Type definitions for vinyl 2.0 // Project: https://github.com/gulpjs/vinyl // Definitions by: vvakame , jedmao , Georgii Dolzhykov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/vinyl/tslint.json b/types/vinyl/tslint.json index 4c5f80b2f4..7f4748eed0 100644 --- a/types/vinyl/tslint.json +++ b/types/vinyl/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "dt-header": false, "no-conditional-assignment": false, "no-construct": false, "no-var-requires": false, From 137b307a9784df62baca0c902c8add23cb161af3 Mon Sep 17 00:00:00 2001 From: Syahmi Azhar Date: Fri, 15 Dec 2017 09:28:12 +0800 Subject: [PATCH 179/298] uws: Added missing arguments signature --- types/uws/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/uws/index.d.ts b/types/uws/index.d.ts index 89578fc22d..6072c41534 100644 --- a/types/uws/index.d.ts +++ b/types/uws/index.d.ts @@ -56,7 +56,7 @@ declare class WebSocket extends events.EventEmitter { }) => void): void; addEventListener(method: 'error', cb?: (err: Error) => void): void; addEventListener(method: 'open', cb?: (event: { target: WebSocket }) => void): void; - addEventListener(method: string, listener?: () => void): void; + addEventListener(method: string, listener?: (...args: any[]) => void): void; // Events on(event: 'error', cb: (err: Error) => void): this; @@ -65,7 +65,7 @@ declare class WebSocket extends events.EventEmitter { on(event: 'ping', cb: (data: any, flags: { binary: boolean }) => void): this; on(event: 'pong', cb: (data: any, flags: { binary: boolean }) => void): this; on(event: 'open', cb: () => void): this; - on(event: string, listener: () => void): this; + on(event: string, listener: (...args: any[]) => void): this; addListener(event: 'error', cb: (err: Error) => void): this; addListener(event: 'close', cb: (code: number, message: string) => void): this; @@ -73,7 +73,7 @@ declare class WebSocket extends events.EventEmitter { addListener(event: 'ping', cb: (data: any, flags: { binary: boolean }) => void): this; addListener(event: 'pong', cb: (data: any, flags: { binary: boolean }) => void): this; addListener(event: 'open', cb: () => void): this; - addListener(event: string, listener: () => void): this; + addListener(event: string, listener: (...args: any[]) => void): this; } declare namespace WebSocket { @@ -142,12 +142,12 @@ declare namespace WebSocket { on(event: 'error', cb: (err: Error) => void): this; on(event: 'headers', cb: (headers: string[]) => void): this; on(event: 'connection', cb: (client: WebSocket) => void): this; - on(event: string, listener: () => void): this; + on(event: string, listener: (...args: any[]) => void): this; addListener(event: 'error', cb: (err: Error) => void): this; addListener(event: 'headers', cb: (headers: string[]) => void): this; addListener(event: 'connection', cb: (client: WebSocket) => void): this; - addListener(event: string, listener: () => void): this; + addListener(event: string, listener: (...args: any[]) => void): this; } export interface UwsHttp { From e54a57b93c856a76f1ad04a9bac323e2fac065de Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 10:31:16 +0900 Subject: [PATCH 180/298] cleanup ignore lint error: only-arrow-functions --- types/vinyl/tslint.json | 1 - types/vinyl/vinyl-tests.ts | 304 ++++++++++++++++++------------------- 2 files changed, 152 insertions(+), 153 deletions(-) diff --git a/types/vinyl/tslint.json b/types/vinyl/tslint.json index 7f4748eed0..c8b1832546 100644 --- a/types/vinyl/tslint.json +++ b/types/vinyl/tslint.json @@ -4,7 +4,6 @@ "no-conditional-assignment": false, "no-construct": false, "no-var-requires": false, - "only-arrow-functions": false, "prefer-const": false } } diff --git a/types/vinyl/vinyl-tests.ts b/types/vinyl/vinyl-tests.ts index 079588a4e7..b3f3be868f 100644 --- a/types/vinyl/vinyl-tests.ts +++ b/types/vinyl/vinyl-tests.ts @@ -31,46 +31,46 @@ let isCloneable: (obj: any) => boolean = cloneable.isCloneable; let isWin = (process.platform === 'win32'); -describe('File', function() { - describe('isVinyl()', function() { - it('returns true for a Vinyl object', function(done) { +describe('File', () => { + describe('isVinyl()', () => { + it('returns true for a Vinyl object', done => { let file = new File(); let result = File.isVinyl(file); expect(result).toEqual(true); done(); }); - it('returns false for a normal object', function(done) { + it('returns false for a normal object', done => { let result = File.isVinyl({}); expect(result).toEqual(false); done(); }); - it('returns false for null', function(done) { + it('returns false for null', done => { let result = File.isVinyl(null); expect(result).toEqual(false); done(); }); - it('returns false for a string', function(done) { + it('returns false for a string', done => { let result = File.isVinyl('foobar'); expect(result).toEqual(false); done(); }); - it('returns false for a String object', function(done) { + it('returns false for a String object', done => { let result = File.isVinyl(new String('foobar')); expect(result).toEqual(false); done(); }); - it('returns false for a number', function(done) { + it('returns false for a number', done => { let result = File.isVinyl(1); expect(result).toEqual(false); done(); }); - it('returns false for a Number object', function(done) { + it('returns false for a Number object', done => { let result = File.isVinyl(new Number(1)); expect(result).toEqual(false); done(); @@ -79,54 +79,54 @@ describe('File', function() { // This is based on current implementation // A test was added to document and make aware during internal changes // TODO: decide if this should be leak-able - it('returns true for a mocked object', function(done) { + it('returns true for a mocked object', done => { let result = File.isVinyl({ _isVinyl: true }); expect(result).toEqual(true); done(); }); }); - describe('defaults', function() { - it('defaults cwd to process.cwd', function(done) { + describe('defaults', () => { + it('defaults cwd to process.cwd', done => { let file = new File(); expect(file.cwd).toEqual(process.cwd()); done(); }); - it('defaults base to process.cwd', function(done) { + it('defaults base to process.cwd', done => { let file = new File(); expect(file.base).toEqual(process.cwd()); done(); }); - it('defaults base to cwd property', function(done) { + it('defaults base to cwd property', done => { let cwd = path.normalize('/'); let file = new File({ cwd }); expect(file.base).toEqual(cwd); done(); }); - it('defaults path to null', function(done) { + it('defaults path to null', done => { let file = new File(); expect(file.path).toNotExist(); expect(file.path).toEqual(null); done(); }); - it('defaults history to an empty array', function(done) { + it('defaults history to an empty array', done => { let file = new File(); expect(file.history).toEqual([]); done(); }); - it('defaults stat to null', function(done) { + it('defaults stat to null', done => { let file = new File(); expect(file.stat).toNotExist(); expect(file.stat).toEqual(null); done(); }); - it('defaults contents to null', function(done) { + it('defaults contents to null', done => { let file = new File(); expect(file.contents).toNotExist(); expect(file.contents).toEqual(null); @@ -134,22 +134,22 @@ describe('File', function() { }); }); - describe('constructor()', function() { - it('sets base', function(done) { + describe('constructor()', () => { + it('sets base', done => { let val = path.normalize('/'); let file = new File({ base: val }); expect(file.base).toEqual(val); done(); }); - it('sets cwd', function(done) { + it('sets cwd', done => { let val = path.normalize('/'); let file = new File({ cwd: val }); expect(file.cwd).toEqual(val); done(); }); - it('sets path (and history)', function(done) { + it('sets path (and history)', done => { let val = path.normalize('/test.coffee'); let file = new File({ path: val }); expect(file.path).toEqual(val); @@ -157,7 +157,7 @@ describe('File', function() { done(); }); - it('sets history (and path)', function(done) { + it('sets history (and path)', done => { let val = path.normalize('/test.coffee'); let file = new File({ history: [val] }); expect(file.path).toEqual(val); @@ -165,28 +165,28 @@ describe('File', function() { done(); }); - it('sets stat', function(done) { + it('sets stat', done => { let val = {}; let file = new File({ stat: val as any as fs.Stats }); expect(file.stat).toEqual(val); done(); }); - it('sets contents', function(done) { + it('sets contents', done => { let val = new Buffer('test'); let file = new File({ contents: val }); expect(file.contents).toEqual(val); done(); }); - it('sets custom properties', function(done) { + it('sets custom properties', done => { let sourceMap = {}; let file = new File({ sourceMap }) as TestFile; expect(file.sourceMap).toEqual(sourceMap); done(); }); - it('normalizes path', function(done) { + it('normalizes path', done => { let val = '/test/foo/../test.coffee'; let expected = path.normalize(val); let file = new File({ path: val }); @@ -195,7 +195,7 @@ describe('File', function() { done(); }); - it('normalizes and removes trailing separator from path', function(done) { + it('normalizes and removes trailing separator from path', done => { let val = '/test/foo/../foo/'; let expected = path.normalize(val.slice(0, -1)); let file = new File({ path: val }); @@ -203,12 +203,12 @@ describe('File', function() { done(); }); - it('normalizes history', function(done) { + it('normalizes history', done => { let val = [ '/test/bar/../bar/test.coffee', '/test/foo/../test.coffee', ]; - let expected = val.map(function(p) { + let expected = val.map(p => { return path.normalize(p); }); let file = new File({ history: val }); @@ -217,12 +217,12 @@ describe('File', function() { done(); }); - it('normalizes and removes trailing separator from history', function(done) { + it('normalizes and removes trailing separator from history', done => { let val = [ '/test/foo/../foo/', '/test/bar/../bar/', ]; - let expected = val.map(function(p) { + let expected = val.map(p => { return path.normalize(p.slice(0, -1)); }); let file = new File({ history: val }); @@ -230,7 +230,7 @@ describe('File', function() { done(); }); - it('appends path to history if both exist and different from last', function(done) { + it('appends path to history if both exist and different from last', done => { let val = path.normalize('/test/baz/test.coffee'); let history = [ path.normalize('/test/bar/test.coffee'), @@ -245,7 +245,7 @@ describe('File', function() { done(); }); - it('does not append path to history if both exist and same as last', function(done) { + it('does not append path to history if both exist and same as last', done => { let val = path.normalize('/test/baz/test.coffee'); let history = [ path.normalize('/test/bar/test.coffee'), @@ -259,7 +259,7 @@ describe('File', function() { done(); }); - it('does not mutate history array passed in', function(done) { + it('does not mutate history array passed in', done => { let val = path.normalize('/test/baz/test.coffee'); let history = [ path.normalize('/test/bar/test.coffee'), @@ -277,154 +277,154 @@ describe('File', function() { }); }); - describe('isBuffer()', function() { - it('returns true when the contents are a Buffer', function(done) { + describe('isBuffer()', () => { + it('returns true when the contents are a Buffer', done => { let val = new Buffer('test'); let file = new File({ contents: val }); expect(file.isBuffer()).toEqual(true); done(); }); - it('returns false when the contents are a Stream', function(done) { + it('returns false when the contents are a Stream', done => { let val = from([]); let file = new File({ contents: val }); expect(file.isBuffer()).toEqual(false); done(); }); - it('returns false when the contents are null', function(done) { + it('returns false when the contents are null', done => { let file = new File({ contents: null }); expect(file.isBuffer()).toEqual(false); done(); }); }); - describe('isStream()', function() { - it('returns false when the contents are a Buffer', function(done) { + describe('isStream()', () => { + it('returns false when the contents are a Buffer', done => { let val = new Buffer('test'); let file = new File({ contents: val }); expect(file.isStream()).toEqual(false); done(); }); - it('returns true when the contents are a Stream', function(done) { + it('returns true when the contents are a Stream', done => { let val = from([]); let file = new File({ contents: val }); expect(file.isStream()).toEqual(true); done(); }); - it('returns false when the contents are null', function(done) { + it('returns false when the contents are null', done => { let file = new File({ contents: null }); expect(file.isStream()).toEqual(false); done(); }); }); - describe('isNull()', function() { - it('returns false when the contents are a Buffer', function(done) { + describe('isNull()', () => { + it('returns false when the contents are a Buffer', done => { let val = new Buffer('test'); let file = new File({ contents: val }); expect(file.isNull()).toEqual(false); done(); }); - it('returns false when the contents are a Stream', function(done) { + it('returns false when the contents are a Stream', done => { let val = from([]); let file = new File({ contents: val }); expect(file.isNull()).toEqual(false); done(); }); - it('returns true when the contents are null', function(done) { + it('returns true when the contents are null', done => { let file = new File({ contents: null }); expect(file.isNull()).toEqual(true); done(); }); }); - describe('isDirectory()', function() { + describe('isDirectory()', () => { let fakeStat = { isDirectory() { return true; }, } as any as fs.Stats; - it('returns false when the contents are a Buffer', function(done) { + it('returns false when the contents are a Buffer', done => { let val = new Buffer('test'); let file = new File({ contents: val, stat: fakeStat }); expect(file.isDirectory()).toEqual(false); done(); }); - it('returns false when the contents are a Stream', function(done) { + it('returns false when the contents are a Stream', done => { let val = from([]); let file = new File({ contents: val, stat: fakeStat }); expect(file.isDirectory()).toEqual(false); done(); }); - it('returns true when the contents are null & stat.isDirectory is true', function(done) { + it('returns true when the contents are null & stat.isDirectory is true', done => { let file = new File({ contents: null, stat: fakeStat }); expect(file.isDirectory()).toEqual(true); done(); }); - it('returns false when stat exists but does not contain an isDirectory method', function(done) { + it('returns false when stat exists but does not contain an isDirectory method', done => { let file = new File({ contents: null, stat: {} as any as fs.Stats }); expect(file.isDirectory()).toEqual(false); done(); }); - it('returns false when stat does not exist', function(done) { + it('returns false when stat does not exist', done => { let file = new File({ contents: null }); expect(file.isDirectory()).toEqual(false); done(); }); }); - describe('isSymbolic()', function() { + describe('isSymbolic()', () => { let fakeStat = { isSymbolicLink() { return true; }, } as any as fs.Stats; - it('returns false when the contents are a Buffer', function(done) { + it('returns false when the contents are a Buffer', done => { let val = new Buffer('test'); let file = new File({ contents: val, stat: fakeStat }); expect(file.isSymbolic()).toEqual(false); done(); }); - it('returns false when the contents are a Stream', function(done) { + it('returns false when the contents are a Stream', done => { let val = from([]); let file = new File({ contents: val, stat: fakeStat }); expect(file.isSymbolic()).toEqual(false); done(); }); - it('returns true when the contents are null & stat.isSymbolicLink is true', function(done) { + it('returns true when the contents are null & stat.isSymbolicLink is true', done => { let file = new File({ contents: null, stat: fakeStat }); expect(file.isSymbolic()).toEqual(true); done(); }); - it('returns false when stat exists but does not contain an isSymbolicLink method', function(done) { + it('returns false when stat exists but does not contain an isSymbolicLink method', done => { let file = new File({ contents: null, stat: {} as any as fs.Stats }); expect(file.isSymbolic()).toEqual(false); done(); }); - it('returns false when stat does not exist', function(done) { + it('returns false when stat does not exist', done => { let file = new File({ contents: null }); expect(file.isSymbolic()).toEqual(false); done(); }); }); - describe('clone()', function() { - it('copies all attributes over with Buffer contents', function(done) { + describe('clone()', () => { + it('copies all attributes over with Buffer contents', done => { let options = { cwd: '/', base: '/test/', @@ -443,7 +443,7 @@ describe('File', function() { done(); }); - it('assigns Buffer content reference when contents option is false', function(done) { + it('assigns Buffer content reference when contents option is false', done => { let options = { cwd: '/', base: '/test/', @@ -464,7 +464,7 @@ describe('File', function() { // done(); }); - it('copies all attributes over with Stream contents', function(done) { + it('copies all attributes over with Stream contents', done => { let options = { cwd: '/', base: '/test/', @@ -499,20 +499,20 @@ describe('File', function() { pipe([ file.contents, - concat(function(d) { + concat(d => { data = d; }), ], assert); pipe([ file2.contents, - concat(function(d) { + concat(d => { data2 = d; }), ], assert); }); - it('does not start flowing until all clones flows (data)', function(done) { + it('does not start flowing until all clones flows (data)', done => { let options = { cwd: '/', base: '/test/', @@ -534,17 +534,17 @@ describe('File', function() { } // Start flowing file2 - file2.contents.on('data', function(chunk: Buffer) { + file2.contents.on('data', (chunk: Buffer) => { data2 += chunk.toString('utf8'); }); - process.nextTick(function() { + process.nextTick(() => { // Nothing was written yet expect(data).toEqual(''); expect(data2).toEqual(''); // Starts flowing file - file.contents.on('data', function(chunk: Buffer) { + file.contents.on('data', (chunk: Buffer) => { data += chunk.toString('utf8'); }); }); @@ -553,7 +553,7 @@ describe('File', function() { file.contents.on('end', assert); }); - it('does not start flowing until all clones flows (readable)', function(done) { + it('does not start flowing until all clones flows (readable)', done => { let options = { cwd: '/', base: '/test/', @@ -583,7 +583,7 @@ describe('File', function() { ], done); }); - it('copies all attributes over with null contents', function(done) { + it('copies all attributes over with null contents', done => { let options = { cwd: '/', base: '/test/', @@ -601,7 +601,7 @@ describe('File', function() { done(); }); - it('properly clones the `stat` property', function(done) { + it('properly clones the `stat` property', done => { let options = { cwd: '/', base: '/test/', @@ -623,7 +623,7 @@ describe('File', function() { done(); }); - it('properly clones the `history` property', function(done) { + it('properly clones the `history` property', done => { let options = { cwd: path.normalize('/'), base: path.normalize('/test/'), @@ -640,7 +640,7 @@ describe('File', function() { done(); }); - it('copies custom properties', function(done) { + it('copies custom properties', done => { let options = { cwd: '/', base: '/test/', @@ -662,7 +662,7 @@ describe('File', function() { done(); }); - it('copies history', function(done) { + it('copies history', done => { let options = { cwd: '/', base: '/test/', @@ -686,7 +686,7 @@ describe('File', function() { done(); }); - it('supports deep & shallow copy of all attributes', function(done) { + it('supports deep & shallow copy of all attributes', done => { let options = { cwd: '/', base: '/test/', @@ -747,21 +747,21 @@ describe('File', function() { // }); }); - describe('inspect()', function() { - it('returns correct format when no contents and no path', function(done) { + describe('inspect()', () => { + it('returns correct format when no contents and no path', done => { let file = new File(); expect(file.inspect()).toEqual(''); done(); }); - it('returns correct format when Buffer contents and no path', function(done) { + it('returns correct format when Buffer contents and no path', done => { let val = new Buffer('test'); let file = new File({ contents: val }); expect(file.inspect()).toEqual('>'); done(); }); - it('returns correct format when Buffer contents and relative path', function(done) { + it('returns correct format when Buffer contents and relative path', done => { let val = new Buffer('test'); let file = new File({ cwd: '/', @@ -773,7 +773,7 @@ describe('File', function() { done(); }); - it('returns correct format when Stream contents and relative path', function(done) { + it('returns correct format when Stream contents and relative path', done => { let file = new File({ cwd: '/', base: '/test/', @@ -784,7 +784,7 @@ describe('File', function() { done(); }); - it('returns correct format when null contents and relative path', function(done) { + it('returns correct format when null contents and relative path', done => { let file = new File({ cwd: '/', base: '/test/', @@ -796,8 +796,8 @@ describe('File', function() { }); }); - describe('contents get/set', function() { - it('returns _contents', function(done) { + describe('contents get/set', () => { + it('returns _contents', done => { let val = new Buffer('test'); let file = new File() as TestFile; file._contents = val; @@ -805,7 +805,7 @@ describe('File', function() { done(); }); - it('sets _contents', function(done) { + it('sets _contents', done => { let val = new Buffer('test'); let file = new File() as TestFile; file.contents = val; @@ -813,7 +813,7 @@ describe('File', function() { done(); }); - it('sets a Buffer', function(done) { + it('sets a Buffer', done => { let val = new Buffer('test'); let file = new File(); file.contents = val; @@ -821,7 +821,7 @@ describe('File', function() { done(); }); - it('wraps Stream in Cloneable', function(done) { + it('wraps Stream in Cloneable', done => { let val = from([]); let file = new File(); file.contents = val; @@ -829,7 +829,7 @@ describe('File', function() { done(); }); - it('does not double wrap a Cloneable', function(done) { + it('does not double wrap a Cloneable', done => { let val = from([]); let clone = cloneable(val); let file = new File(); @@ -838,7 +838,7 @@ describe('File', function() { done(); }); - it('sets null', function(done) { + it('sets null', done => { let val = null; let file = new File(); file.contents = val; @@ -858,8 +858,8 @@ describe('File', function() { // }); }); - describe('cwd get/set', function() { - it('returns _cwd', function(done) { + describe('cwd get/set', () => { + it('returns _cwd', done => { let val = '/test'; let file = new File() as TestFile; file._cwd = val; @@ -867,7 +867,7 @@ describe('File', function() { done(); }); - it('sets _cwd', function(done) { + it('sets _cwd', done => { let val = '/test'; let file = new File() as TestFile; file.cwd = val; @@ -875,7 +875,7 @@ describe('File', function() { done(); }); - it('normalizes and removes trailing separator on set', function(done) { + it('normalizes and removes trailing separator on set', done => { let val = '/test/foo/../foo/'; let expected = path.normalize(val.slice(0, -1)); let file = new File(); @@ -920,14 +920,14 @@ describe('File', function() { // }); }); - describe('base get/set', function() { - it('proxies cwd when omitted', function(done) { + describe('base get/set', () => { + it('proxies cwd when omitted', done => { let file = new File({ cwd: '/test' }); expect(file.base).toEqual(file.cwd); done(); }); - it('proxies cwd when same', function(done) { + it('proxies cwd when same', done => { let file = new File({ cwd: '/test', base: '/test', @@ -960,7 +960,7 @@ describe('File', function() { // done(); // }); - it('returns _base', function(done) { + it('returns _base', done => { let val = '/test/'; let file = new File() as TestFile; file._base = val; @@ -968,7 +968,7 @@ describe('File', function() { done(); }); - it('sets _base', function(done) { + it('sets _base', done => { let val = '/test/foo'; let file = new File() as TestFile; file.base = val; @@ -976,7 +976,7 @@ describe('File', function() { done(); }); - it('normalizes and removes trailing separator on set', function(done) { + it('normalizes and removes trailing separator on set', done => { let val = '/test/foo/../foo/'; let expected = path.normalize(val.slice(0, -1)); let file = new File(); @@ -1020,8 +1020,8 @@ describe('File', function() { // }); }); - describe('relative get/set', function() { - it('throws on set', function(done) { + describe('relative get/set', () => { + it('throws on set', done => { let file = new File(); function invalid() { @@ -1032,7 +1032,7 @@ describe('File', function() { done(); }); - it('throws on get with no path', function(done) { + it('throws on get with no path', done => { let file = new File(); function invalid() { @@ -1043,7 +1043,7 @@ describe('File', function() { done(); }); - it('returns a relative path from base', function(done) { + it('returns a relative path from base', done => { let file = new File({ base: '/test/', path: '/test/test.coffee', @@ -1053,7 +1053,7 @@ describe('File', function() { done(); }); - it('returns a relative path from cwd', function(done) { + it('returns a relative path from cwd', done => { let file = new File({ cwd: '/', path: '/test/test.coffee', @@ -1063,7 +1063,7 @@ describe('File', function() { done(); }); - it('does not append separator when directory', function(done) { + it('does not append separator when directory', done => { let file = new File({ base: '/test', path: '/test/foo/bar', @@ -1078,7 +1078,7 @@ describe('File', function() { done(); }); - it('does not append separator when symlink', function(done) { + it('does not append separator when symlink', done => { let file = new File({ base: '/test', path: '/test/foo/bar', @@ -1093,7 +1093,7 @@ describe('File', function() { done(); }); - it('does not append separator when directory & symlink', function(done) { + it('does not append separator when directory & symlink', done => { let file = new File({ base: '/test', path: '/test/foo/bar', @@ -1112,8 +1112,8 @@ describe('File', function() { }); }); - describe('dirname get/set', function() { - it('throws on get with no path', function(done) { + describe('dirname get/set', () => { + it('throws on get with no path', done => { let file = new File(); function invalid() { @@ -1124,7 +1124,7 @@ describe('File', function() { done(); }); - it('returns the dirname without trailing separator', function(done) { + it('returns the dirname without trailing separator', done => { let file = new File({ cwd: '/', base: '/test', @@ -1135,7 +1135,7 @@ describe('File', function() { done(); }); - it('throws on set with no path', function(done) { + it('throws on set with no path', done => { let file = new File(); function invalid() { @@ -1146,7 +1146,7 @@ describe('File', function() { done(); }); - it('replaces the dirname of the path', function(done) { + it('replaces the dirname of the path', done => { let file = new File({ cwd: '/', base: '/test/', @@ -1159,8 +1159,8 @@ describe('File', function() { }); }); - describe('basename get/set', function() { - it('throws on get with no path', function(done) { + describe('basename get/set', () => { + it('throws on get with no path', done => { let file = new File(); function invalid() { @@ -1171,7 +1171,7 @@ describe('File', function() { done(); }); - it('returns the basename of the path', function(done) { + it('returns the basename of the path', done => { let file = new File({ cwd: '/', base: '/test/', @@ -1182,7 +1182,7 @@ describe('File', function() { done(); }); - it('does not append trailing separator when directory', function(done) { + it('does not append trailing separator when directory', done => { let file = new File({ path: '/test/foo', stat: { @@ -1196,7 +1196,7 @@ describe('File', function() { done(); }); - it('does not append trailing separator when symlink', function(done) { + it('does not append trailing separator when symlink', done => { let file = new File({ path: '/test/foo', stat: { @@ -1210,7 +1210,7 @@ describe('File', function() { done(); }); - it('does not append trailing separator when directory & symlink', function(done) { + it('does not append trailing separator when directory & symlink', done => { let file = new File({ path: '/test/foo', stat: { @@ -1227,7 +1227,7 @@ describe('File', function() { done(); }); - it('removes trailing separator', function(done) { + it('removes trailing separator', done => { let file = new File({ path: '/test/foo/', }); @@ -1236,7 +1236,7 @@ describe('File', function() { done(); }); - it('removes trailing separator when directory', function(done) { + it('removes trailing separator when directory', done => { let file = new File({ path: '/test/foo/', stat: { @@ -1250,7 +1250,7 @@ describe('File', function() { done(); }); - it('removes trailing separator when symlink', function(done) { + it('removes trailing separator when symlink', done => { let file = new File({ path: '/test/foo/', stat: { @@ -1264,7 +1264,7 @@ describe('File', function() { done(); }); - it('removes trailing separator when directory & symlink', function(done) { + it('removes trailing separator when directory & symlink', done => { let file = new File({ path: '/test/foo/', stat: { @@ -1281,7 +1281,7 @@ describe('File', function() { done(); }); - it('throws on set with no path', function(done) { + it('throws on set with no path', done => { let file = new File(); function invalid() { @@ -1292,7 +1292,7 @@ describe('File', function() { done(); }); - it('replaces the basename of the path', function(done) { + it('replaces the basename of the path', done => { let file = new File({ cwd: '/', base: '/test/', @@ -1305,8 +1305,8 @@ describe('File', function() { }); }); - describe('stem get/set', function() { - it('throws on get with no path', function(done) { + describe('stem get/set', () => { + it('throws on get with no path', done => { let file = new File(); function invalid() { @@ -1317,7 +1317,7 @@ describe('File', function() { done(); }); - it('returns the stem of the path', function(done) { + it('returns the stem of the path', done => { let file = new File({ cwd: '/', base: '/test/', @@ -1328,7 +1328,7 @@ describe('File', function() { done(); }); - it('throws on set with no path', function(done) { + it('throws on set with no path', done => { let file = new File(); function invalid() { @@ -1339,7 +1339,7 @@ describe('File', function() { done(); }); - it('replaces the stem of the path', function(done) { + it('replaces the stem of the path', done => { let file = new File({ cwd: '/', base: '/test/', @@ -1352,8 +1352,8 @@ describe('File', function() { }); }); - describe('extname get/set', function() { - it('throws on get with no path', function(done) { + describe('extname get/set', () => { + it('throws on get with no path', done => { let file = new File(); function invalid() { @@ -1364,7 +1364,7 @@ describe('File', function() { done(); }); - it('returns the extname of the path', function(done) { + it('returns the extname of the path', done => { let file = new File({ cwd: '/', base: '/test/', @@ -1375,7 +1375,7 @@ describe('File', function() { done(); }); - it('throws on set with no path', function(done) { + it('throws on set with no path', done => { let file = new File(); function invalid() { @@ -1386,7 +1386,7 @@ describe('File', function() { done(); }); - it('replaces the extname of the path', function(done) { + it('replaces the extname of the path', done => { let file = new File({ cwd: '/', base: '/test/', @@ -1399,8 +1399,8 @@ describe('File', function() { }); }); - describe('path get/set', function() { - it('records path in history upon instantiation', function(done) { + describe('path get/set', () => { + it('records path in history upon instantiation', done => { let file = new File({ cwd: '/', path: '/test/test.coffee', @@ -1414,7 +1414,7 @@ describe('File', function() { done(); }); - it('records path in history when set', function(done) { + it('records path in history when set', done => { let val = path.normalize('/test/test.js'); let file = new File({ cwd: '/', @@ -1438,7 +1438,7 @@ describe('File', function() { done(); }); - it('does not record path in history when set to the current path', function(done) { + it('does not record path in history when set to the current path', done => { let val = path.normalize('/test/test.coffee'); let file = new File({ cwd: '/', @@ -1455,7 +1455,7 @@ describe('File', function() { done(); }); - it('does not record path in history when set to empty string', function(done) { + it('does not record path in history when set to empty string', done => { let val = path.normalize('/test/test.coffee'); let file = new File({ cwd: '/', @@ -1472,7 +1472,7 @@ describe('File', function() { }); // TypeScript: known issue, see the comment for the `base` property. - // it('throws on set with null path', function(done) { + // it('throws on set with null path', done => { // var file = new File(); // expect(file.path).toNotExist(); @@ -1486,7 +1486,7 @@ describe('File', function() { // done(); // }); - it('normalizes the path upon set', function(done) { + it('normalizes the path upon set', done => { let val = '/test/foo/../test.coffee'; let expected = path.normalize(val); let file = new File(); @@ -1498,7 +1498,7 @@ describe('File', function() { done(); }); - it('removes the trailing separator upon set', function(done) { + it('removes the trailing separator upon set', done => { let file = new File(); file.path = '/test/'; @@ -1507,7 +1507,7 @@ describe('File', function() { done(); }); - it('removes the trailing separator upon set when directory', function(done) { + it('removes the trailing separator upon set when directory', done => { let file = new File({ stat: { isDirectory() { @@ -1522,7 +1522,7 @@ describe('File', function() { done(); }); - it('removes the trailing separator upon set when symlink', function(done) { + it('removes the trailing separator upon set when symlink', done => { let file = new File({ stat: { isSymbolicLink() { @@ -1537,7 +1537,7 @@ describe('File', function() { done(); }); - it('removes the trailing separator upon set when directory & symlink', function(done) { + it('removes the trailing separator upon set when directory & symlink', done => { let file = new File({ stat: { isDirectory() { @@ -1556,15 +1556,15 @@ describe('File', function() { }); }); - describe('symlink get/set', function() { - it('return null on get with no symlink', function(done) { + describe('symlink get/set', () => { + it('return null on get with no symlink', done => { let file = new File(); expect(file.symlink).toEqual(null); done(); }); - it('returns _symlink', function(done) { + it('returns _symlink', done => { let val = '/test/test.coffee'; let file = new File() as TestFile; file._symlink = val; @@ -1573,7 +1573,7 @@ describe('File', function() { done(); }); - it('throws on set with non-string', function(done) { + it('throws on set with non-string', done => { let file = new File(); function invalid() { @@ -1584,7 +1584,7 @@ describe('File', function() { done(); }); - it('sets _symlink', function(done) { + it('sets _symlink', done => { let val = '/test/test.coffee'; let expected = path.normalize(val); let file = new File() as TestFile; @@ -1594,7 +1594,7 @@ describe('File', function() { done(); }); - it('allows relative symlink', function(done) { + it('allows relative symlink', done => { let val = 'test.coffee'; let file = new File(); file.symlink = val; @@ -1603,7 +1603,7 @@ describe('File', function() { done(); }); - it('normalizes and removes trailing separator upon set', function(done) { + it('normalizes and removes trailing separator upon set', done => { let val = '/test/foo/../bar/'; let expected = path.normalize(val.slice(0, -1)); let file = new File(); From fef403eff4a76ac4c49ce6bd71e666d8526194bd Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 10:35:12 +0900 Subject: [PATCH 181/298] cleanup ignore lint error: prefer-const --- types/vinyl/tslint.json | 3 +- types/vinyl/vinyl-tests.ts | 464 ++++++++++++++++++------------------- 2 files changed, 233 insertions(+), 234 deletions(-) diff --git a/types/vinyl/tslint.json b/types/vinyl/tslint.json index c8b1832546..54cc466d67 100644 --- a/types/vinyl/tslint.json +++ b/types/vinyl/tslint.json @@ -3,7 +3,6 @@ "rules": { "no-conditional-assignment": false, "no-construct": false, - "no-var-requires": false, - "prefer-const": false + "no-var-requires": false } } diff --git a/types/vinyl/vinyl-tests.ts b/types/vinyl/vinyl-tests.ts index b3f3be868f..31b1b68ee6 100644 --- a/types/vinyl/vinyl-tests.ts +++ b/types/vinyl/vinyl-tests.ts @@ -24,54 +24,54 @@ interface TestFile extends File { _base?: string; } -let pipe: (streams: [NodeJS.ReadableStream, NodeJS.WritableStream], cb: (err?: Error) => void) => void = miss.pipe; -let from: (values: any[]) => NodeJS.ReadableStream = miss.from; -let concat: (fn: (d: Buffer) => void) => NodeJS.WritableStream = miss.concat; -let isCloneable: (obj: any) => boolean = cloneable.isCloneable; +const pipe: (streams: [NodeJS.ReadableStream, NodeJS.WritableStream], cb: (err?: Error) => void) => void = miss.pipe; +const from: (values: any[]) => NodeJS.ReadableStream = miss.from; +const concat: (fn: (d: Buffer) => void) => NodeJS.WritableStream = miss.concat; +const isCloneable: (obj: any) => boolean = cloneable.isCloneable; -let isWin = (process.platform === 'win32'); +const isWin = (process.platform === 'win32'); describe('File', () => { describe('isVinyl()', () => { it('returns true for a Vinyl object', done => { - let file = new File(); - let result = File.isVinyl(file); + const file = new File(); + const result = File.isVinyl(file); expect(result).toEqual(true); done(); }); it('returns false for a normal object', done => { - let result = File.isVinyl({}); + const result = File.isVinyl({}); expect(result).toEqual(false); done(); }); it('returns false for null', done => { - let result = File.isVinyl(null); + const result = File.isVinyl(null); expect(result).toEqual(false); done(); }); it('returns false for a string', done => { - let result = File.isVinyl('foobar'); + const result = File.isVinyl('foobar'); expect(result).toEqual(false); done(); }); it('returns false for a String object', done => { - let result = File.isVinyl(new String('foobar')); + const result = File.isVinyl(new String('foobar')); expect(result).toEqual(false); done(); }); it('returns false for a number', done => { - let result = File.isVinyl(1); + const result = File.isVinyl(1); expect(result).toEqual(false); done(); }); it('returns false for a Number object', done => { - let result = File.isVinyl(new Number(1)); + const result = File.isVinyl(new Number(1)); expect(result).toEqual(false); done(); }); @@ -80,7 +80,7 @@ describe('File', () => { // A test was added to document and make aware during internal changes // TODO: decide if this should be leak-able it('returns true for a mocked object', done => { - let result = File.isVinyl({ _isVinyl: true }); + const result = File.isVinyl({ _isVinyl: true }); expect(result).toEqual(true); done(); }); @@ -88,46 +88,46 @@ describe('File', () => { describe('defaults', () => { it('defaults cwd to process.cwd', done => { - let file = new File(); + const file = new File(); expect(file.cwd).toEqual(process.cwd()); done(); }); it('defaults base to process.cwd', done => { - let file = new File(); + const file = new File(); expect(file.base).toEqual(process.cwd()); done(); }); it('defaults base to cwd property', done => { - let cwd = path.normalize('/'); - let file = new File({ cwd }); + const cwd = path.normalize('/'); + const file = new File({ cwd }); expect(file.base).toEqual(cwd); done(); }); it('defaults path to null', done => { - let file = new File(); + const file = new File(); expect(file.path).toNotExist(); expect(file.path).toEqual(null); done(); }); it('defaults history to an empty array', done => { - let file = new File(); + const file = new File(); expect(file.history).toEqual([]); done(); }); it('defaults stat to null', done => { - let file = new File(); + const file = new File(); expect(file.stat).toNotExist(); expect(file.stat).toEqual(null); done(); }); it('defaults contents to null', done => { - let file = new File(); + const file = new File(); expect(file.contents).toNotExist(); expect(file.contents).toEqual(null); done(); @@ -136,109 +136,109 @@ describe('File', () => { describe('constructor()', () => { it('sets base', done => { - let val = path.normalize('/'); - let file = new File({ base: val }); + const val = path.normalize('/'); + const file = new File({ base: val }); expect(file.base).toEqual(val); done(); }); it('sets cwd', done => { - let val = path.normalize('/'); - let file = new File({ cwd: val }); + const val = path.normalize('/'); + const file = new File({ cwd: val }); expect(file.cwd).toEqual(val); done(); }); it('sets path (and history)', done => { - let val = path.normalize('/test.coffee'); - let file = new File({ path: val }); + const val = path.normalize('/test.coffee'); + const file = new File({ path: val }); expect(file.path).toEqual(val); expect(file.history).toEqual([val]); done(); }); it('sets history (and path)', done => { - let val = path.normalize('/test.coffee'); - let file = new File({ history: [val] }); + const val = path.normalize('/test.coffee'); + const file = new File({ history: [val] }); expect(file.path).toEqual(val); expect(file.history).toEqual([val]); done(); }); it('sets stat', done => { - let val = {}; - let file = new File({ stat: val as any as fs.Stats }); + const val = {}; + const file = new File({ stat: val as any as fs.Stats }); expect(file.stat).toEqual(val); done(); }); it('sets contents', done => { - let val = new Buffer('test'); - let file = new File({ contents: val }); + const val = new Buffer('test'); + const file = new File({ contents: val }); expect(file.contents).toEqual(val); done(); }); it('sets custom properties', done => { - let sourceMap = {}; - let file = new File({ sourceMap }) as TestFile; + const sourceMap = {}; + const file = new File({ sourceMap }) as TestFile; expect(file.sourceMap).toEqual(sourceMap); done(); }); it('normalizes path', done => { - let val = '/test/foo/../test.coffee'; - let expected = path.normalize(val); - let file = new File({ path: val }); + const val = '/test/foo/../test.coffee'; + const expected = path.normalize(val); + const file = new File({ path: val }); expect(file.path).toEqual(expected); expect(file.history).toEqual([expected]); done(); }); it('normalizes and removes trailing separator from path', done => { - let val = '/test/foo/../foo/'; - let expected = path.normalize(val.slice(0, -1)); - let file = new File({ path: val }); + const val = '/test/foo/../foo/'; + const expected = path.normalize(val.slice(0, -1)); + const file = new File({ path: val }); expect(file.path).toEqual(expected); done(); }); it('normalizes history', done => { - let val = [ + const val = [ '/test/bar/../bar/test.coffee', '/test/foo/../test.coffee', ]; - let expected = val.map(p => { + const expected = val.map(p => { return path.normalize(p); }); - let file = new File({ history: val }); + const file = new File({ history: val }); expect(file.path).toEqual(expected[1]); expect(file.history).toEqual(expected); done(); }); it('normalizes and removes trailing separator from history', done => { - let val = [ + const val = [ '/test/foo/../foo/', '/test/bar/../bar/', ]; - let expected = val.map(p => { + const expected = val.map(p => { return path.normalize(p.slice(0, -1)); }); - let file = new File({ history: val }); + const file = new File({ history: val }); expect(file.history).toEqual(expected); done(); }); it('appends path to history if both exist and different from last', done => { - let val = path.normalize('/test/baz/test.coffee'); - let history = [ + const val = path.normalize('/test/baz/test.coffee'); + const history = [ path.normalize('/test/bar/test.coffee'), path.normalize('/test/foo/test.coffee'), ]; - let file = new File({ path: val, history }); + const file = new File({ path: val, history }); - let expectedHistory = history.concat(val); + const expectedHistory = history.concat(val); expect(file.path).toEqual(val); expect(file.history).toEqual(expectedHistory); @@ -246,13 +246,13 @@ describe('File', () => { }); it('does not append path to history if both exist and same as last', done => { - let val = path.normalize('/test/baz/test.coffee'); - let history = [ + const val = path.normalize('/test/baz/test.coffee'); + const history = [ path.normalize('/test/bar/test.coffee'), path.normalize('/test/foo/test.coffee'), val, ]; - let file = new File({ path: val, history }); + const file = new File({ path: val, history }); expect(file.path).toEqual(val); expect(file.history).toEqual(history); @@ -260,15 +260,15 @@ describe('File', () => { }); it('does not mutate history array passed in', done => { - let val = path.normalize('/test/baz/test.coffee'); - let history = [ + const val = path.normalize('/test/baz/test.coffee'); + const history = [ path.normalize('/test/bar/test.coffee'), path.normalize('/test/foo/test.coffee'), ]; - let historyCopy = Array.prototype.slice.call(history); - let file = new File({ path: val, history }); + const historyCopy = Array.prototype.slice.call(history); + const file = new File({ path: val, history }); - let expectedHistory = history.concat(val); + const expectedHistory = history.concat(val); expect(file.path).toEqual(val); expect(file.history).toEqual(expectedHistory); @@ -279,21 +279,21 @@ describe('File', () => { describe('isBuffer()', () => { it('returns true when the contents are a Buffer', done => { - let val = new Buffer('test'); - let file = new File({ contents: val }); + const val = new Buffer('test'); + const file = new File({ contents: val }); expect(file.isBuffer()).toEqual(true); done(); }); it('returns false when the contents are a Stream', done => { - let val = from([]); - let file = new File({ contents: val }); + const val = from([]); + const file = new File({ contents: val }); expect(file.isBuffer()).toEqual(false); done(); }); it('returns false when the contents are null', done => { - let file = new File({ contents: null }); + const file = new File({ contents: null }); expect(file.isBuffer()).toEqual(false); done(); }); @@ -301,21 +301,21 @@ describe('File', () => { describe('isStream()', () => { it('returns false when the contents are a Buffer', done => { - let val = new Buffer('test'); - let file = new File({ contents: val }); + const val = new Buffer('test'); + const file = new File({ contents: val }); expect(file.isStream()).toEqual(false); done(); }); it('returns true when the contents are a Stream', done => { - let val = from([]); - let file = new File({ contents: val }); + const val = from([]); + const file = new File({ contents: val }); expect(file.isStream()).toEqual(true); done(); }); it('returns false when the contents are null', done => { - let file = new File({ contents: null }); + const file = new File({ contents: null }); expect(file.isStream()).toEqual(false); done(); }); @@ -323,101 +323,101 @@ describe('File', () => { describe('isNull()', () => { it('returns false when the contents are a Buffer', done => { - let val = new Buffer('test'); - let file = new File({ contents: val }); + const val = new Buffer('test'); + const file = new File({ contents: val }); expect(file.isNull()).toEqual(false); done(); }); it('returns false when the contents are a Stream', done => { - let val = from([]); - let file = new File({ contents: val }); + const val = from([]); + const file = new File({ contents: val }); expect(file.isNull()).toEqual(false); done(); }); it('returns true when the contents are null', done => { - let file = new File({ contents: null }); + const file = new File({ contents: null }); expect(file.isNull()).toEqual(true); done(); }); }); describe('isDirectory()', () => { - let fakeStat = { + const fakeStat = { isDirectory() { return true; }, } as any as fs.Stats; it('returns false when the contents are a Buffer', done => { - let val = new Buffer('test'); - let file = new File({ contents: val, stat: fakeStat }); + const val = new Buffer('test'); + const file = new File({ contents: val, stat: fakeStat }); expect(file.isDirectory()).toEqual(false); done(); }); it('returns false when the contents are a Stream', done => { - let val = from([]); - let file = new File({ contents: val, stat: fakeStat }); + const val = from([]); + const file = new File({ contents: val, stat: fakeStat }); expect(file.isDirectory()).toEqual(false); done(); }); it('returns true when the contents are null & stat.isDirectory is true', done => { - let file = new File({ contents: null, stat: fakeStat }); + const file = new File({ contents: null, stat: fakeStat }); expect(file.isDirectory()).toEqual(true); done(); }); it('returns false when stat exists but does not contain an isDirectory method', done => { - let file = new File({ contents: null, stat: {} as any as fs.Stats }); + const file = new File({ contents: null, stat: {} as any as fs.Stats }); expect(file.isDirectory()).toEqual(false); done(); }); it('returns false when stat does not exist', done => { - let file = new File({ contents: null }); + const file = new File({ contents: null }); expect(file.isDirectory()).toEqual(false); done(); }); }); describe('isSymbolic()', () => { - let fakeStat = { + const fakeStat = { isSymbolicLink() { return true; }, } as any as fs.Stats; it('returns false when the contents are a Buffer', done => { - let val = new Buffer('test'); - let file = new File({ contents: val, stat: fakeStat }); + const val = new Buffer('test'); + const file = new File({ contents: val, stat: fakeStat }); expect(file.isSymbolic()).toEqual(false); done(); }); it('returns false when the contents are a Stream', done => { - let val = from([]); - let file = new File({ contents: val, stat: fakeStat }); + const val = from([]); + const file = new File({ contents: val, stat: fakeStat }); expect(file.isSymbolic()).toEqual(false); done(); }); it('returns true when the contents are null & stat.isSymbolicLink is true', done => { - let file = new File({ contents: null, stat: fakeStat }); + const file = new File({ contents: null, stat: fakeStat }); expect(file.isSymbolic()).toEqual(true); done(); }); it('returns false when stat exists but does not contain an isSymbolicLink method', done => { - let file = new File({ contents: null, stat: {} as any as fs.Stats }); + const file = new File({ contents: null, stat: {} as any as fs.Stats }); expect(file.isSymbolic()).toEqual(false); done(); }); it('returns false when stat does not exist', done => { - let file = new File({ contents: null }); + const file = new File({ contents: null }); expect(file.isSymbolic()).toEqual(false); done(); }); @@ -425,14 +425,14 @@ describe('File', () => { describe('clone()', () => { it('copies all attributes over with Buffer contents', done => { - let options = { + const options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: new Buffer('test'), }; - let file = new File(options); - let file2 = file.clone(); + const file = new File(options); + const file2 = file.clone(); expect(file2).toNotBe(file); expect(file2.cwd).toEqual(file.cwd); @@ -444,18 +444,18 @@ describe('File', () => { }); it('assigns Buffer content reference when contents option is false', done => { - let options = { + const options = { cwd: '/', base: '/test/', path: '/test/test.js', contents: new Buffer('test'), }; - let file = new File(options); + const file = new File(options); - let copy1 = file.clone({ contents: false }); + const copy1 = file.clone({ contents: false }); expect(copy1.contents).toBe(file.contents); - let copy2 = file.clone(); + const copy2 = file.clone(); expect(copy2.contents).toNotBe(file.contents); // TypeScript: expected compilation error @@ -465,14 +465,14 @@ describe('File', () => { }); it('copies all attributes over with Stream contents', done => { - let options = { + const options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: from(['wa', 'dup']), }; - let file = new File(options); - let file2 = file.clone(); + const file = new File(options); + const file2 = file.clone(); expect(file2).toNotBe(file); expect(file2.cwd).toEqual(file.cwd); @@ -513,14 +513,14 @@ describe('File', () => { }); it('does not start flowing until all clones flows (data)', done => { - let options = { + const options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: from(['wa', 'dup']), }; - let file = new File(options); - let file2 = file.clone(); + const file = new File(options); + const file2 = file.clone(); let ends = 2; let data = ''; @@ -554,14 +554,14 @@ describe('File', () => { }); it('does not start flowing until all clones flows (readable)', done => { - let options = { + const options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: from(['wa', 'dup']), }; - let file = new File(options); - let file2 = file.clone(); + const file = new File(options); + const file2 = file.clone(); let data2 = ''; @@ -584,14 +584,14 @@ describe('File', () => { }); it('copies all attributes over with null contents', done => { - let options = { + const options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: null, }; - let file = new File(options); - let file2 = file.clone(); + const file = new File(options); + const file2 = file.clone(); expect(file2).toNotBe(file); expect(file2.cwd).toEqual(file.cwd); @@ -602,7 +602,7 @@ describe('File', () => { }); it('properly clones the `stat` property', done => { - let options = { + const options = { cwd: '/', base: '/test/', path: '/test/test.js', @@ -610,8 +610,8 @@ describe('File', () => { stat: fs.statSync(__filename), }; - let file = new File(options); - let copy = file.clone(); + const file = new File(options); + const copy = file.clone(); expect(copy.stat).toExist(); if (copy.stat != null) { @@ -624,15 +624,15 @@ describe('File', () => { }); it('properly clones the `history` property', done => { - let options = { + const options = { cwd: path.normalize('/'), base: path.normalize('/test/'), path: path.normalize('/test/test.js'), contents: new Buffer('test'), }; - let file = new File(options); - let copy = file.clone(); + const file = new File(options); + const copy = file.clone(); expect(copy.history[0]).toEqual(options.path); copy.path = 'lol'; @@ -641,7 +641,7 @@ describe('File', () => { }); it('copies custom properties', done => { - let options = { + const options = { cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -649,8 +649,8 @@ describe('File', () => { custom: { meta: {} }, }; - let file = new File(options) as TestFile; - let file2 = file.clone(); + const file = new File(options) as TestFile; + const file2 = file.clone(); expect(file2).toNotBe(file); expect(file2.cwd).toEqual(file.cwd); @@ -663,22 +663,22 @@ describe('File', () => { }); it('copies history', done => { - let options = { + const options = { cwd: '/', base: '/test/', path: '/test/test.coffee', contents: null, }; - let history = [ + const history = [ path.normalize('/test/test.coffee'), path.normalize('/test/test.js'), path.normalize('/test/test-938di2s.js'), ]; - let file = new File(options); + const file = new File(options); file.path = history[1]; file.path = history[2]; - let file2 = file.clone(); + const file2 = file.clone(); expect(file2.history).toEqual(history); expect(file2.history).toNotBe(file.history); @@ -687,7 +687,7 @@ describe('File', () => { }); it('supports deep & shallow copy of all attributes', done => { - let options = { + const options = { cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -695,33 +695,33 @@ describe('File', () => { custom: { meta: {} }, }; - let file = new File(options) as TestFile; + const file = new File(options) as TestFile; - let file2 = file.clone(); + const file2 = file.clone(); expect(file2.custom).toEqual(file.custom); expect(file2.custom).toNotBe(file.custom); expect(file2.custom.meta).toEqual(file.custom.meta); expect(file2.custom.meta).toNotBe(file.custom.meta); - let file3 = file.clone(true); + const file3 = file.clone(true); expect(file3.custom).toEqual(file.custom); expect(file3.custom).toNotBe(file.custom); expect(file3.custom.meta).toEqual(file.custom.meta); expect(file3.custom.meta).toNotBe(file.custom.meta); - let file4 = file.clone({ deep: true }); + const file4 = file.clone({ deep: true }); expect(file4.custom).toEqual(file.custom); expect(file4.custom).toNotBe(file.custom); expect(file4.custom.meta).toEqual(file.custom.meta); expect(file4.custom.meta).toNotBe(file.custom.meta); - let file5 = file.clone(false); + const file5 = file.clone(false); expect(file5.custom).toEqual(file.custom); expect(file5.custom).toBe(file.custom); expect(file5.custom.meta).toEqual(file.custom.meta); expect(file5.custom.meta).toBe(file.custom.meta); - let file6 = file.clone({ deep: false }); + const file6 = file.clone({ deep: false }); expect(file6.custom).toEqual(file.custom); expect(file6.custom).toBe(file.custom); expect(file6.custom.meta).toEqual(file.custom.meta); @@ -749,21 +749,21 @@ describe('File', () => { describe('inspect()', () => { it('returns correct format when no contents and no path', done => { - let file = new File(); + const file = new File(); expect(file.inspect()).toEqual(''); done(); }); it('returns correct format when Buffer contents and no path', done => { - let val = new Buffer('test'); - let file = new File({ contents: val }); + const val = new Buffer('test'); + const file = new File({ contents: val }); expect(file.inspect()).toEqual('>'); done(); }); it('returns correct format when Buffer contents and relative path', done => { - let val = new Buffer('test'); - let file = new File({ + const val = new Buffer('test'); + const file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -774,7 +774,7 @@ describe('File', () => { }); it('returns correct format when Stream contents and relative path', done => { - let file = new File({ + const file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -785,7 +785,7 @@ describe('File', () => { }); it('returns correct format when null contents and relative path', done => { - let file = new File({ + const file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -798,49 +798,49 @@ describe('File', () => { describe('contents get/set', () => { it('returns _contents', done => { - let val = new Buffer('test'); - let file = new File() as TestFile; + const val = new Buffer('test'); + const file = new File() as TestFile; file._contents = val; expect(file.contents).toEqual(val); done(); }); it('sets _contents', done => { - let val = new Buffer('test'); - let file = new File() as TestFile; + const val = new Buffer('test'); + const file = new File() as TestFile; file.contents = val; expect(file._contents).toEqual(val); done(); }); it('sets a Buffer', done => { - let val = new Buffer('test'); - let file = new File(); + const val = new Buffer('test'); + const file = new File(); file.contents = val; expect(file.contents).toEqual(val); done(); }); it('wraps Stream in Cloneable', done => { - let val = from([]); - let file = new File(); + const val = from([]); + const file = new File(); file.contents = val; expect(isCloneable(file.contents)).toEqual(true); done(); }); it('does not double wrap a Cloneable', done => { - let val = from([]); - let clone = cloneable(val); - let file = new File(); + const val = from([]); + const clone = cloneable(val); + const file = new File(); file.contents = clone; expect((file.contents as any)._original).toBe(val); done(); }); it('sets null', done => { - let val = null; - let file = new File(); + const val = null; + const file = new File(); file.contents = val; expect(file.contents).toEqual(null); done(); @@ -860,32 +860,32 @@ describe('File', () => { describe('cwd get/set', () => { it('returns _cwd', done => { - let val = '/test'; - let file = new File() as TestFile; + const val = '/test'; + const file = new File() as TestFile; file._cwd = val; expect(file.cwd).toEqual(val); done(); }); it('sets _cwd', done => { - let val = '/test'; - let file = new File() as TestFile; + const val = '/test'; + const file = new File() as TestFile; file.cwd = val; expect(file._cwd).toEqual(path.normalize(val)); done(); }); it('normalizes and removes trailing separator on set', done => { - let val = '/test/foo/../foo/'; - let expected = path.normalize(val.slice(0, -1)); - let file = new File(); + const val = '/test/foo/../foo/'; + const expected = path.normalize(val.slice(0, -1)); + const file = new File(); file.cwd = val; expect(file.cwd).toEqual(expected); - let val2 = '\\test\\foo\\..\\foo\\'; - let expected2 = path.normalize(isWin ? val2.slice(0, -1) : val2); + const val2 = '\\test\\foo\\..\\foo\\'; + const expected2 = path.normalize(isWin ? val2.slice(0, -1) : val2); file.cwd = val2; @@ -922,20 +922,20 @@ describe('File', () => { describe('base get/set', () => { it('proxies cwd when omitted', done => { - let file = new File({ cwd: '/test' }); + const file = new File({ cwd: '/test' }); expect(file.base).toEqual(file.cwd); done(); }); it('proxies cwd when same', done => { - let file = new File({ + const file = new File({ cwd: '/test', base: '/test', }); file.cwd = '/foo/'; expect(file.base).toEqual(file.cwd); - let file2 = new File({ + const file2 = new File({ cwd: '/test', }); file2.base = '/test/'; @@ -961,32 +961,32 @@ describe('File', () => { // }); it('returns _base', done => { - let val = '/test/'; - let file = new File() as TestFile; + const val = '/test/'; + const file = new File() as TestFile; file._base = val; expect(file.base).toEqual(val); done(); }); it('sets _base', done => { - let val = '/test/foo'; - let file = new File() as TestFile; + const val = '/test/foo'; + const file = new File() as TestFile; file.base = val; expect(file._base).toEqual(path.normalize(val)); done(); }); it('normalizes and removes trailing separator on set', done => { - let val = '/test/foo/../foo/'; - let expected = path.normalize(val.slice(0, -1)); - let file = new File(); + const val = '/test/foo/../foo/'; + const expected = path.normalize(val.slice(0, -1)); + const file = new File(); file.base = val; expect(file.base).toEqual(expected); - let val2 = '\\test\\foo\\..\\foo\\'; - let expected2 = path.normalize(isWin ? val2.slice(0, -1) : val2); + const val2 = '\\test\\foo\\..\\foo\\'; + const expected2 = path.normalize(isWin ? val2.slice(0, -1) : val2); file.base = val2; @@ -1022,7 +1022,7 @@ describe('File', () => { describe('relative get/set', () => { it('throws on set', done => { - let file = new File(); + const file = new File(); function invalid() { file.relative = 'test'; @@ -1033,7 +1033,7 @@ describe('File', () => { }); it('throws on get with no path', done => { - let file = new File(); + const file = new File(); function invalid() { file.relative; @@ -1044,7 +1044,7 @@ describe('File', () => { }); it('returns a relative path from base', done => { - let file = new File({ + const file = new File({ base: '/test/', path: '/test/test.coffee', }); @@ -1054,7 +1054,7 @@ describe('File', () => { }); it('returns a relative path from cwd', done => { - let file = new File({ + const file = new File({ cwd: '/', path: '/test/test.coffee', }); @@ -1064,7 +1064,7 @@ describe('File', () => { }); it('does not append separator when directory', done => { - let file = new File({ + const file = new File({ base: '/test', path: '/test/foo/bar', stat: { @@ -1079,7 +1079,7 @@ describe('File', () => { }); it('does not append separator when symlink', done => { - let file = new File({ + const file = new File({ base: '/test', path: '/test/foo/bar', stat: { @@ -1094,7 +1094,7 @@ describe('File', () => { }); it('does not append separator when directory & symlink', done => { - let file = new File({ + const file = new File({ base: '/test', path: '/test/foo/bar', stat: { @@ -1114,7 +1114,7 @@ describe('File', () => { describe('dirname get/set', () => { it('throws on get with no path', done => { - let file = new File(); + const file = new File(); function invalid() { file.dirname; @@ -1125,7 +1125,7 @@ describe('File', () => { }); it('returns the dirname without trailing separator', done => { - let file = new File({ + const file = new File({ cwd: '/', base: '/test', path: '/test/test.coffee', @@ -1136,7 +1136,7 @@ describe('File', () => { }); it('throws on set with no path', done => { - let file = new File(); + const file = new File(); function invalid() { file.dirname = '/test'; @@ -1147,7 +1147,7 @@ describe('File', () => { }); it('replaces the dirname of the path', done => { - let file = new File({ + const file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1161,7 +1161,7 @@ describe('File', () => { describe('basename get/set', () => { it('throws on get with no path', done => { - let file = new File(); + const file = new File(); function invalid() { return file.basename; @@ -1172,7 +1172,7 @@ describe('File', () => { }); it('returns the basename of the path', done => { - let file = new File({ + const file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1183,7 +1183,7 @@ describe('File', () => { }); it('does not append trailing separator when directory', done => { - let file = new File({ + const file = new File({ path: '/test/foo', stat: { isDirectory() { @@ -1197,7 +1197,7 @@ describe('File', () => { }); it('does not append trailing separator when symlink', done => { - let file = new File({ + const file = new File({ path: '/test/foo', stat: { isSymbolicLink() { @@ -1211,7 +1211,7 @@ describe('File', () => { }); it('does not append trailing separator when directory & symlink', done => { - let file = new File({ + const file = new File({ path: '/test/foo', stat: { isDirectory() { @@ -1228,7 +1228,7 @@ describe('File', () => { }); it('removes trailing separator', done => { - let file = new File({ + const file = new File({ path: '/test/foo/', }); @@ -1237,7 +1237,7 @@ describe('File', () => { }); it('removes trailing separator when directory', done => { - let file = new File({ + const file = new File({ path: '/test/foo/', stat: { isDirectory() { @@ -1251,7 +1251,7 @@ describe('File', () => { }); it('removes trailing separator when symlink', done => { - let file = new File({ + const file = new File({ path: '/test/foo/', stat: { isSymbolicLink() { @@ -1265,7 +1265,7 @@ describe('File', () => { }); it('removes trailing separator when directory & symlink', done => { - let file = new File({ + const file = new File({ path: '/test/foo/', stat: { isDirectory() { @@ -1282,7 +1282,7 @@ describe('File', () => { }); it('throws on set with no path', done => { - let file = new File(); + const file = new File(); function invalid() { file.basename = 'test.coffee'; @@ -1293,7 +1293,7 @@ describe('File', () => { }); it('replaces the basename of the path', done => { - let file = new File({ + const file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1307,7 +1307,7 @@ describe('File', () => { describe('stem get/set', () => { it('throws on get with no path', done => { - let file = new File(); + const file = new File(); function invalid() { file.stem; @@ -1318,7 +1318,7 @@ describe('File', () => { }); it('returns the stem of the path', done => { - let file = new File({ + const file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1329,7 +1329,7 @@ describe('File', () => { }); it('throws on set with no path', done => { - let file = new File(); + const file = new File(); function invalid() { file.stem = 'test.coffee'; @@ -1340,7 +1340,7 @@ describe('File', () => { }); it('replaces the stem of the path', done => { - let file = new File({ + const file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1354,7 +1354,7 @@ describe('File', () => { describe('extname get/set', () => { it('throws on get with no path', done => { - let file = new File(); + const file = new File(); function invalid() { file.extname; @@ -1365,7 +1365,7 @@ describe('File', () => { }); it('returns the extname of the path', done => { - let file = new File({ + const file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1376,7 +1376,7 @@ describe('File', () => { }); it('throws on set with no path', done => { - let file = new File(); + const file = new File(); function invalid() { file.extname = '.coffee'; @@ -1387,7 +1387,7 @@ describe('File', () => { }); it('replaces the extname of the path', done => { - let file = new File({ + const file = new File({ cwd: '/', base: '/test/', path: '/test/test.coffee', @@ -1401,11 +1401,11 @@ describe('File', () => { describe('path get/set', () => { it('records path in history upon instantiation', done => { - let file = new File({ + const file = new File({ cwd: '/', path: '/test/test.coffee', }); - let history = [ + const history = [ path.normalize('/test/test.coffee'), ]; @@ -1415,12 +1415,12 @@ describe('File', () => { }); it('records path in history when set', done => { - let val = path.normalize('/test/test.js'); - let file = new File({ + const val = path.normalize('/test/test.js'); + const file = new File({ cwd: '/', path: '/test/test.coffee', }); - let history = [ + const history = [ path.normalize('/test/test.coffee'), val, ]; @@ -1429,7 +1429,7 @@ describe('File', () => { expect(file.path).toEqual(val); expect(file.history).toEqual(history); - let val2 = path.normalize('/test/test.es6'); + const val2 = path.normalize('/test/test.es6'); history.push(val2); file.path = val2; @@ -1439,12 +1439,12 @@ describe('File', () => { }); it('does not record path in history when set to the current path', done => { - let val = path.normalize('/test/test.coffee'); - let file = new File({ + const val = path.normalize('/test/test.coffee'); + const file = new File({ cwd: '/', path: val, }); - let history = [ + const history = [ val, ]; @@ -1456,12 +1456,12 @@ describe('File', () => { }); it('does not record path in history when set to empty string', done => { - let val = path.normalize('/test/test.coffee'); - let file = new File({ + const val = path.normalize('/test/test.coffee'); + const file = new File({ cwd: '/', path: val, }); - let history = [ + const history = [ val, ]; @@ -1487,9 +1487,9 @@ describe('File', () => { // }); it('normalizes the path upon set', done => { - let val = '/test/foo/../test.coffee'; - let expected = path.normalize(val); - let file = new File(); + const val = '/test/foo/../test.coffee'; + const expected = path.normalize(val); + const file = new File(); file.path = val; @@ -1499,7 +1499,7 @@ describe('File', () => { }); it('removes the trailing separator upon set', done => { - let file = new File(); + const file = new File(); file.path = '/test/'; expect(file.path).toEqual(path.normalize('/test')); @@ -1508,7 +1508,7 @@ describe('File', () => { }); it('removes the trailing separator upon set when directory', done => { - let file = new File({ + const file = new File({ stat: { isDirectory() { return true; @@ -1523,7 +1523,7 @@ describe('File', () => { }); it('removes the trailing separator upon set when symlink', done => { - let file = new File({ + const file = new File({ stat: { isSymbolicLink() { return true; @@ -1538,7 +1538,7 @@ describe('File', () => { }); it('removes the trailing separator upon set when directory & symlink', done => { - let file = new File({ + const file = new File({ stat: { isDirectory() { return true; @@ -1558,15 +1558,15 @@ describe('File', () => { describe('symlink get/set', () => { it('return null on get with no symlink', done => { - let file = new File(); + const file = new File(); expect(file.symlink).toEqual(null); done(); }); it('returns _symlink', done => { - let val = '/test/test.coffee'; - let file = new File() as TestFile; + const val = '/test/test.coffee'; + const file = new File() as TestFile; file._symlink = val; expect(file.symlink).toEqual(val); @@ -1574,7 +1574,7 @@ describe('File', () => { }); it('throws on set with non-string', done => { - let file = new File(); + const file = new File(); function invalid() { file.symlink = null; @@ -1585,9 +1585,9 @@ describe('File', () => { }); it('sets _symlink', done => { - let val = '/test/test.coffee'; - let expected = path.normalize(val); - let file = new File() as TestFile; + const val = '/test/test.coffee'; + const expected = path.normalize(val); + const file = new File() as TestFile; file.symlink = val; expect(file._symlink).toEqual(expected); @@ -1595,8 +1595,8 @@ describe('File', () => { }); it('allows relative symlink', done => { - let val = 'test.coffee'; - let file = new File(); + const val = 'test.coffee'; + const file = new File(); file.symlink = val; expect(file.symlink).toEqual(val); @@ -1604,9 +1604,9 @@ describe('File', () => { }); it('normalizes and removes trailing separator upon set', done => { - let val = '/test/foo/../bar/'; - let expected = path.normalize(val.slice(0, -1)); - let file = new File(); + const val = '/test/foo/../bar/'; + const expected = path.normalize(val.slice(0, -1)); + const file = new File(); file.symlink = val; expect(file.symlink).toEqual(expected); From 37c948fdc189cf42a755cfecacdaa17f6d60519c Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 10:38:06 +0900 Subject: [PATCH 182/298] cleanup ignore lint error: no-conditional-assignment --- types/vinyl/tslint.json | 1 - types/vinyl/vinyl-tests.ts | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/types/vinyl/tslint.json b/types/vinyl/tslint.json index 54cc466d67..5eea98e41f 100644 --- a/types/vinyl/tslint.json +++ b/types/vinyl/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "no-conditional-assignment": false, "no-construct": false, "no-var-requires": false } diff --git a/types/vinyl/vinyl-tests.ts b/types/vinyl/vinyl-tests.ts index 31b1b68ee6..777ed6fcce 100644 --- a/types/vinyl/vinyl-tests.ts +++ b/types/vinyl/vinyl-tests.ts @@ -571,8 +571,7 @@ describe('File', () => { // Start flowing file2 file2.contents.on('readable', function(this: NodeJS.ReadableStream) { - let chunk: string | Buffer; - while ((chunk = this.read()) !== null) { + for (let chunk: string | Buffer = this.read(); chunk !== null; chunk = this.read()) { data2 += chunk.toString(); } }); From 349c8bb54469b8e78da9a2aa663db2d32aa77aa5 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 10:41:26 +0900 Subject: [PATCH 183/298] cleanup ignore lint error: no-construct All lines whose rules are ignored are all clearly intentioned codes. --- types/vinyl/tslint.json | 1 - types/vinyl/vinyl-tests.ts | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/vinyl/tslint.json b/types/vinyl/tslint.json index 5eea98e41f..1e30988418 100644 --- a/types/vinyl/tslint.json +++ b/types/vinyl/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "no-construct": false, "no-var-requires": false } } diff --git a/types/vinyl/vinyl-tests.ts b/types/vinyl/vinyl-tests.ts index 777ed6fcce..3a73249b60 100644 --- a/types/vinyl/vinyl-tests.ts +++ b/types/vinyl/vinyl-tests.ts @@ -59,6 +59,7 @@ describe('File', () => { }); it('returns false for a String object', done => { + // tslint:disable-next-line:no-construct const result = File.isVinyl(new String('foobar')); expect(result).toEqual(false); done(); @@ -71,6 +72,7 @@ describe('File', () => { }); it('returns false for a Number object', done => { + // tslint:disable-next-line:no-construct const result = File.isVinyl(new Number(1)); expect(result).toEqual(false); done(); From 2d8abb5309e86705e7b7e4922a968fb8c915d862 Mon Sep 17 00:00:00 2001 From: Colby Dehart Date: Thu, 14 Dec 2017 16:52:26 -0500 Subject: [PATCH 184/298] Adds luxon types --- types/luxon/index.d.ts | 365 +++++++++++++++++++++++++++++++++++++ types/luxon/luxon-tests.ts | 70 +++++++ types/luxon/tsconfig.json | 23 +++ types/luxon/tslint.json | 10 + 4 files changed, 468 insertions(+) create mode 100644 types/luxon/index.d.ts create mode 100644 types/luxon/luxon-tests.ts create mode 100644 types/luxon/tsconfig.json create mode 100644 types/luxon/tslint.json diff --git a/types/luxon/index.d.ts b/types/luxon/index.d.ts new file mode 100644 index 0000000000..be452819be --- /dev/null +++ b/types/luxon/index.d.ts @@ -0,0 +1,365 @@ +// Type definitions for luxon 0.2 +// Project: https://github.com/moment/luxon#readme +// Definitions by: Colby DeHart +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'luxon' { + namespace luxon { + type DateTimeFormat = any; + type ZoneOptions = { + keepCalendarTime?: boolean; + }; + + type ToFormatOptions = { + round: boolean; + }; + + type ISOTimeOptions = { + suppressMilliseconds?: boolean; + supressSeconds?: boolean; + }; + + type DateTimeOptions = { + zone?: string | Zone; + setZone?: boolean; + locale?: string; + outputCalendar?: string; + numberingSystem?: string; + }; + + type DateTimeJSOptions = { + zone?: string | Zone; + }; + + type DateObjectUnits = { + year?: number; + day?: number; + ordinal?: number; + weekYear?: number; + weekNumber?: number; + weekday?: number; + hour?: number; + minute?: number; + second?: number; + millisecond?: number; + }; + + type DateObject = DateObjectUnits & { + zone?: string | Zone; + locale?: string; + outputCalendar?: string; + numberingSystem?: string; + }; + + type DiffOptions = { + conversionAccuracy?: string; + }; + + class DateTime { + static DATETIME_FULL: DateTimeFormat; + static DATETIME_FULL_WITH_SECONDS: DateTimeFormat; + static DATEIME_HUGE: DateTimeFormat; + static DATEIME_HUGE_WITH_SECONDS: DateTimeFormat; + static DATETIME_MED: DateTimeFormat; + static DATETIME_MED_WITH_SECONDS: DateTimeFormat; + static DATETIME_SHORT: DateTimeFormat; + static DATETIME_SHORT_WITH_SECONDS: DateTimeFormat; + static DATE_FULL: DateTimeFormat; + static DATE_HUGE: DateTimeFormat; + static DATE_MED: DateTimeFormat; + static DATE_SHORT: DateTimeFormat; + static TIME_24_SIMPLE: DateTimeFormat; + static TIME_24_WITH_LONG_OFFSET: DateTimeFormat; + static TIME_24_WITH_SECONDS: DateTimeFormat; + static TIME_24_WITH_SHORT_OFFSET: DateTimeFormat; + static TIME_SIMPLE: DateTimeFormat; + static TIME_WITH_LONG_OFFSET: DateTimeFormat; + static TIME_WITH_SECONDS: DateTimeFormat; + static TIME_WITH_SHORT_OFFSET: DateTimeFormat; + static fromHTTP(text: string, options?: DateTimeOptions): DateTime; + static fromISO(text: string, options?: DateTimeOptions): DateTime; + static fromJSDate( + date: Date, + options?: DateTimeJSOptions + ): DateTime; + static fromMillis(ms: number, options?: DateTimeOptions): DateTime; + static fromObject(obj: DateObject): DateTime; + static fromRFC2822( + text: string, + options?: DateTimeOptions + ): DateTime; + static fromString( + text: string, + format: string, + options?: DateTimeOptions + ): DateTime; + static fromStringExplain( + text: string, + format: string, + options?: DateTimeOptions + ): Object; + static invalid(reason: any): DateTime; + static local( + year?: number, + month?: number, + day?: number, + hour?: number, + minute?: number, + second?: number, + millisecond?: number + ): DateTime; + static max(...dateTimes: DateTime[]): DateTime | undefined; + static min(...dateTimes: DateTime[]): DateTime; + static utc( + year?: number, + month?: number, + day?: number, + hour?: number, + minute?: number, + second?: number, + millisecond?: number + ): DateTime; + day: number; + daysInMonth: number; + daysInYear: number; + hour: number; + invalidReason: string; + isInDST: boolean; + isOffsetFixed: boolean; + isValid: boolean; + locale: string; + millisecond: number; + minute: number; + month: number; + monthLong: string; + monthShort: string; + numberingSystem: string; + offset: number; + offsetNameLong: string; + offsetNameShort: string; + ordinal: number | DateTime; + outputCalendar: string; + second: number; + weekNumber: number; + weekYear: number; + weekday: string; + weekdayLong: string; + weekdayShort: string; + year: number; + zoneName: string; + diff( + other: DateTime, + unit?: string | string[], + options?: DiffOptions + ): Duration; + diffNow(unit?: string | string[], options?: DiffOptions): Duration; + endOf(unit: string): DateTime; + equals(other: DateTime): boolean; + get(unit: string): number; + hasSame(other: DateTime, unit: string): boolean; + minus(duration: Duration): DateTime; + minus(milliseconds: number): DateTime; + minus(durationObject: DurationObject): DateTime; + plus(duration: Duration | number | Object): DateTime; + reconfigure(properties: Object): DateTime; + resolvedLocaleOptions(options?: Object): Object; + set(values: DateObjectUnits): DateTime; + setLocale(locale: any): DateTime; + setZone(zone: string | Zone, options?: ZoneOptions): DateTime; + startOf(unit: string): DateTime; + toFormat(format: string, options?: ToFormatOptions): string; + toHTTP(): string; + toISO(options?: Object): string; + toISODate(): string; + toISOTime(options?: ISOTimeOptions): string; + toISOWeekDate(): string; + toJSDate(): Date; + toJSON(): string; + toLocal(): DateTime; + toLocaleParts(options?: Object): any[]; + toLocaleString(options?: DateTimeFormat): string; + toObject(options?: { includeConfig?: boolean }): DateObject; + toRFC2822(): string; + toString(): string; + toUTC(offset?: number, options?: ZoneOptions): DateTime; + until(other: DateTime): Duration; + valueOf(): number; + } + + type DurationOptions = { + locale?: string; + numberingSystem?: string; + conversionAccuracy?: string; + }; + + type DurationObject = { + years?: number; + months?: number; + weeks?: number; + days?: number; + hours?: number; + minutes?: number; + seconds?: number; + milliseconds?: number; + }; + + class Duration { + static fromISO(text: string, options?: DurationOptions): Duration; + static fromMillis( + count: number, + options?: DurationOptions + ): Duration; + static fromObject( + Object: DurationObject & DurationOptions + ): Duration; + static invalid(reason?: string): Duration; + days: number; + hours: number; + invalidReason: string; + isValid: boolean; + locale: string; + milliseconds: number; + minutes: number; + months: number; + numberingSystem: string; + seconds: number; + weeks: number; + years: number; + as(unit: string): number; + equals(other: Duration): boolean; + get(unit: string): number; + minus(duration: Duration | number | Object): Duration; + negate(): Duration; + normalize(): Duration; + plus(duration: Duration | number | Object): Duration; + reconfigure(objectPattern: DurationOptions): Duration; + set(values: DurationObject): Duration; + shiftTo(...units: string[]): Duration; + toFormat(format: string, options?: ToFormatOptions): string; + toISO(): string; + toJSON(): string; + toObject(options?: { + includeConfig?: boolean; + }): DurationObject & DurationOptions; + toString(): string; + } + + type EraLength = 'short' | 'long'; + type UnitLength = EraLength & 'numeric' | '2-digit' | 'narrow'; + type UnitOptions = InfoOptions & { + numberingSystem?: string; + outputCalendar?: string; + }; + + type InfoOptions = { + locale?: string; + }; + + type Features = { + intl: boolean; + intlTokens: boolean; + timezones: boolean; + }; + + type Info = { + eras(length?: EraLength, options?: InfoOptions): string[]; + features(): Features; + hasDST(zone: string | Zone): boolean; + meridiems(options?: InfoOptions): string[]; + months(length?: UnitLength, options?: UnitOptions): string[]; + monthsFormat(length?: UnitLength, options?: UnitOptions): string[]; + weeksdays(length?: UnitLength, options?: UnitOptions): string[]; + weekdaysFormat( + length?: UnitLength, + options?: UnitOptions + ): string[]; + }; + + type IntervalObject = { + start: DateTime; + end: DateTime; + }; + + class Interval { + static after( + start: DateTime | DateObject | Date, + duration: Duration | number | DurationObject + ): Interval; + static before( + end: DateTime | DateObject | Date, + duration: Duration | number | DurationObject + ): Interval; + static fromDateTimes( + start: DateTime | DateObject | Date, + end: DateTime | DateObject | Date + ): Interval; + static fromISO(string: string, options?: DateTimeOptions): Interval; + static invalid(reason?: string): Interval; + static merge(intervals: Interval[]): [Interval]; + static xor(intervals: Interval[]): [Interval]; + end: DateTime; + invalidReason: string; + isValid: boolean; + start: DateTime; + abutsEnd(other: Interval): boolean; + abutsStart(other: Interval): boolean; + contains(dateTime: DateTime): boolean; + count(unit?: string): number; + difference(...intervals: Interval[]): Interval; + divideEqually(numberOfParts?: number): Interval[]; + engulfs(other: Interval): boolean; + equals(other: Interval): boolean; + hasSame(unit: string): boolean; + intersection(other: Interval): Interval; + isAfter(dateTime: DateTime): boolean; + isBefore(dateTime: DateTime): boolean; + isEmpty(): boolean; + length(unit?: string): number; + overlaps(other: Interval): boolean; + set(values: IntervalObject): Interval; + splitAt(...dateTimes: DateTime[]): Interval[]; + splitBy(duration: Duration | DurationObject | number): Interval[]; + toDuration( + unit: string | string[], + options?: DiffOptions + ): Duration; + toFormat( + dateFormat: string, + options?: { + seperator?: string; + } + ): string; + toISO(options?: Object): string; + toString(): string; + union(other: Interval): Interval; + } + + type Settings = { + defaultLocale: string; + defaultNumberingSystem: string; + defaultOutputCalendar: string; + defaultZone: Zone; + defaultZoneName: string; + now: Function; + throwOnInvalid: boolean; + resetCache(): void; + }; + + type ZoneOffsetOptions = { + format?: 'short' | 'long'; + localeCode?: string; + }; + + class Zone { + static offsetName(ts: number, options?: ZoneOffsetOptions): string; + static isValid: boolean; + static name: string; + static type: string; + static universal: boolean; + equals(other: Zone): boolean; + static offset(ts: number): number; + } + } + + export = luxon; +} diff --git a/types/luxon/luxon-tests.ts b/types/luxon/luxon-tests.ts new file mode 100644 index 0000000000..e76ce7d1ba --- /dev/null +++ b/types/luxon/luxon-tests.ts @@ -0,0 +1,70 @@ +import { DateTime, Duration, Interval } from 'luxon'; + +const dt = DateTime.local(2017, 5, 15, 8, 30); + +const now = DateTime.local(); + +const fromObject = DateTime.fromObject({ + day: 22, + hour: 12, + zone: 'America/Los_Angeles', + numberingSystem: 'beng' +}); + +const fromIso = DateTime.fromISO('2017-05-15'); // => May 15, 2017 at midnight +const fromIso2 = DateTime.fromISO('2017-05-15T08:30:00'); // => May 15, 2017 at midnight + +DateTime.local().toString(); // => '2017-09-14T03:20:34.091-04:00' + +const getters = DateTime.local(); +getters.year; +getters.month; +getters.day; +getters.second; +getters.weekday; +getters.zoneName; +getters.offset; +getters.daysInMonth; + +dt.toLocaleString(); +dt.toLocaleString(DateTime.DATE_MED); +dt.toISO(); + +dt.plus({ hours: 3, minutes: 2 }); +dt.minus({ days: 7 }); +dt.startOf('day'); +dt.endOf('hour'); + +dt.set({ hour: 3 }).hour; + +const f = { month: 'long', day: 'numeric' }; +dt.setLocale('fr').toLocaleString(f); +dt.setLocale('en-GB').toLocaleString(f); +dt.setLocale('en-US').toLocaleString(f); + +DateTime.fromObject({ zone: 'America/Los_Angeles' }); +DateTime.local().setZone('America/Los_Angeles'); + +DateTime.utc(2017, 5, 15); +DateTime.utc(); +DateTime.local().toUTC(); +DateTime.utc().toLocal(); + +const dur = Duration.fromObject({ hours: 2, minutes: 7 }); +dt.plus(dur); +dur.hours; +dur.minutes; +dur.seconds; + +dur.as('seconds'); +dur.toObject(); +dur.toISO(); + +const later = DateTime.local(); +const i = Interval.fromDateTimes(now, later); +i.length(); +i.length('years'); +i.contains(DateTime.local(2019)); + +i.toISO(); +i.toString(); diff --git a/types/luxon/tsconfig.json b/types/luxon/tsconfig.json new file mode 100644 index 0000000000..a425d6f79f --- /dev/null +++ b/types/luxon/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "luxon-tests.ts" + ] +} \ No newline at end of file diff --git a/types/luxon/tslint.json b/types/luxon/tslint.json new file mode 100644 index 0000000000..f5f19998ca --- /dev/null +++ b/types/luxon/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "ban-types": false, + "no-single-declare-module": false, + "interface-over-type-literal": false, + "unified-signatures": false, + "no-declare-current-package": false + } +} From 4066f1d06e2c1e646622ace6459b97c4a37427d3 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 11:27:03 +0900 Subject: [PATCH 185/298] Delete unnecessary rule invalidation setting --- types/vinyl-buffer/tslint.json | 71 +--------------------------------- 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/types/vinyl-buffer/tslint.json b/types/vinyl-buffer/tslint.json index a41bf5d19a..9466d3255b 100644 --- a/types/vinyl-buffer/tslint.json +++ b/types/vinyl-buffer/tslint.json @@ -1,79 +1,10 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, "callable-types": false, - "comment-format": false, "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "semicolon": false } } From 64b77e2e76ae2e4e5af732c00e57117c7aa10da8 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 11:28:51 +0900 Subject: [PATCH 186/298] cleanup simple format ignore lint errors - no-consecutive-blank-lines - only-arrow-functions - semicolon --- types/vinyl-buffer/index.d.ts | 1 - types/vinyl-buffer/tslint.json | 5 +---- types/vinyl-buffer/vinyl-buffer-tests.ts | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/types/vinyl-buffer/index.d.ts b/types/vinyl-buffer/index.d.ts index 72d5067769..f0ff53a035 100644 --- a/types/vinyl-buffer/index.d.ts +++ b/types/vinyl-buffer/index.d.ts @@ -5,7 +5,6 @@ /// - declare namespace buffer { interface Buffer { (): NodeJS.ReadWriteStream; diff --git a/types/vinyl-buffer/tslint.json b/types/vinyl-buffer/tslint.json index 9466d3255b..6951b16e6e 100644 --- a/types/vinyl-buffer/tslint.json +++ b/types/vinyl-buffer/tslint.json @@ -2,9 +2,6 @@ "extends": "dtslint/dt.json", "rules": { "callable-types": false, - "dt-header": false, - "no-consecutive-blank-lines": false, - "only-arrow-functions": false, - "semicolon": false + "dt-header": false } } diff --git a/types/vinyl-buffer/vinyl-buffer-tests.ts b/types/vinyl-buffer/vinyl-buffer-tests.ts index b1311ccbc0..fdfb84b194 100644 --- a/types/vinyl-buffer/vinyl-buffer-tests.ts +++ b/types/vinyl-buffer/vinyl-buffer-tests.ts @@ -1,8 +1,8 @@ import buffer = require('vinyl-buffer'); -import gulp = require('gulp') +import gulp = require('gulp'); import browserify = require('browserify'); -gulp.task('build', function() { +gulp.task('build', () => { return browserify('./index.js') .bundle() .pipe(buffer()) From 164fadcca67409a70c98d17a83a21e8a64df4249 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 11:33:32 +0900 Subject: [PATCH 187/298] cleanup ignore lint error: dt-header --- types/vinyl-buffer/index.d.ts | 2 +- types/vinyl-buffer/tslint.json | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/vinyl-buffer/index.d.ts b/types/vinyl-buffer/index.d.ts index f0ff53a035..bdda31817c 100644 --- a/types/vinyl-buffer/index.d.ts +++ b/types/vinyl-buffer/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for vinyl-buffer +// Type definitions for vinyl-buffer 1.0 // Project: https://github.com/hughsk/vinyl-buffer // Definitions by: Qubo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/vinyl-buffer/tslint.json b/types/vinyl-buffer/tslint.json index 6951b16e6e..a4bcc87748 100644 --- a/types/vinyl-buffer/tslint.json +++ b/types/vinyl-buffer/tslint.json @@ -1,7 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "callable-types": false, - "dt-header": false + "callable-types": false } } From 310ffa955e08105852078d60139b4e5a0a63f4bd Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 11:40:39 +0900 Subject: [PATCH 188/298] cleanup ignore lint error: callable-types --- types/vinyl-buffer/index.d.ts | 4 +--- types/vinyl-buffer/tslint.json | 7 +------ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/types/vinyl-buffer/index.d.ts b/types/vinyl-buffer/index.d.ts index bdda31817c..949efd20cc 100644 --- a/types/vinyl-buffer/index.d.ts +++ b/types/vinyl-buffer/index.d.ts @@ -6,9 +6,7 @@ /// declare namespace buffer { - interface Buffer { - (): NodeJS.ReadWriteStream; - } + type Buffer = () => NodeJS.ReadWriteStream; } declare var buffer: buffer.Buffer; diff --git a/types/vinyl-buffer/tslint.json b/types/vinyl-buffer/tslint.json index a4bcc87748..3db14f85ea 100644 --- a/types/vinyl-buffer/tslint.json +++ b/types/vinyl-buffer/tslint.json @@ -1,6 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "callable-types": false - } -} +{ "extends": "dtslint/dt.json" } From 8a6af8aabda3038b3445335df0e9bafdad0e3b74 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 11:52:26 +0900 Subject: [PATCH 189/298] Delete unnecessary rule invalidation setting --- types/stylus/tslint.json | 63 +--------------------------------------- 1 file changed, 1 insertion(+), 62 deletions(-) diff --git a/types/stylus/tslint.json b/types/stylus/tslint.json index a41bf5d19a..b20ec58f95 100644 --- a/types/stylus/tslint.json +++ b/types/stylus/tslint.json @@ -1,79 +1,18 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, "ban-types": false, "callable-types": false, - "comment-format": false, "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, "no-var-keyword": false, "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, "one-line": false, - "one-variable-per-declaration": false, "only-arrow-functions": false, - "prefer-conditional-expression": false, "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, "space-before-function-paren": false, - "space-within-parens": false, "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "unified-signatures": false } } From 2add5d1ab9fd2f9a61c0b2aaa06a056aa9c716a0 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 11:56:36 +0900 Subject: [PATCH 190/298] cleanup simple format ignore lint errors * no-padding * no-var-keyword * one-line * space-before-function-paren --- types/stylus/index.d.ts | 6 +----- types/stylus/stylus-tests.ts | 22 +++++++++++----------- types/stylus/tslint.json | 4 ---- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/types/stylus/index.d.ts b/types/stylus/index.d.ts index 47854aaf60..bac45c8cce 100644 --- a/types/stylus/index.d.ts +++ b/types/stylus/index.d.ts @@ -10,7 +10,6 @@ declare var stylus: Stylus.Static; export = stylus; declare namespace Stylus { - export interface Static { /** * Return a new `Renderer` for the given `str` and `options`. @@ -720,7 +719,6 @@ declare namespace Stylus { //#region Nodes Classes export module Nodes { - export class Node { lineno: number; column: number; @@ -807,9 +805,7 @@ declare namespace Stylus { toJSON(): { val: string; quote: string; lineno: number; column: number; filename: string }; } - export class Number extends Node { - - } + export class Number extends Node { } export class Boolean extends Node { val: boolean; diff --git a/types/stylus/stylus-tests.ts b/types/stylus/stylus-tests.ts index 248b6a9a04..91c143308b 100644 --- a/types/stylus/stylus-tests.ts +++ b/types/stylus/stylus-tests.ts @@ -6,19 +6,19 @@ import stylus = require("stylus"); -var str = "This is a stylus test"; +let str = "This is a stylus test"; /** * Basic Usage */ -stylus.render(str, { filename: 'nesting.css' }, function(err, css){ +stylus.render(str, { filename: 'nesting.css' }, function(err, css) { if (err) throw err; console.log(css); }); stylus(str) .set('filename', 'nesting.css') - .render(function (err, css) { + .render(function(err, css) { // logic }); @@ -29,7 +29,7 @@ stylus(str) stylus(str) .set('filename', __dirname + '/test.styl') .set('paths', [__dirname, __dirname + '/mixins']) - .render(function (err, css) { + .render(function(err, css) { // logic }); @@ -40,7 +40,7 @@ stylus(str) stylus(str) .include(require('nib').path) .include(process.env.HOME + '/mixins') - .render(function (err, css) { + .render(function(err, css) { // logic }); @@ -51,7 +51,7 @@ stylus(str) stylus(str) .set('filename', __dirname + '/test.styl') .import('mixins/vendor') - .render(function (err, css) { + .render(function(err, css) { if (err) throw err; console.log(css); }); @@ -72,11 +72,11 @@ stylus(str) .define('list', { foo: 'bar', bar: 'baz' }) .define('families', ['Helvetica Neue', 'Helvetica', 'sans-serif']) - .define('get-list', function () { + .define('get-list', function() { return ['foo', 'bar', 'baz']; }) - .render(function (err, css) { + .render(function(err, css) { if (err) throw err; console.log(css); }); @@ -85,16 +85,16 @@ stylus(str) * .use(fn) * https://github.com/LearnBoost/stylus/blob/master/docs/js.md#usefn */ -var mylib = function (style: any) { +let mylib = function(style: any) { style.define('number', 15.5); - style.define('get-list', function () { + style.define('get-list', function() { return ['foo', 'bar', 'baz']; }); }; stylus(str) .use(mylib) - .render(function (err, css) { + .render(function(err, css) { if (err) throw err; console.log(css); }); diff --git a/types/stylus/tslint.json b/types/stylus/tslint.json index b20ec58f95..f86d5e1a30 100644 --- a/types/stylus/tslint.json +++ b/types/stylus/tslint.json @@ -5,13 +5,9 @@ "callable-types": false, "dt-header": false, "no-internal-module": false, - "no-padding": false, - "no-var-keyword": false, "no-var-requires": false, - "one-line": false, "only-arrow-functions": false, "prefer-const": false, - "space-before-function-paren": false, "strict-export-declare-modifiers": false, "unified-signatures": false } From 9176b6ea8279480db84d1a8ce77ce5b2dda952f6 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 11:59:49 +0900 Subject: [PATCH 191/298] cleanup lint ignore error: only-arrow-functions --- types/stylus/stylus-tests.ts | 20 ++++++++++---------- types/stylus/tslint.json | 1 - 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/types/stylus/stylus-tests.ts b/types/stylus/stylus-tests.ts index 91c143308b..9483d6d70f 100644 --- a/types/stylus/stylus-tests.ts +++ b/types/stylus/stylus-tests.ts @@ -11,14 +11,14 @@ let str = "This is a stylus test"; /** * Basic Usage */ -stylus.render(str, { filename: 'nesting.css' }, function(err, css) { +stylus.render(str, { filename: 'nesting.css' }, (err, css) => { if (err) throw err; console.log(css); }); stylus(str) .set('filename', 'nesting.css') - .render(function(err, css) { + .render((err, css) => { // logic }); @@ -29,7 +29,7 @@ stylus(str) stylus(str) .set('filename', __dirname + '/test.styl') .set('paths', [__dirname, __dirname + '/mixins']) - .render(function(err, css) { + .render((err, css) => { // logic }); @@ -40,7 +40,7 @@ stylus(str) stylus(str) .include(require('nib').path) .include(process.env.HOME + '/mixins') - .render(function(err, css) { + .render((err, css) => { // logic }); @@ -51,7 +51,7 @@ stylus(str) stylus(str) .set('filename', __dirname + '/test.styl') .import('mixins/vendor') - .render(function(err, css) { + .render((err, css) => { if (err) throw err; console.log(css); }); @@ -72,11 +72,11 @@ stylus(str) .define('list', { foo: 'bar', bar: 'baz' }) .define('families', ['Helvetica Neue', 'Helvetica', 'sans-serif']) - .define('get-list', function() { + .define('get-list', () => { return ['foo', 'bar', 'baz']; }) - .render(function(err, css) { + .render((err, css) => { if (err) throw err; console.log(css); }); @@ -85,16 +85,16 @@ stylus(str) * .use(fn) * https://github.com/LearnBoost/stylus/blob/master/docs/js.md#usefn */ -let mylib = function(style: any) { +let mylib = (style: any) => { style.define('number', 15.5); - style.define('get-list', function() { + style.define('get-list', () => { return ['foo', 'bar', 'baz']; }); }; stylus(str) .use(mylib) - .render(function(err, css) { + .render((err, css) => { if (err) throw err; console.log(css); }); diff --git a/types/stylus/tslint.json b/types/stylus/tslint.json index f86d5e1a30..3ea4fd2963 100644 --- a/types/stylus/tslint.json +++ b/types/stylus/tslint.json @@ -6,7 +6,6 @@ "dt-header": false, "no-internal-module": false, "no-var-requires": false, - "only-arrow-functions": false, "prefer-const": false, "strict-export-declare-modifiers": false, "unified-signatures": false From 81be59be0aa0a0449cc0aa87be5721e90c9a4641 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 12:00:53 +0900 Subject: [PATCH 192/298] cleanup lint ignore error: prefer-const --- types/stylus/stylus-tests.ts | 4 ++-- types/stylus/tslint.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/stylus/stylus-tests.ts b/types/stylus/stylus-tests.ts index 9483d6d70f..d92dcbc0c8 100644 --- a/types/stylus/stylus-tests.ts +++ b/types/stylus/stylus-tests.ts @@ -6,7 +6,7 @@ import stylus = require("stylus"); -let str = "This is a stylus test"; +const str = "This is a stylus test"; /** * Basic Usage @@ -85,7 +85,7 @@ stylus(str) * .use(fn) * https://github.com/LearnBoost/stylus/blob/master/docs/js.md#usefn */ -let mylib = (style: any) => { +const mylib = (style: any) => { style.define('number', 15.5); style.define('get-list', () => { return ['foo', 'bar', 'baz']; diff --git a/types/stylus/tslint.json b/types/stylus/tslint.json index 3ea4fd2963..c7235b92f0 100644 --- a/types/stylus/tslint.json +++ b/types/stylus/tslint.json @@ -6,7 +6,6 @@ "dt-header": false, "no-internal-module": false, "no-var-requires": false, - "prefer-const": false, "strict-export-declare-modifiers": false, "unified-signatures": false } From 260fc4a0dc0ff7f380d8d600cf3dcd7d85ae9e72 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 12:01:52 +0900 Subject: [PATCH 193/298] cleanup lint ignore error: dt-header --- types/stylus/index.d.ts | 2 +- types/stylus/tslint.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/types/stylus/index.d.ts b/types/stylus/index.d.ts index bac45c8cce..9009d86665 100644 --- a/types/stylus/index.d.ts +++ b/types/stylus/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for stylus 0.48.1 +// Type definitions for stylus 0.48 // Project: https://github.com/LearnBoost/stylus // Definitions by: Maxime LUCE // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/stylus/tslint.json b/types/stylus/tslint.json index c7235b92f0..8a0741c21d 100644 --- a/types/stylus/tslint.json +++ b/types/stylus/tslint.json @@ -3,7 +3,6 @@ "rules": { "ban-types": false, "callable-types": false, - "dt-header": false, "no-internal-module": false, "no-var-requires": false, "strict-export-declare-modifiers": false, From 068a4b653b94cf2cf0f17c7c622bf787472c3432 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 12:54:18 +0900 Subject: [PATCH 194/298] cleanup ignore lint errors: ban-types, callable-types --- types/stylus/index.d.ts | 48 ++++++++++++++++++---------------------- types/stylus/tslint.json | 2 -- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/types/stylus/index.d.ts b/types/stylus/index.d.ts index 9009d86665..6713b54eb0 100644 --- a/types/stylus/index.d.ts +++ b/types/stylus/index.d.ts @@ -582,7 +582,7 @@ declare namespace Stylus { /** * Return param names for `fn`. */ - params(fn: Function): string[]; + params(fn: (...args: any[]) => any): string[]; /** * Merge object `b` with `a`. @@ -617,9 +617,7 @@ declare namespace Stylus { }; } - export interface Middleware { - (req: any, res: any, next: Function): void; - } + export type Middleware = (req: any, res: any, next: (...args: any[]) => any) => void; //#endregion @@ -663,7 +661,7 @@ declare namespace Stylus { /** * Set option `key` to `val`. */ - set(key: string, val: any): Renderer; + set(key: string, val: any): this; /** * Get option `key`. @@ -673,7 +671,7 @@ declare namespace Stylus { /** * Include the given `path` to the lookup paths array. */ - include(path: string): Renderer; + include(path: string): this; /** * Use the given `fn`. @@ -681,34 +679,34 @@ declare namespace Stylus { * This allows for plugins to alter the renderer in * any way they wish, exposing paths etc. */ - use(fn: (renderer: Renderer) => any): Renderer; + use(fn: (renderer: Renderer) => any): this; /** * Define function or global var with the given `name`. Optionally * the function may accept full expressions, by setting `raw` * to `true`. */ - define(name: string, fn: Function): Renderer; - define(name: string, node: Nodes.Node): Renderer; - define(name: string, val: any): Renderer; - define(name: string, fn: Function, raw: boolean): Renderer; - define(name: string, node: Nodes.Node, raw: boolean): Renderer; - define(name: string, val: any, raw: boolean): Renderer; + define(name: string, fn: (...args: any[]) => any): this; + define(name: string, node: Nodes.Node): this; + define(name: string, val: any): this; + define(name: string, fn: (...args: any[]) => any, raw: boolean): this; + define(name: string, node: Nodes.Node, raw: boolean): this; + define(name: string, val: any, raw: boolean): this; /** * Import the given `file`. */ - import(file: string): Renderer; + import(file: string): this; //#region EventEmitter Members - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; + addListener(event: string, listener: (...args: any[]) => any): this; + on(event: string, listener: (...args: any[]) => any): this; + once(event: string, listener: (...args: any[]) => any): this; + removeListener(event: string, listener: (...args: any[]) => any): this; removeAllListeners(event?: string): this; setMaxListeners(n: number): this; getMaxListeners(): number; - listeners(event: string): Function[]; + listeners(event: string): Array<(...args: any[]) => any>; emit(event: string, ...args: any[]): boolean; listenerCount(type: string): number; //#endregion @@ -748,7 +746,7 @@ declare namespace Stylus { /** * Return true. */ - toBoolean(): Boolean; + toBoolean(): Nodes.Boolean; /** * Return the expression, or wrap this node in an expression. @@ -818,12 +816,12 @@ declare namespace Stylus { /** * Negate the value. */ - negate(): Boolean; + negate(): Nodes.Boolean; /** * Return 'Boolean'. */ - inspect(): Boolean; + inspect(): string; /** * Return a JSON representation of this node. @@ -840,7 +838,7 @@ declare namespace Stylus { /** * Set `key` to `val`. */ - set(key: string, value: Node): Object; + set(key: string, value: Node): this; /** * Get `key`. @@ -1416,9 +1414,7 @@ declare namespace Stylus { Evaluator?: typeof Evaluator; } - export interface RenderCallback { - (err: Error, css: string, js: string): void; - } + export type RenderCallback = (err: Error, css: string, js: string) => void; export interface UrlOptions { limit?: string; diff --git a/types/stylus/tslint.json b/types/stylus/tslint.json index 8a0741c21d..ec84f4dd4a 100644 --- a/types/stylus/tslint.json +++ b/types/stylus/tslint.json @@ -1,8 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "ban-types": false, - "callable-types": false, "no-internal-module": false, "no-var-requires": false, "strict-export-declare-modifiers": false, From efec996129cabe6abbe9474e94273ec4a27b083e Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 15 Dec 2017 13:14:20 +0900 Subject: [PATCH 195/298] Fix lint error: no-unnecessary-qualifier If you do not ignore it, it hides builtin 's type, making it difficult to grasp which type it is. --- types/stylus/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/stylus/index.d.ts b/types/stylus/index.d.ts index 6713b54eb0..58a41872b1 100644 --- a/types/stylus/index.d.ts +++ b/types/stylus/index.d.ts @@ -746,6 +746,7 @@ declare namespace Stylus { /** * Return true. */ + // tslint:disable-next-line no-unnecessary-qualifier toBoolean(): Nodes.Boolean; /** @@ -816,6 +817,7 @@ declare namespace Stylus { /** * Negate the value. */ + // tslint:disable-next-line no-unnecessary-qualifier negate(): Nodes.Boolean; /** From a6f2a61bae0019568ce271b686e0ce21ffdcec77 Mon Sep 17 00:00:00 2001 From: kamijin_fanta Date: Fri, 15 Dec 2017 14:18:07 +0900 Subject: [PATCH 196/298] update `ConnectedRouterProps` in react-redux-router see: https://github.com/ReactTraining/react-router/pull/5777 --- types/react-router-redux/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-router-redux/index.d.ts b/types/react-router-redux/index.d.ts index 8f92012e0a..5f5d9b31ea 100644 --- a/types/react-router-redux/index.d.ts +++ b/types/react-router-redux/index.d.ts @@ -22,7 +22,7 @@ import * as React from 'react'; export interface ConnectedRouterProps { store?: Store; - history?: History; + history: History; } export class ConnectedRouter extends React.Component> {} From 91c9412a28c42ab3730409be6d6b8487d67ee267 Mon Sep 17 00:00:00 2001 From: Mister 4 Eyes Date: Fri, 15 Dec 2017 02:35:40 -0500 Subject: [PATCH 197/298] Changed 'import * as ... from ...' to 'import ... = require(...)' This was in response to plantain-00's review. --- .../express-flash-notification-tests.ts | 4 ++-- types/express-flash-notification/index.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/express-flash-notification/express-flash-notification-tests.ts b/types/express-flash-notification/express-flash-notification-tests.ts index d5f5f3151f..df740cff01 100644 --- a/types/express-flash-notification/express-flash-notification-tests.ts +++ b/types/express-flash-notification/express-flash-notification-tests.ts @@ -1,5 +1,5 @@ -import * as express from "express"; -import * as flash from "express-flash-notification"; +import express = require("express"); +import flash = require("express-flash-notification"); const app = express(); diff --git a/types/express-flash-notification/index.d.ts b/types/express-flash-notification/index.d.ts index 7c9fdff97e..68bbb8eaeb 100644 --- a/types/express-flash-notification/index.d.ts +++ b/types/express-flash-notification/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 -import * as express from "express"; +import express = require("express"); interface efnOptions { sessionName?: string; From 36a406471410778dbffcf34559a267ff3c18026b Mon Sep 17 00:00:00 2001 From: RonanDrouglazet Date: Fri, 15 Dec 2017 11:04:33 +0100 Subject: [PATCH 198/298] Improve return def of context and contexts mobile method --- types/webdriverio/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/webdriverio/index.d.ts b/types/webdriverio/index.d.ts index f1d37d0f88..a0fee79a19 100644 --- a/types/webdriverio/index.d.ts +++ b/types/webdriverio/index.d.ts @@ -793,8 +793,8 @@ declare namespace WebdriverIO { interface Client { background(seconds: number): Client; closeApp(): Client; - context(id?: string): Client; - contexts(): Client; + context(id?: string): Client & RawResult; + contexts(): Client & RawResult; currentActivity(): any; deviceKeyEvent(keyValue: number): Client; getAppStrings(language: string): Client; From 2242fe7adf610eda0283b55a2e3af36faf4fd23c Mon Sep 17 00:00:00 2001 From: Ricky Lippmann Date: Fri, 15 Dec 2017 11:25:32 +0100 Subject: [PATCH 199/298] clean some linting issues, export namespace, add version and provide small test --- types/amcharts/amcharts-tests.ts | 7 + types/amcharts/index.d.ts | 225 ++++++++++++++----------------- types/amcharts/tsconfig.json | 3 +- types/amcharts/tslint.json | 72 +--------- 4 files changed, 112 insertions(+), 195 deletions(-) create mode 100644 types/amcharts/amcharts-tests.ts diff --git a/types/amcharts/amcharts-tests.ts b/types/amcharts/amcharts-tests.ts new file mode 100644 index 0000000000..067643b1ce --- /dev/null +++ b/types/amcharts/amcharts-tests.ts @@ -0,0 +1,7 @@ +import { AmCharts } from "amcharts"; + +// TODO: provide much more tests + +const gauge = new AmCharts.AmAngularGauge({ + theme: "light" +}); diff --git a/types/amcharts/index.d.ts b/types/amcharts/index.d.ts index e18602df4c..37351b0d1a 100644 --- a/types/amcharts/index.d.ts +++ b/types/amcharts/index.d.ts @@ -1,32 +1,31 @@ -// Type definitions for amCharts +// Type definitions for amCharts 3.21 // Project: http://www.amcharts.com/ // Definitions by: aleksey-bykov // ldrick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// AmCharts object (it's not a class) is create automatically when amcharts.js or amstock.js file is included in a web page. -declare namespace AmCharts { - +export namespace AmCharts { /** Set it to true if you have base href set for your page. This will fix rendering problems in Firefox caused by base href. */ - var baseHref: boolean; + let baseHref: boolean; /** Array of day names, used when formatting dates (if categoryAxis.parseDates is set to true) ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] */ - var dayNames: string[]; + let dayNames: string[]; /** Array of month names, used when formatting dates (if categoryAxis.parseDates is set to true) ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] */ - var monthNames: string[]; + let monthNames: string[]; /** Array of short versions of day names, used when formatting dates (if categoryAxis.parseDates is set to true) ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] */ - var shortDayNames: string[]; + let shortDayNames: string[]; /** Array of short versions of month names, used when formatting dates (if categoryAxis.parseDates is set to true) ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] */ - var shortMonthNames: string[]; + let shortMonthNames: string[]; /** Set it to true if you want UTC time to be used instead of local time. */ - var useUTC: boolean; + let useUTC: boolean; /** Object with themes */ - var themes: any; + let themes: any; /** Clears all the charts on page, removes listeners and intervals. */ function clear(): void; @@ -41,16 +40,16 @@ declare namespace AmCharts { * When the method is called, the chart instance is passed as an attribute. * You can use this feature to preprocess chart data or do some other things you need * before initializing the chart. - * @param {Function} handler - The method to be called. - * @param {string[]} types - Which chart types should call this method. Defaults to all + * @param handler - The method to be called. + * @param types - Which chart types should call this method. Defaults to all * if none is passed. */ function addInitHandler(handler: Function, types: string[]): any; /** AmPieChart class creates pie/donut chart. In order to display pie chart you need to set at least three properties - dataProvider, titleField and valueField. @example - var chartData = [{title:"Pie I have eaten",value:70},{title:"Pie I haven\'t eaten",value:30}]; - var chart = new AmCharts.AmPieChart(); + let chartData = [{title:"Pie I have eaten",value:70},{title:"Pie I haven\'t eaten",value:30}]; + let chart = new AmCharts.AmPieChart(); chart.valueField = "value"; chart.titleField = "title"; chart.dataProvider = chartData; @@ -224,8 +223,8 @@ declare namespace AmCharts { /** AmRadarChart is the class you have to use for radar and polar chart types. @example - var chart; - var chartData = [ + let chart; + let chartData = [ {country:"Czech Republic",litres:156.90}, {country:"Ireland",litres:131.10}, {country:"Germany",litres:115.80}, @@ -233,27 +232,27 @@ declare namespace AmCharts { {country:"Austria",litres:108.30}, {country:"UK",litres:99.00} ]; - + window.onload = function() { chart = new AmCharts.AmRadarChart(); chart.dataProvider = chartData; chart.categoryField = "country"; chart.startDuration = 2; - - var valueAxis = new AmCharts.ValueAxis(); + + let valueAxis = new AmCharts.ValueAxis(); valueAxis.axisAlpha = 0.15; valueAxis.minimum = 0; valueAxis.dashLength = 3; valueAxis.axisTitleOffset = 20; valueAxis.gridCount = 5; chart.addValueAxis(valueAxis); - - var graph = new AmCharts.AmGraph(); + + let graph = new AmCharts.AmGraph(); graph.valueField = "litres"; graph.bullet = "round"; graph.balloonText = "[[value]] litres of beer per year" chart.addGraph(graph); - + chart.write("chartdiv"); } */ @@ -272,7 +271,7 @@ declare namespace AmCharts { /** AmXYChart is the class you have to use for XY/Bubble/Scatter chart types. The chart supports simple and logarithmic scales, it can have multiple value axes. @example - var chartData = [ + let chartData = [ {x:10, y:14, value:59}, {x:5, y:3, value:50}, {x:-10, y:-3, value:19}, @@ -281,38 +280,38 @@ declare namespace AmCharts { {x:13, y:1, value:8}, {x:1, y:6, value:35} ]; - - var chart = new AmCharts.AmXYChart(); + + let chart = new AmCharts.AmXYChart(); chart.pathToImages = "../../amcharts/javascript/images/"; chart.dataProvider = chartData; chart.marginLeft = 35; chart.startDuration = 1.5; - - var xAxis = new AmCharts.ValueAxis(); + + let xAxis = new AmCharts.ValueAxis(); xAxis.position = "left"; xAxis.autoGridCount = true; chart.addValueAxis(xAxis); - - var yAxis = new AmCharts.ValueAxis(); + + let yAxis = new AmCharts.ValueAxis(); yAxis.position = "bottom"; yAxis.autoGridCount = true; chart.addValueAxis(yAxis); - - var graph = new AmCharts.AmGraph(); + + let graph = new AmCharts.AmGraph(); graph.valueField = "value"; graph.xField = "x"; graph.yField = "y"; graph.lineAlpha = 0; graph.bullet = "round"; chart.addGraph(graph); - - var chartCursor = new AmCharts.ChartCursor(); + + let chartCursor = new AmCharts.ChartCursor(); chart.addChartCursor(chartCursor); - - var chartScrollbar = new AmCharts.ChartScrollbar(); + + let chartScrollbar = new AmCharts.ChartScrollbar(); chartScrollbar.hideResizeGrips = false; chart.addChartScrollbar(chartScrollbar); - + chart.write("chartdiv); */ class AmXYChart extends AmRectangularChart { @@ -328,7 +327,7 @@ declare namespace AmCharts { zoomOut(): void; } /** Guides are straight vertical or horizontal lines or areas supported by AmSerialChart, AmXYChart and AmRadarChart. You can have guides both on value and category axes. To add/remove a guide to an axis, use axis.addGuide(guide)/axis.removeGuide(guide) methods. - + If you do not set properties such as dashLength, lineAlpha, lineColor, etc - values of the axis are used.*/ class Guide { /** If you set it to true, the guide will be displayed above the graphs. */ @@ -518,7 +517,6 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val visibleInLegend: boolean; } - /** AmStockChart is a main class Stock chart. */ class AmStockChart { /** Specifies if animation was already played. Animation is only played once, when chart is rendered for the first time. If you want the animation to be repeated, set this property to false. */ @@ -579,8 +577,6 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val clear(): void; /** Hides event bullets. */ hideStockEvents(): void; - /** Removes event listener from the object. */ - removeListener(obj: any, type: string, handler: any): void; /** Removes panel from the stock chart. Requires stockChart.validateNow() method to be called after this action. */ removePanel(panel: StockPanel): void; /** Shows event bullets. */ @@ -713,18 +709,15 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val unit: string; /** Position of the unit. Possible values are "left" or "right". */ unitPosition: string; - } - /** AmLegend is the class that displays legend of the chart. Legend to the chart should be added using chart.addLegend(legend) method. @example - var chart = new AmCharts.AmSerialChart(); - var legend = new AmCharts.AmLegend(); + let chart = new AmCharts.AmSerialChart(); + let legend = new AmCharts.AmLegend(); chart.addLegend(legend); */ class AmLegend { - /** Alignment of legend entries. Possible values are: "left", "center", "right". left */ align: string; /** Used if chart is Serial or XY. In case true, margins of the legend are adjusted and made equal to chart's margins. @@ -851,10 +844,11 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val If the type if "rollOverMarker", dispatched when user clicks on a legend item marker and shows corresponding object. */ - /** Adds event listener of the type "showItem" to the object. - @param type Always "showItem". - @param handler - */ + /** + * Adds event listener of the type "showItem" to the object. + * @param type Always "showItem". + * @param handler The event handler. + */ addListener(type: string, handler: (e: {/** Always "showItem". */ type: string; dataItem: Object; chart: AmChart; }) => void): void; @@ -864,18 +858,14 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val } /** StockLegend is a legend of StockPanel. */ - class StockLegend extends AmLegend { /** The text which will be displayed in the value portion of the legend when graph is comparable and at least one dataSet is selected for comparing. You can use tags like [[value]], [[open]], [[high]], [[low]], [[close]], [[percents.value/open/close/low/high]], [[description]]. [[percents.value]]% */ - valueTextComparing: string; /** The text which will be displayed in the value portion of the legend. You can use tags like [[value]], [[open]], [[high]], [[low]], [[close]], [[percents]], [[description]]. [[value]] */ - valueTextRegular: string; } /** StockPanel class creates stock panels (charts). AmStockChart can have multiple Stock panels. */ - class StockPanel extends AmSerialChart { /** Specifies whether x button will be displayed near the panel. This button allows turning panel off. */ allowTurningOff: boolean; @@ -897,7 +887,6 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val @default true */ showCategoryAxis: boolean; - /** */ stockGraphs: StockGraph[]; /** Stock chart legend. */ stockLegend: StockLegend; @@ -992,7 +981,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** Specifies absolute or relative path to amCharts files, i.e. "amcharts/". (where all .js files are located) If relative URLs are used, they will be relative to the current web page, displaying the chart. You can also set path globally, using global JavaScript variable AmCharts_path. If this variable is set, and "path" is not set in chart config, the chart will assume the path from the global variable. This allows setting amCharts path globally. I.e.: - var AmCharts_path = "/libs/amcharts/"; + let AmCharts_path = "/libs/amcharts/"; "path" parameter will be used by the charts to locate it's files, like images, plugins or patterns.*/ path: string; /** Specifies path to the folder where images like resize grips, lens and similar are. @@ -1037,22 +1026,24 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val url - url */ addLabel(x: number | string, y: number | string, text: string, align: string, size?: number, color?: string, rotation?: number, alpha?: number, bold?: boolean, url?: string): any; - /** Adds a legend to the chart. - By default, you don't need to create div for your legend, however if you want it to be positioned in some different way, you can create div anywhere you want and pass id or reference to your div as a second parameter. - (NOTE: This method will not work on StockPanel.) - @param legend - @param legendDivId - Id of the legend div (optional). - */ + /** + * Adds a legend to the chart. + * By default, you don't need to create div for your legend, however if you want it to be positioned in some different way, you can create div anywhere you want and pass id or reference to your div as a second parameter. + * (NOTE: This method will not work on StockPanel.) + * @param legend - The legend. + * @param legendDivId - Id of the legend div (optional). + */ addLegend(legend: AmLegend, legendDivId?: string): void; - /** Adds a legend to the chart. - By default, you don't need to create div for your legend, however if you want it to be positioned in some different way, you can create div anywhere you want and pass id or reference to your div as a second parameter. - (NOTE: This method will not work on StockPanel.) - @param legend - @param legendDiv - Legend div (optional). + /** + * Adds a legend to the chart. + * By default, you don't need to create div for your legend, however if you want it to be positioned in some different way, you can create div anywhere you want and pass id or reference to your div as a second parameter. + * (NOTE: This method will not work on StockPanel.) + * @param legend - The legend. + * @param legendDiv - Legend div (optional). */ addLegend(legend: AmLegend, legendDiv: HTMLElement): void; - /** Adds title to the top of the chart. Pie, Radar positions are updated so that they won't overlap. Plot area of Serial/XY chart is also updated unless autoMargins property is set to false. You can add any number of titles - each of them will be placed in a new line. To remove titles, simply clear titles array: chart.titles = []; and call chart.validateNow() method. text - text of a title size - font size color - title color alpha - title opacity bold - boolean value indicating if title should be bold. */ + /** Adds title to the top of the chart. Pie, Radar positions are updated so that they won't overlap. Plot area of Serial/XY chart is also updated unless autoMargins property is set to false. You can add any number of titles - each of them will be placed in a new line. To remove titles, simply clear titles array: chart.titles = []; and call chart.validateNow() method. text - text of a title size - font size color - title color alpha - title opacity bold - boolean value indicating if title should be bold. */ addTitle(text: string, size: number, color: string, alpha: number, bold: boolean): void; /** Clears the chart area, intervals, etc. */ clear(): void; @@ -1227,22 +1218,17 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** SerialDataItem holds all the information about each series. When working with a chart, you do not create SerialDataItem objects or change it's properties directly. Consider properties of a SerialDataItem read-only - change values in chart's data provider if you need to. When serial chart parses dataProvider, it generates "chartData" array. Objects of this array are SerialDataItem objects. */ class SerialDataItem { - /** You can access each GraphDataItem using this object. The data structure is: graphDataItem = serialDataItem.axes[axisId].graphs[graphId]. */ axes: Object; - /** category value. String if parseDates is false, Date if true. */ category: any; - /** Timestamp of a series date. Avalable only if parseDates property of CategoryAxis is set to true. */ time: number; - /** Coordinate (horizontal or vertical, depends on chart's rotate property) of the series. */ x: number; } class CategoryAxis extends AxisBase { - /** When parse dates is on for the category axis, the chart will try to highlight the beginning of the periods, like month, in bold. Set this to false to disable the functionality. @default true */ @@ -1300,8 +1286,8 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** ChartScrollbar class displays chart scrollbar. Supported by AmSerialChart and AmXYChart. @example - var chart = new AmCharts.AmSerialChart(); - var chartScrollbar = new AmCharts.ChartScrollbar(); + let chart = new AmCharts.AmSerialChart(); + let chartScrollbar = new AmCharts.ChartScrollbar(); chart.addChartScrollbar(chartScrollbar); */ class ChartScrollbar { @@ -1474,7 +1460,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /* Trend lines are straight lines indicating trends, might also be used for some different purposes. Can be used by Serial and XY charts. To add/remove trend line, use chart.addTrendLine(trendLine)/chart.removeTrendLine(trendLine) methods or simply pass array of trend lines: chart.trendLines = [trendLine1, trendLine2]. @example - var trendLine = new AmCharts.TrendLine(); + let trendLine = new AmCharts.TrendLine(); trendLine.initialDate = new Date(2012, 0, 2, 12); // 12 is hour - to start trend line in the middle of the day trendLine.finalDate = new Date(2012, 0, 11, 12); trendLine.initialValue = 10; @@ -1482,14 +1468,12 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val trendLine.lineColor = "#CC0000"; chart.addTrendLine(trendLine); */ - class TrendLine { - - } + class TrendLine { } /** ChartCursor is a class which displays a cursor which follows the mouse. In case of Serial chart it also shows value and category balloons. @example - var chart = new AmCharts.AmSerialChart(); - var chartCursor = new AmCharts.ChartCursor(); + let chart = new AmCharts.AmSerialChart(); + let chartCursor = new AmCharts.ChartCursor(); chart.addChartCursor(chartCursor); */ class ChartCursor { @@ -1546,7 +1530,6 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** Indicates if currently user is selecting some chart area to zoom-in. */ zooming: boolean; - /** Hides cursor. */ hideCursor(): void; /** You can force cursor to appear at specified cateogry or date. */ @@ -1579,18 +1562,18 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** AmSerialChart is the class you have to use for majority of chart types. The supported chart types are: line, area, column, bar, step line, smoothed line, candlestick and OHLC. The chart can be rotated by 90 degrees so the column chart becomes bar chart. The chart supports simple and logarithmic scales, it can have multiple value axes. The chart can place data points at equal intervals or can parse dates and place data points at irregular intervals. @example - var chartData = [{title:"sample 1",value:130},{title:"sample 2",value:26}]; - - var chart = new AmCharts.AmSerialChart(); + let chartData = [{title:"sample 1",value:130},{title:"sample 2",value:26}]; + + let chart = new AmCharts.AmSerialChart(); chart.categoryField = "title"; chart.dataProvider = chartData; - - var graph = new AmCharts.AmGraph(); + + let graph = new AmCharts.AmGraph(); graph.valueField = "value"; graph.type = "column"; graph.fillAlphas = 1; chart.addGraph(graph); - + chart.write("chartdiv"); */ class AmSerialChart extends AmRectangularChart { @@ -1680,7 +1663,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val {"x": 20, "y": 20, "text": "this is label", "align": "left", "size": 12, "color": "#CC0000", "alpha": 1, "rotation": 0, "bold": true, "url": "http://www.amcharts.com"} @default [] */ - allLabels: [Label] + allLabels: [Label]; /** Array of arrows. */ arrows: [GaugeArrow]; @@ -1700,7 +1683,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val */ autoTransform: boolean; - /** Array of axes. + /** Array of axes. @default [GaugeAxis] */ axes: [GaugeAxis]; @@ -1754,9 +1737,9 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val dataLoader: Object; /** Array of data objects, for example: [{country:"US", value:524},{country:"UK", value:624},{country:"Lithuania", value:824}]. You can have any number of fields and use any field names. In case of AmMap, data provider should be MapData object. - + The data set data. - + Important: if you are using date/time-based category axis, the data points needs to come pre-ordered in ascending order. Data with incorrect order might result in visual and functional glitches on the chart. */ dataProvider: [Object]; @@ -1837,7 +1820,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** Read-only. Reference to the div of the legend. */ legendDiv: HTMLElement; - /** You can add listeners of events using this property. Example: listeners = [{"event":"dataUpdated", "method":handleEvent}]; + /** You can add listeners of events using this property. Example: listeners = [{"event":"dataUpdated", "method":handleEvent}]; @default [Object] */ listeners: [Object]; @@ -1875,14 +1858,14 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** Specifies absolute or relative path to amCharts files, i.e."amcharts/". (where all.js files are located) If relative URLs are used, they will be relative to the current web page, displaying the chart. You can also set path globally, using global JavaScript variable AmCharts_path.If this variable is set, and "path" is not set in chart config, the chart will assume the path from the global variable.This allows setting amCharts path globally.I.e.: - var AmCharts_path = "/libs/amcharts/"; - "path" parameter will be used by the charts to locate it's files, like images, plugins or patterns. + let AmCharts_path = "/libs/amcharts/"; + "path" parameter will be used by the charts to locate it's files, like images, plugins or patterns. @default 'amcharts/' */ path: string; /** Specifies path to the folder where images like resize grips, lens and similar are. - + IMPORTANT: Since V3.14.12, you should use "path" to point to amCharts directory instead. The "pathToImages" will be automatically set and does not need to be in the chart config, unless you keep your images separately from other amCharts files. */ pathToImages: string; @@ -1917,7 +1900,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val processTimeout: number; /** A config object for Responsive plugin. Please refer to the following page for more information. */ - responsive: Object + responsive: Object; /** Duration of arrow animation. @default 1 @@ -1944,7 +1927,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val */ theme: string; - /** Thousands separator. + /** Thousands separator. @default , */ thousandsSeparator: string; @@ -1981,12 +1964,13 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** Adds a legend to the chart. By default, you don't need to create div for your legend, however if you want it to be positioned in some different way, you can create div anywhere you want and pass id or reference to your div as a second parameter. (NOTE: This method will not work on StockPanel.) */ addLegend(legend: AmLegend, legendDivId?: string): void; - /** Adds a legend to the chart. - By default, you don't need to create div for your legend, however if you want it to be positioned in some different way, you can create div anywhere you want and pass id or reference to your div as a second parameter. - (NOTE: This method will not work on StockPanel.) - @param legend - @param legendDiv - Legend div (optional). - */ + /** + * Adds a legend to the chart. + * By default, you don't need to create div for your legend, however if you want it to be positioned in some different way, you can create div anywhere you want and pass id or reference to your div as a second parameter. + * (NOTE: This method will not work on StockPanel.) + * @param legend - The legend. + * @param legendDiv - Legend div (optional). + */ addLegend(legend: AmLegend, legendDiv: HTMLElement): void; /** Adds event listener to the object. */ @@ -2042,7 +2026,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** Axis of the arrow. You can use reference to the axis or id of the axis. If you don't set any axis, the first axis of a chart will be used. @default GaugeAxis */ - axis: GaugeAxis + axis: GaugeAxis; /** Opacity of arrow border. @default 1 @@ -2178,7 +2162,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val centerY: any; /** Specifies labels color of the axis. */ - color: string + color: string; /** Axis end angle. Valid values are from - 180 to 180. @default 120 @@ -2236,7 +2220,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** Length of a minor tick. @default 5 */ - minorTickLength: number + minorTickLength: number; /** Axis radius. @default '95%' @@ -2244,7 +2228,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val radius: any; /** Specifies if the first label should be shown. - @default true + @default true */ showFirstLabel: boolean; @@ -2284,7 +2268,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val tickThickness: number; /** Text displayed above the axis center. */ - topText: string + topText: string; /** Specifies if text should be bold. @default true @@ -2292,10 +2276,10 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val topTextBold: boolean; /** Color of top text. */ - topTextColor: string + topTextColor: string; /** Font size of top text. */ - topTextFontSize: number + topTextFontSize: number; /** Y offset of top text. @default 0 @@ -2345,7 +2329,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val color: string; /** End value of a fill. */ - endValue: number + endValue: number; /** Example: [-0.2, 0, -0.2]. Will make bands to be filled with color gradients. Negative value means the color will be darker than the original, and positive number means the color will be lighter. @default [] @@ -2660,7 +2644,6 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val valueWidth: number; /** Vertical space between legend items, in pixels. */ verticalGap: number; - } /** DataSetSelector is a tool for selecting data set's as main and for comparing with main data set. */ @@ -2685,9 +2668,9 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** AmBalloon is the class which generates balloons (datatips). Balloon follows the mouse when you roll-over the pie slice/line bullet/column/etc, chart indicator of serial charts displays value balloons and category balloon. Balloon instance is created by the chart automatically and can be accessed via "balloon" property of AmChart. Chart shows/hides and sets position for every balloon automatically, so all you need to do is to change balloon appearance, if you want to. @example - var chart = new AmCharts.AmSerialChart(); + let chart = new AmCharts.AmSerialChart(); // get balloon intance - var balloon = chart.balloon; + let balloon = chart.balloon; // set properties balloon.adjustBorderColor = true; balloon.color = "#000000"; @@ -2905,8 +2888,8 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** AmGraph class displays all types of graphs - line, column, step line, smoothed line, ohlc and candlestick. @example - var chart = new AmCharts.AmSerialChart(); - var graph = new AmCharts.AmGraph(); + let chart = new AmCharts.AmSerialChart(); + let graph = new AmCharts.AmGraph(); graph.valueField = 'value'; graph.type = 'column'; graph.fillAlphas = 1; @@ -2978,7 +2961,7 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val /** Name of the close field (used by candlesticks and ohlc) in your dataProvider. */ closeField: string; /** In case you want to place this graph's columns in front of other columns, set this to false. In case "true", the columns will be clustered next to each other. - + NOTE: clustering works only for graphs of type "column". @default true */ @@ -3367,10 +3350,10 @@ If you do not set properties such as dashLength, lineAlpha, lineColor, etc - val integersOnly: boolean; /** You can use this function to format Value axis labels. This function is called and these parameters are passed: labelFunction(value, valueText, valueAxis); Where value is numeric value, valueText is formatted string and valueAxis is a reference to valueAxis object. - + If axis type is "date", labelFunction will pass different arguments: labelFunction(valueText, date, valueAxis) - + Your function should return string.*/ labelFunction(value: number, valueText: string, valueAxis: ValueAxis): string; labelFunction(valueText: string, data: Date, valueAxis: ValueAxis): string; @@ -3435,16 +3418,12 @@ Your function should return string.*/ /** Adds guide to the axis. */ addGuide(guide: Guide): void; - /** Adds event listener to the object. type - string like 'axisChanged' (should be listed in 'events' section of this class or classes which extend this class). handler - function which is called when event happens */ - addListener(type: string, handler: any): void; /** Number, - value of coordinate. Returns value of the coordinate. coordinate - y or x coordinate, in pixels. */ coordinateToValue(coordinate: number): void; /** Number - coordinate Returns coordinate of the value in pixels. value - Number */ getCoordinate(value: number): void; /** Removes guide from the axis.*/ removeGuide(guide: Guide): void; - /** Removes event listener from the object. */ - removeListener(obj: any, type: string, handler: any): void; /** One value axis can be synchronized with another value axis. You should set synchronizationMultiplyer in order for this to work. */ synchronizeWithAxis(axis: ValueAxis): void; diff --git a/types/amcharts/tsconfig.json b/types/amcharts/tsconfig.json index 2eae92bb60..9f1b8f25e3 100644 --- a/types/amcharts/tsconfig.json +++ b/types/amcharts/tsconfig.json @@ -18,6 +18,7 @@ "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "amcharts-tests.ts" ] } \ No newline at end of file diff --git a/types/amcharts/tslint.json b/types/amcharts/tslint.json index a41bf5d19a..3ed772907a 100644 --- a/types/amcharts/tslint.json +++ b/types/amcharts/tslint.json @@ -1,79 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, "jsdoc-format": false, "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "unified-signatures": false } } From 01bf7fda21c061fb6d1efaf29a6b84236c924d8c Mon Sep 17 00:00:00 2001 From: KonstantinKai Date: Fri, 15 Dec 2017 14:23:53 +0200 Subject: [PATCH 200/298] [expo] updated to expo-sdk@24.0.0 --- types/expo/expo-tests.tsx | 45 ++++++++++++- types/expo/index.d.ts | 136 ++++++++++++++++++++++++++++++++++---- 2 files changed, 167 insertions(+), 14 deletions(-) diff --git a/types/expo/expo-tests.tsx b/types/expo/expo-tests.tsx index 333b9d3e3c..6ea634e9c5 100644 --- a/types/expo/expo-tests.tsx +++ b/types/expo/expo-tests.tsx @@ -15,7 +15,10 @@ import { DocumentPicker, Facebook, FacebookAds, - FileSystem + FileSystem, + ImagePicker, + ImageManipulator, + FaceDetector } from 'expo'; Accelerometer.addListener((obj) => { @@ -201,3 +204,43 @@ async () => { result.uri; result.md5; }; + +async () => { + const result = await ImagePicker.launchImageLibraryAsync({ + mediaTypes: ImagePicker.MediaTypeOptions.Videos + }); + + if (result.cancelled === false) { + result.uri; + result.width; + result.height; + } +}; + +async () => { + const result = await ImageManipulator.manipulate('url', { + rotate: 90 + }, { + compress: 0.5 + }); + + result.height; + result.uri; + result.width; +}; + +FaceDetector.Constants.Mode.fast; +FaceDetector.Constants.Mode.accurate; +FaceDetector.Constants.Landmarks.all; +FaceDetector.Constants.Landmarks.none; +FaceDetector.Constants.Classifications.all; +FaceDetector.Constants.Classifications.none; +async () => { + const result = await FaceDetector.detectFaces('url', { + mode: FaceDetector.Constants.Mode.fast, + detectLandmarks: FaceDetector.Constants.Landmarks.all, + runClassifications: FaceDetector.Constants.Classifications.none + }); + + result.faces[0]; +}; diff --git a/types/expo/index.d.ts b/types/expo/index.d.ts index 04d500ab6b..ff4fe25017 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for expo 23.0 +// Type definitions for expo 24.0 // Project: https://github.com/expo/expo-sdk // Definitions by: Konstantin Kai // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -456,7 +456,11 @@ export namespace Constants { version?: string; orientation?: Orientation; primaryColor?: string; + privacy?: 'public' | 'unlisted'; + scheme?: string; icon?: string; + platforms?: string[]; + githubUrl?: string; notification?: { icon?: string, color?: string, @@ -472,13 +476,11 @@ export namespace Constants { hideExponentText?: boolean }; appKey?: string; - androidStatusBarColor?: string; androidStatusBar?: { barStyle?: 'lignt-content' | 'dark-content', backgroundColor?: string }; - androidHideExponentNotificationInShellApp?: boolean; - scheme?: string; + androidShowExponentNotificationInShellApp?: boolean; extra?: { [propName: string]: any }; @@ -525,16 +527,16 @@ export namespace Constants { } } }; - facebookScheme: any; - xde: boolean; - developper?: { - tool?: string, - [propName: string]: any + facebookScheme?: any; + facebookAppId?: string; + facebookDisplayName?: string; + splash?: { + backgroundColor?: string; + resizeMode?: ResizeModeContain | ResizeModeCover; + image?: string; }; - bundleUrl?: string; - debuggerHost?: string; - mainModuleName?: string; - logUrl?: string; + assetBundlePatterns?: string[]; + releaseChannel: string; [propName: string]: any; } const manifest: Manifest; @@ -968,10 +970,19 @@ export namespace ImagePicker { type ImageResult = { cancelled: true } | ({ cancelled: false } & ImageInfo); + interface _MediaTypeOptions { + All: 'All'; + Videos: 'Videos'; + Images: 'Images'; + } + + const MediaTypeOptions: _MediaTypeOptions; + interface ImageLibraryOptions { allowsEditing?: boolean; aspect?: [number, number]; quality?: number; + mediaTypes?: keyof _MediaTypeOptions; } function launchImageLibraryAsync(options?: ImageLibraryOptions): Promise; @@ -1479,3 +1490,102 @@ export namespace WebBrowser { function openAuthSessionAsync(url: string, redirectUrl?: string): Promise<{ type: 'cancelled' | 'dismissed' }>; function dismissBrowser(): Promise<{ type: 'dismissed' }>; } + +/** + * ImageManipulator + */ +export namespace ImageManipulator { + interface ImageResult { + uri: string; + width: number; + height: number; + base64?: string; + } + interface SaveOptions { + base64?: boolean; + compress?: FloatFromZeroToOne; + format?: 'jpeg' | 'png'; + } + interface CropParameters { + originX: number; + originY: number; + width: number; + height: number; + } + interface ImageManipulationOptions { + resize?: { width?: number; height?: number }; + rotate?: number; + flip?: { vertical?: boolean; horizontal?: boolean }; + crop?: CropParameters; + } + function manipulate(uri: string, actions: ImageManipulationOptions, saveOptions?: SaveOptions): Promise; +} + +/** + * FaceDetector + */ +export namespace FaceDetector { + interface Point { + x: Axis; + y: Axis; + } + interface Face { + bounds: { + size: { + width: number; + height: number; + }, + origin: Point; + }, + smilingProbability?: number; + leftEarPosition?: Point; + rightEarPosition?: Point; + leftEyePosition?: Point; + leftEyeOpenProbability?: number; + rightEyePosition?: Point; + rightEyeOpenProbability?: number; + leftCheekPosition?: Point; + rightCheekPosition?: Point; + leftMouthPosition?: Point; + mouthPosition?: Point; + rightMouthPosition?: Point; + bottomMouthPosition?: Point; + noseBasePosition?: Point; + yawAngle?: number; + rollAngle?: number; + } + interface DetectFaceResult { + faces: Face[]; + image: { + uri: string; + width: number; + height: number; + orientation: number; + } + } + interface Mode { + fast: 'fast'; + accurate: 'accurate'; + } + interface _Shared { + all: 'all'; + none: 'none'; + } + type Landmarks = _Shared; + type Classifications = _Shared; + interface _Constants { + Mode: Mode; + Landmarks: Landmarks; + Classifications: Classifications; + } + + const Constants: _Constants; + + interface Options { + mode?: keyof Mode; + detectLandmarks?: keyof Landmarks; + runClassifications?: keyof Classifications; + } + + function detectFaces(uri: string, options?: Options): Promise; +} From 18c1fba49771618ece93cf9b7b3c934b8cef95b4 Mon Sep 17 00:00:00 2001 From: DovidM Date: Fri, 15 Dec 2017 07:29:01 -0500 Subject: [PATCH 201/298] Made a regular (non default) export --- types/word-list-json/index.d.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/types/word-list-json/index.d.ts b/types/word-list-json/index.d.ts index a9435519ce..e221d3795f 100644 --- a/types/word-list-json/index.d.ts +++ b/types/word-list-json/index.d.ts @@ -2,15 +2,19 @@ // Project: https://github.com/sindresorhus/word-list // Definitions by: Dovid Meiseles // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/*~ You can declare types that are available via importing the module */ +// TypeScript Version: 2.4 interface Lengths { [key: string]: number; } -type words = string[]; +export const lengths: Lengths; -export default interface Words extends words { +type wordsArray = string[]; +interface Words extends wordsArray { lengths: Lengths; -} \ No newline at end of file +} + +declare const words: Words; + +export default words; From 11e3c1ac94d20eb36f03b410806989b410fe794f Mon Sep 17 00:00:00 2001 From: DovidM Date: Fri, 15 Dec 2017 07:29:09 -0500 Subject: [PATCH 202/298] Added tests --- types/word-list-json/word-list-json-tests.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/types/word-list-json/word-list-json-tests.ts b/types/word-list-json/word-list-json-tests.ts index e69de29bb2..d12edf731d 100644 --- a/types/word-list-json/word-list-json-tests.ts +++ b/types/word-list-json/word-list-json-tests.ts @@ -0,0 +1,5 @@ +import wordListJson from 'word-list-json'; + +wordListJson.lengths; // $ExpectType Lengths + +wordListJson; // $ExpectType Words From 1d54ed0bcde80e6e45e7bab87a98b027b4205e04 Mon Sep 17 00:00:00 2001 From: DovidM Date: Fri, 15 Dec 2017 07:29:28 -0500 Subject: [PATCH 203/298] Fixed tslint error --- types/word-list-json/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/word-list-json/tsconfig.json b/types/word-list-json/tsconfig.json index af12c82665..8f34d90409 100644 --- a/types/word-list-json/tsconfig.json +++ b/types/word-list-json/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 540812f059b1802a35a25393c065dfc5964996cd Mon Sep 17 00:00:00 2001 From: KonstantinKai Date: Fri, 15 Dec 2017 14:30:43 +0200 Subject: [PATCH 204/298] [expo] linter fixes --- types/expo/expo-tests.tsx | 2 +- types/expo/index.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/types/expo/expo-tests.tsx b/types/expo/expo-tests.tsx index 6ea634e9c5..b9010090dd 100644 --- a/types/expo/expo-tests.tsx +++ b/types/expo/expo-tests.tsx @@ -210,7 +210,7 @@ async () => { mediaTypes: ImagePicker.MediaTypeOptions.Videos }); - if (result.cancelled === false) { + if (!result.cancelled) { result.uri; result.width; result.height; diff --git a/types/expo/index.d.ts b/types/expo/index.d.ts index ff4fe25017..58b332392f 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -1536,7 +1536,7 @@ export namespace FaceDetector { height: number; }, origin: Point; - }, + }; smilingProbability?: number; leftEarPosition?: Point; rightEarPosition?: Point; @@ -1561,7 +1561,7 @@ export namespace FaceDetector { width: number; height: number; orientation: number; - } + }; } interface Mode { fast: 'fast'; From acf0d886e0b93e6ab2a8d5a9bf45d7ad4bc91e5f Mon Sep 17 00:00:00 2001 From: KonstantinKai Date: Fri, 15 Dec 2017 15:14:01 +0200 Subject: [PATCH 205/298] [expo] added support for expo-sdk@23.0.0 --- types/expo/v2/expo-tests.tsx | 204 +++++ types/expo/v2/index.d.ts | 1482 ++++++++++++++++++++++++++++++++++ types/expo/v2/tsconfig.json | 32 + types/expo/v2/tslint.json | 1 + 4 files changed, 1719 insertions(+) create mode 100644 types/expo/v2/expo-tests.tsx create mode 100644 types/expo/v2/index.d.ts create mode 100644 types/expo/v2/tsconfig.json create mode 100644 types/expo/v2/tslint.json diff --git a/types/expo/v2/expo-tests.tsx b/types/expo/v2/expo-tests.tsx new file mode 100644 index 0000000000..dd8696d5ba --- /dev/null +++ b/types/expo/v2/expo-tests.tsx @@ -0,0 +1,204 @@ +import * as React from 'react'; + +import { + Accelerometer, + Amplitude, + Asset, + AuthSession, + Audio, + AppLoading, + BarCodeScanner, + BlurViewProps, + BlurView, + Brightness, + Camera, + DocumentPicker, + Facebook, + FacebookAds, + FileSystem, + ImagePicker +} from 'expo'; + +Accelerometer.addListener((obj) => { + obj.x; + obj.y; + obj.z; +}); +Accelerometer.removeAllListeners(); +Accelerometer.setUpdateInterval(1000); + +Amplitude.initialize('key'); +Amplitude.setUserId('userId'); +Amplitude.setUserProperties({key: 1}); +Amplitude.clearUserProperties(); +Amplitude.logEvent('name'); +Amplitude.logEventWithProperties('event', {key: 'value'}); +Amplitude.setGroup('type', {key: 'value'}); + +const asset = Asset.fromModule(1); +asset.downloadAsync(); +Asset.loadAsync(1); +Asset.loadAsync([1, 2, 3]); +const asset1 = new Asset({ + uri: 'uri', + type: 'type', + name: 'name', + hash: 'hash', + width: 122, + height: 122 +}); + +const url = AuthSession.getRedirectUrl(); +AuthSession.dismiss(); +AuthSession.startAsync({ + authUrl: 'url1', + returnUrl: 'url2' +}).then(result => { + switch (result.type) { + case 'success': + result.event; + result.params; + break; + case 'error': + result.errorCode; + result.params; + result.event; + break; + case 'dismissed': + case 'cancel': + result.type; + break; + } +}); + +Audio.setAudioModeAsync({ + shouldDuckAndroid: false, + playsInSilentModeIOS: true, + interruptionModeIOS: 2, + interruptionModeAndroid: 1, + allowsRecordingIOS: true +}); +Audio.setIsEnabledAsync(true); +async () => { + const result = await Audio.Sound.create('uri', { + volume: 0.5, + rate: 0.6 + }, null, true); + + const sound = result.sound; + const status = result.status; + + if (!status.isLoaded) { + status.error; + } else { + status.didJustFinish; + // etc. + } + + const _status = await sound.getStatusAsync(); + await sound.loadAsync('uri'); +}; + +() => ( + Promise.resolve()} + onFinish={() => {}} + onError={(error) => console.log(error)} /> +); +() => ( + +); + +const barcodeReadCallback = () => {}; +() => ( + +); + +() => ( + +); + +async () => { + await Brightness.setBrightnessAsync(.6); + await Brightness.setSystemBrightnessAsync(.7); + const br1 = await Brightness.getBrightnessAsync(); + const br2 = await Brightness.getSystemBrightnessAsync(); +}; + +Camera.Constants.AutoFocus; +Camera.Constants.Type; +Camera.Constants.FlashMode; +Camera.Constants.WhiteBalance; +Camera.Constants.VideoQuality; +Camera.Constants.BarCodeType; +() => { + return( { + if (component) { + component.recordAsync(); + } + }} />); +}; + +async () => { + const result = await DocumentPicker.getDocumentAsync(); + + if (result.type === 'success') { + result.name; + result.uri; + result.size; + } +}; + +async () => { + const result = await Facebook.logInWithReadPermissionsAsync('appId'); + + if (result.type === 'success') { + result.expires; + result.token; + } +}; + +() => ( + {}} + onError={() => {}} /> +); + +async () => { + const info = await FileSystem.getInfoAsync('file'); + + info.exists; + info.isDirectory; + + if (info.exists) { + info.md5; + info.uri; + info.size; + info.modificationTime; + } + + const string: string = await FileSystem.readAsStringAsync('file'); + await FileSystem.writeAsStringAsync('file', 'content'); + await FileSystem.deleteAsync('file'); + await FileSystem.moveAsync({ from: 'from', to: 'to'}); + await FileSystem.copyAsync({ from: 'from', to: 'to' }); + await FileSystem.makeDirectoryAsync('dir'); + const dirs: string[] = await FileSystem.readDirectoryAsync('dir'); + const result = await FileSystem.downloadAsync('from', 'to'); + + result.headers; + result.status; + result.uri; + result.md5; +}; diff --git a/types/expo/v2/index.d.ts b/types/expo/v2/index.d.ts new file mode 100644 index 0000000000..076cd43f8c --- /dev/null +++ b/types/expo/v2/index.d.ts @@ -0,0 +1,1482 @@ +// Type definitions for expo 23.0 +// Project: https://github.com/expo/expo-sdk +// Definitions by: Konstantin Kai +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import { EventSubscription } from 'fbemitter'; +import { Component, Ref } from 'react'; +import { + ViewStyle, + ViewProperties, + ColorPropType, + ImageURISource, + NativeEventEmitter, + ImageRequireSource +} from 'react-native'; + +export type URISource = ImageURISource; +export type RequireSource = ImageRequireSource; +export type ResizeModeContain = 'contain'; +export type ResizeModeCover = 'cover'; +export type ResizeModeStretch = 'stretch'; +export type Orientation = 'portrait' | 'landscape'; +export type Axis = number; +export interface HashMap { [key: string]: any; } +export type FloatFromZeroToOne = 0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1; +export type BarCodeReadCallback = (params: { type: string; data: string; }) => void; +export type Md5 = string; + +/** + * Accelerometer + */ +export namespace Accelerometer { + interface AccelerometerObject { + x: Axis; + y: Axis; + z: Axis; + } + + function addListener(listener: (obj: AccelerometerObject) => any): EventSubscription; + function removeAllListeners(): void; + function setUpdateInterval(intervalMs: number): void; +} + +/** + * Amplitude + */ +export namespace Amplitude { + function initialize(apiKey: string): void; + function setUserId(userId: string): void; + function setUserProperties(userProperties: HashMap): void; + function clearUserProperties(): void; + function logEvent(eventName: string): void; + function logEventWithProperties(eventName: string, properties: HashMap): void; + function setGroup(groupType: string, groupNames: HashMap): void; +} + +/** + * Asset + */ +export class Asset { + constructor({ name, type, hash, uri, width, height }: { + name: string; + type: string; + hash: string; + uri: string; + width?: number; + height?: number; + }); + name: string; + type: string; + hash: string; + uri: string; + localUri: string; + width?: number; + height?: number; + + downloading: boolean; + downloaded: boolean; + downloadCallbacks: Array<{ resolve: () => any, reject: (e?: any) => any }>; + + downloadAsync(): Promise; + + static fromModule(module: RequireSource): Asset; + static loadAsync(module: RequireSource[] | RequireSource): Promise; +} + +/** + * AuthSession + */ +export namespace AuthSession { + function startAsync(options: { authUrl: string; returnUrl: string; }): Promise<{ + type: 'cancel'; + } | { + type: 'dismissed'; + } | { + type: 'success'; + params: HashMap; + event: HashMap; + } | { + type: 'error'; + params: HashMap; + errorCode: string; + event: HashMap; + }>; + function dismiss(): void; + function getRedirectUrl(): string; +} + +/** + * AV + */ +export type PlaybackStatus = { + isLoaded: false; + androidImplementation?: string; + error?: string; +} | { + isLoaded: true; + androidImplementation?: string; + uri: string; + progressUpdateIntervalMillis: number; + durationMillis?: number; + positionMillis: number; + playableDurationMillis?: number; + shouldPlay: boolean; + isPlaying: boolean; + isBuffering: boolean; + rate: number; + shouldCorrectPitch: boolean; + volume: number; + isMuted: boolean; + isLooping: boolean; + didJustFinish: boolean; +}; + +export interface PlaybackStatusToSet { + androidImplementation?: string; + progressUpdateIntervalMillis?: number; + positionMillis?: number; + shouldPlay?: boolean; + rate?: FloatFromZeroToOne; + shouldCorrectPitch?: boolean; + volume?: FloatFromZeroToOne; + isMuted?: boolean; + isLooping?: boolean; +} + +export type Source = string | RequireSource | Asset; + +export class PlaybackObject { + loadAsync(source: Source, initialStatus?: PlaybackStatusToSet, downloadFirst?: boolean): Promise; + unloadAsync(): Promise; + getStatusAsync(): Promise; + setOnPlaybackStatusUpdate(onPlaybackStatusUpdate: (status: PlaybackStatus) => void): void; + setStatusAsync(status: PlaybackStatusToSet): Promise; + playAsync(): Promise; + playFromPositionAsync(positionMillis: number): Promise; + pauseAsync(): Promise; + stopAsync(): Promise; + setPositionAsync(positionMillis: number): Promise; + setRateAsync(rate: number, shouldCorrectPitch: boolean): Promise; + setVolumeAsync(volume: number): Promise; + setIsMutedAsync(isMuted: boolean): Promise; + setIsLoopingAsync(isLooping: boolean): Promise; + setProgressUpdateIntervalAsync(progressUpdateIntervalMillis: number): Promise; +} + +export namespace Audio { + enum InterruptionModeIOS { + INTERRUPTION_MODE_IOS_MIX_WITH_OTHERS = 0, + INTERRUPTION_MODE_IOS_DO_NOT_MIX = 1, + INTERRUPTION_MODE_IOS_DUCK_OTHERS = 2 + } + + enum InterruptionModeAndroid { + INTERRUPTION_MODE_ANDROID_DO_NOT_MIX = 1, + INTERRUPTION_MODE_ANDROID_DUCK_OTHERS = 2 + } + + type RecordingStatus = { + canRecord: false, + isDoneRecording: false + } | { + canRecord: true, + isRecording: boolean, + durationMillis: number + } | { + canRecord: false, + isDoneRecording: true, + durationMillis: number + }; + + interface AudioMode { + playsInSilentModeIOS: boolean; + allowsRecordingIOS: boolean; + interruptionModeIOS: InterruptionModeIOS; + shouldDuckAndroid: boolean; + interruptionModeAndroid: InterruptionModeAndroid; + } + + function setIsEnabledAsync(value: boolean): Promise; + function setAudioModeAsync(mode: AudioMode): Promise; + + class Sound extends PlaybackObject { + constructor(); + + static create( + source: Source, + initialStatus?: PlaybackStatusToSet, + onPlaybackStatusUpdate?: ((status: PlaybackStatus) => void) | null, + downloadFirst?: boolean + ): Promise<{ sound: Sound, status: PlaybackStatus }>; + } + + interface RecordingOptions { + android: { + extension: string; + outputFormat: number; + audioEncoder: number; + sampleRate?: number; + numberOfChannels?: number; + bitRate?: number; + maxFileSize?: number; + }; + ios: { + extension: string; + outputFormat?: string | number; + audioQuality: number; + sampleRate: number; + numberOfChannels: number; + bitRate: number; + bitRateStrategy?: number; + bitDepthHint?: number; + linearPCMBitDepth?: number; + linearPCMIsBigEndian?: boolean; + linearPCMIsFloat?: boolean; + }; + } + + class Recording { + constructor(); + + getStatusAsync(): Promise; + setOnRecordingStatusUpdate(onRecordingStatusUpdate: (status: RecordingStatus) => void): void; + setProgressUpdateInterval(miliss: number): void; + prepareToRecordAsync(options: Recording): Promise; + isPreparedToRecord(): boolean; + startAsync(): Promise; + pauseAsync(): Promise; + stopAndUnloadAsync(): Promise; + getURI(): string | undefined; + createNewLoadedSound(initialStatus: PlaybackStatusToSet, onPlaybackStatusUpdate: (status: PlaybackStatus) => void): Promise<{ sound: Sound, status: PlaybackStatus }>; + } +} + +/** + * Expo Video + */ +export interface NaturalSize { + width: number; + height: number; + orientation: Orientation; +} + +export interface ReadyForDisplayEvent { + naturalSize: NaturalSize; + status: PlaybackStatus; +} + +export enum FullscreenUpdateVariants { + IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = 0, + IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = 1, + IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = 2, + IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = 3 +} + +export interface FullscreenUpdateEvent { + fullscreenUpdate: FullscreenUpdateVariants; + status: PlaybackStatus; +} + +export interface VideoProps { + source?: Source | null; + posterSource?: URISource | RequireSource; + + resizeMode?: ResizeModeContain | ResizeModeCover | ResizeModeStretch; + useNativeControls?: boolean; + usePoster?: boolean; + + onPlaybackStatusUpdate?: (status: PlaybackStatus) => void; + onReadyForDisplay?: (event: ReadyForDisplayEvent) => void; + onIOSFullscreenUpdate?: (event: FullscreenUpdateEvent) => void; + + onLoadStart?: () => void; + onLoad?: (status: PlaybackStatus) => void; + onError?: (error: string) => void; + + status?: PlaybackStatusToSet; + progressUpdateIntervalMillis?: number; + positionMillis?: number; + shouldPlay?: boolean; + rate?: number; + shouldCorrectPitch?: boolean; + volume?: number; + isMuted?: boolean; + isLooping?: boolean; + + scaleX?: number; + scaleY?: number; + translateX?: number; + translateY?: number; + rotation?: number; + ref?: Ref; +} + +export interface VideoState { + showPoster: boolean; +} + +export class Video extends Component { + static RESIZE_MODE_CONTAIN: ResizeModeContain; + static RESIZE_MODE_COVER: ResizeModeCover; + static RESIZE_MODE_STRETCH: ResizeModeStretch; + static IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT; + static IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT; + static IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS; + static IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS; +} + +/** + * AppLoading + */ +export type AppLoadingProperties = { + startAsync: () => Promise; + onFinish: () => void; + onError?: (error: Error) => void; +} | { + startAsync: null; + onFinish: null; + onError?: null; +}; +export class AppLoading extends Component { } + +/** + * BarCodeScanner + */ +export interface BarCodeScannerProps extends ViewProperties { + type?: 'front' | 'back'; + torchMode?: 'on' | 'off'; + barCodeTypes?: string[]; + onBarCodeRead?: BarCodeReadCallback; +} + +export class BarCodeScanner extends Component { } + +/** + * BlurView + */ +export interface BlurViewProps extends ViewProperties { + tint: 'light' | 'default' | 'dark'; + intensity: number; +} +export class BlurView extends Component { } + +/** + * Brightness + */ +export namespace Brightness { + function setBrightnessAsync(brightnessValue: FloatFromZeroToOne): Promise; + function getBrightnessAsync(): Promise; + function getSystemBrightnessAsync(): Promise; + function setSystemBrightnessAsync(brightnessValue: FloatFromZeroToOne): Promise; +} + +/** + * Camera + */ +export interface TakePictureOptions { + quality?: number; + base64?: boolean; + exif?: boolean; +} +export interface PictureResponse { + uri: string; + width: number; + height: number; + exif: string; + base64: string; +} +export interface RecordOptions { + quality?: string; + maxDuration?: number; + maxFileSize?: number; + mute?: boolean; +} +export class CameraObject { + takePictureAsync(options: TakePictureOptions): Promise; + recordAsync(options: RecordOptions): Promise<{ uri: string; }>; + stopRecording(): void; + getSupportedRatiosAsync(): Promise; // Android only +} +export interface CameraProperties extends ViewProperties { + flashMode?: string | number; + type?: string | number; + ratio?: string; + autoFocus?: string | number | boolean; + focusDepth?: FloatFromZeroToOne; + zoom?: FloatFromZeroToOne; + whiteBalance?: string | number; + barCodeTypes?: string[]; + onCameraReady?: () => void; + onMountError?: () => void; + onBarCodeRead?: BarCodeReadCallback; + ref?: Ref; +} +export interface CameraConstants { + readonly Type: string; + readonly FlashMode: string; + readonly AutoFocus: string; + readonly WhiteBalance: string; + readonly VideoQuality: string; + readonly BarCodeType: string; +} +export class Camera extends Component { + static readonly Constants: CameraConstants; +} + +/** + * Constants + */ +export namespace Constants { + const appOwnership: 'expo' | 'standalone' | 'guest'; + const expoVersion: string; + const deviceId: string; + const deviceName: string; + const deviceYearClass: number; + const isDevice: boolean; + + interface Platform { + ios: { + platform: string; + model: string; + userInterfaceIdiom: string; + }; + } + const platform: Platform; + const sessionId: string; + const statusBarHeight: number; + const systemFonts: string[]; + + interface Manifest { + name: string; + description?: string; + slug?: string; + sdkVersion?: string; + version?: string; + orientation?: Orientation; + primaryColor?: string; + privacy?: 'public' | 'unlisted'; + scheme?: string; + icon?: string; + platforms?: string[]; + githubUrl?: string; + notification?: { + icon?: string, + color?: string, + androidMode?: 'default' | 'collapse', + androidCollapsedTitle?: string + }; + loading?: { + icon?: string, + exponentIconColor?: 'white' | 'blue', + exponentIconGrayscale?: 1 | 0, + backgroundImage?: string, + backgroundColor?: string, + hideExponentText?: boolean + }; + appKey?: string; + androidStatusBar?: { + barStyle?: 'lignt-content' | 'dark-content', + backgroundColor?: string + }; + androidShowExponentNotificationInShellApp?: boolean; + extra?: { + [propName: string]: any + }; + rnCliPath?: any; + entryPoint?: string; + packagerOpts?: { + hostType?: string, + dev?: boolean, + strict?: boolean, + minify?: boolean, + urlType?: string, + urlRandomness?: string, + lanType?: string, + [propName: string]: any + }; + ignoreNodeModulesValidation?: any; + nodeModulesPath?: string; + ios?: { + bundleIdentifier?: string, + buildNumber?: string, + config?: { + usesNonExemptEncryption?: boolean, + googleSignIn?: { + reservedClientId: string + } + }, + supportsTablet?: boolean, + infoPlist?: any + }; + android?: { + package?: string, + versionCode?: string, + config?: { + fabric?: { + apiKey: string, + buildSecret: string + }, + googleMaps?: { + apiKey: string + }, + googleSignIn?: { + apiKey: string, + certificateHash: string + } + } + }; + facebookScheme?: any; + facebookAppId?: string; + facebookDisplayName?: string; + splash?: { + backgroundColor?: string; + resizeMode?: ResizeModeContain | ResizeModeCover; + image?: string; + }; + assetBundlePatterns?: string[]; + [propName: string]: any; + } + const manifest: Manifest; + const linkingUri: string; +} + +/** + * Contacts + */ +export namespace Contacts { + type PhoneNumbers = 'phoneNumbers'; + type Emails = 'emails'; + type Addresses = 'addresses'; + type Image = 'image'; + type Thumbnail = 'thumbnail'; + type Note = 'note'; + type Birthday = 'birthday'; + type NonGregorianBirthday = 'nonGregorianBirthday'; + type NamePrefix = 'namePrefix'; + type NameSuffix = 'nameSuffix'; + type PhoneticFirstName = 'phoneticFirstName'; + type PhoneticMiddleName = 'phoneticMiddleName'; + type PhoneticLastName = 'phoneticLastName'; + type SocialProfiles = 'socialProfiles'; + type InstantMessageAddresses = 'instantMessageAddresses'; + type UrlAddresses = 'urlAddresses'; + type Dates = 'dates'; + type Relationships = 'relationships'; + + const PHONE_NUMBERS: PhoneNumbers; + const EMAILS: Emails; + const ADDRESSES: Addresses; + const IMAGE: Image; + const THUMBNAIL: Thumbnail; + const NOTE: Note; + const BIRTHDAY: Birthday; + const NON_GREGORIAN_BIRTHDAY: NonGregorianBirthday; + const NAME_PREFIX: NamePrefix; + const NAME_SUFFIX: NameSuffix; + const PHONETIC_FIRST_NAME: PhoneticFirstName; + const PHONETIC_MIDDLE_NAME: PhoneticMiddleName; + const PHONETIC_LAST_NAME: PhoneticLastName; + const SOCIAL_PROFILES: SocialProfiles; + const IM_ADDRESSES: InstantMessageAddresses; + const URLS: UrlAddresses; + const DATES: Dates; + const RELATIONSHIPS: Relationships; + + type FieldType = PhoneNumbers | Emails | Addresses | Image | Thumbnail | + Note | Birthday | NonGregorianBirthday | NamePrefix | NameSuffix | + PhoneticFirstName | PhoneticMiddleName | PhoneticLastName | SocialProfiles | + InstantMessageAddresses | UrlAddresses | Dates | Relationships; + + interface Options { + pageSize?: number; + pageOffset?: number; + fields?: FieldType[]; + } + + interface Contact { + id: string; + contactType: string; + name: string; + firstName?: string; + middleName?: string; + lastName?: string; + previousLastName?: string; + namePrefix?: string; + nameSuffix?: string; + nickname?: string; + phoneticFirstName?: string; + phoneticMiddleName?: string; + phoneticLastName?: string; + emails?: Array<{ + email?: string; + primary?: boolean; + label: string; + id: string; + }>; + phoneNumbers?: Array<{ + number?: string; + primary?: boolean; + digits?: string; + countryCode?: string; + label: string; + id: string; + }>; + addresses?: Array<{ + street?: string; + city?: string; + country?: string; + region?: string; + neighborhood?: string; + postalCode?: string; + poBox?: string; + isoCountryCode?: string; + label: string; + id: string; + }>; + socialProfiles?: Array<{ + service?: string; + localizedProfile?: string; + url?: string; + username?: string; + userId?: string; + label: string; + id: string; + }>; + instantMessageAddresses?: Array<{ + service?: string; + username?: string; + localizedService?: string; + label: string; + id: string; + }>; + urls?: { + label: string; + url?: string; + id: string; + }; + company?: string; + jobTitle?: string; + department?: string; + imageAvailable?: boolean; + image?: { + uri?: string; + }; + thumbnail?: { + uri?: string; + }; + note?: string; + dates?: Array<{ + day?: number; + month?: number; + year?: number; + id: string; + label: string; + }>; + relationships?: Array<{ + label: string; + name?: string; + id: string; + }>; + } + + interface Response { + data: Contact[]; + total: number; + hasNextPage: boolean; + hasPreviousPage: boolean; + } + + function getContactsAsync(options: Options): Promise; + function getContactByIdAsync(options: { id?: string; fields?: FieldType[] }): Promise; +} + +/** + * DocumentPicker + */ +export namespace DocumentPicker { + interface Options { + type?: string; + } + type Response = { + type: 'success'; + uri: string; + name: string; + size: number; + } | { + type: 'cancel'; + }; + + function getDocumentAsync(options?: Options): Promise; +} + +/** + * ErrorRecovery + */ +export namespace ErrorRecovery { + function setRecoveryProps(props: HashMap): void; +} + +/** + * Facebook + */ +export namespace Facebook { + interface Options { + permissions?: string[]; + behavior?: 'web' | 'native' | 'browser' | 'system'; + } + type Response = { + type: 'success'; + token: string; + expires: number; + } | { + type: 'cancel'; + }; + function logInWithReadPermissionsAsync(appId: string, options?: Options): Promise; +} + +/** + * Facebook Ads + */ +export namespace FacebookAds { + /** + * Interstitial Ads + */ + namespace InterstitialAdManager { + function showAd(placementId: string): Promise; + } + + /** + * Native Ads + */ + type MediaCachePolicy = 'none' | 'icon' | 'image' | 'all'; + class NativeAdsManager { + constructor(placementId: string, numberOfAdsToRequest?: number); + disableAutoRefresh(): void; + setMediaCachePolicy(cachePolicy: MediaCachePolicy): void; + } + + function withNativeAd(component: Component<{ + icon?: string; + coverImage?: string; + title?: string; + subtitle?: string; + description?: string; + callToActionText?: string; + socialContext?: string; + }>): Component<{ adsManager: NativeAdsManager }, { ad: any, canRequestAds: boolean }>; + + /** + * Banner View + */ + type AdType = 'large' | 'rectangle' | 'standard'; + + interface BannerViewProps { + type: AdType; + placementId: string; + onPress: () => void; + onError: () => void; + } + + class BannerView extends Component { } + + /** + * Ad Settings + */ + namespace AdSettings { + const currentDeviceHash: string; + function addTestDevice(device: string): void; + function clearTestDevices(): void; + type SDKLogLevel = 'none' | 'debug' | 'verbose' | 'warning' | 'error' | 'notification'; + function setLogLevel(logLevel: SDKLogLevel): void; + function setIsChildDirected(isDirected: boolean): void; + function setMediationService(mediationService: string): void; + function setUrlPrefix(urlPrefix: string): void; + } +} + +/** + * FileSystem + */ +export namespace FileSystem { + type FileInfo = { + exists: true; + isDirectory: boolean; + uri: string; + size: number; + modificationTime: number; + md5?: Md5; + } | { + exists: false; + isDirectory: false; + }; + + interface DownloadResult { + uri: string; + status: number; + headers: { [name: string]: string }; + md5?: Md5; + } + + const documentDirectory: string; + const cacheDirectory: string; + + function getInfoAsync(fileUri: string, options?: { md5?: string, size?: boolean; }): Promise; + function readAsStringAsync(fileUri: string): Promise; + function writeAsStringAsync(fileUri: string, contents: string): Promise; + function deleteAsync(fileUri: string, options?: { idempotent: boolean; }): Promise; + function moveAsync(options: { from: string, to: string; }): Promise; + function copyAsync(options: { from: string, to: string; }): Promise; + function makeDirectoryAsync(dirUri: string, options?: { intermediates: boolean }): Promise; + function readDirectoryAsync(dirUri: string): Promise; + function downloadAsync(uri: string, fileUri: string, options?: { md5?: boolean; }): Promise; + function createDownloadResumable( + uri: string, + fileUri: string, + options?: DownloadOptions, + callback?: (totalBytesWritten: number, totalBytesExpectedToWrite: number) => void, + resumeData?: string | null + ): DownloadResumable; + + interface PauseResult { + url: string; + fileUri: string; + options: { md5: boolean; }; + resumeData: string; + } + + interface DownloadOptions { + md5?: boolean; + headers?: { [name: string]: string }; + } + + interface DownloadProgressData { + totalBytesWritten: number; + totalBytesExpectedToWrite: number; + } + + type DownloadProgressCallback = (data: DownloadProgressData) => void; + + class DownloadResumable { + constructor( + url: string, + fileUri: string, + options: DownloadOptions, + callback?: DownloadProgressCallback, + resumeData?: string + ); + + downloadAsync(): Promise; + pauseAsync(): Promise; + resumeAsync(): Promise; + savable(): PauseResult; + } +} + +/** + * Fingerprint + */ +export namespace Fingerprint { + type FingerprintAuthenticationResult = { success: true } | { success: false, error: string }; + + function hasHardwareAsync(): Promise; + function isEnrolledAsync(): Promise; + function authenticateAsync(promptMessageIOS?: string): Promise; + function cancelAuthenticate(): void; +} + +/** + * Font + */ +export namespace Font { + interface FontMap { + [name: string]: RequireSource; + } + + function loadAsync(name: string, url: string): Promise; + function loadAsync(map: FontMap): Promise; +} + +/** + * GLView + */ +export interface GLViewProps extends ViewProperties { + onContextCreate(): void; + msaaSamples: number; +} +export class GLView extends Component { } + +/** + * Google + */ +export namespace Google { + interface LogInConfig { + androidClientId?: string; + androidStandaloneAppClientId?: string; + iosClientId?: string; + iosStandaloneAppClientId?: string; + webClientId?: string; + behavior?: 'system' | 'web'; + scopes?: string[]; + } + + type LogInResult = { + type: 'cancel'; + } | { + type: 'success'; + accessToken: string; + idToken?: string; + refreshToken?: string; + serverAuthCode?: string; + user: { + id: string; + name: string; + givenName: string; + familyName: string; + photoUrl?: string; + email?: string; + } + }; + + function logInAsync(config: LogInConfig): Promise; +} + +/** + * Gyroscope + */ +export namespace Gyroscope { + interface GyroscopeObject { + x: Axis; + y: Axis; + z: Axis; + } + + function addListener(listener: (obj: GyroscopeObject) => any): EventSubscription; + function removeAllListeners(): void; + function setUpdateInterval(intervalMs: number): void; +} + +/** + * Image Picker + */ +export namespace ImagePicker { + interface ImageInfo { + uri: string; + width: number; + height: number; + } + + type ImageResult = { cancelled: true } | ({ cancelled: false } & ImageInfo); + + interface ImageLibraryOptions { + allowsEditing?: boolean; + aspect?: [number, number]; + quality?: number; + } + + function launchImageLibraryAsync(options?: ImageLibraryOptions): Promise; + + interface CameraOptions { + allowsEditing?: boolean; + aspect?: [number, number]; + quality?: number; + } + function launchCameraAsync(options?: CameraOptions): Promise; +} + +/** + * IntentLauncherAndroid + */ +export namespace IntentLauncherAndroid { + const ACTION_ACCESSIBILITY_SETTINGS: string; + const ACTION_APP_NOTIFICATION_REDACTION: string; + const ACTION_CONDITION_PROVIDER_SETTINGS: string; + const ACTION_NOTIFICATION_LISTENER_SETTINGS: string; + const ACTION_PRINT_SETTINGS: string; + const ACTION_ADD_ACCOUNT_SETTINGS: string; + const ACTION_AIRPLANE_MODE_SETTINGS: string; + const ACTION_APN_SETTINGS: string; + const ACTION_APPLICATION_DETAILS_SETTINGS: string; + const ACTION_APPLICATION_DEVELOPMENT_SETTINGS: string; + const ACTION_APPLICATION_SETTINGS: string; + const ACTION_APP_NOTIFICATION_SETTINGS: string; + const ACTION_APP_OPS_SETTINGS: string; + const ACTION_BATTERY_SAVER_SETTINGS: string; + const ACTION_BLUETOOTH_SETTINGS: string; + const ACTION_CAPTIONING_SETTINGS: string; + const ACTION_CAST_SETTINGS: string; + const ACTION_DATA_ROAMING_SETTINGS: string; + const ACTION_DATE_SETTINGS: string; + const ACTION_DEVICE_INFO_SETTINGS: string; + const ACTION_DEVICE_NAME: string; + const ACTION_DISPLAY_SETTINGS: string; + const ACTION_DREAM_SETTINGS: string; + const ACTION_HARD_KEYBOARD_SETTINGS: string; + const ACTION_HOME_SETTINGS: string; + const ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS: string; + const ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS: string; + const ACTION_INPUT_METHOD_SETTINGS: string; + const ACTION_INPUT_METHOD_SUBTYPE_SETTINGS: string; + const ACTION_INTERNAL_STORAGE_SETTINGS: string; + const ACTION_LOCALE_SETTINGS: string; + const ACTION_LOCATION_SOURCE_SETTINGS: string; + const ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS: string; + const ACTION_MANAGE_APPLICATIONS_SETTINGS: string; + const ACTION_MANAGE_DEFAULT_APPS_SETTINGS: string; + const ACTION_MEMORY_CARD_SETTINGS: string; + const ACTION_MONITORING_CERT_INFO: string; + const ACTION_NETWORK_OPERATOR_SETTINGS: string; + const ACTION_NFCSHARING_SETTINGS: string; + const ACTION_NFC_PAYMENT_SETTINGS: string; + const ACTION_NFC_SETTINGS: string; + const ACTION_NIGHT_DISPLAY_SETTINGS: string; + const ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS: string; + const ACTION_NOTIFICATION_SETTINGS: string; + const ACTION_PAIRING_SETTINGS: string; + const ACTION_PRIVACY_SETTINGS: string; + const ACTION_QUICK_LAUNCH_SETTINGS: string; + const ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS: string; + const ACTION_SECURITY_SETTINGS: string; + const ACTION_SETTINGS: string; + const ACTION_SHOW_ADMIN_SUPPORT_DETAILS: string; + const ACTION_SHOW_INPUT_METHOD_PICKER: string; + const ACTION_SHOW_REGULATORY_INFO: string; + const ACTION_SHOW_REMOTE_BUGREPORT_DIALOG: string; + const ACTION_SOUND_SETTINGS: string; + const ACTION_STORAGE_MANAGER_SETTINGS: string; + const ACTION_SYNC_SETTINGS: string; + const ACTION_SYSTEM_UPDATE_SETTINGS: string; + const ACTION_TETHER_PROVISIONING_UI: string; + const ACTION_TRUSTED_CREDENTIALS_USER: string; + const ACTION_USAGE_ACCESS_SETTINGS: string; + const ACTION_USER_DICTIONARY_INSERT: string; + const ACTION_USER_DICTIONARY_SETTINGS: string; + const ACTION_USER_SETTINGS: string; + const ACTION_VOICE_CONTROL_AIRPLANE_MODE: string; + const ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE: string; + const ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE: string; + const ACTION_VOICE_INPUT_SETTINGS: string; + const ACTION_VPN_SETTINGS: string; + const ACTION_VR_LISTENER_SETTINGS: string; + const ACTION_WEBVIEW_SETTINGS: string; + const ACTION_WIFI_IP_SETTINGS: string; + const ACTION_WIFI_SETTINGS: string; + const ACTION_WIRELESS_SETTINGS: string; + const ACTION_ZEN_MODE_AUTOMATION_SETTINGS: string; + const ACTION_ZEN_MODE_EVENT_RULE_SETTINGS: string; + const ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS: string; + const ACTION_ZEN_MODE_PRIORITY_SETTINGS: string; + const ACTION_ZEN_MODE_SCHEDULE_RULE_SETTINGS: string; + const ACTION_ZEN_MODE_SETTINGS: string; + + function startActivityAsync(activity: string, data?: HashMap): Promise; +} + +/** + * KeepAwake + */ +export class KeepAwake extends Component { + static activate(): void; + static deactivate(): void; +} + +/** + * LinearGradient + */ +export interface LinearGradientProps { + colors: string[]; + start: [number, number]; + end: [number, number]; + locations: number[]; +} + +export class LinearGradient extends Component { } + +/** + * Location + */ +export namespace Location { + interface LocationOptions { + enableHighAccuracy?: boolean; + timeInterval?: number; + distanceInterval?: number; + } + + interface LocationProps { + latitude: number; + longitude: number; + } + + interface Coords extends LocationProps { + altitude: number; + accuracy: number; + } + + interface LocationData { + coords: { + heading: number; + speed: number + } & Coords; + timestamp: number; + } + + interface ProviderStatus { + locationServicesEnabled: boolean; + gpsAvailable?: boolean; + networkAvailable?: boolean; + passiveAvailable?: boolean; + } + + interface HeadingStatus { + magHeading: number; + trueHeading: number; + accuracy: number; + } + + interface GeocodeData { + city: string; + street: string; + region: string; + postalCode: string; + country: string; + name: string; + } + + type LocationCallback = (data: LocationData) => void; + + function getCurrentPositionAsync(options: LocationOptions): Promise; + function watchPositionAsync(options: LocationOptions, callback: LocationCallback): EventSubscription; + function getProviderStatusAsync(): Promise; + function getHeadingAsync(): Promise; + function watchHeadingAsync(callback: (status: HeadingStatus) => void): EventSubscription; + function geocodeAsync(address: string): Promise; + function reverseGeocodeAsync(location: LocationProps): Promise; + function setApiKey(key: string): void; +} + +/** + * Magnetometer + */ +export namespace Magnetometer { + interface MagnetometerObject { + x: Axis; + y: Axis; + z: Axis; + } + + function addListener(listener: (obj: MagnetometerObject) => any): EventSubscription; + function removeAllListeners(): void; + function setUpdateInterval(intervalMs: number): void; +} + +/** + * Notifications + */ +export namespace Notifications { + interface Notification { + origin: 'selected' | 'received'; + data: any; + remote: boolean; + isMultiple: boolean; + } + + interface LocalNotification { + title: string; + body?: string; + data?: any; + ios?: { + sound?: boolean + }; + android?: { + sound?: boolean; + icon?: string; + color?: string; + priority?: 'min' | 'low' | 'high' | 'max'; + sticky?: boolean; + vibrate?: boolean | number[]; + link?: string; + }; + } + + type LocalNotificationId = string | number; + + function addListener(listener: (notification: Notification) => any): EventSubscription; + function getExponentPushTokenAsync(): Promise; + function presentLocalNotificationAsync(localNotification: LocalNotification): Promise; + function scheduleLocalNotificationAsync( + localNotification: LocalNotification, + schedulingOptions: { time: Date | number, repeat?: 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year' } + ): Promise; + function dismissNotificationAsync(localNotificationId: LocalNotificationId): Promise; + function dismissAllNotificationsAsync(): Promise; + function cancelScheduledNotificationAsync(localNotificationId: LocalNotificationId): Promise; + function cancelAllScheduledNotificationsAsync(): Promise; + function getBadgeNumberAsync(): Promise; + function setBadgeNumberAsync(number: number): Promise; +} + +/** + * Pedometer + */ +export namespace Pedometer { + function isAvailableAsync(): Promise; + function getStepCountAsync(start: Date, end: Date): Promise<{ steps: number; }>; + function watchStepCount(callback: (params: { steps: number; }) => void): EventSubscription; +} + +/** + * Permissions + */ +export namespace Permissions { + type PermissionType = 'remoteNotifications' | 'location' | + 'camera' | 'contacts' | 'audioRecording'; + type PermissionStatus = 'undetermined' | 'granted' | 'denied'; + type PermissionExpires = 'never'; + interface PermissionDetailsLocationIOS { + scope: 'whenInUse' | 'always'; + } + interface PermissionDetailsLocationAndroid { + scope: 'fine' | 'coarse' | 'none'; + } + interface PermissionResponse { + status: PermissionStatus; + expires: PermissionExpires; + ios?: PermissionDetailsLocationIOS; + android?: PermissionDetailsLocationAndroid; + } + + function getAsync(type: PermissionType): Promise; + function askAsync(type: PermissionType): Promise; + + const CAMERA: string; + const CAMERA_ROLL: string; + const AUDIO_RECORDING: string; + const LOCATION: string; + const REMOTE_NOTIFICATIONS: string; + const NOTIFICATIONS: string; + const CONTACTS: string; +} + +/** + * Register Root Component + */ +export function registerRootComponent(component: Component): Component; + +/** + * ScreenOrientation + */ +export namespace ScreenOrientation { + interface Orientation { + ALL: 'ALL'; + ALL_BUT_UPSIDE_DOWN: 'ALL_BUT_UPSIDE_DOWN'; + PORTRAIT: 'PORTRAIT'; + PORTRAIT_UP: 'PORTRAIT_UP'; + PORTRAIT_DOWN: 'PORTRAIT_DOWN'; + LANDSCAPE: 'LANDSCAPE'; + LANDSCAPE_LEFT: 'LANDSCAPE_LEFT'; + LANDSCAPE_RIGHT: 'LANDSCAPE_RIGHT'; + } + const Orientation: Orientation; + function allow(orientation: string): void; +} + +/** + * SecureStore + */ +export namespace SecureStore { + interface SecureStoreOptions { + keychainService?: string; + keychainAccessible?: number; + } + function setItemAsync(key: string, value: string, options?: SecureStoreOptions): Promise; + function getItemAsync(key: string, options?: SecureStoreOptions): Promise; + function deleteItemAsync(key: string, options?: SecureStoreOptions): Promise; +} + +/** + * Segment + */ +export namespace Segment { + function initialize(keys: { + androidWriteKey: string; + iosWriteKey: string; + }): void; + function identify(userId: string): void; + function identifyWithTraits(userId: string, traits: object): void; + function track(event: string): void; + function reset(): void; + function trackWithProperties(event: string, properties: object): void; + function screen(screenName: string): void; + function screenWithProperties(screenName: string, properties: object): void; + function flush(): void; +} + +/** + * Speech + */ +export namespace Speech { + interface SpeechOptions { + language?: string; + pitch?: number; + rate?: number; + onStart?: () => void; + onStopped?: () => void; + onDone?: () => void; + onError?: (error: string) => void; + } + + function speak(text: string, options?: SpeechOptions): void; + function stop(): void; + function isSpeakingAsync(): Promise; +} + +/** + * SQLite + */ +export namespace SQLite { + type Error = any; + + interface Database { + transaction( + callback: (transaction: Transaction) => any, + error?: (error: Error) => any, // TODO def of error + success?: () => any + ): void; + } + + interface Transaction { + executeSql( + sqlStatement: string, + arguments?: string[] | number[], + success?: (transaction: Transaction, resultSet: ResultSet) => any, + error?: (transaction: Transaction, error: Error) => any + ): void; + } + + interface ResultSet { + insertId: number; + rowAffected: number; + rows: { + length: number; + item: (index: number) => any; + _array: HashMap[]; + }; + } + + function openDatabase( + name: string | { + name: string, + version?: string, + description?: string, + size?: number, + callback?: () => any + }, + version?: string, + description?: string, + size?: number, + callback?: () => any + ): any; +} + +/** + * Svg + */ +export interface SvgCommonProps { + fill?: string; + fillOpacity?: number; + stroke?: string; + strokeWidth?: number; + strokeOpacity?: number; + strokeLinecap?: string; + strokeLineJoin?: string; + strokeDasharray?: any[]; + strokeDashoffset?: any; + x?: Axis; + y?: Axis; + rotate?: number; + scale?: number; + origin?: number | string; + originX?: number; + originY?: number; +} + +export class Svg extends Component<{ width: number, heigth: number }> { } +export class Rect extends Component { } + +export interface CircleProps extends SvgCommonProps { + cx: Axis; + cy: Axis; +} +export class Circle extends Component { } + +export interface EllipseProps extends CircleProps { + rx: Axis; + ry: Axis; +} +export class Ellipse extends Component { } + +export interface LineProps extends SvgCommonProps { + x1: Axis; + y1: Axis; + x2: Axis; + y2: Axis; +} +export class Line extends Component { } + +export interface PolyProps extends SvgCommonProps { + points: string; +} +export class Polygon extends Component { } +export class Polyline extends Component { } + +export interface PathLine extends SvgCommonProps { + d: string; +} +export class Path extends Component { } + +export interface TextProps extends SvgCommonProps { + textAnchor: string; +} +export class Text extends Component { } +export class G extends Component { } +export class Use extends Component<{ href: string, x: number, y: number }> { } +export class Symbol extends Component<{ viewbox: string, widt: number, height: number }> { } +export class Defs extends Component { } +export class RadialGradient extends Component { } + +/** + * Take Snapshot + */ +export function takeSnapshotAsync( + view?: (number | React.ReactElement), + options?: { + width?: number, + height?: number, + format?: 'png' | 'jpg' | 'jpeg' | 'webm', + quality?: number, + result?: 'file' | 'base64' | 'data-uri', + } +): Promise; + +/** + * Util + */ +export namespace Util { + function getCurrentDeviceCountryAsync(): Promise; + function getCurrentLocaleAsync(): Promise; + function getCurrentTimeZoneAsync(): Promise; + function reload(): void; + function addNewVersionListenerExperimental(listener: (event: { + manifest: object; + }) => void): { remove(): void; }; // Android only +} + +/** + * Web Browser + */ +export namespace WebBrowser { + function openBrowserAsync(url: string): Promise<{ type: 'cancelled' | 'dismissed' }>; + function openAuthSessionAsync(url: string, redirectUrl?: string): Promise<{ type: 'cancelled' | 'dismissed' }>; + function dismissBrowser(): Promise<{ type: 'dismissed' }>; +} diff --git a/types/expo/v2/tsconfig.json b/types/expo/v2/tsconfig.json new file mode 100644 index 0000000000..7b8759476b --- /dev/null +++ b/types/expo/v2/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "jsx": "react", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "expo": [ + "expo/v2" + ], + "expo/*": [ + "expo/v2/*" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "expo-tests.tsx" + ] +} diff --git a/types/expo/v2/tslint.json b/types/expo/v2/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/expo/v2/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 3de6da989a9acc1192222649ecdaff8c63c2d800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miika=20H=C3=A4nninen?= Date: Fri, 15 Dec 2017 14:38:21 +0200 Subject: [PATCH 206/298] Ramda: Replace Array with ReadonlyArray in input positions Ramda never modifies its input arrays, so this allows the use of the stricter ReadonlyArray. All Arrays are compatible with ReadonlyArray, so this won't break them. Return types are left as Array, since the user should be free to do what they want with the results. --- types/ramda/index.d.ts | 405 +++++++++++++++++++++-------------------- 1 file changed, 207 insertions(+), 198 deletions(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index be97f3ee32..a8c3c9ab47 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -11,6 +11,7 @@ // Charles-Philippe Clermont // Samson Keung // Angelo Ocana +// Miika Hänninen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -19,7 +20,7 @@ declare let R: R.Static; declare namespace R { type Ord = number | string | boolean; - type Path = Array<(number | string)>; + type Path = ReadonlyArray<(number | string)>; interface Functor { map(fn: (t: T) => U): Functor; @@ -66,7 +67,7 @@ declare namespace R { } interface Filter { - (list: T[]): T[]; + (list: ReadonlyArray): T[]; (obj: Dictionary): Dictionary; } @@ -163,29 +164,29 @@ declare namespace R { * Creates a new list iteration function from an existing one by adding two new parameters to its callback * function: the current index, and the entire list. */ - addIndex(fn: (f: (item: T) => U, list: T[]) => U[]): CurriedFunction2<(item: T, idx: number, list?: T[]) => U, T[], U[]>; + addIndex(fn: (f: (item: T) => U, list: T[]) => U[]): CurriedFunction2<(item: T, idx: number, list?: T[]) => U, ReadonlyArray, U[]>; /* Special case for forEach */ - addIndex(fn: (f: (item: T) => void, list: T[]) => T[]): CurriedFunction2<(item: T, idx: number, list?: T[]) => void, T[], T[]>; + addIndex(fn: (f: (item: T) => void, list: T[]) => T[]): CurriedFunction2<(item: T, idx: number, list?: T[]) => void, ReadonlyArray, T[]>; /* Special case for reduce */ - addIndex(fn: (f: (acc: U, item: T) => U, aci: U, list: T[]) => U): CurriedFunction3<(acc: U, item: T, idx: number, list?: T[]) => U, U, T[], U>; + addIndex(fn: (f: (acc: U, item: T) => U, aci: U, list: T[]) => U): CurriedFunction3<(acc: U, item: T, idx: number, list?: T[]) => U, U, ReadonlyArray, U>; /** * Applies a function to the value at the given index of an array, returning a new copy of the array with the * element at the given index replaced with the result of the function application. */ - adjust(fn: (a: T) => T, index: number, list: T[]): T[]; - adjust(fn: (a: T) => T, index: number): (list: T[]) => T[]; + adjust(fn: (a: T) => T, index: number, list: ReadonlyArray): T[]; + adjust(fn: (a: T) => T, index: number): (list: ReadonlyArray) => T[]; /** * Returns true if all elements of the list match the predicate, false if there are any that don't. */ - all(fn: (a: T) => boolean, list: T[]): boolean; - all(fn: (a: T) => boolean): (list: T[]) => boolean; + all(fn: (a: T) => boolean, list: ReadonlyArray): boolean; + all(fn: (a: T) => boolean): (list: ReadonlyArray) => boolean; /** * Given a list of predicates, returns a new predicate that will be true exactly when all of them are. */ - allPass(preds: Pred[]): Pred; + allPass(preds: ReadonlyArray): Pred; /** * Returns a function that always returns the given value. @@ -202,39 +203,39 @@ declare namespace R { /** * Returns true if at least one of elements of the list match the predicate, false otherwise. */ - any(fn: (a: T) => boolean, list: T[]): boolean; - any(fn: (a: T) => boolean): (list: T[]) => boolean; + any(fn: (a: T) => boolean, list: ReadonlyArray): boolean; + any(fn: (a: T) => boolean): (list: ReadonlyArray) => boolean; /** * Given a list of predicates returns a new predicate that will be true exactly when any one of them is. */ - anyPass(preds: Pred[]): Pred; + anyPass(preds: ReadonlyArray): Pred; /** * ap applies a list of functions to a list of values. */ - ap(fns: Array<((a: T) => U)>, vs: T[]): U[]; - ap(fns: Array<((a: T) => U)>): (vs: T[]) => U[]; + ap(fns: Array<((a: T) => U)>, vs: ReadonlyArray): U[]; + ap(fns: Array<((a: T) => U)>): (vs: ReadonlyArray) => U[]; /** * Returns a new list, composed of n-tuples of consecutive elements If n is greater than the length of the list, * an empty list is returned. */ - aperture(n: number, list: T[]): T[][]; - aperture(n: number): (list: T[]) => T[][]; + aperture(n: number, list: ReadonlyArray): T[][]; + aperture(n: number): (list: ReadonlyArray) => T[][]; /** * Returns a new list containing the contents of the given list, followed by the given element. */ - append(el: T, list: T[]): T[]; - append(el: T): (list: T[]) => T[]; + append(el: T, list: ReadonlyArray): T[]; + append(el: T): (list: ReadonlyArray) => T[]; /** * Applies function fn to the argument list args. This is useful for creating a fixed-arity function from * a variadic function. fn should be a bound function if context is significant. */ - apply(fn: (arg0: T, ...args: T[]) => TResult, args: U[]): TResult; - apply(fn: (arg0: T, ...args: T[]) => TResult): (args: U[]) => TResult; + apply(fn: (arg0: T, ...args: T[]) => TResult, args: ReadonlyArray): TResult; + apply(fn: (arg0: T, ...args: T[]) => TResult): (args: ReadonlyArray) => TResult; /** * Given a spec object recursively mapping properties to functions, creates a function producing an object @@ -302,8 +303,8 @@ declare namespace R { * `chain` maps a function over a list and concatenates the results. * This implementation is compatible with the Fantasy-land Chain spec */ - chain(fn: (n: T) => U[], list: T[]): U[]; - chain(fn: (n: T) => U[]): (list: T[]) => U[]; + chain(fn: (n: T) => U[], list: ReadonlyArray): U[]; + chain(fn: (n: T) => U[]): (list: ReadonlyArray) => U[]; /** * Restricts a number to be within a range. @@ -318,7 +319,7 @@ declare namespace R { * Creates a deep copy of the value which may contain (nested) Arrays and Objects, Numbers, Strings, Booleans and Dates. */ clone(value: T): T; - clone(value: T[]): T[]; + clone(value: ReadonlyArray): T[]; /** * Makes a comparator function out of a function that reports whether the first element is less than the second. @@ -387,8 +388,8 @@ declare namespace R { * Returns a new list consisting of the elements of the first list followed by the elements * of the second. */ - concat(list1: T[], list2: T[]): T[]; - concat(list1: T[]): (list2: T[]) => T[]; + concat(list1: ReadonlyArray, list2: ReadonlyArray): T[]; + concat(list1: ReadonlyArray): (list2: ReadonlyArray) => T[]; concat(list1: string, list2: string): string; concat(list1: string): (list2: string) => string; @@ -398,7 +399,7 @@ declare namespace R { * point fn returns the result of applying its arguments to the corresponding transformer. If none of the predicates * matches, fn returns undefined. */ - cond(fns: Array<[Pred, (...a: any[]) => any]>): (...a: any[]) => any; + cond(fns: ReadonlyArray<[Pred, (...a: any[]) => any]>): (...a: any[]) => any; /** * Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type. @@ -416,9 +417,9 @@ declare namespace R { * Equivalent to `indexOf(a)(list) > -1`. Uses strict (`===`) equality checking. */ contains(a: string, list: string): boolean; - contains(a: T, list: T[]): boolean; + contains(a: T, list: ReadonlyArray): boolean; contains(a: string): (list: string) => boolean; - contains(a: T): (list: T[]) => boolean; + contains(a: T): (list: ReadonlyArray) => boolean; /** * Accepts a converging function and a list of branching functions and returns a new @@ -426,7 +427,7 @@ declare namespace R { * function is applied to those same arguments. The results of each branching function * are passed as arguments to the converging function to produce the return value. */ - converge(after: ((...a: any[]) => any), fns: Array<((...a: any[]) => any)>): (...a: any[]) => any; + converge(after: ((...a: any[]) => any), fns: ReadonlyArray<((...a: any[]) => any)>): (...a: any[]) => any; /** * Counts the elements of a list according to how many match each value @@ -435,8 +436,8 @@ declare namespace R { * the list. Note that all keys are coerced to strings because of how * JavaScript objects work. */ - countBy(fn: (a: T) => string | number, list: T[]): { [index: string]: number }; - countBy(fn: (a: T) => string | number): (list: T[]) => { [index: string]: number }; + countBy(fn: (a: T) => string | number, list: ReadonlyArray): { [index: string]: number }; + countBy(fn: (a: T) => string | number): (list: ReadonlyArray) => { [index: string]: number }; /** * Returns a curried equivalent of the provided function. The curried function has two unusual capabilities. @@ -481,15 +482,15 @@ declare namespace R { /** * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. */ - difference(list1: T[], list2: T[]): T[]; - difference(list1: T[]): (list2: T[]) => T[]; + difference(list1: ReadonlyArray, list2: ReadonlyArray): T[]; + difference(list1: ReadonlyArray): (list2: ReadonlyArray) => T[]; /** * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. * Duplication is determined according to the value returned by applying the supplied predicate to two list * elements. */ - differenceWith(pred: (a: T, b: T) => boolean, list1: T[], list2: T[]): T[]; + differenceWith(pred: (a: T, b: T) => boolean, list1: ReadonlyArray, list2: ReadonlyArray): T[]; /* * Returns a new object that does not contain a prop property. @@ -513,20 +514,20 @@ declare namespace R { /** * Returns a new list containing all but the first n elements of the given list. */ - drop(n: number, xs: T[]): T[]; + drop(n: number, xs: ReadonlyArray): T[]; drop(n: number, xs: string): string; drop(n: number): { (xs: string): string; - (xs: T[]): T[]; + (xs: ReadonlyArray): T[]; }; /** * Returns a list containing all but the last n elements of the given list. */ - dropLast(n: number, xs: T[]): T[]; + dropLast(n: number, xs: ReadonlyArray): T[]; dropLast(n: number, xs: string): string; dropLast(n: number): { - (xs: T[]): T[]; + (xs: ReadonlyArray): T[]; (xs: string): string; }; @@ -534,15 +535,15 @@ declare namespace R { * Returns a new list containing all but last then elements of a given list, passing each value from the * right to the supplied predicate function, skipping elements while the predicate function returns true. */ - dropLastWhile(fn: (a: T) => boolean, list: T[]): T[]; - dropLastWhile(fn: (a: T) => boolean): (list: T[]) => T[]; + dropLastWhile(fn: (a: T) => boolean, list: ReadonlyArray): T[]; + dropLastWhile(fn: (a: T) => boolean): (list: ReadonlyArray) => T[]; /** * Returns a new list containing the last n elements of a given list, passing each value to the supplied * predicate function, skipping elements while the predicate function returns true. */ - dropWhile(fn: (a: T) => boolean, list: T[]): T[]; - dropWhile(fn: (a: T) => boolean): (list: T[]) => T[]; + dropWhile(fn: (a: T) => boolean, list: ReadonlyArray): T[]; + dropWhile(fn: (a: T) => boolean): (list: ReadonlyArray) => T[]; /** * A function wrapping calls to the two functions in an || operation, returning the result of the first @@ -564,8 +565,8 @@ declare namespace R { */ endsWith(a: string, list: string): boolean; endsWith(a: string): (list: string) => boolean; - endsWith(a: T | T[], list: T[]): boolean; - endsWith(a: T | T[]): (list: T[]) => boolean; + endsWith(a: T | ReadonlyArray, list: ReadonlyArray): boolean; + endsWith(a: T | ReadonlyArray): (list: ReadonlyArray) => boolean; /** * Takes a function and two values in its domain and returns true if the values map to the same value in the @@ -605,42 +606,42 @@ declare namespace R { * Returns a new list containing only those items that match a given predicate function. The predicate function is passed one argument: (value). */ filter(fn: (value: T) => boolean): Filter; - filter(fn: (value: T) => boolean, list: T[]): T[]; + filter(fn: (value: T) => boolean, list: ReadonlyArray): T[]; filter(fn: (value: T) => boolean, obj: Dictionary): Dictionary; /** * Returns the first element of the list which matches the predicate, or `undefined` if no * element matches. */ - find(fn: (a: T) => boolean, list: T[]): T | undefined; - find(fn: (a: T) => boolean): (list: T[]) => T | undefined; + find(fn: (a: T) => boolean, list: ReadonlyArray): T | undefined; + find(fn: (a: T) => boolean): (list: ReadonlyArray) => T | undefined; /** * Returns the index of the first element of the list which matches the predicate, or `-1` * if no element matches. */ - findIndex(fn: (a: T) => boolean, list: T[]): number; - findIndex(fn: (a: T) => boolean): (list: T[]) => number; + findIndex(fn: (a: T) => boolean, list: ReadonlyArray): number; + findIndex(fn: (a: T) => boolean): (list: ReadonlyArray) => number; /** * Returns the last element of the list which matches the predicate, or `undefined` if no * element matches. */ - findLast(fn: (a: T) => boolean, list: T[]): T | undefined; - findLast(fn: (a: T) => boolean): (list: T[]) => T | undefined; + findLast(fn: (a: T) => boolean, list: ReadonlyArray): T | undefined; + findLast(fn: (a: T) => boolean): (list: ReadonlyArray) => T | undefined; /** * Returns the index of the last element of the list which matches the predicate, or * `-1` if no element matches. */ - findLastIndex(fn: (a: T) => boolean, list: T[]): number; - findLastIndex(fn: (a: T) => boolean): (list: T[]) => number; + findLastIndex(fn: (a: T) => boolean, list: ReadonlyArray): number; + findLastIndex(fn: (a: T) => boolean): (list: ReadonlyArray) => number; /** * Returns a new list by pulling every item out of it (and all its sub-arrays) and putting * them in a new array, depth-first. */ - flatten(x: T[] | T[][]): T[]; + flatten(x: ReadonlyArray | ReadonlyArray): T[]; /** * Returns a new function much like the supplied one, except that the first two arguments' @@ -654,6 +655,8 @@ declare namespace R { */ forEach(fn: (x: T) => void, list: T[]): T[]; forEach(fn: (x: T) => void): (list: T[]) => T[]; + forEach(fn: (x: T) => void, list: ReadonlyArray): ReadonlyArray; + forEach(fn: (x: T) => void): (list: ReadonlyArray) => ReadonlyArray; /** * Iterate over an input object, calling a provided function fn for each key and value in the object. @@ -672,13 +675,13 @@ declare namespace R { * calling a String-returning function * on each element, and grouping the results according to values returned. */ - groupBy(fn: (a: T) => string, list: T[]): { [index: string]: T[] }; - groupBy(fn: (a: T) => string): (list: T[]) => { [index: string]: T[] }; + groupBy(fn: (a: T) => string, list: ReadonlyArray): { [index: string]: T[] }; + groupBy(fn: (a: T) => string): (list: ReadonlyArray) => { [index: string]: T[] }; /** * Takes a list and returns a list of lists where each sublist's elements are all "equal" according to the provided equality function */ - groupWith(fn: (x: T, y: T) => boolean, list: T[]): T[][]; + groupWith(fn: (x: T, y: T) => boolean, list: ReadonlyArray): T[][]; groupWith(fn: (x: T, y: T) => boolean, list: string): string[]; /** @@ -709,7 +712,7 @@ declare namespace R { * Returns the first element in a list. * In some libraries this function is named `first`. */ - head(list: T[]): T | undefined; + head(list: ReadonlyArray): T | undefined; head(list: string): string; /** @@ -740,44 +743,44 @@ declare namespace R { * Given a function that generates a key, turns a list of objects into an object indexing the objects * by the given key. */ - indexBy(fn: (a: T) => string, list: T[]): { [key: string]: T }; - indexBy(fn: (a: T) => string): (list: T[]) => { [key: string]: T }; + indexBy(fn: (a: T) => string, list: ReadonlyArray): { [key: string]: T }; + indexBy(fn: (a: T) => string): (list: ReadonlyArray) => { [key: string]: T }; /** * Returns the position of the first occurrence of an item in an array * (by strict equality), * or -1 if the item is not included in the array. */ - indexOf(target: T, list: T[]): number; - indexOf(target: T): (list: T[]) => number; + indexOf(target: T, list: ReadonlyArray): number; + indexOf(target: T): (list: ReadonlyArray) => number; /** * Returns all but the last element of a list or string. */ - init(list: T[]): T[]; + init(list: ReadonlyArray): T[]; init(list: string): string; /** * Inserts the supplied element into the list, at index index. Note that * this is not destructive: it returns a copy of the list with the changes. */ - insert(index: number, elt: T, list: T[]): T[]; - insert(index: number, elt: T): (list: T[]) => T[]; - insert(index: number): (elt: T, list: T[]) => T[]; + insert(index: number, elt: T, list: ReadonlyArray): T[]; + insert(index: number, elt: T): (list: ReadonlyArray) => T[]; + insert(index: number): (elt: T, list: ReadonlyArray) => T[]; /** * Inserts the sub-list into the list, at index `index`. _Note that this * is not destructive_: it returns a copy of the list with the changes. */ - insertAll(index: number, elts: T[], list: T[]): T[]; - insertAll(index: number, elts: T[]): (list: T[]) => T[]; - insertAll(index: number): (elts: T[], list: T[]) => T[]; + insertAll(index: number, elts: ReadonlyArray, list: ReadonlyArray): T[]; + insertAll(index: number, elts: ReadonlyArray): (list: ReadonlyArray) => T[]; + insertAll(index: number): (elts: ReadonlyArray, list: ReadonlyArray) => T[]; /** * Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists. */ - intersection(list1: T[], list2: T[]): T[]; - intersection(list1: T[]): (list2: T[]) => T[]; + intersection(list1: ReadonlyArray, list2: ReadonlyArray): T[]; + intersection(list1: ReadonlyArray): (list2: ReadonlyArray) => T[]; /** * Combines two lists into a set (i.e. no duplicates) composed of those @@ -785,21 +788,21 @@ declare namespace R { * to the value returned by applying the supplied predicate to two list * elements. */ - intersectionWith(pred: (a: T, b: T) => boolean, list1: T[], list2: T[]): T[]; + intersectionWith(pred: (a: T, b: T) => boolean, list1: ReadonlyArray, list2: ReadonlyArray): T[]; /** * Creates a new list with the separator interposed between elements. */ - intersperse(separator: T, list: T[]): T[]; - intersperse(separator: T): (list: T[]) => T[]; + intersperse(separator: T, list: ReadonlyArray): T[]; + intersperse(separator: T): (list: ReadonlyArray) => T[]; /** * Transforms the items of the list with the transducer and appends the transformed items to the accumulator * using an appropriate iterator function based on the accumulator type. */ - into(acc: any, xf: (...a: any[]) => any, list: T[]): T[]; - into(acc: any, xf: (...a: any[]) => any): (list: T[]) => T[]; - into(acc: any): (xf: (...a: any[]) => any, list: T[]) => T[]; + into(acc: any, xf: (...a: any[]) => any, list: ReadonlyArray): T[]; + into(acc: any, xf: (...a: any[]) => any): (list: ReadonlyArray) => T[]; + into(acc: any): (xf: (...a: any[]) => any, list: ReadonlyArray) => T[]; /** * Same as R.invertObj, however this accounts for objects with duplicate values by putting the values into an array. @@ -853,8 +856,8 @@ declare namespace R { * Returns a string made by inserting the `separator` between each * element and concatenating all the elements into a single string. */ - join(x: string, xs: any[]): string; - join(x: string): (xs: any[]) => string; + join(x: string, xs: ReadonlyArray): string; + join(x: string): (xs: ReadonlyArray) => string; /** * Applies a list of functions to a list of values. @@ -876,19 +879,19 @@ declare namespace R { /** * Returns the last element from a list. */ - last(list: T[]): T | undefined; + last(list: ReadonlyArray): T | undefined; last(list: string): string; /** * Returns the position of the last occurrence of an item (by strict equality) in * an array, or -1 if the item is not included in the array. */ - lastIndexOf(target: T, list: T[]): number; + lastIndexOf(target: T, list: ReadonlyArray): number; /** * Returns the number of elements in the array by returning list.length. */ - length(list: any[]): number; + length(list: ReadonlyArray): number; /** * Returns a lens for the given getter and setter functions. The getter @@ -944,25 +947,25 @@ declare namespace R { /** * Returns a new list, constructed by applying the supplied function to every element of the supplied list. */ - map(fn: (x: T) => U, list: T[]): U[]; + map(fn: (x: T) => U, list: ReadonlyArray): U[]; map(fn: (x: T) => U, obj: Functor): Functor; // used in functors - map(fn: (x: T) => U): (list: T[]) => U[]; + map(fn: (x: T) => U): (list: ReadonlyArray) => U[]; map(fn: (x: T[keyof T]) => U[keyof T], obj: T): U; map(fn: (x: T[keyof T]) => U[keyof T]): (obj: T) => U; /** * The mapAccum function behaves like a combination of map and reduce. */ - mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U, list: T[]): [U, TResult[]]; - mapAccum(fn: (acc: U, value: T) => [U, TResult]): (acc: U, list: T[]) => [U, TResult[]]; - mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: T[]) => [U, TResult[]]; + mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U, list: ReadonlyArray): [U, TResult[]]; + mapAccum(fn: (acc: U, value: T) => [U, TResult]): (acc: U, list: ReadonlyArray) => [U, TResult[]]; + mapAccum(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: ReadonlyArray) => [U, TResult[]]; /** * The mapAccumRight function behaves like a combination of map and reduce. */ - mapAccumRight(fn: (acc: U, value: T) => [U, TResult], acc: U, list: T[]): [U, TResult[]]; - mapAccumRight(fn: (acc: U, value: T) => [U, TResult]): (acc: U, list: T[]) => [U, TResult[]]; - mapAccumRight(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: T[]) => [U, TResult[]]; + mapAccumRight(fn: (acc: U, value: T) => [U, TResult], acc: U, list: ReadonlyArray): [U, TResult[]]; + mapAccumRight(fn: (acc: U, value: T) => [U, TResult]): (acc: U, list: ReadonlyArray) => [U, TResult[]]; + mapAccumRight(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: ReadonlyArray) => [U, TResult[]]; /** * Like mapObj, but but passes additional arguments to the predicate function. @@ -1002,12 +1005,12 @@ declare namespace R { /** * Returns the mean of the given list of numbers. */ - mean(list: number[]): number; + mean(list: ReadonlyArray): number; /** * Returns the median of the given list of numbers. */ - median(list: number[]): number; + median(list: ReadonlyArray): number; /** * Creates a new function that, when invoked, caches the result of calling fn for a given argument set and @@ -1027,7 +1030,7 @@ declare namespace R { /** * Merges a list of objects together into one object. */ - mergeAll(list: any[]): T; + mergeAll(list: ReadonlyArray): T; /** * Creates a new object with the own properties of the first object merged with the own properties of the second object. @@ -1132,8 +1135,8 @@ declare namespace R { /** * Returns true if no elements of the list match the predicate, false otherwise. */ - none(fn: (a: T) => boolean, list: T[]): boolean; - none(fn: (a: T) => boolean): (list: T[]) => boolean; + none(fn: (a: T) => boolean, list: ReadonlyArray): boolean; + none(fn: (a: T) => boolean): (list: ReadonlyArray) => boolean; /** * A function wrapping a call to the given function in a `!` operation. It will return `true` when the @@ -1144,8 +1147,8 @@ declare namespace R { /** * Returns the nth element in a list. */ - nth(n: number, list: T[]): T; - nth(n: number): (list: T[]) => T; + nth(n: number, list: ReadonlyArray): T; + nth(n: number): (list: ReadonlyArray) => T; /** * Returns a function which returns its nth argument. @@ -1166,8 +1169,8 @@ declare namespace R { /** * Returns a partial copy of an object omitting the keys specified. */ - omit(names: string[], obj: T): T; - omit(names: string[]): (obj: T) => T; + omit(names: ReadonlyArray, obj: T): T; + omit(names: ReadonlyArray): (obj: T) => T; /** * Accepts a function fn and returns a function that guards invocation of fn such that fn can only ever be @@ -1221,10 +1224,10 @@ declare namespace R { * Takes a predicate and a list and returns the pair of lists of elements * which do and do not satisfy the predicate, respectively. */ - partition(fn: (a: string) => boolean, list: string[]): string[][]; - partition(fn: (a: T) => boolean, list: T[]): T[][]; - partition(fn: (a: T) => boolean): (list: T[]) => T[][]; - partition(fn: (a: string) => boolean): (list: string[]) => string[][]; + partition(fn: (a: string) => boolean, list: ReadonlyArray): string[][]; + partition(fn: (a: T) => boolean, list: ReadonlyArray): T[][]; + partition(fn: (a: T) => boolean): (list: ReadonlyArray) => T[][]; + partition(fn: (a: string) => boolean): (list: ReadonlyArray) => string[][]; /** * Retrieve the value at a given path. @@ -1259,14 +1262,14 @@ declare namespace R { * Returns a partial copy of an object containing only the keys specified. If the key does not exist, the * property is ignored. */ - pick(names: Array, obj: T): Pick; - pick(names: string[]): (obj: T) => U; + pick(names: ReadonlyArray, obj: T): Pick; + pick(names: ReadonlyArray): (obj: T) => U; /** * Similar to `pick` except that this one includes a `key: undefined` pair for properties that don't exist. */ - pickAll(names: string[], obj: T): U; - pickAll(names: string[]): (obj: T) => U; + pickAll(names: ReadonlyArray, obj: T): U; + pickAll(names: ReadonlyArray): (obj: T) => U; /** * Returns a partial copy of an object containing only the keys that satisfy the supplied predicate. @@ -1430,27 +1433,27 @@ declare namespace R { /** * Returns a new list by plucking the same named property off all objects in the list supplied. */ - pluck

(p: P, list: Array>): T[]; - pluck(p: number, list: Array<{ [k: number]: T }>): T[]; - pluck

(p: P): (list: Array>) => T[]; - pluck(p: number): (list: Array<{ [k: number]: T }>) => T[]; + pluck

(p: P, list: ReadonlyArray>): T[]; + pluck(p: number, list: ReadonlyArray<{ [k: number]: T }>): T[]; + pluck

(p: P): (list: ReadonlyArray>) => T[]; + pluck(p: number): (list: ReadonlyArray<{ [k: number]: T }>) => T[]; /** * Returns a new list with the given element at the front, followed by the contents of the * list. */ - prepend(el: T, list: T[]): T[]; - prepend(el: T): (list: T[]) => T[]; + prepend(el: T, list: ReadonlyArray): T[]; + prepend(el: T): (list: ReadonlyArray) => T[]; /** * Multiplies together all the elements of a list. */ - product(list: number[]): number; + product(list: ReadonlyArray): number; /** * Reasonable analog to SQL `select` statement. */ - project(props: string[], objs: T[]): U[]; + project(props: ReadonlyArray, objs: ReadonlyArray): U[]; /** * Returns a function that when supplied an object returns the indicated property of that object, if it exists. @@ -1495,8 +1498,8 @@ declare namespace R { * The only difference from `prop` is the parameter order. * Note: TS1.9 # replace any by dictionary */ - props

(ps: P[], obj: Record): T[]; - props

(ps: P[]): (obj: Record) => T[]; + props

(ps: ReadonlyArray

, obj: Record): T[]; + props

(ps: ReadonlyArray

): (obj: Record) => T[]; /** * Returns true if the specified object property satisfies the given predicate; false otherwise. @@ -1518,18 +1521,18 @@ declare namespace R { * function and passing it an accumulator value and the current value from the array, and * then passing the result to the next call. */ - reduce(fn: (acc: TResult, elem: T) => TResult | Reduced, acc: TResult, list: T[]): TResult; - reduce(fn: (acc: TResult, elem: T) => TResult | Reduced): (acc: TResult, list: T[]) => TResult; - reduce(fn: (acc: TResult, elem: T) => TResult | Reduced, acc: TResult): (list: T[]) => TResult; + reduce(fn: (acc: TResult, elem: T) => TResult | Reduced, acc: TResult, list: ReadonlyArray): TResult; + reduce(fn: (acc: TResult, elem: T) => TResult | Reduced): (acc: TResult, list: ReadonlyArray) => TResult; + reduce(fn: (acc: TResult, elem: T) => TResult | Reduced, acc: TResult): (list: ReadonlyArray) => TResult; /** * Groups the elements of the list according to the result of calling the String-returning function keyFn on each * element and reduces the elements of each group to a single value via the reducer function valueFn. */ - reduceBy(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult, keyFn: (elem: T) => string, list: T[]): { [index: string]: TResult }; - reduceBy(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult, keyFn: (elem: T) => string): (list: T[]) => { [index: string]: TResult }; - reduceBy(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult): CurriedFunction2<(elem: T) => string, T[], { [index: string]: TResult }>; - reduceBy(valueFn: (acc: TResult, elem: T) => TResult): CurriedFunction3 string, T[], { [index: string]: TResult }>; + reduceBy(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult, keyFn: (elem: T) => string, list: ReadonlyArray): { [index: string]: TResult }; + reduceBy(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult, keyFn: (elem: T) => string): (list: ReadonlyArray) => { [index: string]: TResult }; + reduceBy(valueFn: (acc: TResult, elem: T) => TResult, acc: TResult): CurriedFunction2<(elem: T) => string, ReadonlyArray, { [index: string]: TResult }>; + reduceBy(valueFn: (acc: TResult, elem: T) => TResult): CurriedFunction3 string, ReadonlyArray, { [index: string]: TResult }>; /** * Returns a value wrapped to indicate that it is the final value of the reduce and @@ -1543,24 +1546,24 @@ declare namespace R { * function and passing it an accumulator value and the current value from the array, and * then passing the result to the next call. */ - reduceRight(fn: (elem: T, acc: TResult) => TResult, acc: TResult, list: T[]): TResult; - reduceRight(fn: (elem: T, acc: TResult) => TResult): (acc: TResult, list: T[]) => TResult; - reduceRight(fn: (elem: T, acc: TResult) => TResult, acc: TResult): (list: T[]) => TResult; + reduceRight(fn: (elem: T, acc: TResult) => TResult, acc: TResult, list: ReadonlyArray): TResult; + reduceRight(fn: (elem: T, acc: TResult) => TResult): (acc: TResult, list: ReadonlyArray) => TResult; + reduceRight(fn: (elem: T, acc: TResult) => TResult, acc: TResult): (list: ReadonlyArray) => TResult; /** * Similar to `filter`, except that it keeps only values for which the given predicate * function returns falsy. */ reject(fn: (value: T) => boolean): Filter; - reject(fn: (value: T) => boolean, list: T[]): T[]; + reject(fn: (value: T) => boolean, list: ReadonlyArray): T[]; reject(fn: (value: T) => boolean, obj: Dictionary): Dictionary; /** * Removes the sub-list of `list` starting at index `start` and containing `count` elements. */ - remove(start: number, count: number, list: T[]): T[]; - remove(start: number): (count: number, list: T[]) => T[]; - remove(start: number, count: number): (list: T[]) => T[]; + remove(start: number, count: number, list: ReadonlyArray): T[]; + remove(start: number): (count: number, list: ReadonlyArray) => T[]; + remove(start: number, count: number): (list: ReadonlyArray) => T[]; /** * Returns a fixed list of size n containing a specified identical value. @@ -1578,14 +1581,14 @@ declare namespace R { /** * Returns a new list with the same elements as the original list, just in the reverse order. */ - reverse(list: T[]): T[]; + reverse(list: ReadonlyArray): T[]; /** * Scan is similar to reduce, but returns a list of successively reduced values from the left. */ - scan(fn: (acc: TResult, elem: T) => any, acc: TResult, list: T[]): TResult[]; - scan(fn: (acc: TResult, elem: T) => any, acc: TResult): (list: T[]) => TResult[]; - scan(fn: (acc: TResult, elem: T) => any): (acc: TResult, list: T[]) => TResult[]; + scan(fn: (acc: TResult, elem: T) => any, acc: TResult, list: ReadonlyArray): TResult[]; + scan(fn: (acc: TResult, elem: T) => any, acc: TResult): (list: ReadonlyArray) => TResult[]; + scan(fn: (acc: TResult, elem: T) => any): (acc: TResult, list: ReadonlyArray) => TResult[]; /** * Returns the result of "setting" the portion of the given data structure focused by the given lens to the @@ -1599,29 +1602,35 @@ declare namespace R { * Returns the elements from `xs` starting at `a` and ending at `b - 1`. */ slice(a: number, b: number, list: string): string; - slice(a: number, b: number, list: T[]): T[]; - slice(a: number, b: number): (list: string | T[]) => string | T[]; - slice(a: number): (b: number, list: string | T[]) => string | T[]; + slice(a: number, b: number, list: ReadonlyArray): T[]; + slice(a: number, b: number): { + (list: string): string; + (list: ReadonlyArray): T[]; + }; + slice(a: number): { + (b: number, list: string): string; + (b: number, list: ReadonlyArray): T[]; + }; /** * Returns a copy of the list, sorted according to the comparator function, which should accept two values at a * time and return a negative number if the first value is smaller, a positive number if it's larger, and zero * if they are equal. */ - sort(fn: (a: T, b: T) => number, list: T[]): T[]; - sort(fn: (a: T, b: T) => number): (list: T[]) => T[]; + sort(fn: (a: T, b: T) => number, list: ReadonlyArray): T[]; + sort(fn: (a: T, b: T) => number): (list: ReadonlyArray) => T[]; /** * Sorts the list according to a key generated by the supplied function. */ - sortBy(fn: (a: T) => Ord, list: T[]): T[]; - sortBy(fn: (a: any) => Ord): (list: T[]) => T[]; + sortBy(fn: (a: T) => Ord, list: ReadonlyArray): T[]; + sortBy(fn: (a: any) => Ord): (list: ReadonlyArray) => T[]; /** * Sorts a list according to a list of comparators. */ - sortWith(fns: Array<((a: T, b: T) => number)>, list: T[]): T[]; - sortWith(fns: Array<((a: T, b: T) => number)>): (list: T[]) => T[]; + sortWith(fns: ReadonlyArray<((a: T, b: T) => number)>, list: ReadonlyArray): T[]; + sortWith(fns: ReadonlyArray<((a: T, b: T) => number)>): (list: ReadonlyArray) => T[]; /** * Splits a string into an array of strings based on the given @@ -1635,14 +1644,14 @@ declare namespace R { */ splitAt(index: number, list: T): T[]; splitAt(index: number): (list: T) => T[]; - splitAt(index: number, list: T[]): T[][]; - splitAt(index: number): (list: T[]) => T[][]; + splitAt(index: number, list: ReadonlyArray): T[][]; + splitAt(index: number): (list: ReadonlyArray) => T[][]; /** * Splits a collection into slices of the specified length. */ - splitEvery(a: number, list: T[]): T[][]; - splitEvery(a: number): (list: T[]) => T[][]; + splitEvery(a: number, list: ReadonlyArray): T[][]; + splitEvery(a: number): (list: ReadonlyArray) => T[][]; /** * Takes a list and a predicate and returns a pair of lists with the following properties: @@ -1650,16 +1659,16 @@ declare namespace R { * - none of the elements of the first output list satisfies the predicate; and * - if the second output list is non-empty, its first element satisfies the predicate. */ - splitWhen(pred: (val: T) => boolean, list: U[]): U[][]; - splitWhen(pred: (val: T) => boolean): (list: U[]) => U[][]; + splitWhen(pred: (val: T) => boolean, list: ReadonlyArray): U[][]; + splitWhen(pred: (val: T) => boolean): (list: ReadonlyArray) => U[][]; /** * Checks if a list starts with the provided values */ startsWith(a: string, list: string): boolean; startsWith(a: string): (list: string) => boolean; - startsWith(a: T | T[], list: T[]): boolean; - startsWith(a: T | T[]): (list: T[]) => boolean; + startsWith(a: T | ReadonlyArray, list: ReadonlyArray): boolean; + startsWith(a: T | ReadonlyArray): (list: ReadonlyArray) => boolean; /** * Subtracts two numbers. Equivalent to `a - b` but curried. @@ -1670,20 +1679,20 @@ declare namespace R { /** * Adds together all the elements of a list. */ - sum(list: number[]): number; + sum(list: ReadonlyArray): number; /** * Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both. */ - symmetricDifference(list1: T[], list2: T[]): T[]; - symmetricDifference(list: T[]): (list: T[]) => T[]; + symmetricDifference(list1: ReadonlyArray, list2: ReadonlyArray): T[]; + symmetricDifference(list: ReadonlyArray): (list: ReadonlyArray) => T[]; /** * Finds the set (i.e. no duplicates) of all elements contained in the first or second list, but not both. * Duplication is determined according to the value returned by applying the supplied predicate to two list elements. */ - symmetricDifferenceWith(pred: (a: T, b: T) => boolean, list1: T[], list2: T[]): T[]; - symmetricDifferenceWith(pred: (a: T, b: T) => boolean): CurriedFunction2; + symmetricDifferenceWith(pred: (a: T, b: T) => boolean, list1: ReadonlyArray, list2: ReadonlyArray): T[]; + symmetricDifferenceWith(pred: (a: T, b: T) => boolean): CurriedFunction2, ReadonlyArray, T[]>; /** * A function that always returns true. Any passed in parameters are ignored. @@ -1693,28 +1702,28 @@ declare namespace R { /** * Returns all but the first element of a list or string. */ - tail(list: T[]): T[]; + tail(list: ReadonlyArray): T[]; tail(list: string): string; /** * Returns a new list containing the first `n` elements of the given list. If * `n > * list.length`, returns a list of `list.length` elements. */ - take(n: number, xs: T[]): T[]; + take(n: number, xs: ReadonlyArray): T[]; take(n: number, xs: string): string; take(n: number): { (xs: string): string; - (xs: T[]): T[]; + (xs: ReadonlyArray): T[]; }; /** * Returns a new list containing the last n elements of the given list. If n > list.length, * returns a list of list.length elements. */ - takeLast(n: number, xs: T[]): T[]; + takeLast(n: number, xs: ReadonlyArray): T[]; takeLast(n: number, xs: string): string; takeLast(n: number): { - (xs: T[]): T[]; + (xs: ReadonlyArray): T[]; (xs: string): string; }; @@ -1724,16 +1733,16 @@ declare namespace R { * false. Excludes the element that caused the predicate function to fail. The predicate * function is passed one argument: (value). */ - takeLastWhile(pred: (a: T) => boolean, list: T[]): T[]; - takeLastWhile(pred: (a: T) => boolean): (list: T[]) => T[]; + takeLastWhile(pred: (a: T) => boolean, list: ReadonlyArray): T[]; + takeLastWhile(pred: (a: T) => boolean): (list: ReadonlyArray) => T[]; /** * Returns a new list containing the first `n` elements of a given list, passing each value * to the supplied predicate function, and terminating when the predicate function returns * `false`. */ - takeWhile(fn: (x: T) => boolean, list: T[]): T[]; - takeWhile(fn: (x: T) => boolean): (list: T[]) => T[]; + takeWhile(fn: (x: T) => boolean, list: ReadonlyArray): T[]; + takeWhile(fn: (x: T) => boolean): (list: ReadonlyArray) => T[]; /** * The function to call with x. The return value of fn will be thrown away. @@ -1797,24 +1806,24 @@ declare namespace R { * list, successively calling the transformed iterator function and passing it an accumulator value and the * current value from the array, and then passing the result to the next call. */ - transduce(xf: (arg: T[]) => T[], fn: (acc: U[], val: U) => U[], acc: T[], list: T[]): U; - transduce(xf: (arg: T[]) => T[]): (fn: (acc: U[], val: U) => U[], acc: T[], list: T[]) => U; - transduce(xf: (arg: T[]) => T[], fn: (acc: U[], val: U) => U[]): (acc: T[], list: T[]) => U; - transduce(xf: (arg: T[]) => T[], fn: (acc: U[], val: U) => U[], acc: T[]): (list: T[]) => U; + transduce(xf: (arg: T[]) => ReadonlyArray, fn: (acc: U[], val: U) => ReadonlyArray, acc: ReadonlyArray, list: ReadonlyArray): U; + transduce(xf: (arg: T[]) => ReadonlyArray): (fn: (acc: U[], val: U) => ReadonlyArray, acc: ReadonlyArray, list: ReadonlyArray) => U; + transduce(xf: (arg: T[]) => ReadonlyArray, fn: (acc: U[], val: U) => ReadonlyArray): (acc: ReadonlyArray, list: ReadonlyArray) => U; + transduce(xf: (arg: T[]) => ReadonlyArray, fn: (acc: U[], val: U) => ReadonlyArray, acc: ReadonlyArray): (list: ReadonlyArray) => U; /** * Transposes the rows and columns of a 2D list. When passed a list of n lists of length x, returns a list of x lists of length n. */ - transpose(list: T[][]): T[][]; + transpose(list: ReadonlyArray): T[][]; /** * Maps an Applicative-returning function over a Traversable, then uses * sequence to transform the resulting Traversable of Applicative into * an Applicative of Traversable. */ - traverse(of: (a: U[]) => A, fn: (t: T) => U, list: T[]): A; - traverse(of: (a: U[]) => A, fn: (t: T) => U): (list: T[]) => A; - traverse(of: (a: U[]) => A): (fn: (t: T) => U, list: T[]) => A; + traverse(of: (a: U[]) => A, fn: (t: T) => U, list: ReadonlyArray): A; + traverse(of: (a: U[]) => A, fn: (t: T) => U): (list: ReadonlyArray) => A; + traverse(of: (a: U[]) => A): (fn: (t: T) => U, list: ReadonlyArray) => A; /** * Removes (strips) whitespace from both ends of the string. @@ -1869,20 +1878,20 @@ declare namespace R { * Combines two lists into a set (i.e. no duplicates) composed of the * elements of each list. */ - union(as: T[], bs: T[]): T[]; - union(as: T[]): (bs: T[]) => T[]; + union(as: ReadonlyArray, bs: ReadonlyArray): T[]; + union(as: ReadonlyArray): (bs: ReadonlyArray) => T[]; /** * Combines two lists into a set (i.e. no duplicates) composed of the elements of each list. Duplication is * determined according to the value returned by applying the supplied predicate to two list elements. */ - unionWith(pred: (a: T, b: T) => boolean, list1: T[], list2: T[]): T[]; - unionWith(pred: (a: T, b: T) => boolean): CurriedFunction2; + unionWith(pred: (a: T, b: T) => boolean, list1: ReadonlyArray, list2: ReadonlyArray): T[]; + unionWith(pred: (a: T, b: T) => boolean): CurriedFunction2, ReadonlyArray, T[]>; /** * Returns a new list containing only one copy of each element in the original list. */ - uniq(list: T[]): T[]; + uniq(list: ReadonlyArray): T[]; /** * Returns a new list containing only one copy of each element in the original list, @@ -1890,15 +1899,15 @@ declare namespace R { * Prefers the first item if the supplied function produces the same value on two items. * R.equals is used for comparison. */ - uniqBy(fn: (a: T) => U, list: T[]): T[]; - uniqBy(fn: (a: T) => U): (list: T[]) => T[]; + uniqBy(fn: (a: T) => U, list: ReadonlyArray): T[]; + uniqBy(fn: (a: T) => U): (list: ReadonlyArray) => T[]; /** * Returns a new list containing only one copy of each element in the original list, based upon the value * returned by applying the supplied predicate to two list elements. */ - uniqWith(pred: (x: T, y: T) => boolean, list: T[]): T[]; - uniqWith(pred: (x: T, y: T) => boolean): (list: T[]) => T[]; + uniqWith(pred: (x: T, y: T) => boolean, list: ReadonlyArray): T[]; + uniqWith(pred: (x: T, y: T) => boolean): (list: ReadonlyArray) => T[]; /** * Tests the final argument by passing it to the given predicate function. If the predicate is not satisfied, @@ -1912,7 +1921,7 @@ declare namespace R { * Returns a new list by pulling every item at the first level of nesting out, and putting * them in a new array. */ - unnest(x: T[][] | T[]): T[]; + unnest(x: ReadonlyArray | ReadonlyArray> | ReadonlyArray): T[]; /** * Takes a predicate, a transformation function, and an initial value, and returns a value of the same type as @@ -1925,8 +1934,8 @@ declare namespace R { /** * Returns a new copy of the array with the element at the provided index replaced with the given value. */ - update(index: number, value: T, list: T[]): T[]; - update(index: number, value: T): (list: T[]) => T[]; + update(index: number, value: T, list: ReadonlyArray): T[]; + update(index: number, value: T): (list: ReadonlyArray) => T[]; /** * Accepts a function fn and a list of transformer functions and returns a new curried function. @@ -1997,8 +2006,8 @@ declare namespace R { * Returns a new list without values in the first argument. R.equals is used to determine equality. * Acts as a transducer if a transformer is given in list position. */ - without(list1: T[], list2: T[]): T[]; - without(list1: T[]): (list2: T[]) => T[]; + without(list1: ReadonlyArray, list2: ReadonlyArray): T[]; + without(list1: ReadonlyArray): (list2: ReadonlyArray) => T[]; /** * Wrap a function inside another to allow you to make adjustments to the parameters, or do other processing @@ -2009,30 +2018,30 @@ declare namespace R { /** * Creates a new list out of the two supplied by creating each possible pair from the lists. */ - xprod(as: K[], bs: V[]): Array>; - xprod(as: K[]): (bs: V[]) => Array>; + xprod(as: ReadonlyArray, bs: ReadonlyArray): Array>; + xprod(as: ReadonlyArray): (bs: ReadonlyArray) => Array>; /** * Creates a new list out of the two supplied by pairing up equally-positioned items from * both lists. Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`. */ - zip(list1: K[], list2: V[]): Array>; - zip(list1: K[]): (list2: V[]) => Array>; + zip(list1: ReadonlyArray, list2: ReadonlyArray): Array>; + zip(list1: ReadonlyArray): (list2: ReadonlyArray) => Array>; /** * Creates a new object out of a list of keys and a list of values. */ // TODO: Dictionary as a return value is to specific, any seems to loose - zipObj(keys: string[], values: T[]): { [index: string]: T }; - zipObj(keys: string[]): (values: T[]) => { [index: string]: T }; + zipObj(keys: ReadonlyArray, values: ReadonlyArray): { [index: string]: T }; + zipObj(keys: ReadonlyArray): (values: ReadonlyArray) => { [index: string]: T }; /** * Creates a new list out of the two supplied by applying the function to each * equally-positioned pair in the lists. */ - zipWith(fn: (x: T, y: U) => TResult, list1: T[], list2: U[]): TResult[]; - zipWith(fn: (x: T, y: U) => TResult, list1: T[]): (list2: U[]) => TResult[]; - zipWith(fn: (x: T, y: U) => TResult): (list1: T[], list2: U[]) => TResult[]; + zipWith(fn: (x: T, y: U) => TResult, list1: ReadonlyArray, list2: ReadonlyArray): TResult[]; + zipWith(fn: (x: T, y: U) => TResult, list1: ReadonlyArray): (list2: ReadonlyArray) => TResult[]; + zipWith(fn: (x: T, y: U) => TResult): (list1: ReadonlyArray, list2: ReadonlyArray) => TResult[]; } } From d20b5b2cad42617b2e7e1f543aca61062a9e4369 Mon Sep 17 00:00:00 2001 From: KonstantinKai Date: Fri, 15 Dec 2017 15:33:24 +0200 Subject: [PATCH 207/298] [expo] change history version to v23 --- types/expo/{v2 => v23}/expo-tests.tsx | 0 types/expo/{v2 => v23}/index.d.ts | 0 types/expo/{v2 => v23}/tsconfig.json | 4 ++-- types/expo/{v2 => v23}/tslint.json | 0 4 files changed, 2 insertions(+), 2 deletions(-) rename types/expo/{v2 => v23}/expo-tests.tsx (100%) rename types/expo/{v2 => v23}/index.d.ts (100%) rename types/expo/{v2 => v23}/tsconfig.json (91%) rename types/expo/{v2 => v23}/tslint.json (100%) diff --git a/types/expo/v2/expo-tests.tsx b/types/expo/v23/expo-tests.tsx similarity index 100% rename from types/expo/v2/expo-tests.tsx rename to types/expo/v23/expo-tests.tsx diff --git a/types/expo/v2/index.d.ts b/types/expo/v23/index.d.ts similarity index 100% rename from types/expo/v2/index.d.ts rename to types/expo/v23/index.d.ts diff --git a/types/expo/v2/tsconfig.json b/types/expo/v23/tsconfig.json similarity index 91% rename from types/expo/v2/tsconfig.json rename to types/expo/v23/tsconfig.json index 7b8759476b..4dbf5afca3 100644 --- a/types/expo/v2/tsconfig.json +++ b/types/expo/v23/tsconfig.json @@ -15,10 +15,10 @@ ], "paths": { "expo": [ - "expo/v2" + "expo/v23" ], "expo/*": [ - "expo/v2/*" + "expo/v23/*" ] }, "types": [], diff --git a/types/expo/v2/tslint.json b/types/expo/v23/tslint.json similarity index 100% rename from types/expo/v2/tslint.json rename to types/expo/v23/tslint.json From 5fc0ddf002c97511858aabf891db86b6a0be5a35 Mon Sep 17 00:00:00 2001 From: Andrei Volchenko Date: Fri, 15 Dec 2017 17:34:22 +0300 Subject: [PATCH 208/298] fix eslint rules --- types/styled-jsx/index.d.ts | 4 ++-- types/styled-jsx/tslint.json | 8 +------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/types/styled-jsx/index.d.ts b/types/styled-jsx/index.d.ts index 61c2cffa23..dc7a46d3d0 100644 --- a/types/styled-jsx/index.d.ts +++ b/types/styled-jsx/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for styled-jsx 2.2.1 +// Type definitions for styled-jsx 2.2 // Project: https://github.com/zeit/styled-jsx // Definitions by: R1ZZU // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,7 +7,7 @@ import "react"; declare module "react" { - interface StyleHTMLAttributes extends React.HTMLAttributes { + interface StyleHTMLAttributes extends HTMLAttributes { jsx?: boolean; global?: boolean; } diff --git a/types/styled-jsx/tslint.json b/types/styled-jsx/tslint.json index 1d415aae00..3db14f85ea 100644 --- a/types/styled-jsx/tslint.json +++ b/types/styled-jsx/tslint.json @@ -1,7 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "dt-header": false, - "no-unnecessary-qualifier": false - } -} +{ "extends": "dtslint/dt.json" } From 598c3f73dd58ad8922b81ab981fe3ebe39d01501 Mon Sep 17 00:00:00 2001 From: Rafal2228 Date: Fri, 15 Dec 2017 15:52:59 +0100 Subject: [PATCH 209/298] @types/node-forge: add namespace ssh --- types/node-forge/index.d.ts | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/types/node-forge/index.d.ts b/types/node-forge/index.d.ts index 2fac7c7e6e..e5f8ffcb77 100644 --- a/types/node-forge/index.d.ts +++ b/types/node-forge/index.d.ts @@ -95,10 +95,40 @@ declare module "node-forge" { } namespace ssh { + interface FingerprintOptions { + /** + * @description the delimiter to use between bytes for `hex` encoded output + */ + delimiter?: string; + /** + * @description if not specified, the function will return `ByteStringBuffer` + */ + encoding?: 'hex'|'binary'; + /** + * @description if not specified defaults to `md.md5` + */ + md?: md.MessageDigest; + } + /** - * Encodes a private RSA key as an OpenSSH file. + * @description Encodes a private RSA key as an OpenSSH file */ - function privateKeyToOpenSSH(privateKey?: string, passphrase?: string): string; + function privateKeyToOpenSSH(privateKey: pki.Key, passphrase?: string): string; + + /** + * @description Encodes (and optionally encrypts) a private RSA key as a Putty PPK file + */ + function privateKeyToPutty(privateKey: pki.Key, passphrase?: string, comment?: string): string; + + /** + * @description Encodes a public RSA key as an OpenSSH file + */ + function publicKeyToOpenSSH(publicKey: pki.Key, comment?: string): string|pki.PEM; + + /** + * @description Gets the SSH fingerprint for the given public key + */ + function getPublicKeyFingerprint(publicKey: pki.Key, options?: FingerprintOptions): util.ByteStringBuffer|Hex|string; } namespace asn1 { From 8748da2412bc8fa1dbdf5e8aa9454da515adf240 Mon Sep 17 00:00:00 2001 From: Rafal2228 Date: Fri, 15 Dec 2017 16:08:15 +0100 Subject: [PATCH 210/298] @types/node-forge: bump version in header --- types/node-forge/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/node-forge/index.d.ts b/types/node-forge/index.d.ts index e5f8ffcb77..ae9c5ab193 100644 --- a/types/node-forge/index.d.ts +++ b/types/node-forge/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for node-forge 0.6.43 +// Type definitions for node-forge 0.7.2 // Project: https://github.com/digitalbazaar/forge // Definitions by: Seth Westphal // Kay Schecker // Aakash Goenka +// Rafal2228 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "node-forge" { From 8026c1736f56cc4e792601ef758261214fc2f058 Mon Sep 17 00:00:00 2001 From: Michael Stuart Date: Fri, 15 Dec 2017 11:49:23 -0600 Subject: [PATCH 211/298] daterangepicker: callback arguments are always of type moment.Moment The start and end date can be assigned from moment.Moment, string, or Date, but the internal representation is always coerced into a moment.Moment. Thus, when the callback is called, the first two arguments are of type moment.Moment. Signed-off-by: Mario Morales --- types/daterangepicker/daterangepicker-tests.ts | 2 +- types/daterangepicker/index.d.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/types/daterangepicker/daterangepicker-tests.ts b/types/daterangepicker/daterangepicker-tests.ts index dc305bf1da..db79671721 100644 --- a/types/daterangepicker/daterangepicker-tests.ts +++ b/types/daterangepicker/daterangepicker-tests.ts @@ -34,7 +34,7 @@ function tests_simple() { $('#demo').daterangepicker({ "startDate": "05/06/2016", "endDate": "05/12/2016" - }, function (start: string, end: string, label: string) { + }, function (start: moment.Moment, end: moment.Moment, label: string) { console.log("New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')"); }); diff --git a/types/daterangepicker/index.d.ts b/types/daterangepicker/index.d.ts index 4fddcc4fbd..37911a8507 100644 --- a/types/daterangepicker/index.d.ts +++ b/types/daterangepicker/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for Date Range Picker v2.1.25 +// Type definitions for Date Range Picker v2.1.30 // Project: http://www.daterangepicker.com/ // Definitions by: SirMartin // Steven Masala +// Grant Hutchins // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -18,7 +19,7 @@ declare global { declare const daterangepicker: daterangepicker.DateRangePicker; declare namespace daterangepicker { - type DataRangePickerCallback = (start?: string | Date | moment.Moment, end?: string | Date | moment.Moment, label?: string) => any; + type DataRangePickerCallback = (start: moment.Moment, end: moment.Moment, label: string) => any; interface DateRangePicker { new (element: HTMLElement, settings?: daterangepicker.Settings, callback?: DataRangePickerCallback): DateRangePicker; @@ -26,7 +27,7 @@ declare namespace daterangepicker { startDate: moment.Moment; endDate: moment.Moment; container: JQuery; - + setStartDate(date: Date | moment.Moment | string): void; setEndDate(date: Date | moment.Moment | string): void; remove(): void; From bf639c0eb723e6657acaf92c77b0b890c371e2b3 Mon Sep 17 00:00:00 2001 From: Sean O'Brien Date: Fri, 15 Dec 2017 17:04:06 -0500 Subject: [PATCH 212/298] Added missing interrupt function signature to ProgressBar class. --- types/progress/index.d.ts | 9 ++++++--- types/progress/progress-tests.ts | 13 +++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/types/progress/index.d.ts b/types/progress/index.d.ts index 1989ebbed8..74596c4c13 100644 --- a/types/progress/index.d.ts +++ b/types/progress/index.d.ts @@ -120,14 +120,17 @@ declare class ProgressBar { * overall completion to. */ update(ratio: number, tokens?: any): void; - + + /** + * "interrupt" the progress bar and write a message above it. + */ + interrupt(message: string): void; /** * Terminates a progress bar. - */ + */ terminate(): void; - /** * Completed status of progress (Boolean) */ diff --git a/types/progress/progress-tests.ts b/types/progress/progress-tests.ts index 12774e7183..561f226b64 100644 --- a/types/progress/progress-tests.ts +++ b/types/progress/progress-tests.ts @@ -27,3 +27,16 @@ bar.tick(2, { 'token1': "Goodbye", 'token2': "World!" }); + +/** + * Interrupt example from https://github.com/visionmedia/node-progress + */ +var bar = new ProgressBar(':bar :current/:total', { total: 10 }); +var timer = setInterval(function () { + bar.tick(); + if (bar.complete) { + clearInterval(timer); + } else if (bar.curr === 5) { + bar.interrupt('this message appears above the progress bar\ncurrent progress is ' + bar.curr + '/' + bar.total); + } +}, 1000); \ No newline at end of file From 27a650b7cffe3ce17e073e28e27319f427c37418 Mon Sep 17 00:00:00 2001 From: Mario Morales Date: Fri, 15 Dec 2017 16:11:07 -0600 Subject: [PATCH 213/298] daterangepicker: label argument in callback can be null Signed-off-by: Grant Hutchins --- types/daterangepicker/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/daterangepicker/index.d.ts b/types/daterangepicker/index.d.ts index 37911a8507..4d777b17b6 100644 --- a/types/daterangepicker/index.d.ts +++ b/types/daterangepicker/index.d.ts @@ -19,7 +19,7 @@ declare global { declare const daterangepicker: daterangepicker.DateRangePicker; declare namespace daterangepicker { - type DataRangePickerCallback = (start: moment.Moment, end: moment.Moment, label: string) => any; + type DataRangePickerCallback = (start: moment.Moment, end: moment.Moment, label: string | null) => any; interface DateRangePicker { new (element: HTMLElement, settings?: daterangepicker.Settings, callback?: DataRangePickerCallback): DateRangePicker; From a5a92fdd74dbbf76bc3a9d7535a41ee8790a2902 Mon Sep 17 00:00:00 2001 From: Rafal2228 Date: Sat, 16 Dec 2017 12:31:58 +0100 Subject: [PATCH 214/298] added spaces around union operators --- types/node-forge/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/node-forge/index.d.ts b/types/node-forge/index.d.ts index ae9c5ab193..5d8b7d0bfd 100644 --- a/types/node-forge/index.d.ts +++ b/types/node-forge/index.d.ts @@ -104,7 +104,7 @@ declare module "node-forge" { /** * @description if not specified, the function will return `ByteStringBuffer` */ - encoding?: 'hex'|'binary'; + encoding?: 'hex' | 'binary'; /** * @description if not specified defaults to `md.md5` */ @@ -124,12 +124,12 @@ declare module "node-forge" { /** * @description Encodes a public RSA key as an OpenSSH file */ - function publicKeyToOpenSSH(publicKey: pki.Key, comment?: string): string|pki.PEM; + function publicKeyToOpenSSH(publicKey: pki.Key, comment?: string): string | pki.PEM; /** * @description Gets the SSH fingerprint for the given public key */ - function getPublicKeyFingerprint(publicKey: pki.Key, options?: FingerprintOptions): util.ByteStringBuffer|Hex|string; + function getPublicKeyFingerprint(publicKey: pki.Key, options?: FingerprintOptions): util.ByteStringBuffer | Hex | string; } namespace asn1 { From 55ac64e75fa6708facdbf3a3c3d11fffa2f3c2b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Sat, 16 Dec 2017 23:00:23 +0800 Subject: [PATCH 215/298] fix --- types/materialize-css/index.d.ts | 10 +++++----- .../test/materialize-css-jquery.test.ts | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/types/materialize-css/index.d.ts b/types/materialize-css/index.d.ts index f1540ff597..a4056b75d2 100644 --- a/types/materialize-css/index.d.ts +++ b/types/materialize-css/index.d.ts @@ -193,7 +193,7 @@ declare global { * Render days of the calendar grid that fall in the next or previous month. * @default false */ - showDaysInNextAndPreviousMonths: false; + showDaysInNextAndPreviousMonths: boolean; /** * Specify a selector for a DOM element to render the calendar in, by default it will be placed before the input. @@ -673,10 +673,10 @@ declare global { autocomplete(method: keyof Pick, data: M.AutocompleteData): JQuery; autocomplete(options?: Partial): JQuery; - datePicker(method: keyof Pick): JQuery; - datePicker(method: keyof Pick, date?: Date): JQuery; - datePicker(method: keyof Pick, date: Date): JQuery; - datePicker(options?: Partial): JQuery; + datepicker(method: keyof Pick): JQuery; + datepicker(method: keyof Pick, date?: Date): JQuery; + datepicker(method: keyof Pick, date: Date): JQuery; + datepicker(options?: Partial): JQuery; floatingActionButton(method: keyof Pick): JQuery; floatingActionButton(options?: Partial): JQuery; diff --git a/types/materialize-css/test/materialize-css-jquery.test.ts b/types/materialize-css/test/materialize-css-jquery.test.ts index 0a70184881..c463044df2 100644 --- a/types/materialize-css/test/materialize-css-jquery.test.ts +++ b/types/materialize-css/test/materialize-css-jquery.test.ts @@ -36,9 +36,9 @@ $(".whatever").floatingActionButton("destroy"); // Toast can not be invoked using jQuery. -$(".whatever").datePicker(); -$(".whatever").datePicker({ defaultDate: new Date() }); -$(".whatever").datePicker("open"); -$(".whatever").datePicker("destroy"); -$(".whatever").datePicker("setDate", new Date()); -$(".whatever").datePicker("gotoDate", new Date()); +$(".whatever").datepicker(); +$(".whatever").datepicker({ defaultDate: new Date() }); +$(".whatever").datepicker("open"); +$(".whatever").datepicker("destroy"); +$(".whatever").datepicker("setDate", new Date()); +$(".whatever").datepicker("gotoDate", new Date()); From 3f31864292901eed0d7c546cad5dda9a99e40494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Sun, 17 Dec 2017 00:43:28 +0800 Subject: [PATCH 216/298] Add TimePicker --- types/materialize-css/index.d.ts | 98 +++++++++++++++++++ .../test/materialize-css-global.test.ts | 4 + .../test/materialize-css-jquery.test.ts | 6 ++ .../test/materialize-css-module.test.ts | 20 ++++ 4 files changed, 128 insertions(+) diff --git a/types/materialize-css/index.d.ts b/types/materialize-css/index.d.ts index a4056b75d2..9c9dbf4b70 100644 --- a/types/materialize-css/index.d.ts +++ b/types/materialize-css/index.d.ts @@ -396,6 +396,100 @@ declare global { responsiveThreshold: number; } + class TimePicker extends Component { + /** + * Get Instance + */ + static getInstance(elem: Element): TimePicker; + + /** + * If the picker is open. + */ + isOpen: boolean; + + /** + * The selected time. + */ + time: string; + + /** + * Open timepicker + */ + open(): void; + + /** + * Close timepicker + */ + close(): void; + + /** + * Show hours or minutes view on timepicker + * @param view The name of the view you want to switch to, 'hours' or 'minutes'. + */ + showView(view: "hours" | "minutes"): void; + } + + interface TimePickerOptions { + /** + * Duration of the transition from/to the hours/minutes view. + * @default 350 + */ + duration: number; + + /** + * Specify a selector for a DOM element to render the calendar in, by default it will be placed before the input. + */ + container: string; + + /** + * Default time to set on the timepicker 'now' or '13:14' + * @default 'now'; + */ + defaultTime: string; + + /** + * Millisecond offset from the defaultTime. + * @default 0 + */ + fromnow: number; + + /** + * Done button text. + * @default 'Ok' + */ + doneText: string; + + /** + * Clear button text. + * @default 'Clear' + */ + clearText: string; + + /** + * Cancel button text. + * @default 'Cancel' + */ + cancelText: string; + + /** + * Automatically close picker when minute is selected. + * @default false; + */ + autoClose: boolean; + + /** + * Use 12 hour AM/PM clock instead of 24 hour clock. + * @default true + */ + twelveHour: boolean; + + /** + * Vibrate device when dragging clock hand. + * @default true + */ + vibrate: boolean; + } + class Modal extends Component implements Openable { /** * Get Instance @@ -688,6 +782,10 @@ declare global { tabs(method: keyof Pick, tabId: string): JQuery; tabs(options?: Partial): JQuery; + timepicker(method: keyof Pick): JQuery; + timepicker(method: keyof Pick, view: "hours" | "minutes"): JQuery; + timepicker(options?: Partial): JQuery; + // Toast can not be invoked using jQuery. tooltip(method: keyof Pick): JQuery; diff --git a/types/materialize-css/test/materialize-css-global.test.ts b/types/materialize-css/test/materialize-css-global.test.ts index 7301d98f58..538941dff5 100644 --- a/types/materialize-css/test/materialize-css-global.test.ts +++ b/types/materialize-css/test/materialize-css-global.test.ts @@ -23,4 +23,8 @@ const fab = new M.FloatingActionButton(elem); // $ExpectType Toast const toast = M.toast({ html: 'I am a toast!' }); +// $ExpectType DatePicker const datePicker = new M.DatePicker(elem); + +// $ExpectType TimePicker +const timePicker = new M.TimePicker(elem); diff --git a/types/materialize-css/test/materialize-css-jquery.test.ts b/types/materialize-css/test/materialize-css-jquery.test.ts index c463044df2..4142ab7294 100644 --- a/types/materialize-css/test/materialize-css-jquery.test.ts +++ b/types/materialize-css/test/materialize-css-jquery.test.ts @@ -42,3 +42,9 @@ $(".whatever").datepicker("open"); $(".whatever").datepicker("destroy"); $(".whatever").datepicker("setDate", new Date()); $(".whatever").datepicker("gotoDate", new Date()); + +$(".whatever").timepicker(); +$(".whatever").timepicker({ defaultTime: "13:14" }); +$(".whatever").timepicker("open"); +$(".whatever").timepicker("destroy"); +$(".whatever").timepicker("showView", "hours"); diff --git a/types/materialize-css/test/materialize-css-module.test.ts b/types/materialize-css/test/materialize-css-module.test.ts index bfe2952e3f..2395b01e61 100644 --- a/types/materialize-css/test/materialize-css-module.test.ts +++ b/types/materialize-css/test/materialize-css-module.test.ts @@ -196,3 +196,23 @@ datePicker.options; datePicker.el; // $ExpectType boolean datePicker.isOpen; + +// TimePicker +// $ExpectType TimePicker +new materialize.TimePicker(elem); +// $ExpectType TimePicker +const timePicker = new materialize.TimePicker(elem, { + defaultTime: "13:14" +}); +// $ExpectType void +timePicker.open(); +// $ExpectType void +timePicker.showView("hours"); +// $ExpectType void +timePicker.destroy(); +// $ExpectType TimePickerOptions +timePicker.options; +// $ExpectType Element +timePicker.el; +// $ExpectType boolean +timePicker.isOpen; From 1a60d6ebf480a8af908f4e28327ad50cc1a73d8f Mon Sep 17 00:00:00 2001 From: Hinell Date: Fri, 15 Dec 2017 01:57:41 +0300 Subject: [PATCH 217/298] [mongodb] Adds ReplaceWriteOpResult --- types/mongodb/index.d.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/types/mongodb/index.d.ts b/types/mongodb/index.d.ts index 0c7b90edfd..6cf21c04b9 100644 --- a/types/mongodb/index.d.ts +++ b/types/mongodb/index.d.ts @@ -607,9 +607,9 @@ export interface Collection { rename(newName: string, options?: { dropTarget?: boolean }): Promise>; rename(newName: string, options: { dropTarget?: boolean }, callback: MongoCallback>): void; //http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#replaceOne - replaceOne(filter: Object, doc: Object, callback: MongoCallback }>): void; - replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise }>; - replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback }>): void; + replaceOne(filter: Object, doc: Object, callback: MongoCallback): void; + replaceOne(filter: Object, doc: Object, options?: ReplaceOneOptions): Promise; + replaceOne(filter: Object, doc: Object, options: ReplaceOneOptions, callback: MongoCallback): void; //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#save /** @deprecated Use insertOne, insertMany, updateOne or updateMany */ save(doc: Object, callback: MongoCallback): void; @@ -1134,6 +1134,11 @@ export interface UpdateWriteOpResult { upsertedId: { _id: ObjectID }; } +// https://github.com/mongodb/node-mongodb-native/blob/2.2/lib/collection.js#L957 +export interface ReplaceWriteOpResult extends UpdateWriteOpResult { + ops: Array +} + //http://mongodb.github.io/node-mongodb-native/2.1/api/Collection.html#mapReduce export interface MapReduceOptions { readPreference?: ReadPreference | string; From 87fe42183ea9b6c9fee5e702de0671981c5fc0ee Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sun, 17 Dec 2017 01:28:55 +0300 Subject: [PATCH 218/298] [atom] setTextInBufferRange returns Range, not void --- types/atom/atom-tests.ts | 16 ++++++++-------- types/atom/index.d.ts | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/types/atom/atom-tests.ts b/types/atom/atom-tests.ts index 6ea7b9ae1f..4bfcfe11cb 100644 --- a/types/atom/atom-tests.ts +++ b/types/atom/atom-tests.ts @@ -2352,14 +2352,14 @@ function testTextEditor() { // Mutating Text editor.setText("Test"); - editor.setTextInBufferRange(range, "Test"); - editor.setTextInBufferRange([pos, pos], "Test"); - editor.setTextInBufferRange([pos, [0, 0]], "Test"); - editor.setTextInBufferRange([[0, 0], pos], "Test"); - editor.setTextInBufferRange([[0, 0], [0, 0]], "Test"); - editor.setTextInBufferRange(range, "Test", {}); - editor.setTextInBufferRange([pos, pos], "Test", { normalizeLineEndings: true }); - editor.setTextInBufferRange(range, "Test", { normalizeLineEndings: true, + range = editor.setTextInBufferRange(range, "Test"); + range = editor.setTextInBufferRange([pos, pos], "Test"); + range = editor.setTextInBufferRange([pos, [0, 0]], "Test"); + range = editor.setTextInBufferRange([[0, 0], pos], "Test"); + range = editor.setTextInBufferRange([[0, 0], [0, 0]], "Test"); + range = editor.setTextInBufferRange(range, "Test", {}); + range = editor.setTextInBufferRange([pos, pos], "Test", { normalizeLineEndings: true }); + range = editor.setTextInBufferRange(range, "Test", { normalizeLineEndings: true, undo: "skip" }); editor.insertText("Test"); diff --git a/types/atom/index.d.ts b/types/atom/index.d.ts index 4adac61dc1..a7398cba18 100644 --- a/types/atom/index.d.ts +++ b/types/atom/index.d.ts @@ -1456,7 +1456,7 @@ export class TextEditor { /** Set the text in the given Range in buffer coordinates. */ setTextInBufferRange(range: RangeCompatible, text: string, options?: - { normalizeLineEndings?: boolean, undo?: "skip" }): void; + { normalizeLineEndings?: boolean, undo?: "skip" }): Range; /* For each selection, replace the selected text with the given text. */ insertText(text: string, options?: { From 0c842ceefe58b3913937d5a3e7637faf9c49bb7d Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sun, 17 Dec 2017 02:14:50 +0300 Subject: [PATCH 219/298] [atom] Add some missing definitions mentioned in #22211 --- types/atom/atom-tests.ts | 18 ++++++++++++++++++ types/atom/index.d.ts | 17 ++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/types/atom/atom-tests.ts b/types/atom/atom-tests.ts index 4bfcfe11cb..28b93c73a8 100644 --- a/types/atom/atom-tests.ts +++ b/types/atom/atom-tests.ts @@ -196,6 +196,8 @@ function testAtomEnvironment() { } atom.executeJavaScriptInDevTools("Test"); + + const path: string = atom.getConfigDirPath(); } // BufferedNodeProcess ======================================================== @@ -1056,6 +1058,10 @@ function testGrammar() { tokenizeLineResult.tokens; grammar.tokenizeLine("Test String", tokenizeLineResult.ruleStack); grammar.tokenizeLine("Test String", tokenizeLineResult.ruleStack, false); + + let str: string; + str = grammar.name; + str = grammar.scopeName; } // GrammarRegistry ============================================================ @@ -1396,6 +1402,9 @@ function testPackageManager() { subscription = atom.packages.onDidDeactivatePackage(pack => pack.path); subscription = atom.packages.onDidLoadPackage(pack => pack.isCompatible()); subscription = atom.packages.onDidUnloadPackage(pack => pack.name); + subscription = atom.packages.onDidTriggerActivationHook( + 'language-javascript:grammar-used', () => {} + ); // Package system data str = atom.packages.getApmPath(); @@ -2922,6 +2931,15 @@ function testTextEditor() { // TextEditor Rendering str = editor.getPlaceholderText(); editor.setPlaceholderText("Test"); + + range = editor.bufferRangeForScopeAtPosition('source.js', [0, 0]); + range = editor.bufferRangeForScopeAtPosition('source.js', {row: 10, column: 11}); + range = editor.bufferRangeForScopeAtPosition('source.js', pos); + + let token: {value: string, scopes: string[]}; + token = editor.tokenForBufferPosition([5, 6]); + token = editor.tokenForBufferPosition({row: 0, column: 1}); + token = editor.tokenForBufferPosition(pos); } // ThemeManager =============================================================== diff --git a/types/atom/index.d.ts b/types/atom/index.d.ts index a7398cba18..24b24c9423 100644 --- a/types/atom/index.d.ts +++ b/types/atom/index.d.ts @@ -238,6 +238,9 @@ export interface AtomEnvironment { /** Execute code in dev tools. */ executeJavaScriptInDevTools(code: string): void; + + /** Undocumented: get Atom config directory path */ + getConfigDirPath(): string; } /** @@ -2379,6 +2382,12 @@ export class TextEditor { * displayed when the editor has no content. */ setPlaceholderText(placeholderText: string): void; + + /** Undocumented: Buffer range for syntax scope at position */ + bufferRangeForScopeAtPosition(scope: string, point: PointCompatible): Range; + + /** Undocumented: Get syntax token at buffer position */ + tokenForBufferPosition(pos: PointCompatible): {value: string, scopes: string[]}; } /** Experimental: This global registry tracks registered TextEditors. */ @@ -3610,7 +3619,10 @@ export class GitRepository { /** Grammar that tokenizes lines of text. */ export interface Grammar { /** The name of the Grammar. */ - name: string; + readonly name: string; + + /** Undocumented: scope name of the Grammar. */ + readonly scopeName: string; // Event Subscription onDidUpdate(callback: () => void): Disposable; @@ -3938,6 +3950,9 @@ export interface PackageManager { /** Invoke the given callback when a package is unloaded. */ onDidUnloadPackage(callback: (package: Package) => void): Disposable; + /** Undocumented: invoke the given callback when an activation hook is triggered */ + onDidTriggerActivationHook(hook: string, callback: () => void): Disposable; + // Package System Data /** Get the path to the apm command. */ getApmPath(): string; From 244e1eea176909bef591f78f0d2bb70434ec3794 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 16 Dec 2017 22:28:07 -0300 Subject: [PATCH 220/298] Add more specific types in ReturnValueTypes used in Lifecycle.Method(). --- types/hapi/definitions/util/lifecycle.d.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/types/hapi/definitions/util/lifecycle.d.ts b/types/hapi/definitions/util/lifecycle.d.ts index 87dcf8ff1a..35f347dcd5 100644 --- a/types/hapi/definitions/util/lifecycle.d.ts +++ b/types/hapi/definitions/util/lifecycle.d.ts @@ -21,18 +21,26 @@ export namespace Lifecycle { /** * Each lifecycle method must return a value or a promise that resolves into a value. If a lifecycle method returns * without a value or resolves to an undefined value, an Internal Server Error (500) error response is sent. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) + * The return value must be one of: + * * Plain value: null, string, number, boolean + * * Buffer object + * * Error object: plain Error OR a Boom object. + * * Stream object + * * any object or array + * * a toolkit signal: + * * a toolkit method response: + * * a promise object that resolve to any of the above values + * For more info please [See docs](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) */ export type ReturnValue = ReturnValueTypes | (Promise); export type ReturnValueTypes = - (null | undefined | string | number | boolean) | + (null | string | number | boolean) | (Buffer) | (Error | Boom.BoomError) | (stream.Stream) | - (Object | Object[]) | - // a toolkit signal: - // a toolkit method response: - any; // TODO need review + (object | object[]) | + Object | + ResponseToolkit; /** * Various configuration options allows defining how errors are handled. For example, when invalid payload is received or malformed cookie, instead of returning an error, the framework can be configured to perform another action. When supported the failAction option supports the following values: From b923c71fdc270a721d0976abd60407dc66d082de Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 16 Dec 2017 22:30:30 -0300 Subject: [PATCH 221/298] Replace "interface ServerMethod" with "type ServerMethod". Suggestion of @SimonSchick --- types/hapi/definitions/server/server-method.d.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/types/hapi/definitions/server/server-method.d.ts b/types/hapi/definitions/server/server-method.d.ts index c7d6e01446..af6f5b79ff 100644 --- a/types/hapi/definitions/server/server-method.d.ts +++ b/types/hapi/definitions/server/server-method.d.ts @@ -7,10 +7,7 @@ import * as catbox from "catbox"; * * * ttl - 0 if result is valid but cannot be cached. Defaults to cache policy. * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) */ -export interface ServerMethod { -// (args: any[], flags: {ttl?: number}): any; - (...args: any[]): any; // TODO it needs review. Look the doc: the first param is a ...args and the second is "flags". Typescript supports ...args only in the last param -} +export type ServerMethod = (...args: any[]) => any; /** * The same cache configuration used in server.cache(). From 3fe936dacecf42aadaed96171e2ed4e60e390afd Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sat, 16 Dec 2017 22:32:23 -0300 Subject: [PATCH 222/298] Remove old, and not more useful, comments in test files. --- types/hapi/test/server/server-cache-provision.ts | 2 -- types/hapi/test/server/server-inject.ts | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/types/hapi/test/server/server-cache-provision.ts b/types/hapi/test/server/server-cache-provision.ts index ce733403f3..19938b4212 100644 --- a/types/hapi/test/server/server-cache-provision.ts +++ b/types/hapi/test/server/server-cache-provision.ts @@ -12,8 +12,6 @@ const cache:catbox.Policy = server.cache({segment: 'countries', cache: 'countrie cache.set('norway', 'oslo', 10 * 1000, null); const value = cache.get('norway', null); -// TODO Not working. It needs review. - server.start(); server.events.on('start', () => { diff --git a/types/hapi/test/server/server-inject.ts b/types/hapi/test/server/server-inject.ts index 4d50f766e0..1f55f803b9 100644 --- a/types/hapi/test/server/server-inject.ts +++ b/types/hapi/test/server/server-inject.ts @@ -16,5 +16,5 @@ server.route(serverRoute); server.start(); const res = server.inject('/'); -console.log(res.result); // 'Success!' // TODO It's not working +console.log(res.result); From 9a0ce85aa95321404f0c39793564b685ac2410e9 Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sat, 16 Dec 2017 13:23:54 +0300 Subject: [PATCH 223/298] [atom] Added TextEditorElement and TextEditorComponent --- types/atom/atom-tests.ts | 45 +++++++++++++++++++ types/atom/index.d.ts | 95 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 132 insertions(+), 8 deletions(-) diff --git a/types/atom/atom-tests.ts b/types/atom/atom-tests.ts index 6ea7b9ae1f..e43b592272 100644 --- a/types/atom/atom-tests.ts +++ b/types/atom/atom-tests.ts @@ -13,6 +13,8 @@ declare let element: HTMLElement; declare let elements: HTMLElement[]; declare const div: HTMLDivElement; declare const event: KeyboardEvent; +declare const mouseEvent: MouseEvent; +declare let pixelPos: {left: number, top: number}; declare let buffer: Atom.TextBuffer; declare const color: Atom.Color; @@ -65,6 +67,8 @@ declare let subscription: Atom.Disposable; declare let subscriptions: Atom.CompositeDisposable; declare let tooltips: Atom.Tooltip[]; declare let workspaceCenter: Atom.WorkspaceCenter; +declare let textEditorElement: Atom.TextEditorElement; +declare let textEditorComponent: Atom.TextEditorComponent; // AtomEnvironment ============================================================ function testAtomEnvironment() { @@ -267,6 +271,10 @@ function testCommandRegistry() { description: "A Command Test", displayName: "Command: Test", }); + atom.commands.add("atom-text-editor", { + "test-function": (event) => event.currentTarget.getModel(), + "test-function2": (event) => event.currentTarget.getComponent(), + }); const commands = atom.commands.findCommands({ target: element }); atom.commands.dispatch(element, "test:function"); @@ -2981,6 +2989,7 @@ function testViewRegistry() { }); element = atom.views.getView(element); + textEditorElement = atom.views.getView(editor); } // Workspace ================================================================== @@ -3220,3 +3229,39 @@ const pathWatcher = Atom.watchPath("/var/test", {}, (events) => { if (event.oldPath) str = event.oldPath; } }); + +// TextEditorElement ========================================================== +function testTextEditorElement() { + textEditorComponent = textEditorElement.getComponent(); + editor = textEditorElement.getModel(); + + textEditorElement.getNextUpdatePromise().then(() => {}); + let num: number = textEditorElement.getBaseCharacterWidth(); + + textEditorElement.scrollToTop(); + textEditorElement.scrollToBottom(); + textEditorElement.setScrollTop(num); + num = textEditorElement.getScrollTop(); + textEditorElement.setScrollLeft(num); + num = textEditorElement.getScrollLeft(); + num = textEditorElement.getScrollHeight(); + + pixelPos = textEditorElement.pixelPositionForBufferPosition(pos); + pixelPos = textEditorElement.pixelPositionForScreenPosition({row: 1, column: 2}); + pixelPos = textEditorElement.pixelPositionForScreenPosition(pos); + + subscription = textEditorElement.onDidChangeScrollTop((scrollTop: number) => {}); + subscription = textEditorElement.onDidChangeScrollLeft((scrollLeft: number) => {}); + subscription = textEditorElement.onDidAttach(() => {}); + subscription = textEditorElement.onDidDetach(() => {}); + + textEditorElement = document.createElement('atom-text-editor'); +} + +// TextEditorComponent ======================================================== +function testTextEditorComponent() { + pixelPos = textEditorComponent.pixelPositionForMouseEvent(mouseEvent); + pixelPos = textEditorComponent.pixelPositionForScreenPosition(pos); + pos = textEditorComponent.screenPositionForMouseEvent(mouseEvent); + pos = textEditorComponent.screenPositionForPixelPosition(pixelPos); +} diff --git a/types/atom/index.d.ts b/types/atom/index.d.ts index 4adac61dc1..cf997bf5a6 100644 --- a/types/atom/index.d.ts +++ b/types/atom/index.d.ts @@ -16,6 +16,10 @@ import { ChildProcess } from "child_process"; declare global { const atom: AtomEnvironment; + + interface HTMLElementTagNameMap { + "atom-text-editor": TextEditorElement; + } } /** @@ -252,21 +256,37 @@ export interface Color { toRGBAString(): string; } +export interface CommandRegistryTargetMap extends HTMLElementTagNameMap { + [key: string]: EventTarget; +} + +export type CommandRegistryListener = { + didDispatch(event: CommandEvent): void, + displayName?: string, + description?: string, +} | ((event: CommandEvent) => void); + /** * Associates listener functions with commands in a context-sensitive way * using CSS selectors. */ export interface CommandRegistry { /** Register a single command. */ - add(target: string|Node, commandName: string, listener: { - didDispatch(event: CommandEvent): void, - displayName?: string, - description?: string, - } | ((event: CommandEvent) => void)): Disposable; + add( + target: T, commandName: string, + listener: CommandRegistryListener + ): Disposable; + add( + target: T, commandName: string, + listener: CommandRegistryListener + ): Disposable; /** Register multiple commands. */ - add(target: string|Node, commands: { - [key: string]: (event: CommandEvent) => void + add(target: T, commands: { + [key: string]: (event: CommandEvent) => void + }): CompositeDisposable; + add(target: T, commands: { + [key: string]: (event: CommandEvent) => void }): CompositeDisposable; /** Find all registered commands matching a query. */ @@ -2381,6 +2401,63 @@ export class TextEditor { setPlaceholderText(placeholderText: string): void; } +/** + * Undocumented: Rendering component for TextEditor + */ +export interface TextEditorComponent { + /** Does not clip screenPosition, unlike similar method on TextEditorElement */ + pixelPositionForScreenPosition(screenPosition: PointLike): {left: number, top: number}; + screenPositionForPixelPosition(pos: {top: number, left: number}): Point; + pixelPositionForMouseEvent(event: { + clientX: number, clientY: number + }): {top: number, left: number}; + screenPositionForMouseEvent(event: {clientX: number, clientY: number}): Point; +} + +/** + * Undocumented: Custom HTML elemnent for TextEditor, atom-text-editor + */ +export interface TextEditorElement extends HTMLElement { + getModel(): TextEditor; + getComponent(): TextEditorComponent; + /** + * Extended: Get a promise that resolves the next time the element's + * DOM is updated in any way. + */ + getNextUpdatePromise(): Promise; + + /** Extended: get the width of an `x` character displayed in this element. */ + getBaseCharacterWidth(): number; + + /** Essential: Scrolls the editor to the top. */ + scrollToTop(): void; + + /** Essential: Scrolls the editor to the bottom. */ + scrollToBottom(): void; + + setScrollTop(scrollTop: number): void; + getScrollTop(): number; + + setScrollLeft(scrollLeft: number): void; + getScrollLeft(): number; + + getScrollHeight(): number; + + /** Extended: Converts a buffer position to a pixel position. */ + pixelPositionForBufferPosition(bufferPosition: PointLike): {left: number, top: number}; + + /** Extended: Converts a screen position to a pixel position. */ + pixelPositionForScreenPosition(screenPosition: PointLike): {left: number, top: number}; + + // Event subscription + onDidChangeScrollTop(callback: (scrollTop: number) => void): Disposable; + onDidChangeScrollLeft(callback: (scrollLeft: number) => void): Disposable; + /** Called when the editor is attached to the DOM. */ + onDidAttach(callback: () => void): Disposable; + /** Called when the editor is detached from the DOM. */ + onDidDetach(callback: () => void): Disposable; +} + /** Experimental: This global registry tracks registered TextEditors. */ export interface TextEditorRegistry { // Managing Text Editors @@ -2469,6 +2546,7 @@ export interface ViewRegistry { (instance: T) => HTMLElement|undefined): Disposable; /** Get the view associated with an object in the workspace. */ + getView(obj: TextEditor): TextEditorElement; getView(obj: object): HTMLElement; } @@ -5268,13 +5346,14 @@ export interface BufferStoppedChangingEvent { * intent to stop propagation so event bubbling can be properly simulated for * detached elements. */ -export interface CommandEvent extends CustomEvent { +export interface CommandEvent extends CustomEvent { keyBindingAborted: boolean; propagationStopped: boolean; abortKeyBinding(): void; stopPropagation(): CustomEvent; stopImmediatePropagation(): CustomEvent; + currentTarget: CurrentTarget; } export interface CursorPositionChangedEvent { From b011a00271115c274065b16390de15ca23e85f20 Mon Sep 17 00:00:00 2001 From: Carsten Klein Date: Sat, 9 Dec 2017 20:40:37 +0100 Subject: [PATCH 224/298] add typings for stevelacy/gulp-bump --- types/gulp-bump/gulp-bump-tests.ts | 22 ++++++++++++++++++++++ types/gulp-bump/index.d.ts | 15 +++++++++++++++ types/gulp-bump/tsconfig.json | 24 ++++++++++++++++++++++++ types/gulp-bump/tslint.json | 3 +++ 4 files changed, 64 insertions(+) create mode 100644 types/gulp-bump/gulp-bump-tests.ts create mode 100644 types/gulp-bump/index.d.ts create mode 100644 types/gulp-bump/tsconfig.json create mode 100644 types/gulp-bump/tslint.json diff --git a/types/gulp-bump/gulp-bump-tests.ts b/types/gulp-bump/gulp-bump-tests.ts new file mode 100644 index 0000000000..b15e800a5e --- /dev/null +++ b/types/gulp-bump/gulp-bump-tests.ts @@ -0,0 +1,22 @@ +import * as gulp from 'gulp'; +import * as GulpBump from 'gulp-bump'; + +gulp + .src('package.json') + .pipe(GulpBump()) + .pipe(gulp.dest('./')); + +gulp + .src('package.json') + .pipe(GulpBump({regex: /^.+$/})) + .pipe(gulp.dest('./')); + +gulp + .src('package.json') + .pipe(GulpBump({version: '1.0.0', global: true})) + .pipe(gulp.dest('./')); + +gulp + .src('package.json') + .pipe(GulpBump({version: '1.0.0', case: true})) + .pipe(gulp.dest('./')); diff --git a/types/gulp-bump/index.d.ts b/types/gulp-bump/index.d.ts new file mode 100644 index 0000000000..4657dc06b2 --- /dev/null +++ b/types/gulp-bump/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for gulp-bump 2.8 +// Project: https://github.com/stevelacy/gulp-bump +// Definitions by: silkentrance +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import * as BumpRegex from 'bump-regex'; + +declare function GulpBump(options?: BumpRegex.Options): NodeJS.ReadWriteStream; + +declare namespace GulpBump { +} + +export = GulpBump; diff --git a/types/gulp-bump/tsconfig.json b/types/gulp-bump/tsconfig.json new file mode 100644 index 0000000000..003c952709 --- /dev/null +++ b/types/gulp-bump/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "jsx": "react", + "types": [], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true + }, + "files": [ + "index.d.ts", + "gulp-bump-tests.ts" + ] +} diff --git a/types/gulp-bump/tslint.json b/types/gulp-bump/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/gulp-bump/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From 3d0964bd85bc23eafd43f95af29be6f3518149fe Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sun, 17 Dec 2017 18:48:21 +0300 Subject: [PATCH 225/298] [atom] Use interface for pixel position type --- types/atom/atom-tests.ts | 2 +- types/atom/index.d.ts | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/types/atom/atom-tests.ts b/types/atom/atom-tests.ts index e43b592272..6001f621f7 100644 --- a/types/atom/atom-tests.ts +++ b/types/atom/atom-tests.ts @@ -14,7 +14,6 @@ declare let elements: HTMLElement[]; declare const div: HTMLDivElement; declare const event: KeyboardEvent; declare const mouseEvent: MouseEvent; -declare let pixelPos: {left: number, top: number}; declare let buffer: Atom.TextBuffer; declare const color: Atom.Color; @@ -67,6 +66,7 @@ declare let subscription: Atom.Disposable; declare let subscriptions: Atom.CompositeDisposable; declare let tooltips: Atom.Tooltip[]; declare let workspaceCenter: Atom.WorkspaceCenter; +declare let pixelPos: Atom.PixelPosition; declare let textEditorElement: Atom.TextEditorElement; declare let textEditorComponent: Atom.TextEditorComponent; diff --git a/types/atom/index.d.ts b/types/atom/index.d.ts index cf997bf5a6..6bf1bc6fd0 100644 --- a/types/atom/index.d.ts +++ b/types/atom/index.d.ts @@ -2401,16 +2401,21 @@ export class TextEditor { setPlaceholderText(placeholderText: string): void; } +export interface PixelPosition { + left: number; + top: number; +} + /** * Undocumented: Rendering component for TextEditor */ export interface TextEditorComponent { /** Does not clip screenPosition, unlike similar method on TextEditorElement */ - pixelPositionForScreenPosition(screenPosition: PointLike): {left: number, top: number}; - screenPositionForPixelPosition(pos: {top: number, left: number}): Point; + pixelPositionForScreenPosition(screenPosition: PointLike): PixelPosition; + screenPositionForPixelPosition(pos: PixelPosition): Point; pixelPositionForMouseEvent(event: { clientX: number, clientY: number - }): {top: number, left: number}; + }): PixelPosition; screenPositionForMouseEvent(event: {clientX: number, clientY: number}): Point; } @@ -2444,10 +2449,10 @@ export interface TextEditorElement extends HTMLElement { getScrollHeight(): number; /** Extended: Converts a buffer position to a pixel position. */ - pixelPositionForBufferPosition(bufferPosition: PointLike): {left: number, top: number}; + pixelPositionForBufferPosition(bufferPosition: PointLike): PixelPosition; /** Extended: Converts a screen position to a pixel position. */ - pixelPositionForScreenPosition(screenPosition: PointLike): {left: number, top: number}; + pixelPositionForScreenPosition(screenPosition: PointLike): PixelPosition; // Event subscription onDidChangeScrollTop(callback: (scrollTop: number) => void): Disposable; From 352277ab37f8a8e7e383b55695aa7f778063a686 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Sun, 17 Dec 2017 17:15:41 +0100 Subject: [PATCH 226/298] update micromatch and add braces --- types/braces/braces-tests.ts | 10 + types/braces/index.d.ts | 107 +++++ types/braces/tsconfig.json | 23 + types/braces/tslint.json | 6 + types/micromatch/index.d.ts | 668 ++++++++++++++++++++++----- types/micromatch/micromatch-tests.ts | 92 ++-- types/micromatch/tsconfig.json | 2 +- types/micromatch/tslint.json | 77 +-- 8 files changed, 759 insertions(+), 226 deletions(-) create mode 100644 types/braces/braces-tests.ts create mode 100644 types/braces/index.d.ts create mode 100644 types/braces/tsconfig.json create mode 100644 types/braces/tslint.json diff --git a/types/braces/braces-tests.ts b/types/braces/braces-tests.ts new file mode 100644 index 0000000000..f6a7ccd0ed --- /dev/null +++ b/types/braces/braces-tests.ts @@ -0,0 +1,10 @@ +import braces = require("braces"); + +const bracesOpts: braces.Options = { + expand: true, +}; + +let strArrResult: string[]; + +strArrResult = braces.expand('a/{x,y,z}/b'); +strArrResult = braces('a/{x,y,z}/b', bracesOpts); diff --git a/types/braces/index.d.ts b/types/braces/index.d.ts new file mode 100644 index 0000000000..07cb5c17c4 --- /dev/null +++ b/types/braces/index.d.ts @@ -0,0 +1,107 @@ +// Type definitions for braces 2.3 +// Project: https://github.com/micromatch/braces +// Definitions by: vemoo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace braces { + interface Options { + /** + * Generate an "expanded" brace pattern (this option is unncessary with the `.expand` method, which does the same thing). + * + * ```js + * console.log(braces('a/{b,c}/d', {expand: true})); + * //=> [ 'a/b/d', 'a/c/d' ] + * ``` + * + * @default undefined + */ + expand?: boolean; + /** + * Enabled by default. + * + * ```js + * console.log(braces('a/{b,c}/d')); + * //=> [ 'a/(b|c)/d' ] + * ``` + * + * @default true + */ + optimize?: boolean; + /** + * Duplicates are removed by default. To keep duplicates, pass `{nodupes: false}` on the options + * + * @default true + */ + nodupes?: boolean; + /** + * When `braces.expand()` is used, or `options.expand` is true, brace patterns will automatically be [optimized](#optionsoptimize) when the difference between the range minimum and range maximum exceeds the `rangeLimit`. This is to prevent huge ranges from freezing your application. + * + * You can set this to any number, or change `options.rangeLimit` to `Inifinity` to disable this altogether. + * + * @default 250 + * + * @example + * ```js + * // pattern exceeds the "rangeLimit", so it's optimized automatically + * console.log(braces.expand('{1..1000}')); + * //=> ['([1-9]|[1-9][0-9]{1,2}|1000)'] + * + * // pattern does not exceed "rangeLimit", so it's NOT optimized + * console.log(braces.expand('{1..100}')); + * //=> ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100'] + * ``` + */ + rangeLimit?: number; + /** + * Customize range expansion. + * + * ```js + * var range = braces.expand('x{a..e}y', { + * transform: function(str) { + * return 'foo' + str; + * } + * }); + * + * console.log(range); + * //=> [ 'xfooay', 'xfooby', 'xfoocy', 'xfoody', 'xfooey' ] + * ``` + * + * @default undefined + */ + transform?: (str: string) => string; + /** + * In regular expressions, quanitifiers can be used to specify how many times a token can be repeated. For example, `a{1,3}` will match the letter `a` one to three times. + * + * Unfortunately, regex quantifiers happen to share the same syntax as [Bash lists](#lists) + * + * The `quantifiers` option tells braces to detect when [regex quantifiers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#quantifiers) are defined in the given pattern, and not to try to expand them as lists. + * + * @default undefined + * + * @example + * ```js + * var braces = require('braces'); + * console.log(braces('a/b{1,3}/{x,y,z}')); + * //=> [ 'a/b(1|3)/(x|y|z)' ] + * console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: true})); + * //=> [ 'a/b{1,3}/(x|y|z)' ] + * console.log(braces('a/b{1,3}/{x,y,z}', {quantifiers: true, expand: true})); + * //=> [ 'a/b{1,3}/x', 'a/b{1,3}/y', 'a/b{1,3}/z' ] + * ``` + */ + quantifiers?: boolean; + /** + * Strip backslashes that were used for escaping from the result. + * + * @default undefined + */ + unescape?: boolean; + } +} +interface Braces { + (pattern: string, options?: braces.Options): string[]; + expand(pattern: string): string[]; +} +declare const braces: Braces; +export as namespace braces; +export = braces; diff --git a/types/braces/tsconfig.json b/types/braces/tsconfig.json new file mode 100644 index 0000000000..bdacb750ad --- /dev/null +++ b/types/braces/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "braces-tests.ts" + ] +} \ No newline at end of file diff --git a/types/braces/tslint.json b/types/braces/tslint.json new file mode 100644 index 0000000000..64f1d180e9 --- /dev/null +++ b/types/braces/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "max-line-length": false + } +} \ No newline at end of file diff --git a/types/micromatch/index.d.ts b/types/micromatch/index.d.ts index 02608693a7..7484e5bfcb 100644 --- a/types/micromatch/index.d.ts +++ b/types/micromatch/index.d.ts @@ -1,171 +1,621 @@ -// Type definitions for micromatch 2.3.7 -// Project: https://github.com/jonschlinkert/micromatch +// Type definitions for micromatch 3.1 +// Project: https://github.com/micromatch/micromatch // Definitions by: glen-84 +// vemoo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 -import parseGlob = require('parse-glob'); - +import * as braces from "braces"; declare namespace micromatch { - type MatchFunction = ((value: T) => boolean); - type Pattern = (string | RegExp | MatchFunction); - interface Options { /** - * Normalize slashes in file paths and glob patterns to forward slashes. + * Allow glob patterns without slashes to match a file path based on its basename. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `matchBase`. + * + * @default false + * + * @example + * ```js + * mm(['a/b.js', 'a/c.md'], '*.js'); + * //=> [] + * + * mm(['a/b.js', 'a/c.md'], '*.js', {matchBase: true}); + * //=> ['a/b.js'] + * ``` */ - unixify?: boolean; + basename?: boolean; /** - * Match dotfiles. Same behavior as minimatch. + * Enabled by default, this option enforces bash-like behavior with stars immediately following a bracket expression. Bash bracket expressions are similar to regex character classes, but unlike regex, a star following a bracket expression **does not repeat the bracketed characters**. Instead, the star is treated the same as an other star. + * + * @default true + * + * @example + * ```js + * var files = ['abc', 'ajz']; + * console.log(mm(files, '[a-c]*')); + * //=> ['abc', 'ajz'] + * + * console.log(mm(files, '[a-c]*', {bash: false})); + * ``` + */ + bash?: boolean; + /** + * Disable regex and function memoization. + * + * @default undefined + */ + cache?: boolean; + /** + * Match dotfiles. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `dot`. + * + * @default false */ dot?: boolean; /** - * Unescape slashes in glob patterns. Use cautiously, especially on windows. + * Similar to the `--failglob` behavior in Bash, throws an error when no matches are found. + * + * @default undefined */ - unescape?: boolean; + failglob?: boolean; /** - * Remove duplicate elements from the result array. + * String or array of glob patterns to match files to ignore. + * + * @default undefined */ - nodupes?: boolean; + ignore?: string | string[]; /** - * Allow glob patterns without slashes to match a file path based on its basename. Same behavior as - * minimatch. + * Alias for [options.basename](#options-basename). */ matchBase?: boolean; /** - * Don't expand braces in glob patterns. Same behavior as minimatch nobrace. + * Disable expansion of brace patterns. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nobrace`. + * + * @default undefined */ - nobraces?: boolean; + nobrace?: boolean; /** - * Don't expand POSIX bracket expressions. - */ - nobrackets?: boolean; - /** - * Don't expand extended globs. - */ - noextglob?: boolean; - /** - * Use a case-insensitive regex for matching files. Same behavior as minimatch. + * Use a case-insensitive regex for matching files. Same behavior as [minimatch](https://github.com/isaacs/minimatch). + * + * @default undefined */ nocase?: boolean; /** - * If true, when no matches are found the actual (array-ified) glob pattern is returned instead of an empty - * array. Same behavior as minimatch. + * Remove duplicate elements from the result array. + * + * @default undefined + * + * @example + * Example of using the `unescape` and `nodupes` options together: + * + * ```js + * mm.match(['a/b/c', 'a/b/c'], 'a/b/c'); + * //=> ['a/b/c', 'a/b/c'] + * + * mm.match(['a/b/c', 'a/b/c'], 'a/b/c', {nodupes: true}); + * //=> ['abc'] + * ``` + */ + nodupes?: boolean; + /** + * Disable extglob support, so that extglobs are regarded as literal characters. + * + * @default undefined + * + * @example + * ```js + * mm(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)'); + * //=> ['a/b', 'a/!(z)'] + * + * mm(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)', {noext: true}); + * //=> ['a/!(z)'] (matches only as literal characters) + * ``` + */ + noext?: boolean; + /** + * Disallow negation (`!`) patterns, and treat leading `!` as a literal character to match. + * + * @default undefined + */ + nonegate?: boolean; + /** + * Disable matching with globstars (`**`). + * + * @default undefined + */ + noglobstar?: boolean; + /** + * Alias for [options.nullglob](#options-nullglob). */ nonull?: boolean; /** - * Cache the platform (e.g. win32) to prevent this from being looked up for every file path. + * If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nonull`. + * + * @default undefined */ - cache?: boolean; - } - - interface Glob { - options: micromatch.Options; - pattern: string; - history: { msg: any, pattern: string }[]; - tokens: parseGlob.Result; - orig: string; - negated: boolean; - + nullglob?: boolean; /** - * Initialize defaults. + * Pass your own instance of [snapdragon](https://github.com/jonschlinkert/snapdragon), to customize parsers or compilers. + * + * @default undefined */ - init(pattern: string): void; - + snapdragon?: object; /** - * Push a change into `glob.history`. Useful for debugging. + * Generate a source map by enabling the `sourcemap` option with the `.parse`, `.compile`, or `.create` methods. + * + * _(Note that sourcemaps are currently not enabled for brace patterns)_ + * + * @example + * ``` js + * var mm = require('micromatch'); + * var pattern = '*(*(of*(a)x)z)'; + * + * var res = mm.create('abc/*.js', {sourcemap: true}); + * console.log(res.map); + * // { version: 3, + * // sources: [ 'string' ], + * // names: [], + * // mappings: 'AAAA,GAAG,EAAC,iBAAC,EAAC,EAAE', + * // sourcesContent: [ 'abc/*.js' ] } + * + * var ast = mm.parse('abc/**\/*.js'); + * var res = mm.compile(ast, {sourcemap: true}); + * console.log(res.map); + * // { version: 3, + * // sources: [ 'string' ], + * // names: [], + * // mappings: 'AAAA,GAAG,EAAC,2BAAE,EAAC,iBAAC,EAAC,EAAE', + * // sourcesContent: [ 'abc/**\/*.js' ] } + * + * var ast = mm.parse(pattern); + * var res = mm.compile(ast, {sourcemap: true}); + * console.log(res.map); + * // { version: 3, + * // sources: [ 'string' ], + * // names: [], + * // mappings: 'AAAA,CAAE,CAAE,EAAE,CAAE,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC', + * // sourcesContent: [ '*(*(of*(a)x)z)' ] } + * ``` */ - track(msg: any): void; - + sourcemap?: boolean; /** - * Return true if `glob.pattern` was negated with `!`, also remove the `!` from the pattern. + * Remove backslashes from returned matches. + * + * @default undefined + * + * @example + * In this example we want to match a literal `*`: + * + * ```js + * mm.match(['abc', 'a\\*c'], 'a\\*c'); + * //=> ['a\\*c'] + * + * mm.match(['abc', 'a\\*c'], 'a\\*c', {unescape: true}); + * //=> ['a*c'] + * ``` */ - isNegated(): boolean; - + unescape?: boolean; /** - * Expand braces in the given glob pattern. + * Convert path separators on returned files to posix/unix-style forward slashes. + * + * @default true + * + * @example + * ```js + * mm.match(['a\\b\\c'], 'a/**'); + * //=> ['a/b/c'] + * + * mm.match(['a\\b\\c'], {unixify: false}); + * //=> ['a\\b\\c'] + * ``` */ - braces(): void; - - /** - * Expand bracket expressions in `glob.pattern`. - */ - brackets(): void; - - /** - * Expand extended globs in `glob.pattern`. - */ - extglob(): void; - - /** - * Parse the given pattern. - */ - parse(pattern: string): parseGlob.Result; - - /** - * Escape special characters in the given string. - */ - escape(pattern: string): string; - - /** - * Unescape special characters in the given string. - */ - unescape(pattern: string): string; - } - - interface GlobData { - pattern: string; - tokens: parseGlob.Result; - options: micromatch.Options; + unixify?: boolean; } } interface Micromatch { - (files: string | string[], patterns: micromatch.Pattern | micromatch.Pattern[]): string[]; - - isMatch: { - /** - * Returns true if a file path matches the given pattern. - */ - (filePath: string, pattern: micromatch.Pattern, opts?: micromatch.Options): boolean; - /** - * Returns a function for matching. - */ - (filePath: string, opts?: micromatch.Options): micromatch.MatchFunction; - }; + /** + * The main function takes a list of strings and one or more glob patterns to use for matching. + * + * @param list A list of strings to match + * @param patterns One or more glob patterns to use for matching. + * @param options See available options for changing how matches are performed + * @returns Returns an array of matches + * + * @example + * ```js + * var mm = require('micromatch'); + * mm(list, patterns[, options]); + * + * console.log(mm(['a.js', 'a.txt'], ['*.js'])); + * //=> [ 'a.js' ] + * ``` + */ + (list: string[], patterns: string | string[], options?: micromatch.Options): string[]; /** - * Returns true if any part of a file path matches the given pattern. Think of this as "has path" versus - * "is path". + * Similar to the main function, but `pattern` must be a string. + * + * @param list Array of strings to match + * @param pattern Glob pattern to use for matching. + * @param options See available options for changing how matches are performed + * @returns Returns an array of matches + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.match(list, pattern[, options]); + * + * console.log(mm.match(['a.a', 'a.aa', 'a.b', 'a.c'], '*.a')); + * //=> ['a.a', 'a.aa'] + * ``` */ - contains(filePath: string, pattern: micromatch.Pattern, opts?: micromatch.Options): boolean; + match(list: string[], pattern: string, options?: micromatch.Options): string[]; /** - * Returns a function for matching using the supplied pattern. e.g. create your own "matcher". The advantage of - * this method is that the pattern can be compiled outside of a loop. + * Returns true if the specified `string` matches the given glob `pattern`. + * + * @param string String to match + * @param pattern Glob pattern to use for matching. + * @param options See available options for changing how matches are performed + * @returns Returns true if the string matches the glob pattern. + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.isMatch(string, pattern[, options]); + * + * console.log(mm.isMatch('a.a', '*.a')); + * //=> true + * console.log(mm.isMatch('a.b', '*.a')); + * //=> false + * ``` */ - matcher(pattern: micromatch.Pattern): micromatch.MatchFunction; + isMatch(string: string, pattern: string, options?: micromatch.Options): boolean; /** - * Returns a function that can be passed to Array#filter(). + * Returns true if some of the strings in the given `list` match any of the given glob `patterns`. + * + * @param list The string or array of strings to test. Returns as soon as the first match is found. + * @param patterns One or more glob patterns to use for matching. + * @param options See available options for changing how matches are performed + * @returns Returns true if any patterns match `str` + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.some(list, patterns[, options]); + * + * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); + * // true + * console.log(mm.some(['foo.js'], ['*.js', '!foo.js'])); + * // false + * ``` */ - filter(patterns: micromatch.Pattern | micromatch.Pattern[], opts?: micromatch.Options): micromatch.MatchFunction; + some(list: string | string[], patterns: string | string[], options?: micromatch.Options): boolean; /** - * Returns true if a file path matches any of the given patterns. + * Returns true if every string in the given `list` matches any of the given glob `patterns`. + * + * @param list The string or array of strings to test. + * @param patterns One or more glob patterns to use for matching. + * @param options See available options for changing how matches are performed + * @returns Returns true if any patterns match `str` + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.every(list, patterns[, options]); + * + * console.log(mm.every('foo.js', ['foo.js'])); + * // true + * console.log(mm.every(['foo.js', 'bar.js'], ['*.js'])); + * // true + * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js'])); + * // false + * console.log(mm.every(['foo.js'], ['*.js', '!foo.js'])); + * // false + * ``` */ - any(filePath: string, patterns: micromatch.Pattern | micromatch.Pattern[], opts?: micromatch.Options): boolean; + every(list: string | string[], patterns: string | string[], options?: micromatch.Options): boolean; /** - * Returns an object with a regex-compatible string and tokens. + * Returns true if **any** of the given glob `patterns` match the specified `string`. + * + * @param str The string to test. + * @param patterns One or more glob patterns to use for matching. + * @param options See available options for changing how matches are performed + * @returns Returns true if any patterns match `str` + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.any(string, patterns[, options]); + * + * console.log(mm.any('a.a', ['b.*', '*.a'])); + * //=> true + * console.log(mm.any('a.a', 'b.*')); + * //=> false + * ``` */ - expand(pattern: string, opts?: micromatch.Options): micromatch.Glob | micromatch.GlobData; + any(str: string | string[], patterns: string | string[], options?: micromatch.Options): boolean; /** - * Create a regular expression for matching file paths based on the given pattern. + * Returns true if **all** of the given `patterns` match the specified string. + * + * @param str The string to test. + * @param patterns One or more glob patterns to use for matching. + * @param options See available options for changing how matches are performed + * @returns Returns true if any patterns match `str` + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.all(string, patterns[, options]); + * + * console.log(mm.all('foo.js', ['foo.js'])); + * // true + * + * console.log(mm.all('foo.js', ['*.js', '!foo.js'])); + * // false + * + * console.log(mm.all('foo.js', ['*.js', 'foo.js'])); + * // true + * + * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js'])); + * // true + * ``` */ - makeRe(pattern: string, opts?: micromatch.Options): RegExp; + all(str: string | string[], patterns: string | string[], options?: micromatch.Options): boolean; + + /** + * Returns a list of strings that _**do not match any**_ of the given `patterns`. + * + * @param list Array of strings to match. + * @param patterns One or more glob pattern to use for matching. + * @param options See available options for changing how matches are performed + * @returns Returns an array of strings that **do not match** the given patterns. + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.not(list, patterns[, options]); + * + * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a')); + * //=> ['b.b', 'c.c'] + * ``` + */ + not(list: string[], patterns: string | string[], options?: micromatch.Options): string[]; + + /** + * Returns true if the given `string` contains the given pattern. Similar to [.isMatch](#isMatch) but the pattern can match any part of the string. + * + * @param str The string to match. + * @param patterns Glob pattern to use for matching. + * @param options See available options for changing how matches are performed + * @returns Returns true if the patter matches any part of `str`. + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.contains(string, pattern[, options]); + * + * console.log(mm.contains('aa/bb/cc', '*b')); + * //=> true + * console.log(mm.contains('aa/bb/cc', '*d')); + * //=> false + * ``` + */ + contains(str: string, patterns: string | string[], options?: micromatch.Options): boolean; + + /** + * Filter the keys of the given object with the given `glob` pattern and `options`. Does not attempt to match nested keys. If you need this feature, use [glob-object](https://github.com/jonschlinkert/glob-object) instead. + * + * @param object The object with keys to filter. + * @param patterns One or more glob patterns to use for matching. + * @param options See available options for changing how matches are performed + * @returns Returns an object with only keys that match the given patterns. + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.matchKeys(object, patterns[, options]); + * + * var obj = { aa: 'a', ab: 'b', ac: 'c' }; + * console.log(mm.matchKeys(obj, '*b')); + * //=> { ab: 'b' } + * ``` + */ + matchKeys(object: T, patterns: string | string[], options?: micromatch.Options): Partial; + + /** + * Returns a memoized matcher function from the given glob `pattern` and `options`. The returned function takes a string to match as its only argument and returns true if the string is a match. + * + * @param pattern Glob pattern + * @param options See available options for changing how matches are performed. + * @returns Returns a matcher function. + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.matcher(pattern[, options]); + * + * var isMatch = mm.matcher('*.!(*a)'); + * console.log(isMatch('a.a')); + * //=> false + * console.log(isMatch('a.b')); + * //=> true + * ``` + */ + matcher(pattern: string, options?: micromatch.Options): (str: string) => boolean; + + /** + * Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match. + * + * @param pattern Glob pattern to use for matching. + * @param string String to match + * @param options See available options for changing how matches are performed + * @returns Returns an array of captures if the string matches the glob pattern, otherwise `null`. + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.capture(pattern, string[, options]); + * + * console.log(mm.capture('test/*.js', 'test/foo.js')); + * //=> ['foo'] + * console.log(mm.capture('test/*.js', 'foo/bar.css')); + * //=> null + * ``` + */ + capture(pattern: string, string: string, options?: micromatch.Options): string[] | null; + + /** + * Create a regular expression from the given glob `pattern`. + * + * @param pattern A glob pattern to convert to regex. + * @param options See available options for changing how matches are performed. + * @returns Returns a regex created from the given pattern. + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.makeRe(pattern[, options]); + * + * console.log(mm.makeRe('*.js')); + * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/ + * ``` + */ + makeRe(pattern: string, options?: micromatch.Options): RegExp; + + /** + * Expand the given brace `pattern`. + * + * @param pattern String with brace pattern to expand. + * @param options Any options to change how expansion is performed. See the [braces](https://github.com/micromatch/braces) library for all available options. + * + * @example + * ```js + * var mm = require('micromatch'); + * console.log(mm.braces('foo/{a,b}/bar')); + * //=> ['foo/(a|b)/bar'] + * + * console.log(mm.braces('foo/{a,b}/bar', {expand: true})); + * //=> ['foo/(a|b)/bar'] + * ``` + */ + braces(pattern: string, options?: braces.Options): string[]; + + /** + * Parses the given glob `pattern` and returns an array of abstract syntax trees (ASTs), with the compiled `output` and optional source `map` on each AST. + * + * @param pattern Glob pattern to parse and compile. + * @param options Any options to change how parsing and compiling is performed. + * @returns Returns an object with the parsed AST, compiled string and optional source map. + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.create(pattern[, options]); + * + * console.log(mm.create('abc/*.js')); + * // [{ options: { source: 'string', sourcemap: true }, + * // state: {}, + * // compilers: + * // { ... }, + * // output: '(\\.[\\\\\\/])?abc\\/(?!\\.)(?=.)[^\\/]*?\\.js', + * // ast: + * // { type: 'root', + * // errors: [], + * // nodes: + * // [ ... ], + * // dot: false, + * // input: 'abc/*.js' }, + * // parsingErrors: [], + * // map: + * // { version: 3, + * // sources: [ 'string' ], + * // names: [], + * // mappings: 'AAAA,GAAG,EAAC,kBAAC,EAAC,EAAE', + * // sourcesContent: [ 'abc/*.js' ] }, + * // position: { line: 1, column: 28 }, + * // content: {}, + * // files: {}, + * // idx: 6 }] + * ``` + */ + create(pattern: string, options?: micromatch.Options): object; + + /** + * Parse the given `str` with the given `options`. + * + * @returns Returns an AST + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.parse(pattern[, options]); + * + * var ast = mm.parse('a/{b,c}/d'); + * console.log(ast); + * // { type: 'root', + * // errors: [], + * // input: 'a/{b,c}/d', + * // nodes: + * // [ { type: 'bos', val: '' }, + * // { type: 'text', val: 'a/' }, + * // { type: 'brace', + * // nodes: + * // [ { type: 'brace.open', val: '{' }, + * // { type: 'text', val: 'b,c' }, + * // { type: 'brace.close', val: '}' } ] }, + * // { type: 'text', val: '/d' }, + * // { type: 'eos', val: '' } ] } + * ``` + */ + parse(str: string, options?: micromatch.Options): object; + + /** + * Compile the given `ast` or string with the given `options`. + * + * @returns Returns an object that has an `output` property with the compiled string. + * + * @example + * ```js + * var mm = require('micromatch'); + * mm.compile(ast[, options]); + * + * var ast = mm.parse('a/{b,c}/d'); + * console.log(mm.compile(ast)); + * // { options: { source: 'string' }, + * // state: {}, + * // compilers: + * // { eos: [Function], + * // noop: [Function], + * // bos: [Function], + * // brace: [Function], + * // 'brace.open': [Function], + * // text: [Function], + * // 'brace.close': [Function] }, + * // output: [ 'a/(b|c)/d' ], + * // ast: + * // { ... }, + * // parsingErrors: [] } + * ``` + */ + compile(ast: object | string, options?: micromatch.Options): object; + + /** + * Clear the regex cache. + * + * @example + * ```js + * mm.clearCache(); + * ``` + */ + clearCache(): void; } +export as namespace micromatch; + declare const micromatch: Micromatch; export = micromatch; diff --git a/types/micromatch/micromatch-tests.ts b/types/micromatch/micromatch-tests.ts index a0e40d0306..8270a0767a 100644 --- a/types/micromatch/micromatch-tests.ts +++ b/types/micromatch/micromatch-tests.ts @@ -1,54 +1,64 @@ - import mm = require('micromatch'); -var strArrResult: string[]; -var boolResult: boolean; -var strMatchFuncResult: mm.MatchFunction; -var anyMatchFuncResult: mm.MatchFunction; -var globDataResult: mm.GlobData; -var regExpResult: RegExp; +// options type is accessible +const micromatchOptions: mm.Options = { + basename: true, + dot: true, +}; -// Usage. -strArrResult = mm(['a.js', 'b.md', 'c.txt'], '*.{js,txt}'); +let strArrResult: string[]; +let boolResult: boolean; -// Multiple patterns. -strArrResult = mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.md', '*.txt']); +// main function +strArrResult = mm(['a.js', 'a.txt'], '*.js', micromatchOptions); +strArrResult = mm(['a.js', 'a.txt'], ['*.js']); -// "isMatch" method. -boolResult = mm.isMatch('.verb.md', '*.md'); -boolResult = mm.isMatch('.verb.md', '*.md', {dot: true}); -boolResult = mm.isMatch('*.md', {dot: true})('.verb.md'); +// .match +strArrResult = mm.match(['a.a', 'a.aa', 'a.b', 'a.c'], '*.a'); -// "contains" method. -boolResult = mm.contains('a/b/c', 'a/b'); -boolResult = mm.contains('a/b/c', 'a/b', {dot: true}); +// .isMatch +boolResult = mm.isMatch('a.a', '*.a'); -// "matcher" method. -strMatchFuncResult = mm.matcher('*.md'); -strMatchFuncResult = mm.matcher(/\.md$/); -strMatchFuncResult = mm.matcher((filePath: string) => true); +// .some +boolResult = mm.some('foo.js', '*.js'); +boolResult = mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']); +boolResult = mm.some(['foo.js', 'bar.js'], '*.js'); -// "filter" method. -anyMatchFuncResult = mm.filter('*.md'); -anyMatchFuncResult = mm.filter(/\.md$/); -anyMatchFuncResult = mm.filter((filePath: string) => true); +// .every +boolResult = mm.every('foo.js', ['foo.js']); +boolResult = mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']); +boolResult = mm.every(['foo.js', 'bar.js'], '*.js'); -anyMatchFuncResult = mm.filter('*.md', {dot: true}); -['a.js', 'b.txt', 'c.md'].filter(anyMatchFuncResult); +// .any +boolResult = mm.any('foo.js', ['foo.js']); +boolResult = mm.any(['foo.js', 'bar.js'], ['*.js', '!foo.js'], micromatchOptions); +boolResult = mm.any(['foo.js', 'bar.js'], '*.js'); -var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; -anyMatchFuncResult = mm.filter(['{1..10}', '![7-9]', '!{3..4}']); -arr.filter(anyMatchFuncResult); +// .all +boolResult = mm.all('foo.js', ['foo.js']); +boolResult = mm.all(['foo.js', 'bar.js'], ['*.js', '!foo.js']); +boolResult = mm.all(['foo.js', 'bar.js'], '*.js'); -// "any" method. -boolResult = mm.any('abc', ['!*z']); -boolResult = mm.any('abc', 'a*'); -boolResult = mm.any('abc', 'a*', {dot: true}); +// .not +strArrResult = mm.not(['a.a', 'b.b', 'c.c'], '*.a'); -// "expand" method. -globDataResult = mm.expand('*.js'); -globDataResult = mm.expand('*.js', {dot: true}); +// .contains +boolResult = mm.contains('aa/bb/cc', '*b'); +boolResult = mm.contains('aa/bb/cc', ['*b', '*a']); -// "makeRe" method. -regExpResult = mm.makeRe('*.js'); -regExpResult = mm.makeRe('*.js', {dot: true}); +// .matchKeys +const obj = { aa: 'a', ab: 'b', ac: 'c' }; +const partialObj: Partial = mm.matchKeys(obj, '*b'); + +// .matcher +const matcherFn: (str: string) => boolean = mm.matcher('*.!(*a)'); + +// .capture +const strArrResultNullable: string[] | null = mm.capture('test/*.js', 'test/foo.js'); + +// .makeRe +const regex: RegExp = mm.makeRe('*.js'); + +// .braces +strArrResult = mm.braces('*.js'); +strArrResult = mm.braces('*.js', { expand: true }); diff --git a/types/micromatch/tsconfig.json b/types/micromatch/tsconfig.json index acbf548c77..277346ea71 100644 --- a/types/micromatch/tsconfig.json +++ b/types/micromatch/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ diff --git a/types/micromatch/tslint.json b/types/micromatch/tslint.json index a41bf5d19a..64f1d180e9 100644 --- a/types/micromatch/tslint.json +++ b/types/micromatch/tslint.json @@ -1,79 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "max-line-length": false } -} +} \ No newline at end of file From e04d65fe120f2cfcdcfbf25acfa75bc9b9bfddbe Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Sun, 17 Dec 2017 19:42:22 +0300 Subject: [PATCH 227/298] [atom] Adding myself (@lierdakil) to authors list Also removing extraneous comma, as per multiline format example at https://github.com/DefinitelyTyped/DefinitelyTyped#edit-an-existing-package --- types/atom/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/atom/index.d.ts b/types/atom/index.d.ts index 6bf1bc6fd0..4a2a83a32a 100644 --- a/types/atom/index.d.ts +++ b/types/atom/index.d.ts @@ -1,7 +1,8 @@ // Type definitions for Atom 1.22 // Project: https://github.com/atom/atom -// Definitions by: GlenCFL , +// Definitions by: GlenCFL // smhxx +// lierdakil // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 065b0707d4654bf39fa5b77a70e8f0f8e7ab96c3 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 17 Dec 2017 16:51:20 -0300 Subject: [PATCH 228/298] Create a consumer extensible interface. Following suggestion of @SimonSchick --- types/hapi/definitions/server/server-route.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/types/hapi/definitions/server/server-route.d.ts b/types/hapi/definitions/server/server-route.d.ts index caaa348fe0..763f70ccf2 100644 --- a/types/hapi/definitions/server/server-route.d.ts +++ b/types/hapi/definitions/server/server-route.d.ts @@ -1,5 +1,8 @@ import {Lifecycle, Server, Util} from "hapi"; +export interface ServerRouteConfig { +} + /** * A route configuration object or an array of configuration objects where each object contains: * * path - (required) the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the server's router configuration. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. @@ -45,8 +48,8 @@ export interface ServerRoute { rules?: object; /** - * TODO: Missing documentation. Exist only in examples and test files. + * Missing documentation. Exist only in examples and test files. */ - config?: any; + config?: ServerRouteConfig; } From 62ae76a50e133263072db5b9262cd60df5dc3292 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Sun, 17 Dec 2017 19:48:08 -0300 Subject: [PATCH 229/298] Add Iron typings, wrote by @SimonSchick --- .../server/server-state-options.d.ts | 6 +- types/hapi/definitions/util/iron.d.ts | 88 +++++++++++++++++++ types/hapi/index.d.ts | 1 + 3 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 types/hapi/definitions/util/iron.d.ts diff --git a/types/hapi/definitions/server/server-state-options.d.ts b/types/hapi/definitions/server/server-state-options.d.ts index 55f749792f..cddc15c37e 100644 --- a/types/hapi/definitions/server/server-state-options.d.ts +++ b/types/hapi/definitions/server/server-state-options.d.ts @@ -1,4 +1,4 @@ -import {Request} from "hapi"; +import {Iron, Request} from "hapi"; /** * Optional cookie settings @@ -43,13 +43,13 @@ export interface ServerStateCookieOptions { * * password - password used for HMAC key generation (must be at least 32 characters long). */ sign?: { - integrity?: object; // TODO make iron definitions and getting typing from iron. Needs review! + integrity?: Iron.ISomething; password: string; }; /** password used for 'iron' encoding (must be at least 32 characters long). */ password?: string; /** options for 'iron' encoding. Defaults to require('iron').defaults. */ - iron?: object; // TODO make iron definitions and getting typing from iron. Needs review! + iron?: Iron.ISealOptions; /** if true, errors are ignored and treated as missing cookies. */ ignoreErrors?: boolean; /** if true, automatically instruct the client to remove invalid cookies. Defaults to false. */ diff --git a/types/hapi/definitions/util/iron.d.ts b/types/hapi/definitions/util/iron.d.ts new file mode 100644 index 0000000000..5f3d711803 --- /dev/null +++ b/types/hapi/definitions/util/iron.d.ts @@ -0,0 +1,88 @@ +/** + * iron is a cryptographic utility for sealing a JSON object using symmetric key encryption with message integrity + * verification. Or in other words, it lets you encrypt an object, send it around (in cookies, authentication + * credentials, etc.), then receive it back and decrypt it. The algorithm ensures that the message was not tampered + * with, and also provides a simple mechanism for password rotation. + * [See docs](https://github.com/hueniverse/iron) + * @author typings wrote by SimonSchick + */ +export namespace Iron { + + export interface ISomething { + saltBits: number; + algorithm: string; + iterations: number; + minPasswordlength: number; + } + + export interface ISealOptions { + encryption: ISomething; + integrity: ISomething; + + ttl: number; + timestampSkewSec: number; + localtimeOffsetMsec: number; + } + + /** + * iron provides a few options for customizing the key deriviation algorithm used to generate encryption and + * integrity verification keys as well as the algorithms and salt sizes used. The 'seal()' and 'unseal()' + * methods take an options object with the following required keys: + * * encryption - defines the options used by the encryption process. + * * integrity - defines the options used by the HMAC integrity verification process. + * Each of these option objects includes the following required keys: + * * saltBits - the size of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result. + * * algorithm - the algorithm used ('aes-256-cbc' for encryption and 'sha256' for integrity are the only two supported at this time). + * * iterations - the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key. + * The 'seal()' and 'unseal()' methods also take the following optional options keys: + * * ttl - sealed object lifetime in milliseconds where 0 means forever. Defaults to 0. + * * timestampSkewSec - number of seconds of permitted clock skew for incoming expirations. Defaults to 60 seconds. + * * localtimeOffsetMsec - local clock time offset, expressed in number of milliseconds (positive or negative). Defaults to 0. + * [See docs](https://github.com/hueniverse/iron#options) + */ + export const defaults: ISealOptions; + + export const algorithms: { + 'aes-128-ctr': { + keyBits: number; + ivBits: number; + }; + 'aes-256-cbc': { + keyBits: number; + ivBits: number; + }; + 'sha256': { + keyBits: number; + }; + }; + + export const macFormatVersion: string; + export const macPrefix: string; + + export interface IGenerateKeyOptions extends Pick { + saltBits?: number; + salt?: string; + iv?: string; + } + + export interface IKey { + key: Buffer; + salt: string; + iv: string; + } + + export function generateKey (password: string, options: IGenerateKeyOptions): Promise; + export function encrypt (password: string, options: IGenerateKeyOptions, data: string): Promise<{ data: Buffer, key: IKey }>; + export function decrypt (password: string, options: IGenerateKeyOptions, data: string): Promise; + + export interface IHMacResult { + digest: string; + salt: string; + } + + export function hmacWithPassword(password: string, options: IGenerateKeyOptions, data: string): Promise; + + export function seal (obj: object, password: string, options: ISealOptions): Promise; + export function unseal (data: string, password: string, options: ISealOptions): Promise; + +} diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 151246f5e9..58d84ba89f 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -65,6 +65,7 @@ export * from './definitions/server/server-state' export * from './definitions/server/server-state-options' /** UTIL */ +export * from './definitions/util/iron' export * from './definitions/util/json' export * from './definitions/util/lifecycle' export * from './definitions/util/util' From af6e63d5ba6aca96aa8d8b3e55d6b83b36ea9ff9 Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Mon, 18 Dec 2017 11:51:42 +1100 Subject: [PATCH 230/298] Add types for fscreen --- types/fscreen/fscreen-tests.ts | 26 ++++++++++++++++++++++++++ types/fscreen/index.d.ts | 22 ++++++++++++++++++++++ types/fscreen/tsconfig.json | 24 ++++++++++++++++++++++++ types/fscreen/tslint.json | 1 + 4 files changed, 73 insertions(+) create mode 100644 types/fscreen/fscreen-tests.ts create mode 100644 types/fscreen/index.d.ts create mode 100644 types/fscreen/tsconfig.json create mode 100644 types/fscreen/tslint.json diff --git a/types/fscreen/fscreen-tests.ts b/types/fscreen/fscreen-tests.ts new file mode 100644 index 0000000000..eb2845f76f --- /dev/null +++ b/types/fscreen/fscreen-tests.ts @@ -0,0 +1,26 @@ +import fscreen from 'fscreen'; + +const element = document.createElement('div'); + +if (fscreen.fullscreenEnabled) { + fscreen.addEventListener('fullscreenchange', handler, false); + fscreen.requestFullscreen(element); +} + +function handler() { + if (fscreen.fullscreenElement !== null) { + // Entered fullscreen mode + } else { + // Exited fullscreen mode + } +} + +fscreen.requestFullscreen(element); +fscreen.requestFullscreenFunction(element); +fscreen.exitFullscreen(); +fscreen.onfullscreenchange = handler; +fscreen.addEventListener('fullscreenchange', handler); +fscreen.removeEventListener('fullscreenchange', handler); +fscreen.onfullscreenerror = handler; +fscreen.addEventListener('fullscreenerror', handler); +fscreen.removeEventListener('fullscreenerror', handler); diff --git a/types/fscreen/index.d.ts b/types/fscreen/index.d.ts new file mode 100644 index 0000000000..dfe2f6117f --- /dev/null +++ b/types/fscreen/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for fscreen 1.0 +// Project: https://github.com/rafrex/fscreen#readme +// Definitions by: Joscha Feth +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type Handler = () => void; + +declare class Fscreen { + readonly fullscreenElement: Element | undefined; + readonly fullscreenEnabled: boolean; + readonly exitFullscreen: Handler; + onfullscreenchange: Handler; + onfullscreenerror: Handler; + + addEventListener(type: string, handler: Handler, useCapture?: boolean): void; + removeEventListener(type: string, handler: Handler): void; + requestFullscreen(element: Element): void; + requestFullscreenFunction(element: Element): void; +} + +declare const fscreen: Fscreen; +export default fscreen; diff --git a/types/fscreen/tsconfig.json b/types/fscreen/tsconfig.json new file mode 100644 index 0000000000..74c4dc119b --- /dev/null +++ b/types/fscreen/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "target": "es6", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fscreen-tests.ts" + ] +} diff --git a/types/fscreen/tslint.json b/types/fscreen/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/fscreen/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From d591ae271b246a79d4703f58b3a7fa7ecc019466 Mon Sep 17 00:00:00 2001 From: Joscha Feth Date: Mon, 18 Dec 2017 12:15:52 +1100 Subject: [PATCH 231/298] strictFunctionTypes --- types/fscreen/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/fscreen/tsconfig.json b/types/fscreen/tsconfig.json index 74c4dc119b..e352d9fd2e 100644 --- a/types/fscreen/tsconfig.json +++ b/types/fscreen/tsconfig.json @@ -10,6 +10,7 @@ "strictNullChecks": true, "baseUrl": "../", "target": "es6", + "strictFunctionTypes": true, "typeRoots": [ "../" ], From 5a4fc269cc6a1e0ea444ef178083b2b9a3d0a993 Mon Sep 17 00:00:00 2001 From: simonxca Date: Sun, 17 Dec 2017 23:54:08 -0800 Subject: [PATCH 232/298] Update comment on id property --- types/mongoose/index.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/types/mongoose/index.d.ts b/types/mongoose/index.d.ts index 311d2d298f..c00772ea2a 100644 --- a/types/mongoose/index.d.ts +++ b/types/mongoose/index.d.ts @@ -1143,7 +1143,12 @@ declare module "mongoose" { } interface MongooseDocumentOptionals { - /** The string version of this documents _id. */ + /** + * Virtual getter that by default returns the document's _id field cast to a string, + * or in the case of ObjectIds, its hexString. This id getter may be disabled by + * passing the option { id: false } at schema construction time. If disabled, id + * behaves like any other field on a document and can be assigned any value. + */ id?: any; } From f203d6458c239f3f61e4a04f1c72a8fec94ca2ca Mon Sep 17 00:00:00 2001 From: KoalaHuman Date: Mon, 18 Dec 2017 10:59:27 +0300 Subject: [PATCH 233/298] Added React Google ReCAPTCHA --- types/react-google-recaptcha/index.d.ts | 86 +++++++++++++++++++ .../react-google-recaptcha-tests.tsx | 8 ++ types/react-google-recaptcha/tsconfig.json | 25 ++++++ types/react-google-recaptcha/tslint.json | 1 + 4 files changed, 120 insertions(+) create mode 100644 types/react-google-recaptcha/index.d.ts create mode 100644 types/react-google-recaptcha/react-google-recaptcha-tests.tsx create mode 100644 types/react-google-recaptcha/tsconfig.json create mode 100644 types/react-google-recaptcha/tslint.json diff --git a/types/react-google-recaptcha/index.d.ts b/types/react-google-recaptcha/index.d.ts new file mode 100644 index 0000000000..ade88fbda4 --- /dev/null +++ b/types/react-google-recaptcha/index.d.ts @@ -0,0 +1,86 @@ +// Type definitions for React Google Recaptcha 0.9 +// Project: https://github.com/dozoisch/react-google-recaptcha +// Definitions by: Koala Human +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as React from 'react'; + +export as namespace RGR; + +export default ReCAPTCHA; + +declare class ReCAPTCHA extends React.Component { + /** + * Resets the reCAPTCHA widget + */ + reset(): void; + /** + * Programatically invoke the reCAPTCHA check. Used if the invisible reCAPTCHA is on a div instead of a button + */ + execute(): void; + + /** + * Gets the response for the reCAPTCHA widget. + * @return the response of the reCAPTCHA widget. + */ + getValue(): string | null; + + /** + * Gets the widgetId of reCAPTCHA widget + * @return widgetId | null + */ + getWidgetId(): number | null; +} + +type Theme = "light" | "dark"; +type Type = "image" | "audio"; +type Size = "compact" | "normal" | "invisible"; +type Badge = "bottomright" | "bottomleft" | "inline"; + +export interface ReCAPTCHAProps { + /** + * The API client key + */ + sitekey: string; + /** + * The function to be called when the user successfully completes the captcha. It will also be called + * with null, when captcha expires + * @param token string or null + */ + onChange: (token: string|null) => void; + /** + * Optional light or dark theme of the widget + * @default "light" + */ + theme?: Theme; + /** + * Optional image or audio The type of initial captcha + * @default "image" + */ + type?: Type; + /** + * Optional the tabindex of the element + * @default 0 + */ + tabindex?: number; + /** + * Optional callback, called when a challenge expires and has to be redone by the user. + */ + onExpired?: () => void; + /** + * Optional set the stoken parameter, which allows the captcha to be used from different domains, + * @see reCAPTCHA secure-token + */ + stoken?: string; + /** + * Optional compact, normal or invisible. This allows you to change the size or do an invisible captcha + */ + size?: Size; + /** + * Optional. The badge location for g-recaptcha with size of "invisible". + * + * @default "bottomright" + */ + badge?: Badge; +} diff --git a/types/react-google-recaptcha/react-google-recaptcha-tests.tsx b/types/react-google-recaptcha/react-google-recaptcha-tests.tsx new file mode 100644 index 0000000000..b3e60d538b --- /dev/null +++ b/types/react-google-recaptcha/react-google-recaptcha-tests.tsx @@ -0,0 +1,8 @@ +import ReCAPTCHA from 'react-google-recaptcha'; +import * as ReactDOM from 'react-dom'; +import * as React from 'react'; + +ReactDOM.render( + a}/>, + document.getElementById('example') +); diff --git a/types/react-google-recaptcha/tsconfig.json b/types/react-google-recaptcha/tsconfig.json new file mode 100644 index 0000000000..bbd1cfd004 --- /dev/null +++ b/types/react-google-recaptcha/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "jsx": "react", + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-google-recaptcha-tests.tsx" + ] +} diff --git a/types/react-google-recaptcha/tslint.json b/types/react-google-recaptcha/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-google-recaptcha/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 034679e9345a8a3abd894e656570fdd8973bcba5 Mon Sep 17 00:00:00 2001 From: David Broder-Rodgers Date: Mon, 18 Dec 2017 12:41:57 +0000 Subject: [PATCH 234/298] Add typings for cordova-universal-links-plugin --- .../cordova-universal-links-plugin-tests.ts | 16 +++++++++++++ .../cordova-universal-links-plugin/index.d.ts | 24 +++++++++++++++++++ .../tsconfig.json | 24 +++++++++++++++++++ .../tslint.json | 3 +++ 4 files changed, 67 insertions(+) create mode 100644 types/cordova-universal-links-plugin/cordova-universal-links-plugin-tests.ts create mode 100644 types/cordova-universal-links-plugin/index.d.ts create mode 100644 types/cordova-universal-links-plugin/tsconfig.json create mode 100644 types/cordova-universal-links-plugin/tslint.json diff --git a/types/cordova-universal-links-plugin/cordova-universal-links-plugin-tests.ts b/types/cordova-universal-links-plugin/cordova-universal-links-plugin-tests.ts new file mode 100644 index 0000000000..e16254312b --- /dev/null +++ b/types/cordova-universal-links-plugin/cordova-universal-links-plugin-tests.ts @@ -0,0 +1,16 @@ +const newsEventname = 'openNewsListPage'; +universalLinks.subscribe(newsEventname, onNewsListPageRequested); + +function onNewsListPageRequested(eventData: EventData) { + alert('Did launch application with news link: ' + eventData.url); +} + +universalLinks.unsubscribe('openNewsListPage'); + +window.universalLinks.subscribe(null, onOtherLinkRequested); + +function onOtherLinkRequested(eventData: EventData) { + alert('Did launch application with other link: ' + eventData.url); +} + +window.universalLinks.unsubscribe(null); diff --git a/types/cordova-universal-links-plugin/index.d.ts b/types/cordova-universal-links-plugin/index.d.ts new file mode 100644 index 0000000000..6b29c1a37e --- /dev/null +++ b/types/cordova-universal-links-plugin/index.d.ts @@ -0,0 +1,24 @@ +// Type definitions for cordova-universal-links-plugin 1.2 +// Project: https://github.com/nordnet/cordova-universal-links-plugin#readme +// Definitions by: David Broder-Rodgers +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface EventData { + url: string; + scheme: string; + host: string; + path: string; + params: { [key: string]: string }; + hash: string; +} + +interface UniversalLinks { + subscribe(eventName: string | null, callback: (data: EventData) => void): void; + unsubscribe(eventName: string | null): void; +} + +interface Window { + universalLinks: UniversalLinks; +} + +declare var universalLinks: UniversalLinks; diff --git a/types/cordova-universal-links-plugin/tsconfig.json b/types/cordova-universal-links-plugin/tsconfig.json new file mode 100644 index 0000000000..69322a9265 --- /dev/null +++ b/types/cordova-universal-links-plugin/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cordova-universal-links-plugin-tests.ts" + ] +} diff --git a/types/cordova-universal-links-plugin/tslint.json b/types/cordova-universal-links-plugin/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/cordova-universal-links-plugin/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From a7c9e3bb8a327a4ba7282cddb137d74c64c20959 Mon Sep 17 00:00:00 2001 From: David Broder-Rodgers Date: Mon, 18 Dec 2017 13:55:46 +0000 Subject: [PATCH 235/298] Update typings to use namespace --- .../cordova-universal-links-plugin-tests.ts | 8 +++--- .../cordova-universal-links-plugin/index.d.ts | 28 ++++++++----------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/types/cordova-universal-links-plugin/cordova-universal-links-plugin-tests.ts b/types/cordova-universal-links-plugin/cordova-universal-links-plugin-tests.ts index e16254312b..1a6981b2e9 100644 --- a/types/cordova-universal-links-plugin/cordova-universal-links-plugin-tests.ts +++ b/types/cordova-universal-links-plugin/cordova-universal-links-plugin-tests.ts @@ -1,16 +1,16 @@ const newsEventname = 'openNewsListPage'; universalLinks.subscribe(newsEventname, onNewsListPageRequested); -function onNewsListPageRequested(eventData: EventData) { +function onNewsListPageRequested(eventData: universalLinks.EventData) { alert('Did launch application with news link: ' + eventData.url); } universalLinks.unsubscribe('openNewsListPage'); -window.universalLinks.subscribe(null, onOtherLinkRequested); +universalLinks.subscribe(null, onOtherLinkRequested); -function onOtherLinkRequested(eventData: EventData) { +function onOtherLinkRequested(eventData: universalLinks.EventData) { alert('Did launch application with other link: ' + eventData.url); } -window.universalLinks.unsubscribe(null); +universalLinks.unsubscribe(null); diff --git a/types/cordova-universal-links-plugin/index.d.ts b/types/cordova-universal-links-plugin/index.d.ts index 6b29c1a37e..98217a1b0a 100644 --- a/types/cordova-universal-links-plugin/index.d.ts +++ b/types/cordova-universal-links-plugin/index.d.ts @@ -3,22 +3,16 @@ // Definitions by: David Broder-Rodgers // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface EventData { - url: string; - scheme: string; - host: string; - path: string; - params: { [key: string]: string }; - hash: string; -} +declare namespace universalLinks { + function subscribe(eventName: string | null, callback: (data: EventData) => void): void; + function unsubscribe(eventName: string | null): void; -interface UniversalLinks { - subscribe(eventName: string | null, callback: (data: EventData) => void): void; - unsubscribe(eventName: string | null): void; + interface EventData { + url: string; + scheme: string; + host: string; + path: string; + params: { [key: string]: string }; + hash: string; + } } - -interface Window { - universalLinks: UniversalLinks; -} - -declare var universalLinks: UniversalLinks; From 835e0b2e46f138aca197be3a0f72e16c2810f897 Mon Sep 17 00:00:00 2001 From: David Broder-Rodgers Date: Mon, 18 Dec 2017 14:26:12 +0000 Subject: [PATCH 236/298] Add typings for onesignal-cordova-sdk --- types/onesignal-cordova-plugin/index.d.ts | 201 ++++++++++++++++++ .../onesignal-cordova-plugin-tests.ts | 70 ++++++ types/onesignal-cordova-plugin/tsconfig.json | 24 +++ types/onesignal-cordova-plugin/tslint.json | 1 + 4 files changed, 296 insertions(+) create mode 100644 types/onesignal-cordova-plugin/index.d.ts create mode 100644 types/onesignal-cordova-plugin/onesignal-cordova-plugin-tests.ts create mode 100644 types/onesignal-cordova-plugin/tsconfig.json create mode 100644 types/onesignal-cordova-plugin/tslint.json diff --git a/types/onesignal-cordova-plugin/index.d.ts b/types/onesignal-cordova-plugin/index.d.ts new file mode 100644 index 0000000000..d2c2534829 --- /dev/null +++ b/types/onesignal-cordova-plugin/index.d.ts @@ -0,0 +1,201 @@ +// Type definitions for onesignal-cordova-plugin 2.2 +// Project: https://github.com/onesignal/OneSignal-Cordova-SDK#readme +// Definitions by: David Broder-Rodgers +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Window { + plugins: { OneSignal: OneSignalCordovaPlugin.OneSignalCordovaPlugin }; +} + +declare namespace OneSignalCordovaPlugin { + interface OneSignalCordovaPlugin { + startInit(appId: string): OneSignalBuilder; + promptForPushNotificationsWithUserResponse(callback: (accepted: boolean) => void): void; + getPermissionSubscriptionState(callback: (status: OSPermissionSubscriptionState) => void): void; + addPermissionObserver(callback: (state: OSPermissionState) => void): void; + addSubscriptionObserver(callback: (state: OSSubscriptionState) => void): void; + getTags(callback: (tags: any) => void): void; + sendTag(key: string, value: string): void; + sendTags(tags: { [key: string]: string }): void; + deleteTag(key: string): void; + deleteTags(keys: string[]): void; + promptLocation(): void; + syncHashedEmail(email: string): void; + postNotification(notificationObj: any, onSuccess: (json: any) => void, onFailure: (json: any) => void): void; + clearOneSignalNotifications(): void; + setSubscription(enable: boolean): void; + enableVibrate(enable: boolean): void; + enableSound(enable: boolean): void; + setLogLevel(logLevel: { logLevel: number, visualLevel: number }): void; + getIds(callback: (id: { userId: string; pushToken: string }) => void): void; + registerForPushNotifications(): void; + } + + interface OneSignalBuilder { + handleNotificationReceived(callback: (json: OSNotification) => void): OneSignalBuilder; + handleNotificationOpened(callback: (json: OSNotificationOpenedResult) => void): OneSignalBuilder; + inFocusDisplaying(displayOption: OSDisplayType): OneSignalBuilder; + iOSSettings(settings: { + kOSSettingsKeyAutoPrompt: boolean; + kOSSettingsKeyInAppLaunchURL: boolean; + }): OneSignalBuilder; + endInit(): void; + } + + interface OSNotification { + isAppInFocus: boolean; + shown: boolean; + androidNotificationId?: number; + payload: OSNotificationPayload; + displayType: OSDisplayType; + groupedNotifications?: OSNotificationPayload[]; + app_id?: string; + contents: any; + headings?: any; + isIos?: boolean; + isAndroid?: boolean; + isWP?: boolean; + isWP_WNS?: boolean; + isAdm?: boolean; + isChrome?: boolean; + isChromeWeb?: boolean; + isSafari?: boolean; + isAnyWeb?: boolean; + included_segments?: string[]; + excluded_segments?: string[]; + include_player_ids?: string[]; + include_ios_tokens?: string[]; + include_android_reg_ids?: string[]; + include_wp_uris?: string[]; + include_wp_wns_uris?: string[]; + include_amazon_reg_ids?: string[]; + include_chrome_reg_ids?: string[]; + include_chrome_web_reg_ids?: string[]; + app_ids?: string[]; + tags?: any[]; + ios_badgeType?: string; + ios_badgeCount?: number; + ios_sound?: string; + android_sound?: string; + adm_sound?: string; + wp_sound?: string; + wp_wns_sound?: string; + data?: any; + buttons?: any; + small_icon?: string; + large_icon?: string; + big_picture?: string; + adm_small_icon?: string; + adm_large_icon?: string; + adm_big_picture?: string; + chrome_icon?: string; + chrome_big_picture?: string; + chrome_web_icon?: string; + firefox_icon?: string; + url?: string; + send_after?: string; + delayed_option?: string; + delivery_time_of_day?: string; + android_led_color?: string; + android_accent_color?: string; + android_visibility?: number; + content_available?: boolean; + amazon_background_data?: boolean; + template_id?: string; + android_group?: string; + android_group_message?: any; + adm_group?: string; + adm_group_message?: any; + ttl?: number; + priority?: number; + ios_category?: string; + } + + interface OSNotificationPayload { + notificationID: string; + title: string; + body: string; + additionalData?: any; + smallIcon?: string; + largeIcon?: string; + bigPicture?: string; + smallIconAccentColor?: string; + launchURL?: string; + sound: string; + ledColor?: string; + lockScreenVisibility?: OSLockScreenVisibility; + groupKey?: string; + groupMessage?: string; + actionButtons: OSActionButton[]; + fromProjectNumber?: string; + backgroundImageLayout?: OSBackgroundImageLayout; + priority?: number; + rawPayload: string; + } + + interface OSActionButton { + id: string; + text: string; + icon: string; + } + + interface OSPermissionState { + hasPrompted: boolean; + status: OSNotificationPermission; + } + + interface OSSubscriptionState { + subscribed: boolean; + userSubscriptionSetting: any; + userId: any; + pushToken: any; + } + + interface OSPermissionSubscriptionState { + permissionStatus: OSPermissionState; + subscriptionStatus: OSSubscriptionState; + } + + interface OSBackgroundImageLayout { + image: string; + titleTextColor: string; + bodyTextColor: string; + } + + interface OSNotificationOpenedResult { + action: { + type: OSActionType; + actionID?: string; + }; + notification: OSNotification; + } + + const enum OSLockScreenVisibility { + Public = 1, + Private = 0, + Secret = -1 + } + + const enum OSDisplayType { + None = 0, + InAppAlert = 1, + Notification = 2 + } + + const enum OSActionType { + Opened = 0, + ActionTake = 1 + } + + const enum OSInFocusDisplayOption { + None = 0, + InAppAlert = 1, + Notification = 2 + } + + const enum OSNotificationPermission { + NotDetermined = 0, + Authorized = 1, + Denied = 2, + } +} diff --git a/types/onesignal-cordova-plugin/onesignal-cordova-plugin-tests.ts b/types/onesignal-cordova-plugin/onesignal-cordova-plugin-tests.ts new file mode 100644 index 0000000000..763338f948 --- /dev/null +++ b/types/onesignal-cordova-plugin/onesignal-cordova-plugin-tests.ts @@ -0,0 +1,70 @@ +window.plugins.OneSignal + .startInit("YOUR_APPID") + .handleNotificationReceived((jsonData) => { + console.log("Notification received:\n" + JSON.stringify(jsonData)); + }) + .handleNotificationOpened((jsonData) => { + console.log("Notification opened:\n" + JSON.stringify(jsonData)); + }) + .inFocusDisplaying(OneSignalCordovaPlugin.OSDisplayType.Notification) + .iOSSettings({ + kOSSettingsKeyAutoPrompt: true, + kOSSettingsKeyInAppLaunchURL: false, + }) + .endInit(); + +window.plugins.OneSignal.promptForPushNotificationsWithUserResponse((accepted) => { + console.log("User accepted notifications: " + accepted); +}); + +window.plugins.OneSignal.addPermissionObserver((state) => { + console.log("Notification permission state changed: " + JSON.stringify(state)); +}); + +window.plugins.OneSignal.addSubscriptionObserver((state) => { + if (!state.subscribed) { + console.log("Subscribed for OneSignal push notifications!"); + } + console.log("Push Subscription state changed: " + JSON.stringify(state)); +}); + +window.plugins.OneSignal.getTags((tags) => { + console.log('Tags Received: ' + JSON.stringify(tags)); +}); + +window.plugins.OneSignal.sendTag("key", "value"); + +window.plugins.OneSignal.deleteTag("key"); + +window.plugins.OneSignal.sendTags({ key1: "value", key2: "value2" }); + +window.plugins.OneSignal.deleteTags(["key1", "key2"]); + +window.plugins.OneSignal.promptLocation(); + +window.plugins.OneSignal.syncHashedEmail("John.Smith@example.com"); + +window.plugins.OneSignal.getIds((ids) => { + const notificationObj = { + contents: { en: "message body" }, + include_player_ids: [ids.userId] + }; + window.plugins.OneSignal.postNotification(notificationObj, + (successResponse) => { + console.log("Notification Post Success:", successResponse); + }, + (failedResponse) => { + console.log("Notification Post Failed: ", failedResponse); + } + ); +}); + +window.plugins.OneSignal.clearOneSignalNotifications(); + +window.plugins.OneSignal.setSubscription(false); + +window.plugins.OneSignal.enableVibrate(false); + +window.plugins.OneSignal.enableSound(false); + +window.plugins.OneSignal.setLogLevel({ logLevel: 4, visualLevel: 4 }); diff --git a/types/onesignal-cordova-plugin/tsconfig.json b/types/onesignal-cordova-plugin/tsconfig.json new file mode 100644 index 0000000000..bcee47426f --- /dev/null +++ b/types/onesignal-cordova-plugin/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "onesignal-cordova-plugin-tests.ts" + ] +} diff --git a/types/onesignal-cordova-plugin/tslint.json b/types/onesignal-cordova-plugin/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/onesignal-cordova-plugin/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 1f58580e8d124bec165d8fd7f7568768b9e3377f Mon Sep 17 00:00:00 2001 From: rsouza Date: Mon, 18 Dec 2017 13:12:54 -0300 Subject: [PATCH 237/298] Add Iron typings https://github.com/hueniverse/iron --- types/iron/index.d.ts | 96 ++++++++++++++++++++++++++++++++++++++++ types/iron/iron-tests.ts | 78 ++++++++++++++++++++++++++++++++ types/iron/tsconfig.json | 23 ++++++++++ types/iron/tslint.json | 79 +++++++++++++++++++++++++++++++++ 4 files changed, 276 insertions(+) create mode 100644 types/iron/index.d.ts create mode 100644 types/iron/iron-tests.ts create mode 100644 types/iron/tsconfig.json create mode 100644 types/iron/tslint.json diff --git a/types/iron/index.d.ts b/types/iron/index.d.ts new file mode 100644 index 0000000000..6e5a77bc9e --- /dev/null +++ b/types/iron/index.d.ts @@ -0,0 +1,96 @@ +// Type definitions for iron 5.0 +// Project: https://github.com/hueniverse/iron +// Definitions by: Simon Schick +// Rafael Souza Fijalkowski +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/// + +/** + * iron is a cryptographic utility for sealing a JSON object using symmetric key encryption with message integrity + * verification. Or in other words, it lets you encrypt an object, send it around (in cookies, authentication + * credentials, etc.), then receive it back and decrypt it. The algorithm ensures that the message was not tampered + * with, and also provides a simple mechanism for password rotation. + * [See docs](https://github.com/hueniverse/iron) + */ +declare module 'iron' { + + export interface ISomething { + saltBits: number; + algorithm: string; + iterations: number; + minPasswordlength: number; + } + + /** + * iron provides a few options for customizing the key deriviation algorithm used to generate encryption and + * integrity verification keys as well as the algorithms and salt sizes used. The 'seal()' and 'unseal()' + * methods take an options object with the following required keys: + * * encryption - defines the options used by the encryption process. + * * integrity - defines the options used by the HMAC integrity verification process. + * Each of these option objects includes the following required keys: + * * saltBits - the size of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result. + * * algorithm - the algorithm used ('aes-256-cbc' for encryption and 'sha256' for integrity are the only two supported at this time). + * * iterations - the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key. + * The 'seal()' and 'unseal()' methods also take the following optional options keys: + * * ttl - sealed object lifetime in milliseconds where 0 means forever. Defaults to 0. + * * timestampSkewSec - number of seconds of permitted clock skew for incoming expirations. Defaults to 60 seconds. + * * localtimeOffsetMsec - local clock time offset, expressed in number of milliseconds (positive or negative). Defaults to 0. + * [See docs](https://github.com/hueniverse/iron#options) + */ + export interface ISealOptions { + encryption: ISomething; + integrity: ISomething; + ttl: number; + timestampSkewSec: number; + localtimeOffsetMsec: number; + } + + export interface IAlgorithms { + 'aes-128-ctr': { + keyBits: number; + ivBits: number; + }; + 'aes-256-cbc': { + keyBits: number; + ivBits: number; + }; + 'sha256': { + keyBits: number; + }; + } + + export const defaults: ISealOptions; + export const algorithms: IAlgorithms; + export const macFormatVersion: string; + export const macPrefix: string; + + export interface IGenerateKeyOptions extends Pick { + saltBits?: number; + salt?: string; + iv?: string; + } + + export interface IKey { + key: Buffer; + salt: string; + iv: string; + } + + export function generateKey (password: string, options: IGenerateKeyOptions): Promise; + export function encrypt (password: string, options: IGenerateKeyOptions, data: string): Promise<{ data: Buffer, key: IKey }>; + export function decrypt (password: string, options: IGenerateKeyOptions, data: string): Promise; + + export interface IHMacResult { + digest: string; + salt: string; + } + + export function hmacWithPassword(password: string, options: IGenerateKeyOptions, data: string): Promise; + + export function seal (obj: object, password: string, options: ISealOptions): Promise; + export function unseal (data: string, password: string, options: ISealOptions): Promise; + +} + diff --git a/types/iron/iron-tests.ts b/types/iron/iron-tests.ts new file mode 100644 index 0000000000..7fb095a0bf --- /dev/null +++ b/types/iron/iron-tests.ts @@ -0,0 +1,78 @@ +import * as Iron from "iron"; + +const options:Iron.ISealOptions = { + encryption: { + saltBits: 256, + algorithm: 'aes-256-cbc', + iterations: 1, + minPasswordlength: 32 + }, + integrity: { + saltBits: 256, + algorithm: 'sha256', + iterations: 1, + minPasswordlength: 32 + }, + ttl: 0, + timestampSkewSec: 60, + localtimeOffsetMsec: 0 +}; + +const algorithms:Iron.IAlgorithms = { + 'aes-128-ctr': { keyBits: 128, ivBits: 128 }, + 'aes-256-cbc': { keyBits: 256, ivBits: 128 }, + 'sha256': { keyBits: 256 } +}; + +const optionsGenerateKey:Iron.IGenerateKeyOptions = { + saltBits: 256, + salt: '4d8nr9q384nr9q384nr93q8nruq9348run', + algorithm: 'aes-128-ctr', + iterations: 10000, + iv: 'sdfsdfsdfsdfscdrgercgesrcgsercg', + minPasswordlength: 32 +}; + +const obj:object = { + a: 1, + b: 2, + c: [3, 4, 5], + d: { + e: 'f' + } +}; + +Iron.seal(obj, 'password', options) + .then((sealed: string) => { + console.log(sealed); + }); + +Iron.unseal('data', 'password', Iron.defaults) + .then((unsealed: object) => { + console.log(unsealed); + }); + +Iron.generateKey('password', options.encryption) + .then((value: Iron.IKey) => { + console.log(value); + }); + +Iron.generateKey('password', optionsGenerateKey) + .then((value: Iron.IKey) => { + console.log(value); + }); + +Iron.encrypt('password', Iron.defaults.encryption, 'data') + .then((obj: { data: Buffer, key: Iron.IKey }) => { + console.log(obj); + }); + +Iron.decrypt('password', Iron.defaults.encryption, 'data') + .then((buffer: Buffer) => { + console.log(buffer); + }); + +Iron.hmacWithPassword('password', Iron.defaults.integrity, 'data') + .then((value: Iron.IHMacResult) => { + console.log(value); + }); diff --git a/types/iron/tsconfig.json b/types/iron/tsconfig.json new file mode 100644 index 0000000000..d322f47b49 --- /dev/null +++ b/types/iron/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "iron-tests.ts" + ] +} diff --git a/types/iron/tslint.json b/types/iron/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/iron/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} From 231bc5e192f1b66f7d384907b419bfe90657e1cc Mon Sep 17 00:00:00 2001 From: rsouza Date: Mon, 18 Dec 2017 14:52:08 -0300 Subject: [PATCH 238/298] Add more JSDocs. --- types/iron/index.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/types/iron/index.d.ts b/types/iron/index.d.ts index 6e5a77bc9e..1f0aa4bb87 100644 --- a/types/iron/index.d.ts +++ b/types/iron/index.d.ts @@ -16,6 +16,12 @@ */ declare module 'iron' { + /** + * saltBits - the size of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result. + * algorithm - the algorithm used ('aes-256-cbc' for encryption and 'sha256' for integrity are the only two supported at this time). + * iterations - the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key. + * minPasswordlength - minimum password size + */ export interface ISomething { saltBits: number; algorithm: string; @@ -33,6 +39,7 @@ declare module 'iron' { * * saltBits - the size of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result. * * algorithm - the algorithm used ('aes-256-cbc' for encryption and 'sha256' for integrity are the only two supported at this time). * * iterations - the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key. + * * minPasswordlength - minimum password size * The 'seal()' and 'unseal()' methods also take the following optional options keys: * * ttl - sealed object lifetime in milliseconds where 0 means forever. Defaults to 0. * * timestampSkewSec - number of seconds of permitted clock skew for incoming expirations. Defaults to 60 seconds. From c454a618f9b590c5a9653bf9515a9b8b042682c5 Mon Sep 17 00:00:00 2001 From: rsouza Date: Mon, 18 Dec 2017 15:18:23 -0300 Subject: [PATCH 239/298] Set "strictNullChecks" to true. --- types/iron/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/iron/tsconfig.json b/types/iron/tsconfig.json index d322f47b49..bddeeac5c0 100644 --- a/types/iron/tsconfig.json +++ b/types/iron/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ From db6053938fd1eb8e2927e1055cada349223003f4 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 18 Dec 2017 20:52:01 +0100 Subject: [PATCH 240/298] restore previous version and put in subfolder --- types/micromatch/v2/index.d.ts | 171 ++++++++++++++++++++++++ types/micromatch/v2/micromatch-tests.ts | 54 ++++++++ types/micromatch/v2/tsconfig.json | 28 ++++ types/micromatch/v2/tslint.json | 79 +++++++++++ 4 files changed, 332 insertions(+) create mode 100644 types/micromatch/v2/index.d.ts create mode 100644 types/micromatch/v2/micromatch-tests.ts create mode 100644 types/micromatch/v2/tsconfig.json create mode 100644 types/micromatch/v2/tslint.json diff --git a/types/micromatch/v2/index.d.ts b/types/micromatch/v2/index.d.ts new file mode 100644 index 0000000000..02608693a7 --- /dev/null +++ b/types/micromatch/v2/index.d.ts @@ -0,0 +1,171 @@ +// Type definitions for micromatch 2.3.7 +// Project: https://github.com/jonschlinkert/micromatch +// Definitions by: glen-84 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +import parseGlob = require('parse-glob'); + +declare namespace micromatch { + type MatchFunction = ((value: T) => boolean); + type Pattern = (string | RegExp | MatchFunction); + + interface Options { + /** + * Normalize slashes in file paths and glob patterns to forward slashes. + */ + unixify?: boolean; + /** + * Match dotfiles. Same behavior as minimatch. + */ + dot?: boolean; + /** + * Unescape slashes in glob patterns. Use cautiously, especially on windows. + */ + unescape?: boolean; + /** + * Remove duplicate elements from the result array. + */ + nodupes?: boolean; + /** + * Allow glob patterns without slashes to match a file path based on its basename. Same behavior as + * minimatch. + */ + matchBase?: boolean; + /** + * Don't expand braces in glob patterns. Same behavior as minimatch nobrace. + */ + nobraces?: boolean; + /** + * Don't expand POSIX bracket expressions. + */ + nobrackets?: boolean; + /** + * Don't expand extended globs. + */ + noextglob?: boolean; + /** + * Use a case-insensitive regex for matching files. Same behavior as minimatch. + */ + nocase?: boolean; + /** + * If true, when no matches are found the actual (array-ified) glob pattern is returned instead of an empty + * array. Same behavior as minimatch. + */ + nonull?: boolean; + /** + * Cache the platform (e.g. win32) to prevent this from being looked up for every file path. + */ + cache?: boolean; + } + + interface Glob { + options: micromatch.Options; + pattern: string; + history: { msg: any, pattern: string }[]; + tokens: parseGlob.Result; + orig: string; + negated: boolean; + + /** + * Initialize defaults. + */ + init(pattern: string): void; + + /** + * Push a change into `glob.history`. Useful for debugging. + */ + track(msg: any): void; + + /** + * Return true if `glob.pattern` was negated with `!`, also remove the `!` from the pattern. + */ + isNegated(): boolean; + + /** + * Expand braces in the given glob pattern. + */ + braces(): void; + + /** + * Expand bracket expressions in `glob.pattern`. + */ + brackets(): void; + + /** + * Expand extended globs in `glob.pattern`. + */ + extglob(): void; + + /** + * Parse the given pattern. + */ + parse(pattern: string): parseGlob.Result; + + /** + * Escape special characters in the given string. + */ + escape(pattern: string): string; + + /** + * Unescape special characters in the given string. + */ + unescape(pattern: string): string; + } + + interface GlobData { + pattern: string; + tokens: parseGlob.Result; + options: micromatch.Options; + } +} + +interface Micromatch { + (files: string | string[], patterns: micromatch.Pattern | micromatch.Pattern[]): string[]; + + isMatch: { + /** + * Returns true if a file path matches the given pattern. + */ + (filePath: string, pattern: micromatch.Pattern, opts?: micromatch.Options): boolean; + /** + * Returns a function for matching. + */ + (filePath: string, opts?: micromatch.Options): micromatch.MatchFunction; + }; + + /** + * Returns true if any part of a file path matches the given pattern. Think of this as "has path" versus + * "is path". + */ + contains(filePath: string, pattern: micromatch.Pattern, opts?: micromatch.Options): boolean; + + /** + * Returns a function for matching using the supplied pattern. e.g. create your own "matcher". The advantage of + * this method is that the pattern can be compiled outside of a loop. + */ + matcher(pattern: micromatch.Pattern): micromatch.MatchFunction; + + /** + * Returns a function that can be passed to Array#filter(). + */ + filter(patterns: micromatch.Pattern | micromatch.Pattern[], opts?: micromatch.Options): micromatch.MatchFunction; + + /** + * Returns true if a file path matches any of the given patterns. + */ + any(filePath: string, patterns: micromatch.Pattern | micromatch.Pattern[], opts?: micromatch.Options): boolean; + + /** + * Returns an object with a regex-compatible string and tokens. + */ + expand(pattern: string, opts?: micromatch.Options): micromatch.Glob | micromatch.GlobData; + + /** + * Create a regular expression for matching file paths based on the given pattern. + */ + makeRe(pattern: string, opts?: micromatch.Options): RegExp; +} + +declare const micromatch: Micromatch; +export = micromatch; diff --git a/types/micromatch/v2/micromatch-tests.ts b/types/micromatch/v2/micromatch-tests.ts new file mode 100644 index 0000000000..a0e40d0306 --- /dev/null +++ b/types/micromatch/v2/micromatch-tests.ts @@ -0,0 +1,54 @@ + +import mm = require('micromatch'); + +var strArrResult: string[]; +var boolResult: boolean; +var strMatchFuncResult: mm.MatchFunction; +var anyMatchFuncResult: mm.MatchFunction; +var globDataResult: mm.GlobData; +var regExpResult: RegExp; + +// Usage. +strArrResult = mm(['a.js', 'b.md', 'c.txt'], '*.{js,txt}'); + +// Multiple patterns. +strArrResult = mm(['a.md', 'b.js', 'c.txt', 'd.json'], ['*.md', '*.txt']); + +// "isMatch" method. +boolResult = mm.isMatch('.verb.md', '*.md'); +boolResult = mm.isMatch('.verb.md', '*.md', {dot: true}); +boolResult = mm.isMatch('*.md', {dot: true})('.verb.md'); + +// "contains" method. +boolResult = mm.contains('a/b/c', 'a/b'); +boolResult = mm.contains('a/b/c', 'a/b', {dot: true}); + +// "matcher" method. +strMatchFuncResult = mm.matcher('*.md'); +strMatchFuncResult = mm.matcher(/\.md$/); +strMatchFuncResult = mm.matcher((filePath: string) => true); + +// "filter" method. +anyMatchFuncResult = mm.filter('*.md'); +anyMatchFuncResult = mm.filter(/\.md$/); +anyMatchFuncResult = mm.filter((filePath: string) => true); + +anyMatchFuncResult = mm.filter('*.md', {dot: true}); +['a.js', 'b.txt', 'c.md'].filter(anyMatchFuncResult); + +var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]; +anyMatchFuncResult = mm.filter(['{1..10}', '![7-9]', '!{3..4}']); +arr.filter(anyMatchFuncResult); + +// "any" method. +boolResult = mm.any('abc', ['!*z']); +boolResult = mm.any('abc', 'a*'); +boolResult = mm.any('abc', 'a*', {dot: true}); + +// "expand" method. +globDataResult = mm.expand('*.js'); +globDataResult = mm.expand('*.js', {dot: true}); + +// "makeRe" method. +regExpResult = mm.makeRe('*.js'); +regExpResult = mm.makeRe('*.js', {dot: true}); diff --git a/types/micromatch/v2/tsconfig.json b/types/micromatch/v2/tsconfig.json new file mode 100644 index 0000000000..e011e8c1cc --- /dev/null +++ b/types/micromatch/v2/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "paths": { + "micromatch": [ + "micromatch/v2" + ] + }, + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "micromatch-tests.ts" + ] +} \ No newline at end of file diff --git a/types/micromatch/v2/tslint.json b/types/micromatch/v2/tslint.json new file mode 100644 index 0000000000..a41bf5d19a --- /dev/null +++ b/types/micromatch/v2/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} From adb8ddc0b43154da8367be5e0bb860fcf73b758a Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 18 Dec 2017 20:52:33 +0100 Subject: [PATCH 241/298] fix tslint issues --- types/braces/index.d.ts | 9 ++++++--- types/braces/tslint.json | 5 +---- types/micromatch/index.d.ts | 10 +++++++--- types/micromatch/tslint.json | 5 +---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/types/braces/index.d.ts b/types/braces/index.d.ts index 07cb5c17c4..880738806e 100644 --- a/types/braces/index.d.ts +++ b/types/braces/index.d.ts @@ -34,7 +34,9 @@ declare namespace braces { */ nodupes?: boolean; /** - * When `braces.expand()` is used, or `options.expand` is true, brace patterns will automatically be [optimized](#optionsoptimize) when the difference between the range minimum and range maximum exceeds the `rangeLimit`. This is to prevent huge ranges from freezing your application. + * When `braces.expand()` is used, or `options.expand` is true, brace patterns will automatically be [optimized](#optionsoptimize) + * when the difference between the range minimum and range maximum exceeds the `rangeLimit`. + * This is to prevent huge ranges from freezing your application. * * You can set this to any number, or change `options.rangeLimit` to `Inifinity` to disable this altogether. * @@ -48,7 +50,7 @@ declare namespace braces { * * // pattern does not exceed "rangeLimit", so it's NOT optimized * console.log(braces.expand('{1..100}')); - * //=> ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100'] + * //=> ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11' ... '89', 90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '100'] * ``` */ rangeLimit?: number; @@ -74,7 +76,8 @@ declare namespace braces { * * Unfortunately, regex quantifiers happen to share the same syntax as [Bash lists](#lists) * - * The `quantifiers` option tells braces to detect when [regex quantifiers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#quantifiers) are defined in the given pattern, and not to try to expand them as lists. + * The `quantifiers` option tells braces to detect when [regex quantifiers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#quantifiers) + * are defined in the given pattern, and not to try to expand them as lists. * * @default undefined * diff --git a/types/braces/tslint.json b/types/braces/tslint.json index 64f1d180e9..e60c15844f 100644 --- a/types/braces/tslint.json +++ b/types/braces/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "max-line-length": false - } + "extends": "dtslint/dt.json" } \ No newline at end of file diff --git a/types/micromatch/index.d.ts b/types/micromatch/index.d.ts index 7484e5bfcb..b2c64ab80f 100644 --- a/types/micromatch/index.d.ts +++ b/types/micromatch/index.d.ts @@ -25,7 +25,9 @@ declare namespace micromatch { */ basename?: boolean; /** - * Enabled by default, this option enforces bash-like behavior with stars immediately following a bracket expression. Bash bracket expressions are similar to regex character classes, but unlike regex, a star following a bracket expression **does not repeat the bracketed characters**. Instead, the star is treated the same as an other star. + * Enabled by default, this option enforces bash-like behavior with stars immediately following a bracket expression. + * Bash bracket expressions are similar to regex character classes, but unlike regex, a star following a bracket expression **does not repeat the bracketed characters**. + * Instead, the star is treated the same as an other star. * * @default true * @@ -128,7 +130,8 @@ declare namespace micromatch { */ nonull?: boolean; /** - * If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nonull`. + * If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array. + * Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nonull`. * * @default undefined */ @@ -408,7 +411,8 @@ interface Micromatch { contains(str: string, patterns: string | string[], options?: micromatch.Options): boolean; /** - * Filter the keys of the given object with the given `glob` pattern and `options`. Does not attempt to match nested keys. If you need this feature, use [glob-object](https://github.com/jonschlinkert/glob-object) instead. + * Filter the keys of the given object with the given `glob` pattern and `options`. Does not attempt to match nested keys. + * If you need this feature, use [glob-object](https://github.com/jonschlinkert/glob-object) instead. * * @param object The object with keys to filter. * @param patterns One or more glob patterns to use for matching. diff --git a/types/micromatch/tslint.json b/types/micromatch/tslint.json index 64f1d180e9..e60c15844f 100644 --- a/types/micromatch/tslint.json +++ b/types/micromatch/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "max-line-length": false - } + "extends": "dtslint/dt.json" } \ No newline at end of file From 48978b95eea785c45b6116c9f680a963423aa5eb Mon Sep 17 00:00:00 2001 From: Bernardo Date: Mon, 18 Dec 2017 22:18:01 +0100 Subject: [PATCH 242/298] add path mappings to dependent packages --- types/browser-sync/tsconfig.json | 5 +++++ types/gulp/v3/tsconfig.json | 3 +++ 2 files changed, 8 insertions(+) diff --git a/types/browser-sync/tsconfig.json b/types/browser-sync/tsconfig.json index 98204d433a..830268a3a6 100644 --- a/types/browser-sync/tsconfig.json +++ b/types/browser-sync/tsconfig.json @@ -9,6 +9,11 @@ "strictNullChecks": false, "strictFunctionTypes": true, "baseUrl": "../", + "paths": { + "micromatch": [ + "micromatch/v2" + ] + }, "typeRoots": [ "../" ], diff --git a/types/gulp/v3/tsconfig.json b/types/gulp/v3/tsconfig.json index 31412b46c3..2948f23682 100644 --- a/types/gulp/v3/tsconfig.json +++ b/types/gulp/v3/tsconfig.json @@ -15,6 +15,9 @@ "paths": { "gulp": [ "gulp/v3" + ], + "micromatch": [ + "micromatch/v2" ] }, "types": [], From f851dac2abb999eee9b1d10422ab45b7e5764ea6 Mon Sep 17 00:00:00 2001 From: "VML\\snau" Date: Mon, 18 Dec 2017 14:45:01 -0800 Subject: [PATCH 243/298] **@types/vanilla-modal Creating definitions for "vanilla-modal"** adding all the required files for the new type definition --- types/vanilla-modal/index.d.ts | 50 ++++++++++++++++++++++ types/vanilla-modal/tsconfig.json | 24 +++++++++++ types/vanilla-modal/tslint.json | 1 + types/vanilla-modal/vanilla-modal-tests.ts | 3 ++ 4 files changed, 78 insertions(+) create mode 100644 types/vanilla-modal/index.d.ts create mode 100644 types/vanilla-modal/tsconfig.json create mode 100644 types/vanilla-modal/tslint.json create mode 100644 types/vanilla-modal/vanilla-modal-tests.ts diff --git a/types/vanilla-modal/index.d.ts b/types/vanilla-modal/index.d.ts new file mode 100644 index 0000000000..90775bf7ee --- /dev/null +++ b/types/vanilla-modal/index.d.ts @@ -0,0 +1,50 @@ +// Type definitions for vanilla-modal 1.6 +// Project: https://github.com/benceg/vanilla-modal +// Definitions by: Sam Nau +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface VanillaModalConfig { + modal?: string | HTMLElement; + modalInner?: string; + modalContent?: string; + open?: string; + close?: string; + page?: string; + class?: string; + loadClass?: string; + clickOutside?: boolean; + closeKeys?: [number]; + transitions?: string; + transitionEnd?(): undefined; + onBeforeOpen?(): undefined; + onBeforeClose?(): undefined; + onOpen?(): undefined; + onClose?(): undefined; +} +export interface VanillaModalDomNodes { + modal: HTMLElement; + page: HTMLElement; + modalInner: HTMLElement; + modalContent: HTMLElement; +} + +export default class VanillaModal { + constructor(settings?: VanillaModalConfig); + getDomNodes(): VanillaModalDomNodes; + addLoadedCssClass(): void; + setOpenId(id: string): void; + removeOpenId(): void; + open(allMatches: string, e?: Event): void; + detectTransition(): boolean; + close(e: Event): void; + closeModal(e: Event): void; + closeModalWithTransition(e: Event): void; + captureNode(node: Node): void; + releaseNode(node: Node): void; + closeKeyHandler(e: Event): void; + outsideClickHandler(e: Event): void; + delegateOpen(e: Event): void; + delegateClose(e: Event): void; + listen(): void; + destroy(): void; +} diff --git a/types/vanilla-modal/tsconfig.json b/types/vanilla-modal/tsconfig.json new file mode 100644 index 0000000000..f6d7663c4f --- /dev/null +++ b/types/vanilla-modal/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames" : true + }, + "files": [ + "index.d.ts", + "vanilla-modal-tests.ts" + ] +} diff --git a/types/vanilla-modal/tslint.json b/types/vanilla-modal/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/vanilla-modal/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/vanilla-modal/vanilla-modal-tests.ts b/types/vanilla-modal/vanilla-modal-tests.ts new file mode 100644 index 0000000000..3f75db3cc8 --- /dev/null +++ b/types/vanilla-modal/vanilla-modal-tests.ts @@ -0,0 +1,3 @@ +import VanillaModal from 'vanilla-modal'; + +const modalInstance = new VanillaModal(); From 46b10dd9035c51ac26d6b6ccbb05df2cef1c2487 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Mon, 18 Dec 2017 19:50:55 -0300 Subject: [PATCH 244/298] Remove the module declaration, this is implicit in DT. --- types/iron/index.d.ts | 174 ++++++++++++++++++++++-------------------- 1 file changed, 91 insertions(+), 83 deletions(-) diff --git a/types/iron/index.d.ts b/types/iron/index.d.ts index 1f0aa4bb87..5a5e657caa 100644 --- a/types/iron/index.d.ts +++ b/types/iron/index.d.ts @@ -7,97 +7,105 @@ /// -/** - * iron is a cryptographic utility for sealing a JSON object using symmetric key encryption with message integrity - * verification. Or in other words, it lets you encrypt an object, send it around (in cookies, authentication - * credentials, etc.), then receive it back and decrypt it. The algorithm ensures that the message was not tampered - * with, and also provides a simple mechanism for password rotation. - * [See docs](https://github.com/hueniverse/iron) - */ -declare module 'iron' { +export interface ISomething { /** - * saltBits - the size of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result. - * algorithm - the algorithm used ('aes-256-cbc' for encryption and 'sha256' for integrity are the only two supported at this time). - * iterations - the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key. - * minPasswordlength - minimum password size + * the size of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result. */ - export interface ISomething { - saltBits: number; - algorithm: string; - iterations: number; - minPasswordlength: number; - } + saltBits: number; /** - * iron provides a few options for customizing the key deriviation algorithm used to generate encryption and - * integrity verification keys as well as the algorithms and salt sizes used. The 'seal()' and 'unseal()' - * methods take an options object with the following required keys: - * * encryption - defines the options used by the encryption process. - * * integrity - defines the options used by the HMAC integrity verification process. - * Each of these option objects includes the following required keys: - * * saltBits - the size of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result. - * * algorithm - the algorithm used ('aes-256-cbc' for encryption and 'sha256' for integrity are the only two supported at this time). - * * iterations - the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key. - * * minPasswordlength - minimum password size - * The 'seal()' and 'unseal()' methods also take the following optional options keys: - * * ttl - sealed object lifetime in milliseconds where 0 means forever. Defaults to 0. - * * timestampSkewSec - number of seconds of permitted clock skew for incoming expirations. Defaults to 60 seconds. - * * localtimeOffsetMsec - local clock time offset, expressed in number of milliseconds (positive or negative). Defaults to 0. - * [See docs](https://github.com/hueniverse/iron#options) + * the algorithm used ('aes-256-cbc' for encryption and 'sha256' for integrity are the only two supported at this time). */ - export interface ISealOptions { - encryption: ISomething; - integrity: ISomething; - ttl: number; - timestampSkewSec: number; - localtimeOffsetMsec: number; - } + algorithm: string; - export interface IAlgorithms { - 'aes-128-ctr': { - keyBits: number; - ivBits: number; - }; - 'aes-256-cbc': { - keyBits: number; - ivBits: number; - }; - 'sha256': { - keyBits: number; - }; - } + /** + * the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key. + */ + iterations: number; - export const defaults: ISealOptions; - export const algorithms: IAlgorithms; - export const macFormatVersion: string; - export const macPrefix: string; - - export interface IGenerateKeyOptions extends Pick { - saltBits?: number; - salt?: string; - iv?: string; - } - - export interface IKey { - key: Buffer; - salt: string; - iv: string; - } - - export function generateKey (password: string, options: IGenerateKeyOptions): Promise; - export function encrypt (password: string, options: IGenerateKeyOptions, data: string): Promise<{ data: Buffer, key: IKey }>; - export function decrypt (password: string, options: IGenerateKeyOptions, data: string): Promise; - - export interface IHMacResult { - digest: string; - salt: string; - } - - export function hmacWithPassword(password: string, options: IGenerateKeyOptions, data: string): Promise; - - export function seal (obj: object, password: string, options: ISealOptions): Promise; - export function unseal (data: string, password: string, options: ISealOptions): Promise; + /** + * minimum password size + */ + minPasswordlength: number; } +/** + * iron provides a few options for customizing the key derivation algorithm used to generate encryption and + * integrity verification keys as well as the algorithms and salt sizes used. + * For context [See docs](https://github.com/hueniverse/iron#options) + */ +export interface ISealOptions { + + /** + * defines the options used by the encryption process. + */ + encryption: ISomething; + + /** + * defines the options used by the HMAC integrity verification process. + */ + integrity: ISomething; + + /** + * sealed object lifetime in milliseconds where 0 means forever. Defaults to 0. + */ + ttl: number; + + /** + * number of seconds of permitted clock skew for incoming expirations. Defaults to 60 seconds. + */ + timestampSkewSec: number; + + /** + * local clock time offset, expressed in number of milliseconds (positive or negative). Defaults to 0. + */ + localtimeOffsetMsec: number; + +} + +export interface IAlgorithms { + 'aes-128-ctr': { + keyBits: number; + ivBits: number; + }; + 'aes-256-cbc': { + keyBits: number; + ivBits: number; + }; + 'sha256': { + keyBits: number; + }; +} + +export const defaults: ISealOptions; +export const algorithms: IAlgorithms; +export const macFormatVersion: string; +export const macPrefix: string; + +export interface IGenerateKeyOptions extends Pick { + saltBits?: number; + salt?: string; + iv?: string; +} + +export interface IKey { + key: Buffer; + salt: string; + iv: string; +} + +export function generateKey (password: string, options: IGenerateKeyOptions): Promise; +export function encrypt (password: string, options: IGenerateKeyOptions, data: string): Promise<{ data: Buffer, key: IKey }>; +export function decrypt (password: string, options: IGenerateKeyOptions, data: string): Promise; + +export interface IHMacResult { + digest: string; + salt: string; +} + +export function hmacWithPassword(password: string, options: IGenerateKeyOptions, data: string): Promise; + +export function seal (obj: object, password: string, options: ISealOptions): Promise; +export function unseal (data: string, password: string, options: ISealOptions): Promise; From c761f2812268bb0fbfbaf9ee08785ba777f4c9e3 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Mon, 18 Dec 2017 19:55:02 -0300 Subject: [PATCH 245/298] Rename ISomething with ISealOptionsSub. --- types/iron/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/iron/index.d.ts b/types/iron/index.d.ts index 5a5e657caa..197c3ab9a6 100644 --- a/types/iron/index.d.ts +++ b/types/iron/index.d.ts @@ -7,7 +7,7 @@ /// -export interface ISomething { +export interface ISealOptionsSub { /** * the size of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result. @@ -41,12 +41,12 @@ export interface ISealOptions { /** * defines the options used by the encryption process. */ - encryption: ISomething; + encryption: ISealOptionsSub; /** * defines the options used by the HMAC integrity verification process. */ - integrity: ISomething; + integrity: ISealOptionsSub; /** * sealed object lifetime in milliseconds where 0 means forever. Defaults to 0. @@ -84,7 +84,7 @@ export const algorithms: IAlgorithms; export const macFormatVersion: string; export const macPrefix: string; -export interface IGenerateKeyOptions extends Pick { +export interface IGenerateKeyOptions extends Pick { saltBits?: number; salt?: string; iv?: string; From f753befe57dff2b86fe851827a58d30d5e1d0d50 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Mon, 18 Dec 2017 20:52:40 -0300 Subject: [PATCH 246/298] Add "strict" compiler options. Enabling --strict enables: --noImplicitAny, --noImplicitThis, --alwaysStrict, --strictNullChecks and --strictFunctionTypes. --- types/iron/tsconfig.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/types/iron/tsconfig.json b/types/iron/tsconfig.json index bddeeac5c0..090685c604 100644 --- a/types/iron/tsconfig.json +++ b/types/iron/tsconfig.json @@ -4,10 +4,7 @@ "lib": [ "es6" ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, + "strict": true, "baseUrl": "../", "typeRoots": [ "../" From 82c407a764753c6e4adc853f5d2048825bb435af Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Mon, 18 Dec 2017 21:18:12 -0300 Subject: [PATCH 247/298] Enable some lint rules. --- types/iron/tslint.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/iron/tslint.json b/types/iron/tslint.json index a41bf5d19a..8c133044cc 100644 --- a/types/iron/tslint.json +++ b/types/iron/tslint.json @@ -11,32 +11,32 @@ "eofline": false, "export-just-namespace": false, "import-spacing": false, - "interface-name": false, + "interface-name": true, "interface-over-type-literal": false, - "jsdoc-format": false, + "jsdoc-format": true, "max-line-length": false, "member-access": false, "new-parens": false, "no-any-union": false, "no-boolean-literal-compare": false, "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, + "no-consecutive-blank-lines": true, "no-construct": false, "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, + "no-duplicate-imports": true, + "no-duplicate-variable": true, "no-empty-interface": false, "no-for-in-array": false, "no-inferrable-types": false, "no-internal-module": false, - "no-irregular-whitespace": false, + "no-irregular-whitespace": true, "no-mergeable-namespace": false, "no-misused-new": false, "no-namespace": false, "no-object-literal-type-assertion": false, "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, + "no-redundant-jsdoc": true, + "no-redundant-jsdoc-2": true, "no-redundant-undefined": false, "no-reference-import": false, "no-relative-import-in-test": false, From 59141deed18c70bc1d4928300a2ade53f320a84d Mon Sep 17 00:00:00 2001 From: devuxer Date: Mon, 18 Dec 2017 17:41:57 -0800 Subject: [PATCH 248/298] Updated material-ui version in header --- types/material-ui/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/material-ui/index.d.ts b/types/material-ui/index.d.ts index 1590771b78..55b34dff34 100644 --- a/types/material-ui/index.d.ts +++ b/types/material-ui/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for material-ui v0.18.17 +// Type definitions for material-ui v0.20.0 // Project: https://github.com/callemall/material-ui // Definitions by: Nathan Brown // Igor Beagorudsky From a8c57406f23dbd4840d07996fc0a9d832f146e8a Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 19 Dec 2017 00:27:42 -0300 Subject: [PATCH 249/298] Update TS version from 2.4 to 2.6. --- types/iron/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/iron/index.d.ts b/types/iron/index.d.ts index 197c3ab9a6..bf3e469e32 100644 --- a/types/iron/index.d.ts +++ b/types/iron/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Simon Schick // Rafael Souza Fijalkowski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 +// TypeScript Version: 2.6 /// From e2d80085488057eaed7124c0beb5cccc9a7d6465 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 19 Dec 2017 00:46:59 -0300 Subject: [PATCH 250/298] Revert "Add 'strict' compiler options." Dtslint does not allow "strict". Referer: https://github.com/Microsoft/dtslint/blob/dffcc5d6877fdec7380cd48a2e4e9357a3d786f9/src/checks.ts#L78 This reverts commit f753bef --- types/iron/tsconfig.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types/iron/tsconfig.json b/types/iron/tsconfig.json index 090685c604..bddeeac5c0 100644 --- a/types/iron/tsconfig.json +++ b/types/iron/tsconfig.json @@ -4,7 +4,10 @@ "lib": [ "es6" ], - "strict": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 5f5c9be6f334de149c09b24ee00e51f62c2dad2f Mon Sep 17 00:00:00 2001 From: Gustavo Henke Date: Tue, 19 Dec 2017 16:29:06 +1100 Subject: [PATCH 251/298] Add react-dnd-test-backend --- types/react-dnd-test-backend/index.d.ts | 15 +++++++++++ .../react-dnd-test-backend-tests.tsx | 17 +++++++++++++ types/react-dnd-test-backend/tsconfig.json | 25 +++++++++++++++++++ types/react-dnd-test-backend/tslint.json | 6 +++++ 4 files changed, 63 insertions(+) create mode 100644 types/react-dnd-test-backend/index.d.ts create mode 100644 types/react-dnd-test-backend/react-dnd-test-backend-tests.tsx create mode 100644 types/react-dnd-test-backend/tsconfig.json create mode 100644 types/react-dnd-test-backend/tslint.json diff --git a/types/react-dnd-test-backend/index.d.ts b/types/react-dnd-test-backend/index.d.ts new file mode 100644 index 0000000000..07f13607dd --- /dev/null +++ b/types/react-dnd-test-backend/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for react-dnd-test-backend 2.5 +// Project: https://github.com/react-dnd/react-dnd#readme +// Definitions by: Gustavo Henke +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as ReactDnd from "react-dnd"; + +export default class TestBackend implements ReactDnd.Backend { + simulateBeginDrag(sourceIds: ReactDnd.Identifier[], options?: {}): void; + simulatePublishDragSource(): void; + simulateHover(targetIds: ReactDnd.Identifier[], options?: {}): void; + simulateDrop(): void; + simulateEndDrag(): void; +} diff --git a/types/react-dnd-test-backend/react-dnd-test-backend-tests.tsx b/types/react-dnd-test-backend/react-dnd-test-backend-tests.tsx new file mode 100644 index 0000000000..aed3117e06 --- /dev/null +++ b/types/react-dnd-test-backend/react-dnd-test-backend-tests.tsx @@ -0,0 +1,17 @@ +import * as React from "react"; +import { ContextComponent, ContextComponentClass, DragDropContext } from "react-dnd"; +import TestBackend from "react-dnd-test-backend"; + +const Component = DragDropContext(TestBackend)(() =>
); +) => { + const backend = instance.getManager().getBackend() as TestBackend; + backend.simulateBeginDrag(["1"]); + backend.simulateBeginDrag(["1"], { foo: "bar" }); + + backend.simulateHover(["2"]); + backend.simulateHover(["2"], { foo: "bar" }); + + backend.simulateDrop(); + backend.simulateEndDrag(); + backend.simulatePublishDragSource(); +}}/>; diff --git a/types/react-dnd-test-backend/tsconfig.json b/types/react-dnd-test-backend/tsconfig.json new file mode 100644 index 0000000000..aaf674e57e --- /dev/null +++ b/types/react-dnd-test-backend/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-dnd-test-backend-tests.tsx" + ] +} diff --git a/types/react-dnd-test-backend/tslint.json b/types/react-dnd-test-backend/tslint.json new file mode 100644 index 0000000000..8b04e2b32d --- /dev/null +++ b/types/react-dnd-test-backend/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "quotemark": [true, "double"] + } +} From d011b1321a718cd017a3bd88346c52a1b13be1c9 Mon Sep 17 00:00:00 2001 From: Timur Manyanov Date: Tue, 19 Dec 2017 09:31:06 +0100 Subject: [PATCH 252/298] Add KrakenJS definitions --- types/kraken-js/index.d.ts | 27 +++++++++++++++++++++++++ types/kraken-js/kraken-js-tests.ts | 32 ++++++++++++++++++++++++++++++ types/kraken-js/tsconfig.json | 21 ++++++++++++++++++++ types/kraken-js/tslint.json | 1 + 4 files changed, 81 insertions(+) create mode 100644 types/kraken-js/index.d.ts create mode 100644 types/kraken-js/kraken-js-tests.ts create mode 100644 types/kraken-js/tsconfig.json create mode 100644 types/kraken-js/tslint.json diff --git a/types/kraken-js/index.d.ts b/types/kraken-js/index.d.ts new file mode 100644 index 0000000000..776228f0ac --- /dev/null +++ b/types/kraken-js/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for krakenjs 2.2 +// Project: http://krakenjs.com +// Definitions by: Timur Manyanov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import { Express } from 'express'; + +declare function k(options?: k.Options | string): Express; + +declare namespace k { + interface Kraken extends Express { + once(name: string, cb: (err: Error | null, result?: any) => any): void; + kraken: Kraken; + } + + interface Options { + protocols?: object; + basedir?: string; + mountpath?: string; + inheritViews?: boolean; + startupHeaders?: Map; + onconfig?(config: object, next: (err: Error | null, config?: object) => any): any; + } +} + +export = k; diff --git a/types/kraken-js/kraken-js-tests.ts b/types/kraken-js/kraken-js-tests.ts new file mode 100644 index 0000000000..86e44caae1 --- /dev/null +++ b/types/kraken-js/kraken-js-tests.ts @@ -0,0 +1,32 @@ +import express = require('express'); +import kraken = require('kraken-js'); +import * as http from 'http'; +import * as https from 'https'; + +const app = express() as kraken.Kraken; + +// $ExpectType Express +kraken(); + +// $ExpectType Express +kraken('path/to/options'); + +// $ExpectType Express +kraken({ + onconfig: (config, next) => { + next(null, config); + } +}); + +// $ExpectType Kraken +app.use(kraken()); + +// $ExpectType void +app.once('event', (err, result) => {}); + +// $ExpectType any +app.kraken.get('configProp'); + +http.createServer(app); + +https.createServer({}, app); diff --git a/types/kraken-js/tsconfig.json b/types/kraken-js/tsconfig.json new file mode 100644 index 0000000000..2fce7a799d --- /dev/null +++ b/types/kraken-js/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "kraken-js-tests.ts" + ] +} diff --git a/types/kraken-js/tslint.json b/types/kraken-js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/kraken-js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 7394ac428f8c4dd033c3a3ecdaf38e0ef968b381 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 19 Dec 2017 09:20:51 -0300 Subject: [PATCH 253/298] Simplify tslint only with default options. --- types/iron/tslint.json | 78 +----------------------------------------- 1 file changed, 1 insertion(+), 77 deletions(-) diff --git a/types/iron/tslint.json b/types/iron/tslint.json index 8c133044cc..f93cf8562a 100644 --- a/types/iron/tslint.json +++ b/types/iron/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": true, - "interface-over-type-literal": false, - "jsdoc-format": true, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": true, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": true, - "no-duplicate-variable": true, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": true, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": true, - "no-redundant-jsdoc-2": true, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } From 1e90d5e21ef3798f29d4a2796c784a08c2a169f8 Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 19 Dec 2017 09:23:15 -0300 Subject: [PATCH 254/298] Rename interface names. And some lint adjusts to compile with the new default link rules. --- types/iron/index.d.ts | 52 ++++++++++++++++------------------------ types/iron/iron-tests.ts | 18 +++++++------- 2 files changed, 29 insertions(+), 41 deletions(-) diff --git a/types/iron/index.d.ts b/types/iron/index.d.ts index bf3e469e32..1ee9ebbb9c 100644 --- a/types/iron/index.d.ts +++ b/types/iron/index.d.ts @@ -7,28 +7,24 @@ /// -export interface ISealOptionsSub { - +export interface SealOptionsSub { /** * the size of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result. */ saltBits: number; - /** * the algorithm used ('aes-256-cbc' for encryption and 'sha256' for integrity are the only two supported at this time). */ algorithm: string; - /** - * the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key. + * the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations + * to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key. */ iterations: number; - /** * minimum password size */ minPasswordlength: number; - } /** @@ -36,36 +32,30 @@ export interface ISealOptionsSub { * integrity verification keys as well as the algorithms and salt sizes used. * For context [See docs](https://github.com/hueniverse/iron#options) */ -export interface ISealOptions { - +export interface SealOptions { /** * defines the options used by the encryption process. */ - encryption: ISealOptionsSub; - + encryption: SealOptionsSub; /** * defines the options used by the HMAC integrity verification process. */ - integrity: ISealOptionsSub; - + integrity: SealOptionsSub; /** * sealed object lifetime in milliseconds where 0 means forever. Defaults to 0. */ ttl: number; - /** * number of seconds of permitted clock skew for incoming expirations. Defaults to 60 seconds. */ timestampSkewSec: number; - /** * local clock time offset, expressed in number of milliseconds (positive or negative). Defaults to 0. */ localtimeOffsetMsec: number; - } -export interface IAlgorithms { +export interface Algorithms { 'aes-128-ctr': { keyBits: number; ivBits: number; @@ -79,33 +69,31 @@ export interface IAlgorithms { }; } -export const defaults: ISealOptions; -export const algorithms: IAlgorithms; -export const macFormatVersion: string; -export const macPrefix: string; - -export interface IGenerateKeyOptions extends Pick { +export interface GenerateKeyOptions extends Pick { saltBits?: number; salt?: string; iv?: string; } -export interface IKey { +export interface Key { key: Buffer; salt: string; iv: string; } -export function generateKey (password: string, options: IGenerateKeyOptions): Promise; -export function encrypt (password: string, options: IGenerateKeyOptions, data: string): Promise<{ data: Buffer, key: IKey }>; -export function decrypt (password: string, options: IGenerateKeyOptions, data: string): Promise; - -export interface IHMacResult { +export interface HMacResult { digest: string; salt: string; } -export function hmacWithPassword(password: string, options: IGenerateKeyOptions, data: string): Promise; +export const defaults: SealOptions; +export const algorithms: Algorithms; +export const macFormatVersion: string; +export const macPrefix: string; -export function seal (obj: object, password: string, options: ISealOptions): Promise; -export function unseal (data: string, password: string, options: ISealOptions): Promise; +export function generateKey(password: string, options: GenerateKeyOptions): Promise; +export function encrypt(password: string, options: GenerateKeyOptions, data: string): Promise<{ data: Buffer, key: Key }>; +export function decrypt(password: string, options: GenerateKeyOptions, data: string): Promise; +export function hmacWithPassword(password: string, options: GenerateKeyOptions, data: string): Promise; +export function seal(obj: object, password: string, options: SealOptions): Promise; +export function unseal(data: string, password: string, options: SealOptions): Promise; diff --git a/types/iron/iron-tests.ts b/types/iron/iron-tests.ts index 7fb095a0bf..59c440801f 100644 --- a/types/iron/iron-tests.ts +++ b/types/iron/iron-tests.ts @@ -1,6 +1,6 @@ import * as Iron from "iron"; -const options:Iron.ISealOptions = { +const options: Iron.SealOptions = { encryption: { saltBits: 256, algorithm: 'aes-256-cbc', @@ -18,13 +18,13 @@ const options:Iron.ISealOptions = { localtimeOffsetMsec: 0 }; -const algorithms:Iron.IAlgorithms = { +const algorithms: Iron.Algorithms = { 'aes-128-ctr': { keyBits: 128, ivBits: 128 }, 'aes-256-cbc': { keyBits: 256, ivBits: 128 }, - 'sha256': { keyBits: 256 } + sha256: { keyBits: 256 } }; -const optionsGenerateKey:Iron.IGenerateKeyOptions = { +const optionsGenerateKey: Iron.GenerateKeyOptions = { saltBits: 256, salt: '4d8nr9q384nr9q384nr93q8nruq9348run', algorithm: 'aes-128-ctr', @@ -33,7 +33,7 @@ const optionsGenerateKey:Iron.IGenerateKeyOptions = { minPasswordlength: 32 }; -const obj:object = { +const obj: object = { a: 1, b: 2, c: [3, 4, 5], @@ -53,17 +53,17 @@ Iron.unseal('data', 'password', Iron.defaults) }); Iron.generateKey('password', options.encryption) - .then((value: Iron.IKey) => { + .then((value: Iron.Key) => { console.log(value); }); Iron.generateKey('password', optionsGenerateKey) - .then((value: Iron.IKey) => { + .then((value: Iron.Key) => { console.log(value); }); Iron.encrypt('password', Iron.defaults.encryption, 'data') - .then((obj: { data: Buffer, key: Iron.IKey }) => { + .then((obj: { data: Buffer, key: Iron.Key }) => { console.log(obj); }); @@ -73,6 +73,6 @@ Iron.decrypt('password', Iron.defaults.encryption, 'data') }); Iron.hmacWithPassword('password', Iron.defaults.integrity, 'data') - .then((value: Iron.IHMacResult) => { + .then((value: Iron.HMacResult) => { console.log(value); }); From 1e67a7aa78d5e79ce226356c352bb63b9cb5210d Mon Sep 17 00:00:00 2001 From: rafaelsouzaf Date: Tue, 19 Dec 2017 09:54:29 -0300 Subject: [PATCH 255/298] Using "keyof" to set the algorithm value types. Thanks @SimonSchick, I understand now. --- types/iron/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/iron/index.d.ts b/types/iron/index.d.ts index 1ee9ebbb9c..14ccfcbc2f 100644 --- a/types/iron/index.d.ts +++ b/types/iron/index.d.ts @@ -15,7 +15,7 @@ export interface SealOptionsSub { /** * the algorithm used ('aes-256-cbc' for encryption and 'sha256' for integrity are the only two supported at this time). */ - algorithm: string; + algorithm: keyof Algorithms; /** * the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations * to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key. From 887fa78e2ffb9d92ad74beac9dd65706bd4d1b97 Mon Sep 17 00:00:00 2001 From: KoalaHuman Date: Tue, 19 Dec 2017 18:12:16 +0300 Subject: [PATCH 256/298] Redundant namespace export --- types/react-google-recaptcha/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/react-google-recaptcha/index.d.ts b/types/react-google-recaptcha/index.d.ts index ade88fbda4..fee09c3ec8 100644 --- a/types/react-google-recaptcha/index.d.ts +++ b/types/react-google-recaptcha/index.d.ts @@ -6,8 +6,6 @@ import * as React from 'react'; -export as namespace RGR; - export default ReCAPTCHA; declare class ReCAPTCHA extends React.Component { From d6f275b131a5b2742bd802308d109092674e685a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Le=CC=81pe=CC=81e?= Date: Tue, 19 Dec 2017 16:45:33 +0100 Subject: [PATCH 257/298] add types for form-urlencoded --- .../form-urlencoded/form-urlencoded-tests.ts | 10 ++++++++ types/form-urlencoded/index.d.ts | 12 ++++++++++ types/form-urlencoded/tsconfig.json | 23 +++++++++++++++++++ types/form-urlencoded/tslint.json | 1 + 4 files changed, 46 insertions(+) create mode 100644 types/form-urlencoded/form-urlencoded-tests.ts create mode 100644 types/form-urlencoded/index.d.ts create mode 100644 types/form-urlencoded/tsconfig.json create mode 100644 types/form-urlencoded/tslint.json diff --git a/types/form-urlencoded/form-urlencoded-tests.ts b/types/form-urlencoded/form-urlencoded-tests.ts new file mode 100644 index 0000000000..34f598383e --- /dev/null +++ b/types/form-urlencoded/form-urlencoded-tests.ts @@ -0,0 +1,10 @@ +import encode, { FormEncodedOptions } from "form-urlencoded"; + +const opts: FormEncodedOptions = { + sorted: true, + skipIndex: false, + ignorenull: true +}; + +encode([1, 2, 3]); +encode([1, 2, 3], opts); diff --git a/types/form-urlencoded/index.d.ts b/types/form-urlencoded/index.d.ts new file mode 100644 index 0000000000..d076b05227 --- /dev/null +++ b/types/form-urlencoded/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for form-urlencoded 2.0 +// Project: https://github.com/iambumblehead/form-urlencoded#readme +// Definitions by: Antoine Lépée +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface FormEncodedOptions { + sorted?: boolean; + skipIndex?: boolean; + ignorenull?: boolean; +} + +export default function(data: any, opts?: FormEncodedOptions): string; diff --git a/types/form-urlencoded/tsconfig.json b/types/form-urlencoded/tsconfig.json new file mode 100644 index 0000000000..4eefbe0a12 --- /dev/null +++ b/types/form-urlencoded/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "form-urlencoded-tests.ts" + ] +} diff --git a/types/form-urlencoded/tslint.json b/types/form-urlencoded/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/form-urlencoded/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From aa0f58044c08d0699544662c9705cff3d1287346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20S?= Date: Tue, 19 Dec 2017 21:00:44 +0100 Subject: [PATCH 258/298] Typings for react-bootstrap-typeahead (Fix: https://github.com/ericgio/react-bootstrap-typeahead/pull/128) (#22296) * Start creation of typings for react-bootstrap-typeahead * Add tslint * Add tsconfig.json * Add test file * Fix trailing comma * Fix wrong filename * Set min TypeScript Version to 2.3 * commonjs only?? * If strictFunctionTypes not present it doesn't fallback on a default value * No consecutive blank lines * Fix lint errors * Fix last lint errors * Remove default export * Last update --- types/react-bootstrap-typeahead/index.d.ts | 64 +++++++++++++++++++ .../react-bootstrap-typeahead-tests.tsx | 32 ++++++++++ types/react-bootstrap-typeahead/tsconfig.json | 25 ++++++++ types/react-bootstrap-typeahead/tslint.json | 1 + 4 files changed, 122 insertions(+) create mode 100644 types/react-bootstrap-typeahead/index.d.ts create mode 100644 types/react-bootstrap-typeahead/react-bootstrap-typeahead-tests.tsx create mode 100644 types/react-bootstrap-typeahead/tsconfig.json create mode 100644 types/react-bootstrap-typeahead/tslint.json diff --git a/types/react-bootstrap-typeahead/index.d.ts b/types/react-bootstrap-typeahead/index.d.ts new file mode 100644 index 0000000000..c31ddd63b5 --- /dev/null +++ b/types/react-bootstrap-typeahead/index.d.ts @@ -0,0 +1,64 @@ +// Type definitions for react-bootstrap-typeahead 2.0 +// Project: https://github.com/ericgio/react-bootstrap-typeahead +// Definitions by: Guymestef +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as React from 'react'; + +export interface TypeaheadProps { + a11yNumResults?: () => void; + a11yNumSelected?: () => void; + align?: 'justify' | 'left' | 'right'; + allowNew?: boolean; + autoFocus?: boolean; + bodyContainer?: boolean; + bsSize?: 'large' | 'lg' | 'small' | 'sm'; + caseSensitive?: boolean; + clearButton?: boolean; + defaultSelected?: T[]; + disabled?: boolean; + dropup?: boolean; + emptyLabel?: string; + filterBy?: (string[] | ((option: T | string, text: string) => boolean)); + highlightOnlyResult?: boolean; + ignoreDiacritics?: boolean; + inputProps?: object; + labelKey?: string | ((option: T | string) => string); + maxHeight?: number; + maxResults?: number; + minLength?: number; + multiple?: boolean; + newSelectionPrefix?: string; + onBlur?: (e: Event) => any; + onChange?: (selected: T[]) => any; + onFocus?: (e: Event) => any; + onInputChange?: (input: string) => any; + onKeyDown?: (e: Event) => any; + onMenuHide?: (e: Event) => any; + onMenuShow?: (e: Event) => any; + onPaginate?: (e: Event) => any; + options: T[]; + paginate?: boolean; + paginationText?: string; + placeholder?: string; + renderMenu?: (results: Array, menuProps: any) => any; + renderMenuItemChildren?: (option: T, props: TypeaheadProps, index: number) => any; + renderToken?: (selectedItem: T | string, onRemove: () => void) => any; + selected?: T[]; + selectHintOnEnter?: boolean; + submitFormOnEnter?: boolean; +} + +export const Typeahead: React.ClassicComponentClass>; + +export interface AsyncTypeaheadProps extends TypeaheadProps { + delay?: number; + isLoading: boolean; + onSearch: (query: string) => void; + promptText?: string; + searchText?: string; + useCache?: boolean; +} + +export const AsyncTypeahead: React.ClassicComponentClass>; diff --git a/types/react-bootstrap-typeahead/react-bootstrap-typeahead-tests.tsx b/types/react-bootstrap-typeahead/react-bootstrap-typeahead-tests.tsx new file mode 100644 index 0000000000..425bfe313b --- /dev/null +++ b/types/react-bootstrap-typeahead/react-bootstrap-typeahead-tests.tsx @@ -0,0 +1,32 @@ +import * as React from 'react'; +import { Typeahead } from 'react-bootstrap-typeahead'; + +const options = [ + { name: 'Alabama', population: 4780127, capital: 'Montgomery', region: 'South' }, + { name: 'Alaska', population: 710249, capital: 'Juneau', region: 'West' }, + { name: 'Arizona', population: 6392307, capital: 'Phoenix', region: 'West' }, + { name: 'Arkansas', population: 2915958, capital: 'Little Rock', region: 'South' }, + { name: 'California', population: 37254503, capital: 'Sacramento', region: 'West' }, + { name: 'Colorado', population: 5029324, capital: 'Denver', region: 'West' }, +]; + +class BasicExample extends React.Component { + state = { + multiple: false, + }; + + render() { + const { multiple } = this.state; + + return ( +
+ +
+ ); + } +} diff --git a/types/react-bootstrap-typeahead/tsconfig.json b/types/react-bootstrap-typeahead/tsconfig.json new file mode 100644 index 0000000000..c8b63ad42b --- /dev/null +++ b/types/react-bootstrap-typeahead/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-bootstrap-typeahead-tests.tsx" + ] +} diff --git a/types/react-bootstrap-typeahead/tslint.json b/types/react-bootstrap-typeahead/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-bootstrap-typeahead/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 4598a8778defa4f11fef75819ebe31d6036a467d Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 19 Dec 2017 13:17:35 -0800 Subject: [PATCH 259/298] ionic: Provides its own types (#22304) --- notNeededPackages.json | 6 + types/ionic/index.d.ts | 398 --------------------- types/ionic/ionic-tests.ts | 417 ----------------------- types/ionic/tsconfig.json | 24 -- types/ionic/tslint.json | 79 ----- types/ng-cordova/test/appAvailability.ts | 7 +- 6 files changed, 12 insertions(+), 919 deletions(-) delete mode 100644 types/ionic/index.d.ts delete mode 100644 types/ionic/ionic-tests.ts delete mode 100644 types/ionic/tsconfig.json delete mode 100644 types/ionic/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 38c0a39808..00a05890bd 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -306,6 +306,12 @@ "sourceRepoURL": "https://github.com/inversify/inversify-restify-utils", "asOfVersion": "2.0.0" }, + { + "libraryName": "Ionic", + "typingsPackageName": "ionic", + "sourceRepoURL": "http://ionicframework.com", + "asOfVersion": "3.19.0" + }, { "libraryName": "is-lower-case", "typingsPackageName": "is-lower-case", diff --git a/types/ionic/index.d.ts b/types/ionic/index.d.ts deleted file mode 100644 index 40f7897a9f..0000000000 --- a/types/ionic/index.d.ts +++ /dev/null @@ -1,398 +0,0 @@ -// Type definitions for Ionic -// Project: http://ionicframework.com -// Definitions by: Spencer Williams -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -/// - -interface IonicStatic { - /** - * What Ionic package version is. - */ - version: string; - Platform: { - /** - * Trigger a callback once the device is ready, or immediately - * if the device is already ready. This method can be run from - * anywhere and does not need to be wrapped by any additonal methods. - * When the app is within a WebView (Cordova), it’ll fire - * the callback once the device is ready. If the app is within - * a web browser, it’ll fire the callback after window.load. - * Please remember that Cordova features (Camera, FileSystem, etc) still - * will not work in a web browser. - */ - ready(callback: ()=>any): void; - /** - * Set the grade of the device: ‘a’, ‘b’, or ‘c’. ‘a’ is the best - * (most css features enabled), ‘c’ is the worst. By default, sets the grade - * depending on the current device. - */ - setGrade(grade: string): void; - /** - * Return the current device (given by cordova). - */ - device(): any; - /** - * Check if the platform name provided is detected. - */ - is(platformName: string): boolean; - /** - * Check if we are running within a WebView (such as Cordova). - */ - isWebView(): boolean; - /** - * Whether we are running on iPad. - */ - isIPad(): boolean; - /** - * Whether we are running on iOS. - */ - isIOS(): boolean; - /** - * Whether we are running on Android. - */ - isAndroid(): boolean; - /** - * Whether we are running on Windows Phone. - */ - isWindowsPhone(): boolean; - /** - * The name of the current platform. - */ - platform(): string; - /** - * The version of the current device platform. - */ - version(): number; - /** - * Exit the app. - */ - exitApp(): void; - /** - * Shows or hides the device status bar (in Cordova). Requires cordova plugin add org.apache.cordova.statusbar - */ - showStatusBar(shouldShow: boolean): void; - /** - * Sets whether the app is fullscreen or not (in Cordova). - */ - fullScreen(showFullScreen?: boolean, showStatusBar?: boolean): void; - /** - * Whether the device is ready. - */ - isReady: boolean; - /** - * Whether the device is fullscreen. - */ - isFullScreen: boolean; - /** - * An array of all platforms found. - */ - platforms: Array; - /** - * What grade the current platform is. - */ - grade: string; - }; -} - -declare var ionic: IonicStatic; - -declare module 'ionic' { - export = ionic; -} - -declare namespace ionic { - namespace actionSheet { - interface IonicActionSheetService { - show(options: IonicActionSheetOptions): ()=>void; - } - interface IonicActionSheetButton { - text: string; - } - interface IonicActionSheetOptions { - buttons?: Array; - titleText?: string; - cancelText?: string; - destructiveText?: string; - cancel?: ()=>any; - buttonClicked?: (index: number)=>boolean; - destructiveButtonClicked?: ()=>boolean; - cancelOnStateChange?: boolean; - cssClass?: string; - } - } - namespace backdrop { - interface IonicBackdropService { - retain(): void; - release(): void; - } - } - namespace gestures { - interface IonicGestureService { - on(eventType: string, callback: (e: any)=>any, $element: angular.IAugmentedJQuery, options: any): IonicGesture; - off(gesture: IonicGesture, eventType: string, callback: (e: any)=>any): void; - } - - interface IonicGesture { - element: Element; - enabled: boolean; - options: {stop_browser_behavior: string }; - on(gesture: string, handler: Function): IonicGesture; - off(gesture: string, handler: Function): IonicGesture; - trigger(gesture: string, eventData: any): IonicGesture; - enable(state: boolean): IonicGesture; - } - - } - namespace list { - interface IonicListDelegate { - showReorder(showReorder?: boolean): boolean; - showDelete(showDelete?: boolean): boolean; - canSwipeItems(canSwipeItems?: boolean): boolean; - closeOptionButtons(): void; - $getByHandle(handle: string): IonicListDelegate; - } - } - namespace loading { - interface IonicLoadingService { - show(opts?: IonicLoadingOptions): void; - hide(): void; - } - interface IonicLoadingOptions { - template?: string; - templateUrl?: string; - scope?: any; - noBackdrop?: boolean; - hideOnStateChange?: boolean; - delay?: number; - duration?: number; - } - } - namespace modal { - interface IonicModalService { - fromTemplate(templateString: string, options?: IonicModalOptions): IonicModalController; - fromTemplateUrl(templateUrl: string, options?: IonicModalOptions): angular.IPromise; - } - - interface IonicModalController { - initialize(options: IonicModalOptions): void; - show(): angular.IPromise; - hide(): angular.IPromise; - remove(): angular.IPromise; - isShown(): boolean; - } - - interface IonicModalOptions { - scope?: any; - animation?: string; - focusFirstInput?: boolean; - backdropClickToClose?: boolean; - hardwareBackButtonClose?: boolean; - } - } - namespace navigation { - interface IonicNavBarDelegate { - align(direction?: string): void; - showBackButton(show?: boolean): boolean; - showBar(show?: boolean): boolean; - title(title: string): void; - } - - interface IonicHistoryService { - viewHistory(): any; - - currentView(view?: any): any; - currentHistoryId(): string; - currentTitle(val?: string): string; - - backView(view?: any): any; - backTitle(): string; - - forwardView(view?: any): any; - - currentStateName(): string; - - goBack(backCount?: number): void; - removeBackView(): void; - clearHistory(): void; - clearCache(): angular.IPromise; - nextViewOptions(options: IonicHistoryNextViewOptions): void; - } - interface IonicHistoryNextViewOptions { - disableAnimate?: boolean; - disableBack?: boolean; - historyRoot?: boolean; - } - } - namespace platform { - interface IonicPlatformService { - onHardwareBackButton(callback: Function): void; - offHardwareBackButton(callback: Function): void; - registerBackButtonAction(callback: Function, priority: number, actionId?: any): Function; - on(type: string, callback: Function): Function; - ready(callback?: Function): angular.IPromise; - } - } - namespace popover { - interface IonicPopoverService { - fromTemplate(templateString: string, options: IonicPopoverOptions): IonicPopoverController; - fromTemplateUrl(templateUrl: string, options: IonicPopoverOptions): angular.IPromise; - } - interface IonicPopoverController { - initialize(options: IonicPopoverOptions): void; - show($event?: any): angular.IPromise; - hide(): angular.IPromise; - isShown(): boolean; - remove(): angular.IPromise; - } - interface IonicPopoverOptions { - scope?: any; - focusFirstInput?: boolean; - backdropClickToClose?: boolean; - hardwareBackButtonClose?: boolean; - } - } - namespace popup { - interface IonicPopupService { - show(options: IonicPopupFullOptions): IonicPopupPromise; - alert(options: IonicPopupAlertOptions): IonicPopupPromise; - confirm(options: IonicPopupConfirmOptions): IonicPopupConfirmPromise; - prompt(options: IonicPopupPromptOptions): IonicPopupPromise; - } - - interface IonicPopupConfirmPromise extends angular.IPromise { - close(value?: boolean): void; - } - interface IonicPopupPromise extends angular.IPromise { - close(value?: any): any; - } - interface IonicPopupBaseOptions { - title?: string; - cssClass?: string; - subTitle?: string; - template?: string; - templateUrl?: string; - } - interface IonicPopupFullOptions extends IonicPopupBaseOptions { - scope?: any; - buttons?: Array; - } - interface IonicPopupButton { - text: string; - type?: string; - onTap?(event?: any): void; - } - interface IonicPopupAlertOptions extends IonicPopupBaseOptions { - okText?: string; - okType?: string; - } - interface IonicPopupConfirmOptions extends IonicPopupBaseOptions { - cancelText?: string; - cancelType?: string; - okText?: string; - okType?: string; - } - interface IonicPopupPromptOptions extends IonicPopupBaseOptions { - inputType?: string; - inputPlaceholder?: string; - cancelText?: string; - cancelType?: string; - okText?: string; - okType?: string; - } - } - namespace scroll { - interface IonicScrollDelegate { - resize(): void; - scrollTop(shouldAnimate?: boolean): void; - scrollBottom(shouldAnimate?: boolean): void; - scrollTo(left: number, top: number, shouldAnimate?: boolean): void; - scrollBy(left: number, top: number, shouldAnimate?: boolean): void; - zoomTo(level: number, animate?: boolean, originLeft?: number, originTop?: number): void; - zoomBy(factor: number, animate?: boolean, originLeft?: number, originTop?: number): void; - getScrollPosition(): {left: number; top: number}; - anchorScroll(shouldAnimate?: boolean): void; - freezeScroll(shouldFreeze?: boolean): boolean; - freezeAllScrolls(shouldFreeze?: boolean): boolean; - getScrollView(): any; - $getByHandle(handle: string): IonicScrollDelegate; - } - } - namespace sideMenu { - interface IonicSideMenuDelegate { - toggleLeft(isOpen?: boolean): void; - toggleRight(isOpen?: boolean): void; - getOpenRatio(): number; - isOpen(): boolean; - isOpenLeft(): boolean; - isOpenRight(): boolean; - canDragContent(canDrag?: boolean): boolean; - edgeDragThreshold(value?: boolean|number): boolean; - $getByHandle(handle: string): IonicSideMenuDelegate; - } - } - namespace slideBox { - interface IonicSlideBoxDelegate { - update(): void; - slide(to: number, speed?: number): void; - enableSlide(shouldEnable?: boolean): boolean; - previous(speed?: number): void; - next(speed?: number): void; - stop(): void; - start(): void; - currentIndex(): number; - slidesCount(): number; - $getByHandle(handle: string): IonicSlideBoxDelegate; - } - } - namespace tabs { - interface IonicTabsDelegate { - select(index: number): void; - selectedIndex(): number; - $getByHandle(handle: string): IonicTabsDelegate; - showBar(show?: boolean): boolean; - } - } - namespace utility { - interface IonicConfigProvider { - views: { - transition(transition?: string): string; - maxCache(maxNumber?: number): number; - forwardCache(value?: boolean): boolean; - swipeBackEnabled(value?: boolean): boolean; - }; - scrolling: { - jsScrolling(value?: boolean): boolean; - }; - backButton: { - icon(value?: string): string; - text(value?: string): string; - previousTitleText(value?: boolean): boolean; - }; - form: { - checkbox(value?: string): string; - toggle(value?: string): string; - }; - spinner: { - icon(value?: string): string; - }; - tabs: { - style(value?: string): string; - position(value?: string): string; - }; - templates: { - maxPrefetch(value?: number): number; - }; - navBar: { - alignTitle(value?: string): string; - positionPrimaryButtons(value?: string): string; - positionSecondaryButtons(value?: string): string; - }; - } - interface IonicPositionService { - position(element: any): {top: number; left: number; width: number; height: number}; - offset(element: any): {top: number; left: number; width: number; height: number}; - } - } -} diff --git a/types/ionic/ionic-tests.ts b/types/ionic/ionic-tests.ts deleted file mode 100644 index 89631663d5..0000000000 --- a/types/ionic/ionic-tests.ts +++ /dev/null @@ -1,417 +0,0 @@ - - -var testIonic = angular.module('testIonic', ['ionic']); - -testIonic.config(['$ionicConfigProvider', ($ionicConfigProvider: ionic.utility.IonicConfigProvider)=>{ - var transition: string = $ionicConfigProvider.views.transition(); - $ionicConfigProvider.views.transition("transition"); - var maxCache: number = $ionicConfigProvider.views.maxCache(); - $ionicConfigProvider.views.maxCache(10); - var forwardCache: boolean = $ionicConfigProvider.views.forwardCache(); - $ionicConfigProvider.views.forwardCache(true); - var swipeBackEnabled: boolean = $ionicConfigProvider.views.swipeBackEnabled(); - $ionicConfigProvider.views.swipeBackEnabled(true); - - var jsScrolling: boolean = $ionicConfigProvider.scrolling.jsScrolling(); - $ionicConfigProvider.scrolling.jsScrolling(true); - - var backButtonIcon: string = $ionicConfigProvider.backButton.icon(); - $ionicConfigProvider.backButton.icon("icon"); - var backButtonText: string = $ionicConfigProvider.backButton.text(); - $ionicConfigProvider.backButton.text("back"); - var usePreviousTitleText: boolean = $ionicConfigProvider.backButton.previousTitleText(); - $ionicConfigProvider.backButton.previousTitleText(false); - - var checkbox: string = $ionicConfigProvider.form.checkbox(); - $ionicConfigProvider.form.checkbox("square"); - var toggle: string = $ionicConfigProvider.form.toggle(); - $ionicConfigProvider.form.toggle("small"); - - var spinnerIcon: string = $ionicConfigProvider.spinner.icon(); - $ionicConfigProvider.spinner.icon("spiral"); - - var tabsStyle: string = $ionicConfigProvider.tabs.style(); - $ionicConfigProvider.tabs.style("standard"); - var tabsPosition: string = $ionicConfigProvider.tabs.position(); - $ionicConfigProvider.tabs.position("bottom"); - - var maxPrefetch: number = $ionicConfigProvider.templates.maxPrefetch(); - $ionicConfigProvider.templates.maxPrefetch(10); - - var alignTitle: string = $ionicConfigProvider.navBar.alignTitle(); - $ionicConfigProvider.navBar.alignTitle("platform"); - var positionPrimaryButtons: string = $ionicConfigProvider.navBar.positionPrimaryButtons(); - $ionicConfigProvider.navBar.positionPrimaryButtons("platform"); - var positionSecondaryButtons: string = $ionicConfigProvider.navBar.positionSecondaryButtons(); - $ionicConfigProvider.navBar.positionSecondaryButtons("platform"); -}]) - -class IonicTestController { - public static $inject = [ - '$ionicActionSheet', - '$ionicBackdrop', - '$ionicGesture', - '$ionicListDelegate', - '$ionicLoading', - '$ionicModal', - '$ionicNavBarDelegate', - '$ionicHistory', - '$ionicPlatform', - '$ionicPopover', - '$ionicPopup', - '$ionicScrollDelegate', - '$ionicSideMenuDelegate', - '$ionicSlideBoxDelegate', - '$ionicTabsDelegate', - '$ionicPosition' - ]; - constructor( - private $ionicActionSheet: ionic.actionSheet.IonicActionSheetService, - private $ionicBackdrop: ionic.backdrop.IonicBackdropService, - private $ionicGesture: ionic.gestures.IonicGestureService, - private $ionicListDelegate: ionic.list.IonicListDelegate, - private $ionicLoading: ionic.loading.IonicLoadingService, - private $ionicModal: ionic.modal.IonicModalService, - private $ionicNavBarDelegate: ionic.navigation.IonicNavBarDelegate, - private $ionicHistory: ionic.navigation.IonicHistoryService, - private $ionicPlatform: ionic.platform.IonicPlatformService, - private $ionicPopover: ionic.popover.IonicPopoverService, - private $ionicPopup: ionic.popup.IonicPopupService, - private $ionicScrollDelegate: ionic.scroll.IonicScrollDelegate, - private $ionicSideMenuDelegate: ionic.sideMenu.IonicSideMenuDelegate, - private $ionicSlideBoxDelegate: ionic.slideBox.IonicSlideBoxDelegate, - private $ionicTabsDelegate: ionic.tabs.IonicTabsDelegate, - private $ionicPositionService: ionic.utility.IonicPositionService - ){} - - private testActionSheet(): void { - var closeActionSheetFn: ()=>void = this.$ionicActionSheet.show({ - buttons: [{ text: 'A button' }], - titleText: "titleText", - cancelText: "cancelText", - destructiveText: "destructiveText", - cancel: ()=>{ console.log("cancel"); }, - buttonClicked: (index)=>{ - console.log("buttonClicked"); - return index === 0; - }, - destructiveButtonClicked: ()=>{ - console.log("destructiveButtonClicked"); - return false; - }, - cancelOnStateChange: true, - cssClass: "cssClass" - }); - closeActionSheetFn(); - } - private testBackdrop(): void { - this.$ionicBackdrop.retain(); - this.$ionicBackdrop.release(); - } - private testGesture(): void { - var gesture: ionic.gestures.IonicGesture = this.$ionicGesture.on( - 'eventType', - (e)=>{ return e; }, - angular.element("body"), - {} - ); - this.$ionicGesture.off(gesture, "eventType", (e) => { return e; }); - } - private testList(): void { - this.$ionicListDelegate.showReorder(true); - var showReorder: boolean = this.$ionicListDelegate.showReorder(); - this.$ionicListDelegate.showDelete(true); - var showDelete: boolean = this.$ionicListDelegate.showDelete(); - this.$ionicListDelegate.canSwipeItems(true); - var canSwipeItems: boolean = this.$ionicListDelegate.canSwipeItems(); - this.$ionicListDelegate.closeOptionButtons(); - var foo: ionic.list.IonicListDelegate = this.$ionicListDelegate.$getByHandle("handle"); - } - private testLoading(): void { - this.$ionicLoading.show({ - template: "template", - templateUrl: "templateUrl", - scope: {}, - noBackdrop: false, - hideOnStateChange: true, - delay: 500, - duration: 8000 - }); - this.$ionicLoading.hide(); - } - private testModal(): void { - var modalOptions: ionic.modal.IonicModalOptions = { - scope: {}, - animation: "animation", - focusFirstInput: true, - backdropClickToClose: false, - hardwareBackButtonClose: true - }; - var ionicModalController: ionic.modal.IonicModalController = this.$ionicModal.fromTemplate("template", modalOptions); - ionicModalController.initialize(modalOptions); - ionicModalController.show().then(() => console.log("shown modal")) - ionicModalController.hide().then(() => console.log("hid modal")) - ionicModalController.remove().then(() => console.log("removed modal")) - var isShown: boolean = ionicModalController.isShown(); - - this.$ionicModal.fromTemplateUrl("templateUrl", modalOptions) - .then(modalCtrl => ionicModalController = modalCtrl); - } - private testNavigation(): void { - this.$ionicNavBarDelegate.align("right"); - this.$ionicNavBarDelegate.showBackButton(true); - var isBackButtonShown: boolean = this.$ionicNavBarDelegate.showBackButton(); - this.$ionicNavBarDelegate.showBar(true); - var isBarShown: boolean = this.$ionicNavBarDelegate.showBar(); - this.$ionicNavBarDelegate.title("title"); - - var viewHistory = this.$ionicHistory.viewHistory(); - var currentView = this.$ionicHistory.currentView(); - this.$ionicHistory.currentView({viewId: 1}); - var currentHistoryId: string = this.$ionicHistory.currentHistoryId(); - this.$ionicHistory.currentTitle("currentTitle"); - var currentTitle: string = this.$ionicHistory.currentTitle(); - var backView = this.$ionicHistory.backView(); - this.$ionicHistory.backView({viewId: 1}); - var backTitle: string = this.$ionicHistory.backTitle(); - var forwardView = this.$ionicHistory.forwardView(); - this.$ionicHistory.forwardView({viewId: 1}); - var currentStateName: string = this.$ionicHistory.currentStateName(); - - this.$ionicHistory.goBack(5); - this.$ionicHistory.removeBackView(); - this.$ionicHistory.clearHistory(); - this.$ionicHistory.clearCache().then(() => console.log("done clearing cache!")); - this.$ionicHistory.nextViewOptions({ - disableAnimate: true, - disableBack: true, - historyRoot: true - }); - } - private testPlatform(): void { - var callback: Function = () => console.log("on!"); - this.$ionicPlatform.onHardwareBackButton(callback); - this.$ionicPlatform.offHardwareBackButton(callback); - this.$ionicPlatform.registerBackButtonAction(callback, 1, "actionId"); - this.$ionicPlatform.on("type", callback); - this.$ionicPlatform.ready(callback); - this.$ionicPlatform.ready().then(() => console.log("ready!")); - } - private testPopover(): void { - var popoverOptions: ionic.popover.IonicPopoverOptions = { - scope: {}, - focusFirstInput: true, - backdropClickToClose: false, - hardwareBackButtonClose: true - }; - var ionicPopoverController: ionic.popover.IonicPopoverController = this.$ionicPopover.fromTemplate("template", popoverOptions); - ionicPopoverController.initialize(popoverOptions); - ionicPopoverController.show(angular.element("body")).then(() => console.log("shown popover")); - ionicPopoverController.hide().then(() => console.log("hid popover")); - ionicPopoverController.remove().then(() => console.log("removed popover")); - var isShown: boolean = ionicPopoverController.isShown(); - - this.$ionicPopover.fromTemplateUrl("templateUrl", popoverOptions) - .then(popoverCtrl => ionicPopoverController = popoverCtrl); - } - private testPopup(): void { - this.$ionicPopup.show({ - title: "title", - subTitle: "subTitle", - cssClass: "cssClass", - template: "template", - templateUrl: "templateUrl", - scope: {}, - buttons: [{text: "text", type: "type", onTap: (e) => {console.log(e)}}] - }).then(() => console.log("popover shown")); - this.$ionicPopup.show({ - title: "title", - subTitle: "subTitle", - cssClass: "cssClass", - template: "template", - templateUrl: "templateUrl", - scope: {}, - buttons: [{text: "text", type: "type", onTap: (e) => {console.log(e)}}] - }).close("done"); - - this.$ionicPopup.alert({ - title: "title", - subTitle: "subTitle", - cssClass: "cssClass", - template: "template", - templateUrl: "templateUrl", - okText: "OK", - okType: "okType" - }).then(() => console.log("popover shown")) - this.$ionicPopup.alert({ - title: "title", - subTitle: "subTitle", - cssClass: "cssClass", - template: "template", - templateUrl: "templateUrl", - okText: "OK", - okType: "okType" - }).close(); - - this.$ionicPopup.confirm({ - title: "title", - subTitle: "subTitle", - cssClass: "cssClass", - template: "template", - templateUrl: "templateUrl", - okText: "OK", - okType: "okType", - cancelText: "Cancel", - cancelType: "cancelType" - }).then((result) => console.log(result === true ? "confirmed": "cancelled")) - this.$ionicPopup.confirm({ - title: "title", - subTitle: "subTitle", - cssClass: "cssClass", - template: "template", - templateUrl: "templateUrl", - okText: "OK", - okType: "okType", - cancelText: "Cancel", - cancelType: "cancelType" - }).close(); - - this.$ionicPopup.prompt({ - title: "title", - subTitle: "subTitle", - cssClass: "cssClass", - template: "template", - templateUrl: "templateUrl", - okText: "OK", - okType: "okType", - cancelText: "Cancel", - cancelType: "cancelType", - inputType: "text", - inputPlaceholder: "Type some text..." - }).then(() => console.log("popover shown")) - this.$ionicPopup.prompt({ - title: "title", - subTitle: "subTitle", - cssClass: "cssClass", - template: "template", - templateUrl: "templateUrl", - okText: "OK", - okType: "okType", - cancelText: "Cancel", - cancelType: "cancelType", - inputType: "text", - inputPlaceholder: "Type some text..." - }).close(); - } - - private testScroll(): void { - this.$ionicScrollDelegate.resize(); - this.$ionicScrollDelegate.scrollTop(); - this.$ionicScrollDelegate.scrollTop(true); - this.$ionicScrollDelegate.scrollBottom(); - this.$ionicScrollDelegate.scrollBottom(true); - this.$ionicScrollDelegate.scrollTo(0, 0); - this.$ionicScrollDelegate.scrollTo(0, 0, true); - this.$ionicScrollDelegate.scrollBy(0, 0); - this.$ionicScrollDelegate.scrollBy(0, 0, true); - this.$ionicScrollDelegate.zoomTo(1); - this.$ionicScrollDelegate.zoomTo(1, true); - this.$ionicScrollDelegate.zoomTo(1, true, 0); - this.$ionicScrollDelegate.zoomTo(1, true, 0, 0); - this.$ionicScrollDelegate.zoomBy(0.5); - this.$ionicScrollDelegate.zoomBy(0.5, true); - this.$ionicScrollDelegate.zoomBy(0.5, true, 50); - this.$ionicScrollDelegate.zoomBy(0.5, true, 50, 50); - var {top: number, left: number} = this.$ionicScrollDelegate.getScrollPosition(); - this.$ionicScrollDelegate.anchorScroll(); - this.$ionicScrollDelegate.anchorScroll(true); - var isScrollFrozen: boolean = this.$ionicScrollDelegate.freezeScroll(); - this.$ionicScrollDelegate.freezeScroll(false); - var areAllScrollsFrozen: boolean = this.$ionicScrollDelegate.freezeAllScrolls(); - this.$ionicScrollDelegate.freezeAllScrolls(false); - var scrollView: any = this.$ionicScrollDelegate.getScrollView(); - var scrollDelegate: ionic.scroll.IonicScrollDelegate = this.$ionicScrollDelegate.$getByHandle("handle"); - } - private testSideMenu(): void { - this.$ionicSideMenuDelegate.toggleLeft(); - this.$ionicSideMenuDelegate.toggleLeft(true); - this.$ionicSideMenuDelegate.toggleRight(); - this.$ionicSideMenuDelegate.toggleRight(true); - var openRatio: number = this.$ionicSideMenuDelegate.getOpenRatio(); - var isOpen: boolean = this.$ionicSideMenuDelegate.isOpen(); - var isOpenLeft: boolean = this.$ionicSideMenuDelegate.isOpenLeft(); - var isOpenRight: boolean = this.$ionicSideMenuDelegate.isOpenRight(); - var canDragContent: boolean = this.$ionicSideMenuDelegate.canDragContent(); - this.$ionicSideMenuDelegate.canDragContent(false); - var edgeDragThreshold: boolean = this.$ionicSideMenuDelegate.edgeDragThreshold(); - this.$ionicSideMenuDelegate.edgeDragThreshold(true); - this.$ionicSideMenuDelegate.edgeDragThreshold(500); - var sideMenuDelegate: ionic.sideMenu.IonicSideMenuDelegate = this.$ionicSideMenuDelegate.$getByHandle("handle"); - } - private testSlideBox(): void { - this.$ionicSlideBoxDelegate.update(); - this.$ionicSlideBoxDelegate.slide(1); - this.$ionicSlideBoxDelegate.slide(1, 500); - var isSlideEnabled: boolean = this.$ionicSlideBoxDelegate.enableSlide(); - this.$ionicSlideBoxDelegate.enableSlide(true); - this.$ionicSlideBoxDelegate.previous(); - this.$ionicSlideBoxDelegate.previous(500); - this.$ionicSlideBoxDelegate.next(); - this.$ionicSlideBoxDelegate.next(500); - this.$ionicSlideBoxDelegate.stop(); - this.$ionicSlideBoxDelegate.start(); - var currentIndex: number = this.$ionicSlideBoxDelegate.currentIndex(); - var slidesCount: number = this.$ionicSlideBoxDelegate.slidesCount(); - var slideBoxDelegate: ionic.slideBox.IonicSlideBoxDelegate = this.$ionicSlideBoxDelegate.$getByHandle("handle"); - } - private testTabs(): void { - this.$ionicTabsDelegate.select(1); - var selectedIndex: number = this.$ionicTabsDelegate.selectedIndex(); - var ionicTabsDelegate: ionic.tabs.IonicTabsDelegate = this.$ionicTabsDelegate.$getByHandle("handle"); - this.$ionicTabsDelegate.showBar(true); - var isBarShown: boolean = this.$ionicTabsDelegate.showBar(); - } - private testUtility(): void { - var {top: number, left: number, width: number, height: number} = this.$ionicPositionService.position(angular.element("body")); - var {top: number, left: number, width: number, height: number} = this.$ionicPositionService.offset(angular.element("body")); - } - - /** - * ionic.version - */ - private testStaticVersion(): void { - var version: string = ionic.version; - } - - /** - * ionic.Platform - */ - private testStaticPlaform(): void { - var callbackWithoutReturn: ()=>void; - var callbackWithReturn: ()=>boolean; - var ready: void = ionic.Platform.ready(callbackWithoutReturn); - ready = ionic.Platform.ready(callbackWithReturn); - var setGrade: void = ionic.Platform.setGrade('iOS'); - var deviceInformation: string = ionic.Platform.device(); - var isBrowser: boolean = ionic.Platform.is('browser'); - var isWebView: boolean = ionic.Platform.isWebView(); - var isIPad: boolean = ionic.Platform.isIPad(); - var isIOS: boolean = ionic.Platform.isIOS(); - var isAndroid: boolean = ionic.Platform.isAndroid(); - var isWindowsPhone: boolean = ionic.Platform.isWindowsPhone(); - var currentPlatform: string = ionic.Platform.platform(); - var currentPlatformVersion: number = ionic.Platform.version(); - var exitApp: void = ionic.Platform.exitApp(); - var showStatusBar: void = ionic.Platform.showStatusBar(true); - var showStatusBar: void = ionic.Platform.fullScreen(); - showStatusBar = ionic.Platform.fullScreen(true); - showStatusBar = ionic.Platform.fullScreen(true, true); - var isReady: boolean = ionic.Platform.isReady; - var isFullScreen: boolean = ionic.Platform.isFullScreen; - var platforms: Array = ionic.Platform.platforms; - var grade: string = ionic.Platform.grade; - } -} - -testIonic.controller('ionicTestController', IonicTestController); - diff --git a/types/ionic/tsconfig.json b/types/ionic/tsconfig.json deleted file mode 100644 index 0c0ab4f00c..0000000000 --- a/types/ionic/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "ionic-tests.ts" - ] -} \ No newline at end of file diff --git a/types/ionic/tslint.json b/types/ionic/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/ionic/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} diff --git a/types/ng-cordova/test/appAvailability.ts b/types/ng-cordova/test/appAvailability.ts index 5cb049a76a..6c0391792b 100644 --- a/types/ng-cordova/test/appAvailability.ts +++ b/types/ng-cordova/test/appAvailability.ts @@ -1,7 +1,12 @@ // For the full application demo please see following repo : // https://github.com/ksachdeva/ngCordova-typescript-demo -/// +// Simplified ionic types to avoid needing a dependency on it +declare namespace ionic.platform { + interface IonicPlatformService { + ready(cb: () => void): void; + } +} namespace demo.appavailability { 'use strict'; From 6b733af1fb0f46e49979f54daa8de9bfbad1c06c Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 19 Dec 2017 14:25:32 -0800 Subject: [PATCH 260/298] moment-strftime2: Follow export-just-namespace lint rule (#22199) --- types/moment-strftime2/index.d.ts | 125 ++++++++++++++---------------- 1 file changed, 59 insertions(+), 66 deletions(-) diff --git a/types/moment-strftime2/index.d.ts b/types/moment-strftime2/index.d.ts index 914b175a5b..37edbd13a5 100644 --- a/types/moment-strftime2/index.d.ts +++ b/types/moment-strftime2/index.d.ts @@ -18,71 +18,64 @@ declare module "moment-timezone" { } } -// tslint:disable:export-just-namespace -// because separator has to be read-write - -declare namespace MomentStrftime2 { - interface Modifiers { - "%": string; - A: string; - B: string; - C?: string; - D: string; - E?: string; - F: string; - G?: string; - H: string; - I: string; - J?: string; - K?: string; - L: string; - M: string; - N?: string; - O?: string; - P: string; - Q?: string; - R: string; - S: string; - T: string; - U?: string; - V: string; - W: string; - X?: string; - Y: string; - Z: string; - a: string; - b: string; - c?: string; - d: string; - e: string; - f?: string; - g: string; - h: string; - i?: string; - j: string; - k: string; - l: string; - m: string; - n?: string; - o?: string; - p: string; - q?: string; - r: string; - s: string; - t?: string; - u: string; - v?: string; - w: string; - x?: string; - y: string; - z: string; - } - - let modifiers: Modifiers; - - let separator: string; - - function installTo(moment: object): void; +export interface Modifiers { + "%": string; + A: string; + B: string; + C?: string; + D: string; + E?: string; + F: string; + G?: string; + H: string; + I: string; + J?: string; + K?: string; + L: string; + M: string; + N?: string; + O?: string; + P: string; + Q?: string; + R: string; + S: string; + T: string; + U?: string; + V: string; + W: string; + X?: string; + Y: string; + Z: string; + a: string; + b: string; + c?: string; + d: string; + e: string; + f?: string; + g: string; + h: string; + i?: string; + j: string; + k: string; + l: string; + m: string; + n?: string; + o?: string; + p: string; + q?: string; + r: string; + s: string; + t?: string; + u: string; + v?: string; + w: string; + x?: string; + y: string; + z: string; } -export = MomentStrftime2; +export let modifiers: Modifiers; + +export let separator: string; + +export function installTo(moment: object): void; From 4b925d212f3d5b5b0501b831c0b7a73062d3fd7d Mon Sep 17 00:00:00 2001 From: Jeremy Fauvel Date: Tue, 19 Dec 2017 23:35:40 +0100 Subject: [PATCH 261/298] [react-router] Remove useless definition for `withRouter` as decorator (#21799) * [react-router] Remove useless definition for `withRouter` as decorator * Add regression test --- types/react-router/index.d.ts | 4 +--- types/react-router/test/WithRouter.tsx | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/types/react-router/index.d.ts b/types/react-router/index.d.ts index a46ddeaa5a..cf5efbbb36 100644 --- a/types/react-router/index.d.ts +++ b/types/react-router/index.d.ts @@ -104,11 +104,9 @@ export type Diff = ({ [P in T]: P } & { [P i export type Omit = Pick>; export function matchPath

(pathname: string, props: RouteProps): match

| null; -export function withRouter

>(component: React.ComponentType

): React.ComponentClass>>; -// decorator signature // There is a known issue in TypeScript, which doesn't allow decorators to change the signature of the classes // they are decorating. Due to this, if you are using @withRouter decorator in your code, // you will see a bunch of errors from TypeScript. The current workaround is to use withRouter() as a function call // on a separate line instead of as a decorator. -export function withRouter>(target: TFunction): TFunction; +export function withRouter

>(component: React.ComponentType

): React.ComponentClass>>; diff --git a/types/react-router/test/WithRouter.tsx b/types/react-router/test/WithRouter.tsx index 5d203d8f01..d22225deae 100644 --- a/types/react-router/test/WithRouter.tsx +++ b/types/react-router/test/WithRouter.tsx @@ -2,13 +2,23 @@ import * as React from 'react'; import { withRouter, RouteComponentProps } from 'react-router-dom'; interface TOwnProps extends RouteComponentProps<{}> { - username: string; + username: string; } -const Component = (props: TOwnProps) =>

Welcome {props.username}

; +const ComponentFunction = (props: TOwnProps) => ( +

Welcome {props.username}

+); -const WithRouterComponent = withRouter(Component); +class ComponentClass extends React.Component { + render() { + return

Welcome {this.props.username}

; + } +} -const WithRouterTest = () => (); +const WithRouterComponentFunction = withRouter(ComponentFunction); +const WithRouterComponentClass = withRouter(ComponentClass); -export default WithRouterTest; +const WithRouterTestFunction = () => ( + +); +const WithRouterTestClass = () => ; From 4d35d9e980b71065627aef25d2e010e5d96a5d24 Mon Sep 17 00:00:00 2001 From: HyunSeob Date: Wed, 20 Dec 2017 11:30:45 +0900 Subject: [PATCH 262/298] Add typings for @storybook/addon-backgrounds --- types/storybook__addon-backgrounds/index.d.ts | 17 ++++++++++ .../storybook__addon-backgrounds-tests.tsx | 19 +++++++++++ .../tsconfig.json | 32 +++++++++++++++++++ .../storybook__addon-backgrounds/tslint.json | 1 + 4 files changed, 69 insertions(+) create mode 100644 types/storybook__addon-backgrounds/index.d.ts create mode 100644 types/storybook__addon-backgrounds/storybook__addon-backgrounds-tests.tsx create mode 100644 types/storybook__addon-backgrounds/tsconfig.json create mode 100644 types/storybook__addon-backgrounds/tslint.json diff --git a/types/storybook__addon-backgrounds/index.d.ts b/types/storybook__addon-backgrounds/index.d.ts new file mode 100644 index 0000000000..c76a6d160e --- /dev/null +++ b/types/storybook__addon-backgrounds/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for @storybook/addon-backgrounds 3.2 +// Project: https://github.com/storybooks/storybook +// Definitions by: HyunSeob +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import { StoryDecorator } from '@storybook/react'; + +export interface Background { + name: string; + value: string; + default?: boolean; +} + +declare function backgrounds(backgrounds: Background[]): StoryDecorator; + +export default backgrounds; diff --git a/types/storybook__addon-backgrounds/storybook__addon-backgrounds-tests.tsx b/types/storybook__addon-backgrounds/storybook__addon-backgrounds-tests.tsx new file mode 100644 index 0000000000..d68d9b146a --- /dev/null +++ b/types/storybook__addon-backgrounds/storybook__addon-backgrounds-tests.tsx @@ -0,0 +1,19 @@ +import * as React from 'react'; +import { storiesOf } from '@storybook/react'; +import backgrounds from '@storybook/addon-backgrounds'; + +storiesOf('Text', module) + .addDecorator( + backgrounds([ + { + name: 'white', + value: '#fff', + default: true + }, + { + name: 'black', + value: '#000' + } + ]) + ) + .add('default', () =>

This is just sample.

); diff --git a/types/storybook__addon-backgrounds/tsconfig.json b/types/storybook__addon-backgrounds/tsconfig.json new file mode 100644 index 0000000000..cfc58e4a8c --- /dev/null +++ b/types/storybook__addon-backgrounds/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "paths": { + "@storybook/addon-backgrounds": [ + "storybook__addon-backgrounds" + ], + "@storybook/react": [ + "storybook__react" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "storybook__addon-backgrounds-tests.tsx" + ] +} \ No newline at end of file diff --git a/types/storybook__addon-backgrounds/tslint.json b/types/storybook__addon-backgrounds/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/storybook__addon-backgrounds/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 31ad79f88f711a9169a0adf54734f0bf6bd334d2 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 13:36:22 +0800 Subject: [PATCH 263/298] Add MKComponent Builder property --- types/react-native-material-kit/index.d.ts | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index d9564be179..dfb7317ca6 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for react-native-material-kit 0.4 +// Type definitions for react-native-material-kit 0.5 // Project: https://github.com/xinthink/react-native-material-kit // Definitions by: Kyle Roach +// Tim Wang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -186,6 +187,10 @@ export interface TickProperties extends ViewProperties { // COMPONENTS /////////////////////////////// +export interface MKComponent extends React.Component { + Builder: () => any; +} + export interface MKColorStatic { Amber: string; Blue: string; @@ -374,32 +379,29 @@ export const MKColor: MKColorStatic; export function setTheme(theme: ThemeStatic): void; export function getTheme(): ThemeStatic; -export class MKButton extends React.Component {} +export class MKButton extends MKComponent {} -export class MKTextField extends React.Component {} +export class MKTextField extends MKComponent {} -export class MKSwitch extends React.Component {} +export class MKSwitch extends MKComponent {} -export class MKIconToggle extends - React.Component {} +export class MKIconToggle extends MKComponent {} -export class MKRipple extends React.Component {} +export class MKRipple extends MKComponent {} -export class MKProgress extends React.Component {} +export class MKProgress extends MKComponent {} export namespace MKProgress { class Indeterminate extends React.Component {} } -export class MKSlider extends React.Component {} +export class MKSlider extends MKComponent {} -export class MKRangeSlider extends - React.Component {} +export class MKRangeSlider extends MKComponent {} -export class MKSpinner extends React.Component {} +export class MKSpinner extends MKComponent {} -export class MKRadioButton extends -React.Component {} +export class MKRadioButton extends MKComponent {} export namespace MKRadioButton { class MKRadioButton {} @@ -416,4 +418,4 @@ export namespace MKRadioButton { } } -export class MKCheckbox extends React.Component {} +export class MKCheckbox extends MKComponent {} From 3acd595b9181b81462254385b0ad8cd770596654 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 13:43:17 +0800 Subject: [PATCH 264/298] Add Builder test --- .../react-native-material-kit-tests.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/types/react-native-material-kit/react-native-material-kit-tests.tsx b/types/react-native-material-kit/react-native-material-kit-tests.tsx index e26abfe5fc..5971d397eb 100644 --- a/types/react-native-material-kit/react-native-material-kit-tests.tsx +++ b/types/react-native-material-kit/react-native-material-kit-tests.tsx @@ -27,6 +27,10 @@ const ButtonTest = () => ; +const ButtonBuilderTest = new MKButton.Builder() + .withBackgroundColor(MKColor.Teal) + .build(); + //// TEXT FIELD interface MKTextFieldTestState { From fb0400356cfe4031b1e0c0c6593e6c547e315fb4 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 14:04:49 +0800 Subject: [PATCH 265/298] Fix interface to class --- types/react-native-material-kit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index dfb7317ca6..568b7b6bf4 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -187,7 +187,7 @@ export interface TickProperties extends ViewProperties { // COMPONENTS /////////////////////////////// -export interface MKComponent extends React.Component { +export class MKComponent extends React.Component { Builder: () => any; } From bac30ca0c35d2f7d2ee81d37b102c8928de643c0 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 14:14:35 +0800 Subject: [PATCH 266/298] Update index.d.ts --- types/react-native-material-kit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index 568b7b6bf4..b01b22080a 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -188,7 +188,7 @@ export interface TickProperties extends ViewProperties { /////////////////////////////// export class MKComponent extends React.Component { - Builder: () => any; + Builder(): any; } export interface MKColorStatic { From b40a6ac0473038456a2f6ccffe86e6ae4e205f41 Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 14:20:00 +0800 Subject: [PATCH 267/298] Builder is static --- types/react-native-material-kit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index b01b22080a..e6b15cb9a5 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -188,7 +188,7 @@ export interface TickProperties extends ViewProperties { /////////////////////////////// export class MKComponent extends React.Component { - Builder(): any; + static Builder(): any; } export interface MKColorStatic { From 890cb36547a16dde3adef77d49edc850ab8fd08e Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 14:33:48 +0800 Subject: [PATCH 268/298] Builder return class itself --- types/react-native-material-kit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index e6b15cb9a5..0d38e23271 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -188,7 +188,7 @@ export interface TickProperties extends ViewProperties { /////////////////////////////// export class MKComponent extends React.Component { - static Builder(): any; + static Builder(): MKComponent; } export interface MKColorStatic { From 71f795500c068bd55eb78ad7c52796ab5f24e52a Mon Sep 17 00:00:00 2001 From: Tim Wang Date: Wed, 20 Dec 2017 14:38:28 +0800 Subject: [PATCH 269/298] Let's just call it any Static members cannot reference class type parameters. --- types/react-native-material-kit/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index 0d38e23271..5dc9b63aff 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -188,7 +188,7 @@ export interface TickProperties extends ViewProperties { /////////////////////////////// export class MKComponent extends React.Component { - static Builder(): MKComponent; + static Builder: any; } export interface MKColorStatic { From 80193a219fca86d1a23b00dadbadf9939e4f4c96 Mon Sep 17 00:00:00 2001 From: Gustavo Henke Date: Wed, 20 Dec 2017 22:27:22 +1100 Subject: [PATCH 270/298] react-dnd-test-backend: remove rules --- types/react-dnd-test-backend/tslint.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/types/react-dnd-test-backend/tslint.json b/types/react-dnd-test-backend/tslint.json index 8b04e2b32d..f93cf8562a 100644 --- a/types/react-dnd-test-backend/tslint.json +++ b/types/react-dnd-test-backend/tslint.json @@ -1,6 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "quotemark": [true, "double"] - } + "extends": "dtslint/dt.json" } From 951ad3283edbc6a2dfcfc4882194ab8347e66303 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 06:56:13 -0800 Subject: [PATCH 271/298] axios-mock-adapter: Provides its own types (#22319) --- notNeededPackages.json | 6 + .../axios-mock-adapter-tests.ts | 113 ------------------ types/axios-mock-adapter/index.d.ts | 51 -------- types/axios-mock-adapter/package.json | 6 - types/axios-mock-adapter/tsconfig.json | 23 ---- types/axios-mock-adapter/tslint.json | 6 - 6 files changed, 6 insertions(+), 199 deletions(-) delete mode 100644 types/axios-mock-adapter/axios-mock-adapter-tests.ts delete mode 100644 types/axios-mock-adapter/index.d.ts delete mode 100644 types/axios-mock-adapter/package.json delete mode 100644 types/axios-mock-adapter/tsconfig.json delete mode 100644 types/axios-mock-adapter/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 00a05890bd..6ccb1e961f 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -84,6 +84,12 @@ "sourceRepoURL": "https://github.com/mzabriskie/axios", "asOfVersion": "0.14.0" }, + { + "libraryName": "axios-mock-adapter", + "typingsPackageName": "axios-mock-adapter", + "sourceRepoURL": "https://github.com/ctimmerm/axios-mock-adapter", + "asOfVersion": "1.10.0" + }, { "libraryName": "azure-mobile-apps", "typingsPackageName": "azure-mobile-apps", diff --git a/types/axios-mock-adapter/axios-mock-adapter-tests.ts b/types/axios-mock-adapter/axios-mock-adapter-tests.ts deleted file mode 100644 index 83fb345cd0..0000000000 --- a/types/axios-mock-adapter/axios-mock-adapter-tests.ts +++ /dev/null @@ -1,113 +0,0 @@ -import axios from "axios"; -import MockAdapter = require("axios-mock-adapter"); - -const instance = axios.create(); -const mock = new MockAdapter(instance); - -namespace AllowsConstructing { - new MockAdapter(instance); -} - -namespace AllowsConstructingWithOptions { - new MockAdapter(instance, { - delayResponse: 2000, - }); -} - -namespace ExposesAdapter { - mock.adapter(); -} - -namespace SupportsReset { - mock.reset(); -} - -namespace SupportsRestore { - mock.restore(); -} - -namespace SupportsAllHttpVerbs { - mock.onGet; - mock.onPost; - mock.onPut; - mock.onHead; - mock.onDelete; - mock.onPatch; -} - -namespace SupportsAnyVerb { - mock.onAny; -} - -namespace AllowsVerbOnlyMatcher { - mock.onGet(); -} - -namespace AllowsUrlMatcher { - mock.onGet("/foo"); -} - -namespace AllowsUrlRegExpMatcher { - mock.onGet(/\/fo+/); -} - -namespace AllowsStringBodyMatcher { - mock.onPatch("/foo", "bar"); -} - -namespace AllowsBodyMatcher { - mock.onGet("/foo", { - id: 4, - name: "foo", - }); -} - -namespace AllowsParameterMatcher { - mock.onGet("/foo", { - params: { - searchText: "John", - }, - }); -} - -namespace AllowsReplyWithStatus { - mock.onGet().reply(200); -} - -namespace SupportsReplyOnce { - mock.onGet().replyOnce(200); -} - -namespace SupportsPassThrough { - mock.onGet().passThrough(); -} - -namespace SupportsTimeout { - mock.onGet().timeout(); -} - -namespace AllowsFunctionReply { - mock.onGet().reply((config) => { - return [ - 200, - { data: "foo" }, - { RequestedURL: config.url }, - ]; - }); -} - -namespace AllowsPromiseReply { - mock.onGet().reply((config) => { - return Promise.resolve([ - 200, - { data: "bar" }, - { RequestedURL: config.url }, - ]); - }); -} - -namespace SupportsChanining { - mock - .onGet("/users").reply(200, [/* users */]) - .onGet("/posts").reply(200, [/* posts */]); -} diff --git a/types/axios-mock-adapter/index.d.ts b/types/axios-mock-adapter/index.d.ts deleted file mode 100644 index dbc37f1b80..0000000000 --- a/types/axios-mock-adapter/index.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -// Type definitions for axios-mock-adapter 1.9 -// Project: https://github.com/ctimmerm/axios-mock-adapter -// Definitions by: Tomasz Kryskiewicz -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version 2.1 - -import { AxiosAdapter, AxiosInstance, AxiosRequestConfig } from "axios"; - -type CallbackResponseSpecFunc = (config: AxiosRequestConfig) => any[] | Promise; - -type ResponseSpecFunc = (statusOrCallback: number | CallbackResponseSpecFunc, data?: any, headers?: any) => MockAdapter; - -interface RequestHandler { - reply: ResponseSpecFunc; - replyOnce: ResponseSpecFunc; - - passThrough(): void; - networkError(): void; - timeout(): void; -} - -interface MockAdapterOptions { - delayResponse?: number; -} - -interface RequestDataMatcher { - [index: string]: any; - params?: { - [index: string]: any, - }; -} - -type RequestMatcherFunc = (matcher?: string | RegExp, body?: string | RequestDataMatcher) => RequestHandler; - -declare class MockAdapter { - constructor(axiosInstance: AxiosInstance, options?: MockAdapterOptions); - - adapter(): AxiosAdapter; - reset(): void; - restore(): void; - - onGet: RequestMatcherFunc; - onPost: RequestMatcherFunc; - onPut: RequestMatcherFunc; - onHead: RequestMatcherFunc; - onDelete: RequestMatcherFunc; - onPatch: RequestMatcherFunc; - onAny: RequestMatcherFunc; -} - -export = MockAdapter; diff --git a/types/axios-mock-adapter/package.json b/types/axios-mock-adapter/package.json deleted file mode 100644 index bd5a40b16d..0000000000 --- a/types/axios-mock-adapter/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "dependencies": { - "axios": "^0.16.2" - } -} diff --git a/types/axios-mock-adapter/tsconfig.json b/types/axios-mock-adapter/tsconfig.json deleted file mode 100644 index 0de216c230..0000000000 --- a/types/axios-mock-adapter/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": "../", - "types": [], - "typeRoots": [ - "../" - ], - "module": "commonjs", - "lib": [ - "es6" - ], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true - }, - "files": [ - "index.d.ts", - "axios-mock-adapter-tests.ts" - ] -} \ No newline at end of file diff --git a/types/axios-mock-adapter/tslint.json b/types/axios-mock-adapter/tslint.json deleted file mode 100644 index 1f85ae1a3b..0000000000 --- a/types/axios-mock-adapter/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "no-namespace": false - } -} From 512edca0d2546308187173ddcc8dc1fb9ca521d7 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 06:58:18 -0800 Subject: [PATCH 272/298] aurelia-knockout: Provides its own types (#22318) --- notNeededPackages.json | 6 +++++ .../aurelia-knockout-tests.ts | 9 ------- types/aurelia-knockout/index.d.ts | 18 -------------- types/aurelia-knockout/tsconfig.json | 24 ------------------- types/aurelia-knockout/tslint.json | 1 - 5 files changed, 6 insertions(+), 52 deletions(-) delete mode 100644 types/aurelia-knockout/aurelia-knockout-tests.ts delete mode 100644 types/aurelia-knockout/index.d.ts delete mode 100644 types/aurelia-knockout/tsconfig.json delete mode 100644 types/aurelia-knockout/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 6ccb1e961f..cab0815f31 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -60,6 +60,12 @@ "sourceRepoURL": "https://github.com/AlexTeixeira/Askmethat-Rating", "asOfVersion": "0.4.0" }, + { + "libraryName": "aurelia-knockout", + "typingsPackageName": "aurelia-knockout", + "sourceRepoURL": "https://github.com/code-chris/aurelia-knockout", + "asOfVersion": "2.1.0" + }, { "libraryName": "autobind-decorator", "typingsPackageName": "autobind-decorator", diff --git a/types/aurelia-knockout/aurelia-knockout-tests.ts b/types/aurelia-knockout/aurelia-knockout-tests.ts deleted file mode 100644 index cf769d0dc2..0000000000 --- a/types/aurelia-knockout/aurelia-knockout-tests.ts +++ /dev/null @@ -1,9 +0,0 @@ -export class ViewModel { - constructor(private knockoutBindable: KnockoutBindable) { - } - - activate(settings: any): void { - this.knockoutBindable.applyBindableValues(settings, this); - this.knockoutBindable.applyBindableValues(settings, this, true); - } -} diff --git a/types/aurelia-knockout/index.d.ts b/types/aurelia-knockout/index.d.ts deleted file mode 100644 index 6f04567a5f..0000000000 --- a/types/aurelia-knockout/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Type definitions for aurelia-knockout 2.0 -// Project: https://github.com/code-chris/aurelia-knockout -// Definitions by: Christian Kotzbauer -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface KnockoutBindable { - /** - * Applys all values from a data object (usually the activation data) to the corresponding instance fields - * in the current view model if they are marked as @bindable. By default all matching values from the data object - * are applied. To only apply observable values set the last parameter to `true`. Subscriptions are created - * for all Knockout observables in the data object to update the view-model values respectively. - * - * @param data - the data object - * @param target - the target view model - * @param applyOnlyObservables - `true` if only observable values should be applied, false by default. - */ - applyBindableValues(data: any, target: any, applyOnlyObservables?: boolean): void; -} diff --git a/types/aurelia-knockout/tsconfig.json b/types/aurelia-knockout/tsconfig.json deleted file mode 100644 index ceb4710331..0000000000 --- a/types/aurelia-knockout/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "aurelia-knockout-tests.ts" - ] -} \ No newline at end of file diff --git a/types/aurelia-knockout/tslint.json b/types/aurelia-knockout/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/aurelia-knockout/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } From fb63b47f076ca1776ce94addfd884c571cb5d875 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 06:58:32 -0800 Subject: [PATCH 273/298] extended-listbox: Provides its own types (#22323) --- notNeededPackages.json | 6 + .../extended-listbox-tests.ts | 134 ----------------- types/extended-listbox/index.d.ts | 141 ------------------ types/extended-listbox/tsconfig.json | 24 --- types/extended-listbox/tslint.json | 79 ---------- 5 files changed, 6 insertions(+), 378 deletions(-) delete mode 100644 types/extended-listbox/extended-listbox-tests.ts delete mode 100644 types/extended-listbox/index.d.ts delete mode 100644 types/extended-listbox/tsconfig.json delete mode 100644 types/extended-listbox/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index cab0815f31..51367512db 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -234,6 +234,12 @@ "sourceRepoURL": "https://github.com/ctavan/express-validator", "asOfVersion": "3.0.0" }, + { + "libraryName": "extended-listbox", + "typingsPackageName": "extended-listbox", + "sourceRepoURL": "https://github.com/code-chris/extended-listbox", + "asOfVersion": "4.0.1" + }, { "libraryName": "JSON-Patch", "typingsPackageName": "fast-json-patch", diff --git a/types/extended-listbox/extended-listbox-tests.ts b/types/extended-listbox/extended-listbox-tests.ts deleted file mode 100644 index 571a455300..0000000000 --- a/types/extended-listbox/extended-listbox-tests.ts +++ /dev/null @@ -1,134 +0,0 @@ -const testElement: HTMLElement = document.getElementById("test"); - -// Create Listbox with defaults -let instance: SingleSelectListBox = new SingleSelectListBox(testElement); -instance = new MultiSelectListBox(testElement); - - -// Create with options -let settings = {}; -settings.searchBar = false; -settings.searchBarWatermark = "Search"; -settings.searchBarButton = { icon: "fa fa-search", visible: true, onClick: function () { alert(); } }; -settings.getItems = (): (string|ListBoxItem)[] => { - return ["Test1"]; -}; -settings.onItemsChanged = (event: ListBoxEvent): void => { - console.log(event.eventName); - console.log(event.args); - console.log(event.target); -}; -settings.onFilterChanged = (event: ListBoxEvent): void => { - console.log(event.args); -}; -settings.onValueChanged = (event: ListBoxEvent): void => { - console.log(event.args); -}; -settings.onItemDoubleClicked = (event: ListBoxEvent): void => { - console.log(event.args); -}; -settings.onItemEnterPressed = (event: ListBoxEvent): void => { - console.log(event.args); -}; - -instance = new SingleSelectListBox(testElement, settings); -instance = new MultiSelectListBox(testElement, settings); - - -/////// NEW API /////// - -// Add string item -var id: string = instance.addItem("Test2"); - - -// Add item -var item: ListBoxItem = {}; -item.selected = true; -item.disabled = false; -item.childItems = [{ text: "Test4" }]; -item.groupHeader = false; -item.id = "ouetioreit"; -item.index = 0; -item.text = "Test3"; -id = instance.addItem(item); - - -// Add string items -var ids: string[] = instance.addItems(["Test2", "Test1"]); - - -// Remove item -instance.removeItem(id); - - -// Remove items -instance.removeItems([id, ids[0]]); - - -// Get item -var i: ListBoxItem = instance.getItem(id); - - -// Get items -var allItems: ListBoxItem[] = instance.getItems(); - -// Get selected items -var allItems: ListBoxItem[] = instance.getSelection(); - - -// Move item up -var newIndex: number = instance.moveItemUp(i.id); - - -// Move item down -newIndex = instance.moveItemDown(i.id); - - -// Move item to top -var newIndex: number = instance.moveItemToTop(i.id); - - -// Move item to bottom -newIndex = instance.moveItemToBottom(i.id); - - -// Clear selection -instance.clearSelection(); - - -// Enable -instance.enable(false); - - -// Destroy -instance.destroy(); - - -// onValueChanged -settings.onValueChanged = (event: ListBoxEvent) => { - console.log(event.args); -}; - - -// onItemsChanged -settings.onItemsChanged = (event: ListBoxEvent) => { - console.log(event.args); -}; - - -// onFilterChanged -settings.onFilterChanged = (event: ListBoxEvent) => { - console.log(event.args); -}; - - -// onItemEnterPressed -settings.onItemEnterPressed = (event: ListBoxEvent) => { - console.log(event.args); -}; - - -// onItemDoubleClicked -settings.onItemDoubleClicked = (event: ListBoxEvent) => { - console.log(event.args); -}; diff --git a/types/extended-listbox/index.d.ts b/types/extended-listbox/index.d.ts deleted file mode 100644 index 5d6e7822d5..0000000000 --- a/types/extended-listbox/index.d.ts +++ /dev/null @@ -1,141 +0,0 @@ -// Type definitions for extended-listbox 4.0.x -// Project: https://github.com/code-chris/extended-listbox -// Definitions by: Christian Kotzbauer -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface ListBoxItem { - /** display text */ - text?: string; - - /** unique identifier, if not set it will be generated */ - id?: string; - - /** index position from the item in the list; only used for manual addItem api calls */ - index?: number; - - /** determines if the item should be clickable */ - disabled?: boolean; - - /** determines if the item is selected */ - selected?: boolean; - - /** determines if the item has childItems */ - groupHeader?: boolean; - - /** display text or id of the parent; only used for manual addItem api calls */ - parentGroupId?: string; - - /** list of childItems */ - childItems?: (string | ListBoxItem)[]; -} - -interface ListBoxSearchBarButtonOptions { - /** determines if the button is visible */ - visible?: boolean; - - /** css class for the i-tag of the button */ - icon?: string; - - /** callback for button click */ - onClick?: () => void; -} - -interface ListBoxSettings { - /** determines if the searchBar is visible */ - searchBar?: boolean; - - /** watermark (placeholder) for the searchBar */ - searchBarWatermark?: string; - - /** settings for the searchBar button */ - searchBarButton?: ListBoxSearchBarButtonOptions; - - /** function which returns a array of items */ - getItems?: () => (string | ListBoxItem)[]; - - /** callback for selection changes */ - onValueChanged?: (event: ListBoxEvent) => void; - - /** callback for searchBar text changes */ - onFilterChanged?: (event: ListBoxEvent) => void; - - /** callback for item changes (item added, item removed, item order) */ - onItemsChanged?: (event: ListBoxEvent) => void; - - /** callback for enter keyPress event on an item */ - onItemEnterPressed?: (event: ListBoxEvent) => void; - - /** callback for doubleClick event on an item */ - onItemDoubleClicked?: (event: ListBoxEvent) => void; -} - -interface ListBoxEvent { - /** unique event name */ - eventName: string; - - /** target object for which event is triggered */ - target: Element; - - /** any object */ - args: any; -} - -interface BaseListBox { - /** Adds a new item to the list */ - addItem(item: string | ListBoxItem): string; - - /** Adds new items to the list */ - addItems(items: (string | ListBoxItem)[]): string[]; - - /** Removes a item from the list */ - removeItem(identifier: string): void; - - /** Removes items from the list */ - removeItems(identifiers: string[]): void; - - /** Reverts all changes from the DOM */ - destroy(): void; - - /** Resets the selection state of all items */ - clearSelection(): void; - - /** Returns a item object for the given id or display text */ - getItem(identifier: string): ListBoxItem; - - /** Returns all item objects */ - getItems(): ListBoxItem[]; - - /** Decreases the index of the matching item by one */ - moveItemUp(identifier: string): number; - - /** Increases the index of the matching item by one */ - moveItemDown(identifier: string): number; - - /** Moves item to the bottom of the list */ - moveItemToBottom(identifier: string): number; - - /** Moves item to the top of the list */ - moveItemToTop(identifier: string): number; - - /** Enables or disables the whole list and all childs */ - enable(state: boolean): void; - - /** Returns all ListBoxItem's which are selected */ - getSelection(): ListBoxItem[]; -} - -interface SingleSelectListBox extends BaseListBox { -} - -interface MultiSelectListBox extends BaseListBox { -} - -declare var SingleSelectListBox: { - prototype: SingleSelectListBox; - new(domElement: HTMLElement, options?: ListBoxSettings): SingleSelectListBox; -}; - -declare var MultiSelectListBox: { - prototype: MultiSelectListBox; - new(domElement: HTMLElement, options?: ListBoxSettings): MultiSelectListBox; -}; diff --git a/types/extended-listbox/tsconfig.json b/types/extended-listbox/tsconfig.json deleted file mode 100644 index 38eda11579..0000000000 --- a/types/extended-listbox/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "extended-listbox-tests.ts" - ] -} \ No newline at end of file diff --git a/types/extended-listbox/tslint.json b/types/extended-listbox/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/extended-listbox/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From d8fdd44cefac42fd94f16e5ac38c4f03096fed7d Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 07:01:42 -0800 Subject: [PATCH 274/298] phonegap-plugin-push: Provides its own types (#22325) --- notNeededPackages.json | 6 + types/phonegap-plugin-push/index.d.ts | 326 ------------------ .../phonegap-plugin-push-tests.ts | 128 ------- types/phonegap-plugin-push/tsconfig.json | 24 -- types/phonegap-plugin-push/tslint.json | 79 ----- 5 files changed, 6 insertions(+), 557 deletions(-) delete mode 100644 types/phonegap-plugin-push/index.d.ts delete mode 100644 types/phonegap-plugin-push/phonegap-plugin-push-tests.ts delete mode 100644 types/phonegap-plugin-push/tsconfig.json delete mode 100644 types/phonegap-plugin-push/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 51367512db..ce5c997b8e 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -540,6 +540,12 @@ "sourceRepoURL": "https://github.com/vitaly-t/pg-promise", "asOfVersion": "5.4.3" }, + { + "libraryName": "phonegap-plugin-push", + "typingsPackageName": "phonegap-plugin-push", + "sourceRepoURL": "https://github.com/phonegap/phonegap-plugin-push", + "asOfVersion": "2.1.2" + }, { "libraryName": "pixi-spine", "typingsPackageName": "pixi-spine", diff --git a/types/phonegap-plugin-push/index.d.ts b/types/phonegap-plugin-push/index.d.ts deleted file mode 100644 index 1f0e7c52f9..0000000000 --- a/types/phonegap-plugin-push/index.d.ts +++ /dev/null @@ -1,326 +0,0 @@ -// Type definitions for phonegap-plugin-push v2.0.0 -// Project: https://github.com/phonegap/phonegap-plugin-push -// Definitions by: Frederico Galvão , Larry Bahr -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace PhonegapPluginPush -{ - type EventResponse = RegistrationEventResponse | NotificationEventResponse | Error; - - interface PushNotification - { - /** - * The event registration will be triggered on each successful registration with the 3rd party push service. - * @param event - * @param callback - */ - on(event: "registration", callback: (response: RegistrationEventResponse) => any): void; - /** - * The event notification will be triggered each time a push notification is received by a 3rd party push service on the device. - * @param event - * @param callback - */ - on(event: "notification", callback: (response: NotificationEventResponse) => any): void; - /** - * The event error will trigger when an internal error occurs and the cache is aborted. - * @param event - * @param callback - */ - on(event: "error", callback: (response: Error) => any): void; - /** - * - * @param event Name of the event to listen to. See below(above) for all the event names. - * @param callback is called when the event is triggered. - * @param event - * @param callback - */ - on(event: string, callback: (response: EventResponse) => any): void; - - off(event: "registration", callback: (response: RegistrationEventResponse) => any): void; - off(event: "notification", callback: (response: NotificationEventResponse) => any): void; - off(event: "error", callback: (response: Error) => any): void; - /** - * As stated in the example, you will have to store your event handler if you are planning to remove it. - * @param event Name of the event type. The possible event names are the same as for the push.on function. - * @param callback handle to the function to get removed. - * @param event - * @param callback - */ - off(event: string, callback: (response: EventResponse) => any): void; - - /** - * The unregister method is used when the application no longer wants to receive push notifications. - * Beware that this cleans up all event handlers previously registered, - * so you will need to re-register them if you want them to function again without an application reload. - * @param successHandler - * @param errorHandler - * @param topics - */ - unregister(successHandler: () => any, errorHandler?: () => any, topics?: string[]): void; - - /** - * The subscribe method is used when the application wants to subscribe a new topic to receive push notifications. - * @param topic Topic to subscribe to. - * @param successHandler Is called when the api successfully unregisters. - * @param errorHandler Is called when the api encounters an error while unregistering. - */ - subscribe(topic: string, successHandler: () => any, errorHandler: () => any): void; - - /** - * The unsubscribe method is used when the application no longer wants to receive push notifications - * from a specific topic but continue to receive other push messages. - * @param topic Topic to unsubscribe from. - * @param successHandler Is called when the api successfully unregisters. - * @param errorHandler Is called when the api encounters an error while unregistering. - */ - unsubscribe(topic: string, successHandler: () => any, errorHandler: () => any): void; - - /*TODO according to js source code, "errorHandler" is optional, but is "count" also optional? I can't read objetive-C code (can anyone at all? I wonder...)*/ - /** - * Set the badge count visible when the app is not running - * - * The count is an integer indicating what number should show up in the badge. - * Passing 0 will clear the badge. - * Each notification event contains a data.count value which can be used to set the badge to correct number. - * @param successHandler - * @param errorHandler - * @param count - */ - setApplicationIconBadgeNumber(successHandler: () => any, errorHandler: () => any, count: number): void; - - /** - * Get the current badge count visible when the app is not running - * successHandler gets called with an integer which is the current badge count - * @param successHandler - * @param errorHandler - */ - getApplicationIconBadgeNumber(successHandler: (count: number) => any, errorHandler: () => any): void; - - /** - * iOS only - * Tells the OS that you are done processing a background push notification. - * successHandler gets called when background push processing is successfully completed. - * @param successHandler - * @param errorHandler - * @param id - */ - finish(successHandler?: () => any, errorHandler?: () => any, id?: string): void; - - /** - * Tells the OS to clear all notifications from the Notification Center - * @param successHandler Is called when the api successfully clears the notifications. - * @param errorHandler Is called when the api encounters an error when attempting to clears the notifications. - */ - clearAllNotifications(successHandler: () => any, errorHandler: () => any): void; - } - - /** - * platform specific initialization options. - */ - interface InitOptions - { - /** - * Android specific initialization options. - */ - android?: { - /** - * Maps to the project number in the Google Developer Console. - */ - senderID: string; - /** - * The name of a drawable resource to use as the small-icon. The name should not include the extension. - */ - icon?: string; - /** - * Sets the background color of the small icon on Android 5.0 and greater. - * Supported Formats - http://developer.android.com/reference/android/graphics/Color.html#parseColor(java.lang.String) - */ - iconColor?: string; - /** - * If true it plays the sound specified in the push data or the default system sound. Default is true. - */ - sound?: boolean; - /** - * If true the device vibrates on receipt of notification. Default is true. - */ - vibrate?: boolean; - /** - * If true the app clears all pending notifications when it is closed. Default is true. - */ - clearNotifications?: boolean; - /** - * If true will always show a notification, even when the app is on the foreground. Default is false. - */ - forceShow?: boolean; - /** - * If the array contains one or more strings each string will be used to subscribe to a GcmPubSub topic. - */ - topics?: string[]; - } - - /** - * iOS specific initialization options. - */ - ios?: { - /** - * If true|"true" the device sets the badge number on receipt of notification. - * Default is false|"false". - * Note: the value you set this option to the first time you call the init method will be how the application always acts. - * Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>App Name. - * This is normal iOS behaviour. - */ - badge?: boolean | string; - /** - * If true|"true" the device plays a sound on receipt of notification. - * Default is false|"false". - * Note: the value you set this option to the first time you call the init method will be how the application always acts. - * Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>App Name. - * This is normal iOS behaviour. - */ - sound?: boolean | string; - /** - * If true|"true" the device shows an alert on receipt of notification. - * Default is false|"false". - * Note: the value you set this option to the first time you call the init method will be how the application always acts. - * Once this is set programmatically in the init method it can only be changed manually by the user in Settings>Notifications>App Name. - * This is normal iOS behaviour. - */ - alert?: boolean | string; - /** - * If true|"true" the badge will be cleared on app startup. Default is false|"false". - */ - clearBadge?: boolean | string; - /** - * The data required in order to enable Action Buttons for iOS. - * Action Buttons on iOS - https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/PAYLOAD.md#action-buttons-1 - */ - categories?: CategoryArray; - /** - * Maps to the project number in the Google Developer Console. Setting this uses GCM for notifications instead of native - */ - senderID?: string; - /** - * Whether to use prod or sandbox GCM setting. Defaults to false. - */ - gcmSandbox?: boolean; - /** - * If the array contains one or more strings each string will be used to subscribe to a GcmPubSub topic. Note: only usable in conjunction with senderID - */ - topics?: string[]; - } - - /** - * Windows specific initialization options. - */ - windows?: { - - } - } - - interface CategoryArray - { - [name: string]: CategoryAction; - } - - interface CategoryAction - { - yes?: CategoryActionData; - no?: CategoryActionData; - maybe?: CategoryActionData; - } - - interface CategoryActionData - { - callback: string; - title: string; - foreground: boolean; - destructive: boolean; - } - - interface HasPermissionCallbackParameters - { - isEnabled: boolean; /** Whether the permission for push notifications has been granted. */ - } - - interface RegistrationEventResponse - { - /** - * The registration ID provided by the 3rd party remote push service. - */ - registrationId: string; - } - - interface NotificationEventResponse - { - /** - * The text of the push message sent from the 3rd party service. - */ - message: string; - /** - * The optional title of the push message sent from the 3rd party service. - */ - title?: string; - /** - * The number of messages to be displayed in the badge iOS or message count in the notification shade in Android. - * For windows, it represents the value in the badge notification which could be a number or a status glyph. - */ - count: string; - /** - * The name of the sound file to be played upon receipt of the notification. - */ - sound: string; - /** - * The path of the image file to be displayed in the notification. - */ - image: string; - /** - * An optional collection of data sent by the 3rd party push service that does not fit in the above properties. - */ - additionalData: NotificationEventAdditionalData; - } - - /** - * TODO: document all possible properties (I only got the android ones) - * - * Loosened up with a dictionary notation, but all non-defined properties need to use (map['prop']) notation - * - * Ideally the developer would overload (merged declaration) this or create a new interface that would extend this one - * so that he could specify any custom code without having to use array notation (map['prop']) for all of them. - */ - interface NotificationEventAdditionalData - { - [name: string]: any; - - /** - * Whether the notification was received while the app was in the foreground - */ - foreground?: boolean; - /** - * Will be true if the application is started by clicking on the push notification, false if the app is already started. (Android/iOS only) - */ - coldstart?: boolean; - collapse_key?: string; - from?: string; - notId?: string; - } - - interface PushNotificationStatic { - init(options: InitOptions): PushNotification; - - /** - * Android & iOS only - * Checks whether the push notification permission has been granted. - * @param successHandler - Is called when the api successfully retrieves the details on the permission. - * @param errorHandler - * @param id - */ - hasPermission(successhandler: (data: HasPermissionCallbackParameters) => any): void; - } -} - -interface Window -{ - PushNotification: PhonegapPluginPush.PushNotificationStatic; -} - -declare var PushNotification: PhonegapPluginPush.PushNotificationStatic; diff --git a/types/phonegap-plugin-push/phonegap-plugin-push-tests.ts b/types/phonegap-plugin-push/phonegap-plugin-push-tests.ts deleted file mode 100644 index 36cfb2e444..0000000000 --- a/types/phonegap-plugin-push/phonegap-plugin-push-tests.ts +++ /dev/null @@ -1,128 +0,0 @@ - - -function test() { - let options: PhonegapPluginPush.InitOptions = { - android: { - senderID: '123456789', - icon: 'phonegap', - iconColor: 'blue', - sound: true, - vibrate: true, - clearNotifications: false, - forceShow: true, - topics: ['foo', 'bar'] - }, - ios: { - badge: true, - sound: true, - alert: true, - clearBadge: true, - senderID: '123456789', - gcmSandbox: true, - categories: { - "invite": { - yes: { - callback: "app.accept", title: "Accept", foreground: true, destructive: false - }, - no: { - callback: "app.reject", title: "Reject", foreground: true, destructive: false - }, - maybe: { - callback: "app.maybe", title: "Maybe", foreground: true, destructive: false - } - }, - "delete": { - yes: { - callback: "app.doDelete", title: "Delete", foreground: true, destructive: true - }, - no: { - callback: "app.cancel", title: "Cancel", foreground: true, destructive: false - } - } - }, - topics: ['foo', 'bar'] - }, - windows: {} - }; - - let iosStringOptions = { - badge: 'true', - sound: 'true', - alert: 'true', - clearBadge: 'true' - }; - - options.ios = iosStringOptions; - - let push: PhonegapPluginPush.PushNotification; - - push.unregister(() => { - console.log('did unregister'); - }, () => { - console.log('did not unregister'); - }, ['foo','bar']); - - /*from init*/ - push = PushNotification.init(options); - push = window.PushNotification.init(options); - - /*hasPermission test*/ - PushNotification.hasPermission(function(data) { - if (data.isEnabled) { - console.log('isEnabled'); - } - }); - - let registrationHandler = (data: PhonegapPluginPush.RegistrationEventResponse) => { - console.log(data.registrationId); - }; - - let notificationHandler = (data: PhonegapPluginPush.NotificationEventResponse) => { - console.log(data.message); - console.log(data.title); - console.log(data.count); - console.log(data.sound); - console.log(data.image); - - /*the rest of the additional fields are not 'canon'*/ - console.log(data.additionalData); - console.log(data.additionalData.foreground); - console.log(data.additionalData.coldstart); - - push.finish(() => { - console.log('did finish'); - }, () => { - console.log('did not finish'); - }, 'push-1'); - }; - - let errorHandler = (e: Error) => { - console.log(e.message); - }; - - push.on('registration', registrationHandler); - push.on('notification', notificationHandler); - push.on('error', errorHandler); - - push.off('registration', registrationHandler); - push.off('notification', notificationHandler); - push.off('error', errorHandler); - - push.setApplicationIconBadgeNumber(() => { - console.log('did setApplicationIconBadgeNumber'); - }, () => { - console.log('did not setApplicationIconBadgeNumber'); - }, 1); - - push.getApplicationIconBadgeNumber((count: number) => { - console.log('did getApplicationIconBadgeNumber', count); - }, () => { - console.log('did not getApplicationIconBadgeNumber'); - }); - - push.clearAllNotifications(() => { - console.log('did clearAllNotifications'); - }, () => { - console.log('did not clearAllNotifications'); - }); -} diff --git a/types/phonegap-plugin-push/tsconfig.json b/types/phonegap-plugin-push/tsconfig.json deleted file mode 100644 index 1508fa279d..0000000000 --- a/types/phonegap-plugin-push/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "phonegap-plugin-push-tests.ts" - ] -} \ No newline at end of file diff --git a/types/phonegap-plugin-push/tslint.json b/types/phonegap-plugin-push/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/phonegap-plugin-push/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From 9146a82e3f747b62b4835c4c80415c0354d1601d Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 11:18:48 -0800 Subject: [PATCH 275/298] spin.js: Provides its own types (#22342) --- notNeededPackages.json | 6 +++ types/spin.js/index.d.ts | 54 ----------------------- types/spin.js/spin.js-tests.ts | 34 --------------- types/spin.js/tsconfig.json | 24 ----------- types/spin.js/tslint.json | 79 ---------------------------------- 5 files changed, 6 insertions(+), 191 deletions(-) delete mode 100644 types/spin.js/index.d.ts delete mode 100644 types/spin.js/spin.js-tests.ts delete mode 100644 types/spin.js/tsconfig.json delete mode 100644 types/spin.js/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index ce5c997b8e..4b6f20790b 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -738,6 +738,12 @@ "sourceRepoURL": "https://github.com/blakeembrey/snake-case", "asOfVersion": "1.1.2" }, + { + "libraryName": "Spin.js", + "typingsPackageName": "spin.js", + "sourceRepoURL": "http://fgnass.github.com/spin.js/", + "asOfVersion": "3.0.0" + }, { "libraryName": "spotify-web-api-js", "typingsPackageName": "spotify-web-api-js", diff --git a/types/spin.js/index.d.ts b/types/spin.js/index.d.ts deleted file mode 100644 index 633a308e53..0000000000 --- a/types/spin.js/index.d.ts +++ /dev/null @@ -1,54 +0,0 @@ -// Type definitions for Spin.js 2.3.2 -// Project: http://fgnass.github.com/spin.js/ -// Definitions by: Boris Yankov , Theodore Brown -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - -interface SpinnerOptions { - lines?: number; // The number of lines to draw - length?: number; // The length of each line - width?: number; // The line thickness - radius?: number; // The radius of the inner circle - corners?: number; // Corner roundness (0..1) - rotate?: number; // The rotation offset - direction?: number; // 1: clockwise, -1: counterclockwise - color?: any; // #rgb or #rrggbb or array of colors - speed?: number; // Rounds per second - trail?: number; // Afterglow percentage - shadow?: boolean; // Whether to render a shadow - hwaccel?: boolean; // Whether to use hardware acceleration - className?: string; // The CSS class to assign to the spinner - zIndex?: number; // The z-index (defaults to 2000000000) - top?: string; // Top position relative to parent in px - left?: string; // Left position relative to parent in px - scale?: number; // Scales overall size of the spinner - opacity?: number; // Opacity of the lines - fps?: number; // Frames per second when using setTimeout() as a fallback for CSS - position?: string; // Element positioning -} - - -declare class Spinner { - /** The Spinner's HTML element - can be used to manually insert the spinner into the DOM */ - public el: HTMLElement; - constructor(options?: SpinnerOptions); - - /** - * Adds the spinner to the given target element. If this instance is already - * spinning, it is automatically removed from its previous target by calling - * stop() internally. - */ - spin(target?: HTMLElement): Spinner; - - /** - * Stops and removes the Spinner. - * Stopped spinners may be reused by calling spin() again. - */ - stop(): Spinner; - lines(el:HTMLElement, o:SpinnerOptions):HTMLElement; - opacity(el:HTMLElement, i:number, val:number, o:SpinnerOptions):void; -} - -declare module "spin.js" { - export = Spinner; -} diff --git a/types/spin.js/spin.js-tests.ts b/types/spin.js/spin.js-tests.ts deleted file mode 100644 index e9ae63c9a7..0000000000 --- a/types/spin.js/spin.js-tests.ts +++ /dev/null @@ -1,34 +0,0 @@ - - -var spinner = new Spinner().spin(); -target.appendChild(spinner.el); - -var target = document.getElementById('foo'); -var opts = { speed: 5, color: '#abcdef' }; -var spinner2 = new Spinner(opts).spin(target); - -var opts2 = { - lines: 10, - length: 20, - width: 7, - radius: 14, - corners: 0.6, - rotate: 0, - direction: 1, - color: ['#aaa', '#fedcba', '#fff', '#aef02b'], - speed: 1.5, - trail: 50, - shadow: true, - hwaccel: true, - className: 'spinner', - zIndex: 5, - top: '28', - left: 'auto', - scale: 1, - opacity: 0.25, - fps: 20, - position: 'absolute' -}; - -var newTarget = document.getElementById('bar'); -var spinner3 = new Spinner(opts2).spin(newTarget); diff --git a/types/spin.js/tsconfig.json b/types/spin.js/tsconfig.json deleted file mode 100644 index 55b1f25e2d..0000000000 --- a/types/spin.js/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "spin.js-tests.ts" - ] -} \ No newline at end of file diff --git a/types/spin.js/tslint.json b/types/spin.js/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/spin.js/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From 3b1f7e96939a0afc1c09d07461431ef0160390c5 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 11:47:15 -0800 Subject: [PATCH 276/298] flux-standard-action: Provides its own types (#22341) --- notNeededPackages.json | 6 ++ .../flux-standard-action-tests.ts | 39 --------- types/flux-standard-action/index.d.ts | 30 ------- types/flux-standard-action/tsconfig.json | 23 ------ types/flux-standard-action/tslint.json | 79 ------------------- 5 files changed, 6 insertions(+), 171 deletions(-) delete mode 100644 types/flux-standard-action/flux-standard-action-tests.ts delete mode 100644 types/flux-standard-action/index.d.ts delete mode 100644 types/flux-standard-action/tsconfig.json delete mode 100644 types/flux-standard-action/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 4b6f20790b..e7e6272ac7 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -264,6 +264,12 @@ "sourceRepoURL": "https://github.com/chmln/flatpickr", "asOfVersion": "3.1.2" }, + { + "libraryName": "flux-standard-action", + "typingsPackageName": "flux-standard-action", + "sourceRepoURL": "https://github.com/acdlite/flux-standard-action", + "asOfVersion": "1.1.0" + }, { "libraryName": "gaea-model", "typingsPackageName": "gaea-model", diff --git a/types/flux-standard-action/flux-standard-action-tests.ts b/types/flux-standard-action/flux-standard-action-tests.ts deleted file mode 100644 index 1a98c6663c..0000000000 --- a/types/flux-standard-action/flux-standard-action-tests.ts +++ /dev/null @@ -1,39 +0,0 @@ - -//import action = require('flux-standard-action'); -import { isError, isFSA, Action, ErrorAction } from 'flux-standard-action'; - -interface TextPayload { - text: string; -} - -var sample1: Action = { - type: 'ADD_TODO', - payload: { - text: 'Do something.' - } -}; - -var sample2: ErrorAction = { - type: 'ADD_TODO', - payload: new Error(), - error: true -}; - -var result1: boolean = isError(sample1); -var result2: boolean = isFSA(sample1); -var result3: boolean = isError(sample2); -var result4: boolean = isFSA(sample2); - -declare function alert (message: string): void - -function unwrapAction(action: { type: string }) { - if (isFSA(action)) { - if (isError(action)) { - alert(action.payload!.message) - } - return action.payload - } -} - -var result5: TextPayload = unwrapAction(sample1) -var result6: Error = unwrapAction(sample2) diff --git a/types/flux-standard-action/index.d.ts b/types/flux-standard-action/index.d.ts deleted file mode 100644 index ce328e9be8..0000000000 --- a/types/flux-standard-action/index.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Type definitions for flux-standard-action 0.5.0 -// Project: https://github.com/acdlite/flux-standard-action -// Definitions by: Qubo -// Simon Fridlund -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - -export interface ErrorAction extends Action { - error: true; -} - -export interface Action { - type: string; - payload?: T; - error?: boolean; -} - -/** Usage: `var action: Action & AnyMeta;` */ -export interface AnyMeta { - meta?: any; -} - -/** Usage: `var action: Action & TypedMeta;` */ -export interface TypedMeta { - meta?: T; -} - -export declare function isFSA(action: any): action is Action; - -export declare function isError(action: any): action is ErrorAction; diff --git a/types/flux-standard-action/tsconfig.json b/types/flux-standard-action/tsconfig.json deleted file mode 100644 index 050e130d5a..0000000000 --- a/types/flux-standard-action/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "flux-standard-action-tests.ts" - ] -} \ No newline at end of file diff --git a/types/flux-standard-action/tslint.json b/types/flux-standard-action/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/flux-standard-action/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From 2f9d9fad25a0abdd4aeae7d5f4cbb32644ae9784 Mon Sep 17 00:00:00 2001 From: Berke Ediz Demiralp Date: Wed, 20 Dec 2017 15:00:22 -0500 Subject: [PATCH 277/298] This commit is replacing ScrollViewProperties with VirtualizedListProperties to conform the specification in the documentation. SectionList documentation for React Native v0.51 (https://facebook.github.io/react-native/docs/0.51/sectionlist.html) states that SectionList inherits VirtualizedList's props. In contrary to documentation SectionListProperties have been extending ScrollViewProperties. --- types/react-native/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index a814788b08..a1634eac57 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3662,7 +3662,7 @@ export interface SectionListData extends SectionBase { [key: string]: any; } -export interface SectionListProperties extends ScrollViewProperties { +export interface SectionListProperties extends VirtualizedListProperties { /** * Rendered in between adjacent Items within each section. */ @@ -3736,7 +3736,7 @@ export interface SectionListProperties extends ScrollViewProperties { /** * Default renderer for every item in every section. Can be over-ridden on a per-section basis. */ - renderItem?: ListRenderItem; + renderItem: ListRenderItem; /** * Rendered at the top of each section. Sticky headers are not yet supported. From 33a2ef703c64bfb4e99e22ce58b3354b22710bdd Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 12:13:44 -0800 Subject: [PATCH 278/298] react-native-google-analytics-bridge: Provides its own types (#22358) --- notNeededPackages.json | 6 + .../index.d.ts | 277 ------------------ ...ct-native-google-analytics-bridge-tests.ts | 117 -------- .../tsconfig.json | 24 -- .../tslint.json | 6 - 5 files changed, 6 insertions(+), 424 deletions(-) delete mode 100644 types/react-native-google-analytics-bridge/index.d.ts delete mode 100644 types/react-native-google-analytics-bridge/react-native-google-analytics-bridge-tests.ts delete mode 100644 types/react-native-google-analytics-bridge/tsconfig.json delete mode 100644 types/react-native-google-analytics-bridge/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index e7e6272ac7..81430d1370 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -618,6 +618,12 @@ "sourceRepoURL": "https://github.com/react-native-training/react-native-elements", "asOfVersion": "0.18.0" }, + { + "libraryName": "react-native-google-analytics-bridge", + "typingsPackageName": "react-native-google-analytics-bridge", + "sourceRepoURL": "https://github.com/idehub/react-native-google-analytics-bridge", + "asOfVersion": "5.3.3" + }, { "libraryName": "realm", "typingsPackageName": "realm", diff --git a/types/react-native-google-analytics-bridge/index.d.ts b/types/react-native-google-analytics-bridge/index.d.ts deleted file mode 100644 index 4a1db944e6..0000000000 --- a/types/react-native-google-analytics-bridge/index.d.ts +++ /dev/null @@ -1,277 +0,0 @@ -// Type definitions for react-native-google-analytics-bridge 5.2 -// Project: https://github.com/idehub/react-native-google-analytics-bridge -// Definitions by: Huhuanming , -// Nathan Brooker Perry -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export interface TimeTrackingOptionalValues { - name: string; - label?: string; -} - -export interface EventOptionalValues { - label?: string; - value?: number; -} - -export interface EventPurchaseProduct { - id: string; - name: string; - category?: string; - brand?: string; - variant?: string; - price?: number; - quantity?: number; - couponCode?: string; -} -export interface EventPurchaseTransaction { - id: string; - /** - * an entity with which the transaction should be affiliated (e.g. a particular store) - */ - affiliation: string; - revenue?: number; - tax?: number; - shipping?: number; - couponCode?: string; -} - -export class GoogleAnalyticsTracker { - /** - * Save all tracker related data that is needed to call native methods with proper data. - * @param customDimensionsFieldsIndexMap Custom dimensions field/index pairs - */ - constructor(trackerId: string, customDimensionsFieldsIndexMap?: { [s: string]: number }) - - /** - * If Tracker has customDimensionsFieldsIndexMap, it will transform - * customDimensions map pairs {field: value} to {fieldIndex: value}. - * Otherwise customDimensions are passed trough untouched. - * Underlay native methods will transform provided customDimensions map to expected format. - * Google analytics expect dimensions to be tracker with 'dimension{index}' keys, - * not dimension field names. - */ - transformCustomDimensionsFieldsToIndexes(customDimensions: {}): void; - - /** - * Track the current screen/view Important: Calling this will also set the "current view" for - * other calls. So events tracked will be tagged as having occured on the current view. - * @param screenName The name of the current screen - */ - trackScreenView(screenName: string): void; - - /** - * Track an event that has occured - * @param category The event category - * @param action The event action - * @param optionalValues An object containing optional label and value - */ - trackEvent(category: string, action: string, optionalValues?: EventOptionalValues): void; - - /** - * Track the current screen/view with custom dimension values - * @param screenName The name of the current screen - * @param customDimensionValues An object containing custom dimension key/value pairs - */ - trackScreenViewWithCustomDimensionValues(screenName: string, customDimensionValues: {}): void; - - /** - * Track an event that has occured with custom dimension values - * @param category The event category - * @param action The event action - * @param optionalValues An object containing optional label and value - * @param customDimensionValues An object containing custom dimension key/value pairs - */ - trackEventWithCustomDimensionValues( - category: string, - action: string, - optionalValues: EventOptionalValues, - customDimensionValues: {}, - ): void; - - /** - * Track an event that has occured - * @param category The event category - * @param value The timing measurement in milliseconds - * @param optionalValues An object containing optional name and label - */ - trackTiming(category: string, value: number, optionalValues?: TimeTrackingOptionalValues): void; - - /** - * Track a purchase event. This uses the Enhanced Ecommerce GA feature. - * @param product An object with product values - * @param transaction An object with transaction values - * @param eventCategory The event category, defaults to Ecommerce - * @param eventAction The event action, defaults to Purchase - */ - trackPurchaseEvent( - product: EventPurchaseProduct, - transaction: EventPurchaseTransaction, - eventCategory?: string, - eventAction?: string, - ): void; - - /** - * Track a purchase event. This uses the Enhanced Ecommerce GA feature. - * @param products An array with products - * @param transaction An object with transaction values - * @param eventCategory The event category, defaults to Ecommerce - * @param eventAction The event action, defaults to Purchase - */ - trackMultiProductsPurchaseEvent( - products: EventPurchaseProduct[], - transaction: EventPurchaseTransaction, - eventCategory?: string, - eventAction?: string - ): void; - - /** - * Track a purchase event with custom dimensions. This uses the Enhanced Ecommerce GA feature. - * @param products An array with products - * @param transaction An object with transaction values - * @param eventCategory The event category, defaults to Ecommerce - * @param eventAction The event action, defaults to Purchase - * @param customDimensionValues An object containing custom dimension key/value pairs - */ - trackMultiProductsPurchaseEventWithCustomDimensionValues( - products: EventPurchaseProduct[], - transaction: EventPurchaseTransaction, - eventCategory?: string, - eventAction?: string, - customDimensions?: {}, - ): void; - - /** - * Track an exception - * @param error The description of the error - * @param fatal A value indiciating if the error was fatal, defaults to false - */ - trackException(error: string, fatal?: boolean): void; - - /** - * Sets the Google Analytics User-ID for the current user for tracking. - * The userId should be an anonymous identifier that complies with Google Analytic's User-ID policy. - * @param userId The current userId, - */ - setUser(userId: string): void; - - /** - * Sets if IDFA (identifier for advertisers) collection should be enabled. - * - * Enabled by default. - * - * Important: For iOS you can only use this method if you have done the optional step 6 from the installation - * guide. Only enable this (and link the appropriate libraries) if you plan to use advertising features - * in your app, or else your app may get rejected from the AppStore. - * @param enabled Defaults to true - */ - allowIDFA(enabled?: boolean): void; - - /** - * Track a social interaction, Facebook, Twitter, etc. - */ - trackSocialInteraction(network: string, action: string, targetUrl: string): void; - - /** - * Sets if uncaught exceptions should be tracked - */ - setTrackUncaughtExceptions(enabled: boolean): void; - - /** - * Sets the trackers appName - * The Bundle name is used by default - */ - setAppName(appName: string): void; - - /** - * Sets the trackers appVersion - */ - setAppVersion(appVersion: string): void; - - /** - * Sets if AnonymizeIp is enabled - * If enabled the last octet of the IP address will be removed - * @param enabled disabled by default - */ - setAnonymizeIp(enabled: string): void; - - /** - * Sets the tracker currency property. See accepted currency codes here - * https://developers.google.com/analytics/devguides/platform/features/currencies - * @param currencyCode ISO 4217 currency code - */ - setCurrency(currencyCode: string): void; - - /** - * Sets tracker sampling rate. - * @param sampleRatio Percentage 0 - 100 - */ - setSamplingRate(sampleRatio: number): void; -} - -export interface GAEvent { - event: string; - payload: T; -} - -export namespace GoogleTagManager { - /** - * Call once to open the container for all subsequent static calls. - */ - function openContainerWithId(containerId: string): Promise; - - /** - * Retrieves a boolean value with the given key from the opened container. - */ - function boolForKey(key: string): Promise; - - /** - * Retrieves a string with the given key from the opened container. - */ - function stringForKey(key: string): Promise; - - /** - * Retrieves a number with the given key from the opened container. - */ - function doubleForKey(key: string): Promise; - - /** - * push a datalayer event for Google Analytics through Google Tag Manager. - * @param dictionary An Map containing key and value pairs. - * it must have at least one key "event" with event name - * example: {event: "eventName", pageId: "/home"} - */ - function pushDataLayerEvent(dictionary: GAEvent): Promise; -} - -export namespace GoogleAnalyticsSettings { - /** - * Sets if OptOut is active and disables Google Analytics - * This has to be set each time the App starts - * - * Disabled by default. - */ - function setOptOut(enabled: boolean): void; - - /** - * Sets the trackers dispatch interval - * This will influence how often batches of events, screen views, etc - * are sent to your tracker. - * - * Events, screen views, etc, are sent in batches to the tracker. This function allows you to configure - * how often (in seconds) the batches are sent to your tracker. Recommended to keep this around - * 20-120 seconds to preserve battery and network traffic. - * - * This is set to 20 seconds by default. - * - */ - function setDispatchInterval(intervalInSeconds: number): void; - - /** - * When enabled the native library prevents any data from being sent to Google Analytics. - * This allows you to test or debug the implementation, without your test data appearing in - * your Google Analytics reports. - * - */ - function setDryRun(enabled: boolean): void; -} diff --git a/types/react-native-google-analytics-bridge/react-native-google-analytics-bridge-tests.ts b/types/react-native-google-analytics-bridge/react-native-google-analytics-bridge-tests.ts deleted file mode 100644 index 7493bfbd03..0000000000 --- a/types/react-native-google-analytics-bridge/react-native-google-analytics-bridge-tests.ts +++ /dev/null @@ -1,117 +0,0 @@ -import { - GoogleAnalyticsTracker, - GoogleTagManager, - GoogleAnalyticsSettings, -} from 'react-native-google-analytics-bridge'; - -const tracker = new GoogleAnalyticsTracker('GA_UA'); - -tracker.allowIDFA(); -tracker.allowIDFA(true); - -tracker.setAnonymizeIp('1.1.1.1'); - -tracker.setAppName('name'); - -// Used for Google Analytics User-ID -tracker.setUser('unique_username'); - -tracker.trackScreenView('Video'); - -// Tracking pagination of a video list -tracker.trackEvent('Videos', 'Page2'); - -// The Video 'Awesome Video Title' has started playing -tracker.trackEvent('Video', 'play', { label: 'Awesome Video Title'}); - -// The video 'Awesome Video Title' has stopped playing 1234 ms into the video -tracker.trackEvent('Video', 'stop', { label: 'Awesome Video Title', value: 1234}); - -// Tracking the time it took to encode a video -tracker.trackTiming('Video', 15000, { name: 'VideoEncoded' }); - -tracker.trackException('Exception Message'); - -// Tracking an ecommerce purchase event happening for a single product -tracker.trackPurchaseEvent({ - id: 'P12345', - name: 'Android Warhol T-Shirt', - category: 'Apparel/T-Shirts', - brand: 'Google', - variant: 'Black', - price: 29.20, - quantity: 1, - couponCode: 'APPARELSALE' -}, { - id: 'T12345', - affiliation: 'Google Store - Online', - revenue: 37.39, - tax: 2.85, - shipping: 5.34, - couponCode: 'SUMMER2013' -}, 'Ecommerce', 'Purchase'); - -// Tracking an ecommerce purchase event happening for mutliple products -tracker.trackMultiProductsPurchaseEvent([{ - id: 'P12345', - name: 'Android Warhol T-Shirt', - category: 'Apparel/T-Shirts', - brand: 'Google', - variant: 'Black', - price: 29.20, - quantity: 1, - couponCode: 'APPARELSALE' -}, -{ - id: 'P67890', - name: 'iOS Warhol T-Shirt', - category: 'Apparel/T-Shirts', - brand: 'Apple', - variant: 'Black', - price: 29.20, - quantity: 1, - couponCode: 'TECHSALE20' -} -], { - id: 'T12345', - affiliation: 'Google Store - Online', - revenue: 37.39, - tax: 2.85, - shipping: 5.34, - couponCode: 'SUMMER2013' -}, 'Ecommerce', 'Purchase'); - -// Usage of custom dimensions -const tracker2 = new GoogleAnalyticsTracker('GA_UA-2', { test: 1, OtherCustomDimension: 2}); - -tracker2.trackScreenViewWithCustomDimensionValues('Home', { test: 'Beta' }); - -tracker2.trackEventWithCustomDimensionValues('Video', 'play', {}, { test: 'data', OtherCustomDimension: 'OtherStuff'}); - -// Google Tag Manager tests -GoogleTagManager.openContainerWithId('123'); - -GoogleTagManager.boolForKey('key').then((value: boolean) => { - console.log('Do something with the boolean for the key "key"'); - }); - -GoogleTagManager.stringForKey('key').then((value: string) => { - console.log('Do something with the string for the key "key"'); - }); - -GoogleTagManager.doubleForKey('key').then((value: number) => { - console.log('Do something with the number for the key "key"'); - }); - -GoogleTagManager.pushDataLayerEvent({ - event: 'event', - payload: 'payload', - }).then((success: boolean) => { - console.log(success ? 'Successfully got pushed the DataLayerEvent' : 'Failed to push the DataLayerEvent'); - }); - -// Google Analytic Settings - -GoogleAnalyticsSettings.setOptOut(true); -GoogleAnalyticsSettings.setDispatchInterval(1000); -GoogleAnalyticsSettings.setDryRun(true); diff --git a/types/react-native-google-analytics-bridge/tsconfig.json b/types/react-native-google-analytics-bridge/tsconfig.json deleted file mode 100644 index 91e51ff21b..0000000000 --- a/types/react-native-google-analytics-bridge/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "react-native-google-analytics-bridge-tests.ts" - ] -} \ No newline at end of file diff --git a/types/react-native-google-analytics-bridge/tslint.json b/types/react-native-google-analytics-bridge/tslint.json deleted file mode 100644 index 71ee04c4e1..0000000000 --- a/types/react-native-google-analytics-bridge/tslint.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "no-unnecessary-generics": false - } -} From 4fb8d29bd92ec9acf8944e7ca57025afa09f7848 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 12:14:06 -0800 Subject: [PATCH 279/298] cypress: Provides its own types (#22354) --- notNeededPackages.json | 6 + types/cypress/cypress-tests.ts | 44 --- types/cypress/index.d.ts | 563 --------------------------------- types/cypress/tsconfig.json | 23 -- types/cypress/tslint.json | 1 - 5 files changed, 6 insertions(+), 631 deletions(-) delete mode 100644 types/cypress/cypress-tests.ts delete mode 100644 types/cypress/index.d.ts delete mode 100644 types/cypress/tsconfig.json delete mode 100644 types/cypress/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 81430d1370..2cd00992e5 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -162,6 +162,12 @@ "sourceRepoURL": "https://github.com/blakeembrey/constant-case", "asOfVersion": "1.1.2" }, + { + "libraryName": "cypress", + "typingsPackageName": "cypress", + "sourceRepoURL": "https://cypress.io", + "asOfVersion": "1.1.3" + }, { "libraryName": "date-fns", "typingsPackageName": "date-fns", diff --git a/types/cypress/cypress-tests.ts b/types/cypress/cypress-tests.ts deleted file mode 100644 index be1b3cc959..0000000000 --- a/types/cypress/cypress-tests.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Samples taken from the cypress kitchen sink example (https://github.com/cypress-io/cypress-example-kitchensink) -cy.title().should('include', 'Kitchen Sink'); - -cy - .get('.query-list') - .contains('bananas').should('have.class', 'third') - .contains(/^b\w+/).should('have.class', 'third') - .get('.query-list') - .contains('apples').should('have.class', 'first') - .get('#querying') - .contains('ul', 'oranges').should('have.class', 'query-list') - .get('.query-button') - .contains('Save Form').should('have.class', 'btn') - .trigger('mousemove', {clientX: 100, clientY: 200}); - -cy.location('host'); - -cy - .get('form') - .find('input') - .then($input => $input.click()) - .then($input => $input.click(), {timeout: 12}); - -cy - .wrap({ sum: (a: number, b: number, c: number) => a + b + c }) - .invoke('sum', 2, 4, 6); - -cy - .get('ul>li') - .each(($el, index, $list) => { - // $el is wrapped jquery element - if ($el.someMethod() === "something") { - // wrap this element so we can - // use cypress commands on it - cy.wrap($el).click(); - } else { - // do something else - } - }) - .spread((x , y, z) => { - x + y + z; - }); - -cy.log('end'); diff --git a/types/cypress/index.d.ts b/types/cypress/index.d.ts deleted file mode 100644 index 6cbc65f819..0000000000 --- a/types/cypress/index.d.ts +++ /dev/null @@ -1,563 +0,0 @@ -// Type definitions for cypress 0.1 -// Project: https://cypress.io -// Definitions by: Gert Hengeveld -// Mike Woudenberg -// Robbert van Markus -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 - -declare namespace Cypress { - type FileContents = string | any[] | object; - type HistoryDirection = "back" | "forward"; - type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "OPTIONS" | "HEAD" | "TRACE" | "CONNECT"; - type RequestBody = string | object; - type ViewportOrientation = "portrait" | "landscape"; - - interface Core { - /** - * @see https://on.cypress.io/api/config - */ - config(): object; - config(key: string): any; - config(key: string, value: any): void; - config(Object: object): void; - - /** - * @see https://on.cypress.io/api/env - */ - env(): object; - env(key: string): any; - env(key: string, value: any): void; - env(Object: object): void; - - /** - * @see https://on.cypress.io/api/commands - */ - addChildCommand(name: string, fn: (...args: any[]) => void): void; - addDualCommand(name: string, fn: (...args: any[]) => void): void; - addParentCommand(name: string, fn: (...args: any[]) => void): void; - - _: any; - $: any; - minimatch: any; - moment: any; - Blob: any; - Promise: any; - Log: any; - - /** - * @see https://on.cypress.io/api/cookies - */ - Cookies: { - debug(enabled: boolean, options?: DebugOptions): void; - preserveOnce(...names: string[]): void; - defaults(options: CookieDefaults): void; - }; - - /** - * @see https://on.cypress.io/api/dom - */ - Dom: { - isHidden(element: object): boolean; - }; - - /** - * @see https://on.cypress.io/api/api-server - */ - Server: { - defaults(options: ServerOptions): void; - }; - } - - interface Chainable { - /** - * @see https://on.cypress.io/api/and - */ - and(chainers: string, value?: any): Chainable; - and(chainers: string, method: string, value: any): Chainable; - and(fn: (currentSubject?: any) => void): Chainable; - - /** - * @see https://on.cypress.io/api/as - */ - as(alias: string): Chainable; - - /** - * @see https://on.cypress.io/api/blur - */ - blur(options?: BlurOptions): Chainable; - - /** - * @see https://on.cypress.io/api/check - */ - check(options?: CheckOptions): Chainable; - check(value: string|string[]): Chainable; // no options - - /** - * @see https://on.cypress.io/api/children - */ - children(options?: LoggableTimeoutable): Chainable; - children(selector: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/clear - */ - clear(options?: ClearOptions): Chainable; - - /** - * @see https://on.cypress.io/api/clearcookie - */ - clearCookie(name: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/clearcookies - */ - clearCookies(options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/clearlocalstorage - */ - clearLocalStorage(key?: string): Chainable; - clearLocalStorage(re: RegExp): Chainable; - - /** - * @see https://on.cypress.io/api/click - */ - click(options?: ClickOptions): Chainable; - click(position: string, options?: ClickOptions): Chainable; - click(x: number, y: number, options?: ClickOptions): Chainable; - - /** - * @see https://on.cypress.io/api/closest - */ - closest(selector: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/contains - */ - contains(text: string, options?: LoggableTimeoutable): Chainable; - contains(num: number|RegExp): Chainable; - contains(selector: string, text: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/dblclick - */ - dblclick(options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/debug - */ - debug(options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/document - */ - document(options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/each - */ - each(fn: (element?: any, index?: number, $list?: any) => void): Chainable; - - /** - * @see https://on.cypress.io/api/end - */ - end(): Chainable; - - /** - * @see https://on.cypress.io/api/eq - */ - eq(index: number, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/exec - */ - exec(command: string, options?: ExecOptions): Chainable; - - /** - * @see https://on.cypress.io/api/filter - */ - filter(selector: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/find - */ - find(selector: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/first - */ - first(options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/fixture - */ - fixture(path: string, options?: Timeoutable): Chainable; // no log? - fixture(path: string, encoding: string, options?: Timeoutable): Chainable; // no log? - - /** - * @see https://on.cypress.io/api/focus - */ - focus(options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/focused - */ - focused(options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/get - */ - get(selector: string, options?: LoggableTimeoutable): Chainable; - get(alias: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/getcookie - */ - getCookie(name: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/getcookies - */ - getCookies(options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/go - */ - go(direction: HistoryDirection|number, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/hash - */ - hash(options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/invoke - */ - invoke(functionName: string, ...args: any[]): Chainable; - - /** - * @see https://on.cypress.io/api/its - */ - its(propertyName: string): Chainable; - - /** - * @see https://on.cypress.io/api/last - */ - last(options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/location - */ - location(options?: LoggableTimeoutable): Chainable; - location(key: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/log - */ - log(message: string, args?: any): Chainable; - - /** - * @see https://on.cypress.io/api/next - */ - next(options?: LoggableTimeoutable): Chainable; - next(selector: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/not - */ - not(selector: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/parent - */ - parent(options?: LoggableTimeoutable): Chainable; - parent(selector: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/parents - */ - parents(options?: LoggableTimeoutable): Chainable; - parents(selector: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/pause - */ - pause(options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/prev - */ - prev(options?: LoggableTimeoutable): Chainable; - prev(selector: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/readfile - */ - readFile(filePath: string, options?: Timeoutable): Chainable; // no log? - readFile(filePath: string, encoding: string, options?: Timeoutable): Chainable; // no log? - - /** - * @see https://on.cypress.io/api/reload - */ - reload(options?: LoggableTimeoutable): Chainable; - reload(forceReload: boolean): Chainable; // no options? - - /** - * @see https://on.cypress.io/api/request - */ - request(url: string, body?: RequestBody): Chainable; - request(method: HttpMethod, url: string, body?: RequestBody): Chainable; - request(options: RequestOptions): Chainable; - - /** - * @see https://on.cypress.io/api/root - */ - root(options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/route - */ - route(url: string | RegExp, response?: any): Chainable; - route(method: string, url: string | RegExp, response?: any): Chainable; - route(fn: (() => RouteOptions) | RouteOptions): Chainable; - - /** - * @see https://on.cypress.io/api/screenshot - */ - screenshot(options?: LoggableTimeoutable): Chainable; - screenshot(fileName: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/select - */ - select(text: string|string[], options?: SelectOptions): Chainable; - select(value: string|string[], options?: SelectOptions): Chainable; - - /** - * @see https://on.cypress.io/api/server - */ - server(options?: ServerOptions): Chainable; - - /** - * @see https://on.cypress.io/api/setcookie - */ - setCookie(name: string, value: string, options?: SetCookieOptions): Chainable; - - /** - * @see https://on.cypress.io/api/should - */ - should(chainers: string, value?: any): Chainable; - should(chainers: string, method: string, value: any): Chainable; - should(fn: (currentSubject?: any) => void): Chainable; - - /** - * @see https://on.cypress.io/api/siblings - */ - siblings(options?: LoggableTimeoutable): Chainable; - siblings(selector: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/spread - */ - spread(fn: (...args: any[]) => any): Chainable; - - /** - * @see https://on.cypress.io/api/submit - */ - submit(options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/then - */ - then(fn: (currentSubject: any) => any, options?: Timeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/title - */ - title(options?: Loggable): Chainable; - - /** - * @description Trigger an event on a DOM element. - * @see https://docs.cypress.io/api/commands/trigger.html - */ - trigger(eventName: string, position?: PositionType, x?: number, y?: number, options?: TriggerOptions): Chainable; - trigger(eventName: string, eventObject: object): Chainable; - - /** - * @see https://on.cypress.io/api/type - */ - type(text: string, options?: TypeOptions): Chainable; - - /** - * @see https://on.cypress.io/api/uncheck - */ - uncheck(options?: CheckOptions): Chainable; - uncheck(values: string[]): Chainable; // no options? missing single value variant - - /** - * @see https://on.cypress.io/api/url - */ - url(options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/viewport - */ - viewport(width: number, height: number, options?: Loggable): Chainable; - viewport(preset: string, orientation: ViewportOrientation, options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/visit - */ - visit(url: string, options?: VisitOptions): Chainable; - - /** - * @see https://on.cypress.io/api/wait - */ - wait(ms: number|string[]): Chainable; // no options? - wait(alias: string, options?: LoggableTimeoutable): Chainable; - - /** - * @see https://on.cypress.io/api/window - */ - window(options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/within - */ - within(fn: (currentSubject?: any) => void): Chainable; - within(options: Loggable, fn: (currentSubject?: any) => void): Chainable; // inconsistent argument order - - /** - * @see https://on.cypress.io/api/wrap - */ - wrap(Object: object, options?: Loggable): Chainable; - - /** - * @see https://on.cypress.io/api/writefile - */ - writeFile(filePath: string, contents: FileContents, options?: Timeoutable): Chainable; - writeFile(filePath: string, contents: FileContents, encoding: string, options?: Timeoutable): Chainable; - } - - interface DebugOptions { - verbose?: boolean; - } - - interface CookieDefaults { - whitelist?: string | string[] | RegExp | ((cookie: any) => boolean); - } - - interface Loggable { - log?: boolean; - } - - interface Timeoutable { - timeout?: number; - } - - interface LoggableTimeoutable extends Loggable, Timeoutable {} - - interface BlurOptions extends Loggable { - force?: boolean; - } - - interface CheckOptions extends Loggable, Timeoutable { - interval?: number; - force?: boolean; - } - - interface ClearOptions extends Loggable, Timeoutable { - force?: boolean; - interval?: number; - } - - interface ClickOptions extends Loggable, Timeoutable { - force?: boolean; - multiple?: boolean; - interval?: number; - } - - interface ExecOptions extends Loggable, Timeoutable { - failOnNonZeroExit?: boolean; - env?: object; - } - - interface RequestOptions extends Loggable, Timeoutable { - auth?: object; - body?: RequestBody; - failOnStatusCode?: boolean; - followRedirect?: boolean; - form?: boolean; - gzip?: boolean; - headers?: object; - method?: HttpMethod; - qs?: string; - url: string; - } - - interface RouteOptions { - method?: HttpMethod; - url?: string | RegExp; - response?: any; - status?: number; - delay?: number; - headers?: object; - force404?: boolean; - onRequest?(...args: any[]): void; - onResponse?(...args: any[]): void; - onAbort?(...args: any[]): void; - } - - interface SelectOptions extends Loggable, Timeoutable { - force?: boolean; - interval?: number; - } - - interface ServerOptions { - delay?: number; - method?: HttpMethod; - status?: number; - headers?: object; - response?: any; - onRequest?(...args: any[]): void; - onResponse?(...args: any[]): void; - onAbort?(...args: any[]): void; - enable?: boolean; - force404?: boolean; - urlMatchingOptions?: object; - whitelist?(...args: any[]): void; - } - - interface SetCookieOptions extends Loggable, Timeoutable { - path?: string; - domain?: string; - secure?: boolean; - httpOnly?: boolean; - expiry?: number; - } - - interface TypeOptions extends Loggable, Timeoutable { - delay?: number; - force?: boolean; - release?: boolean; - interval?: number; - } - - interface VisitOptions extends Loggable, Timeoutable { - onBeforeLoad?(args: any[]): void; - onLoad?(args: any[]): void; - } - - interface TriggerOptions { - log?: boolean; - force?: boolean; - bubbles?: boolean; - cancable?: boolean; - timeout?: number; - } - - type PositionType = "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight"; -} - -declare const cy: Cypress.Chainable; diff --git a/types/cypress/tsconfig.json b/types/cypress/tsconfig.json deleted file mode 100644 index 93fcd9f8c2..0000000000 --- a/types/cypress/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "cypress-tests.ts" - ] -} \ No newline at end of file diff --git a/types/cypress/tslint.json b/types/cypress/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/cypress/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } From 0c2b75b2cf92e19a18fbeba1984d2c5562ee3f68 Mon Sep 17 00:00:00 2001 From: "VML\\snau" Date: Wed, 20 Dec 2017 12:30:46 -0800 Subject: [PATCH 280/298] updating the test per feedback on the PR --- types/vanilla-modal/vanilla-modal-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/vanilla-modal/vanilla-modal-tests.ts b/types/vanilla-modal/vanilla-modal-tests.ts index 3f75db3cc8..69c98baf3c 100644 --- a/types/vanilla-modal/vanilla-modal-tests.ts +++ b/types/vanilla-modal/vanilla-modal-tests.ts @@ -1,3 +1,4 @@ import VanillaModal from 'vanilla-modal'; const modalInstance = new VanillaModal(); +modalInstance.open('#foo'); From 5e9ae3e0e5b5b2da1ba18d9599d792831144413e Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 13:23:31 -0800 Subject: [PATCH 281/298] react-split-pane: Provides its own types (#22368) --- notNeededPackages.json | 6 ++ types/react-split-pane/index.d.ts | 56 ------------- .../react-split-pane-tests.tsx | 21 ----- types/react-split-pane/tsconfig.json | 25 ------ types/react-split-pane/tslint.json | 79 ------------------- 5 files changed, 6 insertions(+), 181 deletions(-) delete mode 100644 types/react-split-pane/index.d.ts delete mode 100644 types/react-split-pane/react-split-pane-tests.tsx delete mode 100644 types/react-split-pane/tsconfig.json delete mode 100644 types/react-split-pane/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 2cd00992e5..369b0c12e0 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -630,6 +630,12 @@ "sourceRepoURL": "https://github.com/idehub/react-native-google-analytics-bridge", "asOfVersion": "5.3.3" }, + { + "libraryName": "react-split-pane", + "typingsPackageName": "react-split-pane", + "sourceRepoURL": "https://github.com/tomkp/react-split-pane", + "asOfVersion": "0.1.67" + }, { "libraryName": "realm", "typingsPackageName": "realm", diff --git a/types/react-split-pane/index.d.ts b/types/react-split-pane/index.d.ts deleted file mode 100644 index db5f27010e..0000000000 --- a/types/react-split-pane/index.d.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Type definitions for react-split-pane v0.1.64 -// Project: https://github.com/tomkp/react-split-pane -// Definitions by: Roger Chen -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -/// - -declare namespace ReactSplitPane { - interface ReactSplitPaneProps { - allowResize?: boolean; - className?: string; - /** - * Either a number (in pixels) or string (percentage) - */ - defaultSize?: number | string; - /** - * Either a number (in pixels) or string (percentage) - */ - maxSize?: number | string; - /** - * Either a number (in pixels) or string (percentage) - */ - minSize?: number | string; - onChange?: Function; - onDragFinished?: Function; - onDragStarted?: Function; - primary?: string; - onResizerClick?: Function; - onResizerDoubleClick?: Function; - - /** - * Either a number (in pixels) or string (percentage) - */ - size?: number | string; - split?: string; - step?: number; - /* Styling to be applied to both panes */ - paneStyle?: React.CSSProperties; - /* Styling to be applied to the first pane, with precedence over paneStyle */ - pane1Style?: React.CSSProperties; - /* Styling to be applied to the second pane, with precedence over paneStyle */ - pane2Style?: React.CSSProperties; - /* Class name to be applied to resizer bar */ - resizerClassName?: string; - /* Styling to be applied to the resizer bar */ - resizerStyle?: React.CSSProperties; - } - - interface ReactSplitPaneClass extends React.ComponentClass { } -} - -declare module "react-split-pane" { - var split: ReactSplitPane.ReactSplitPaneClass; - export = split; -} diff --git a/types/react-split-pane/react-split-pane-tests.tsx b/types/react-split-pane/react-split-pane-tests.tsx deleted file mode 100644 index 91efe8d23f..0000000000 --- a/types/react-split-pane/react-split-pane-tests.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import * as React from "react"; -import * as SplitPane from "react-split-pane"; - -class SplitPaneTest extends React.Component> { - - render() { - return ( - -
-
- - ); - } -} diff --git a/types/react-split-pane/tsconfig.json b/types/react-split-pane/tsconfig.json deleted file mode 100644 index 4c7d16ba33..0000000000 --- a/types/react-split-pane/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "jsx": "react", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "react-split-pane-tests.tsx" - ] -} \ No newline at end of file diff --git a/types/react-split-pane/tslint.json b/types/react-split-pane/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/react-split-pane/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From 2302b6dd8065e16c43a425e8b34ecc80a1817344 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 13:45:02 -0800 Subject: [PATCH 282/298] validate.js: Provides its own types (#22378) --- notNeededPackages.json | 6 + types/validate.js/index.d.ts | 109 --------------- types/validate.js/tsconfig.json | 23 ---- types/validate.js/tslint.json | 79 ----------- types/validate.js/validate.js-tests.ts | 183 ------------------------- 5 files changed, 6 insertions(+), 394 deletions(-) delete mode 100644 types/validate.js/index.d.ts delete mode 100644 types/validate.js/tsconfig.json delete mode 100644 types/validate.js/tslint.json delete mode 100644 types/validate.js/validate.js-tests.ts diff --git a/notNeededPackages.json b/notNeededPackages.json index 369b0c12e0..e8256d8398 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -858,6 +858,12 @@ "sourceRepoURL": "https://github.com/blakeembrey/upper-case-first", "asOfVersion": "1.1.2" }, + { + "libraryName": "Validate.js", + "typingsPackageName": "validate.js", + "sourceRepoURL": "https://github.com/ansman/validate.js", + "asOfVersion": "0.11.0" + }, { "libraryName": "vso-node-api", "typingsPackageName": "vso-node-api", diff --git a/types/validate.js/index.d.ts b/types/validate.js/index.d.ts deleted file mode 100644 index ed0a964d3e..0000000000 --- a/types/validate.js/index.d.ts +++ /dev/null @@ -1,109 +0,0 @@ -// Type definitions for Validate.js -// Project: https://github.com/ansman/validate.js -// Definitions by: Travis Hill -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace ValidateJS { - - export interface Validator { - message?: string | ((value: any, attribute: any, validatorOptions: any, attributes: any, globalOptions: any) => string); - } - - namespace Validator { - - export interface Date extends Validator { - earliest?: string; - latest?: string; - - notValid?: string; - tooEarly?: string; - tooLate?: string; - } - - export interface DateTime extends Date { - dateOnly?: boolean; - } - - export interface Email extends Validator {} - - export interface Equality extends Validator { - attribute?: string; - comparator?: (v1: any, v2: any) => boolean; - } - - export interface Exclusion extends Validator { - within: any[] | {[key: string]: any}; - } - - export interface Format extends Validator { - pattern: string | RegExp; - flags?: string; - } - - export interface Inclusion extends Validator { - within: any[] | {[key: string]: any}; - } - - export interface Length extends Validator { - is?: number; - minimum?: number; - maximum?: number; - - notValid?: string; - tooLong?: string; - tooShort?: string; - wrongLength?: string; - - tokenizer?: (value: string | any[]) => string | any[]; - } - - export interface Numericality extends Validator { - onlyInteger?: boolean; - strict?: boolean; - greaterThan?: number; - greaterThanOrEqualTo?: number; - equalTo?: number; - lessThanOrEqualTo?: number; - lessThan?: number; - divisibleBy?: number; - odd?: boolean; - even?: boolean; - - notValid?: string; - notInteger?: string; - notGreaterThan?: string; - notGreaterThanOrEqualTo?: string; - notEqualTo?: string; - notLessThanOrEqualTo?: string; - notLessThan?: string; - notDivisibleBy?: string; - notOdd?: string; - notEven?: string; - } - - export interface Presence extends Validator {} - - export interface Url extends Validator { - schemes?: (string | RegExp)[]; - allowLocal?: boolean; - } - } - - export interface Field { - date?: Validator.Date | boolean | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Validator.Date); - datetime?: Validator.DateTime | boolean | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Validator.DateTime); - email?: Validator.Email | boolean | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Validator.Email); - equality?: Validator.Equality | string | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Validator.Equality); - exclusion?: Validator.Exclusion | any[] | {[key: string]: any} | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Validator.Exclusion); - format?: Validator.Format | string | RegExp | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Validator.Format); - inclusion?: Validator.Inclusion | any[] | {[key: string]: any} | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Validator.Inclusion); - length?: Validator.Length | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Validator.Length); - numericality?: Validator.Numericality | boolean | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Validator.Numericality); - presence?: Validator.Presence | boolean | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Validator.Presence); - url?: Validator.Url | boolean | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Validator.Url); - } - - export interface Constraints { - [attribute: string]: Field | ((value: any, attributes: any, attributeName: any, options: any, constraints: any) => Field); - } -} diff --git a/types/validate.js/tsconfig.json b/types/validate.js/tsconfig.json deleted file mode 100644 index 3da830187f..0000000000 --- a/types/validate.js/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "validate.js-tests.ts" - ] -} \ No newline at end of file diff --git a/types/validate.js/tslint.json b/types/validate.js/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/validate.js/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} diff --git a/types/validate.js/validate.js-tests.ts b/types/validate.js/validate.js-tests.ts deleted file mode 100644 index f2dcb79838..0000000000 --- a/types/validate.js/validate.js-tests.ts +++ /dev/null @@ -1,183 +0,0 @@ -import Validator = ValidateJS.Validator; -import Field = ValidateJS.Field; -import Constraints = ValidateJS.Constraints; - -let validator: Validator; -validator = {}; -validator = {message: 'test'}; -validator = {message: (value: any, attribute: any, validatorOptions: any, attributes: any, globalOptions: any) => 'test'}; - -let date: Validator.Date; -date = {}; -date = { - earliest: 'a', - latest: 'b', - notValid: 'c', - tooEarly: 'd', - tooLate: 'e', - message: 'test', -}; - -let dateTime: Validator.DateTime; -dateTime = {}; -dateTime = { - dateOnly: true, - earliest: 'a', - latest: 'b', - notValid: 'c', - tooEarly: 'd', - tooLate: 'e', - message: 'test', -}; - -let email: Validator.Email; -email = {}; -email = {message: 'test'}; - -let equality: Validator.Equality; -equality = {}; -equality = { - attribute: 'a', - comparator: (v1: any, v2: any) => true, - message: 'test', -}; - -let exclusion: Validator.Exclusion; -exclusion = { - within: ['a', 'b'], - message: 'test', -}; -exclusion = { - within: {a: 'b', c: 'd'}, -}; - -let format: Validator.Format; -format = { - pattern: 'a', - message: 'test', -}; -format = { - pattern: /a/g, -}; -format = { - pattern: new RegExp('a'), -}; - -let inclusion: Validator.Inclusion; -inclusion = { - within: ['a', 'b'], - message: 'test', -}; -inclusion = { - within: {a: 'b', c: 'd'}, -}; - -let _length: Validator.Length; -_length = {}; -_length = { - is: 1, - notValid: 'a', - wrongLength: 'b', - message: 'test', - tokenizer: (value: any[]) => [1, 2], -}; -_length = { - minimum: 2, - maximum: 4, - tooShort: 'a', - tooLong: 'b', - tokenizer: (value: string) => 'test', -}; - -let numericality: Validator.Numericality; -numericality = {}; -numericality = { - onlyInteger: true, - strict: true, - equalTo: 8, - divisibleBy: 4, - even: true, - notValid: 'a', - notInteger: 'b', - notEqualTo: 'c', - notDivisibleBy: 'd', - notEven: 'e', - message: 'test', -}; -numericality = { - greaterThan: 4, - lessThan: 10, - odd: true, - notGreaterThan: 'a', - notLessThan: 'b', - notOdd: 'c', -}; -numericality = { - greaterThanOrEqualTo: 4, - lessThanOrEqualTo: 7, - notGreaterThanOrEqualTo: 'a', - notLessThanOrEqualTo: 'b', -}; - -let presence: Validator.Presence; -presence = {}; -presence = {message: 'test'}; - -let url: Validator.Url; -url = {}; -url = { - schemes: ['a', /b/g, new RegExp('c')], - allowLocal: true, - message: 'test', -}; - -let field: Field; -field = {}; -field = { - date: {earliest: 'a'}, - datetime: {dateOnly: true}, - email: {message: 'test'}, - equality: {attribute: 'b'}, - exclusion: {within: ['c']}, - format: {pattern: 'd'}, - inclusion: {within: ['e']}, - length: {is: 4}, - numericality: {onlyInteger: true}, - presence: {message: 'test2'}, - url: {schemes: ['f']}, -}; -field = { - date: true, - datetime: true, - email: true, - equality: 'a', - exclusion: ['b'], - format: 'c', - inclusion: ['d'], - numericality: true, - presence: true, - url: true, -}; -field = { - format: /a/g, -}; -field = { - date: (value: any, attributes: any, attributeName: any, options: any, constraints: any) => ({earliest: 'a'}), - datetime: (value: any, attributes: any, attributeName: any, options: any, constraints: any) => ({dateOnly: true}), - email: (value: any, attributes: any, attributeName: any, options: any, constraints: any) => ({message: 'test'}), - equality: (value: any, attributes: any, attributeName: any, options: any, constraints: any) => ({attribute: 'b'}), - exclusion: (value: any, attributes: any, attributeName: any, options: any, constraints: any) => ({within: ['c']}), - format: (value: any, attributes: any, attributeName: any, options: any, constraints: any) => ({pattern: 'd'}), - inclusion: (value: any, attributes: any, attributeName: any, options: any, constraints: any) => ({within: ['e']}), - length: (value: any, attributes: any, attributeName: any, options: any, constraints: any) => ({is: 4}), - numericality: (value: any, attributes: any, attributeName: any, options: any, constraints: any) => ({onlyInteger: true}), - presence: (value: any, attributes: any, attributeName: any, options: any, constraints: any) => ({message: 'test2'}), - url: (value: any, attributes: any, attributeName: any, options: any, constraints: any) => ({schemes: ['f']}), -}; - -let constraints: Constraints; -constraints = {}; -constraints = { - a: {date: true}, - b: (value: any, attribute: any, attributeName: any, options: any, constraints: any) => ({datetime: true}), -}; \ No newline at end of file From 3bfd05f8afb9cbd4ffdf377ed76100b528f8abb3 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 13:58:22 -0800 Subject: [PATCH 283/298] redux-bootstrap: Provides its own types (#22386) --- notNeededPackages.json | 6 ++ types/redux-bootstrap/index.d.ts | 30 ------- types/redux-bootstrap/package.json | 6 -- .../redux-bootstrap/redux-bootstrap-tests.tsx | 18 ----- types/redux-bootstrap/tsconfig.json | 25 ------ types/redux-bootstrap/tslint.json | 79 ------------------- 6 files changed, 6 insertions(+), 158 deletions(-) delete mode 100644 types/redux-bootstrap/index.d.ts delete mode 100644 types/redux-bootstrap/package.json delete mode 100644 types/redux-bootstrap/redux-bootstrap-tests.tsx delete mode 100644 types/redux-bootstrap/tsconfig.json delete mode 100644 types/redux-bootstrap/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index e8256d8398..44abc21b6f 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -654,6 +654,12 @@ "sourceRepoURL": "https://github.com/tshelburne/redux-batched-actions", "asOfVersion": "0.1.5" }, + { + "libraryName": "react-bootstrap", + "typingsPackageName": "redux-bootstrap", + "sourceRepoURL": "https://github.com/remojansen/redux-bootstrap", + "asOfVersion": "1.1.0" + }, { "libraryName": "redux-devtools-extension", "typingsPackageName": "redux-devtools-extension", diff --git a/types/redux-bootstrap/index.d.ts b/types/redux-bootstrap/index.d.ts deleted file mode 100644 index 8a5d8b2152..0000000000 --- a/types/redux-bootstrap/index.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Type definitions for react-bootstrap 1.0 -// Project: https://github.com/remojansen/redux-bootstrap -// Definitions by: Remo H. Jansen -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 - -import * as React from "react"; -import { Middleware, Reducer, Store } from "redux"; -import { History } from "history"; - -export interface BootstrapOptions { - routes: JSX.Element; - reducers: ReducersOption; - middlewares?: Middleware[]; - initialState?: any; - container?: string; -} - -export interface BootstrapResult { - store: Store; - history: History; - root: JSX.Element; -} - -export interface ReducersOption { - [index: string]: Reducer; -} - -export default function bootstrap(options: BootstrapOptions): BootstrapResult; - diff --git a/types/redux-bootstrap/package.json b/types/redux-bootstrap/package.json deleted file mode 100644 index 6d68bf2f9b..0000000000 --- a/types/redux-bootstrap/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "dependencies": { - "redux": "^3.6.0" - } -} diff --git a/types/redux-bootstrap/redux-bootstrap-tests.tsx b/types/redux-bootstrap/redux-bootstrap-tests.tsx deleted file mode 100644 index 1630e759a5..0000000000 --- a/types/redux-bootstrap/redux-bootstrap-tests.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import bootstrap from "redux-bootstrap"; - -let routes: JSX.Element = null; - -let result = bootstrap({ - container: "root", - initialState: {}, - middlewares: [], - reducers: { - reposReducer: (previousState: any, action: any): any => { return null; }, - usersReducer: (previousState: any, action: any): any => { return null; } - }, - routes: routes -}); - -console.log(result.store); -console.log(result.history); -console.log(result.root); diff --git a/types/redux-bootstrap/tsconfig.json b/types/redux-bootstrap/tsconfig.json deleted file mode 100644 index d9dc59cfdd..0000000000 --- a/types/redux-bootstrap/tsconfig.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "jsx": "react" - }, - "files": [ - "index.d.ts", - "redux-bootstrap-tests.tsx" - ] -} \ No newline at end of file diff --git a/types/redux-bootstrap/tslint.json b/types/redux-bootstrap/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/redux-bootstrap/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From bcde7a1be317f1879313deefe98b063d6253ab85 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 13:58:34 -0800 Subject: [PATCH 284/298] ldclient-js: Provides its own types (#22387) --- notNeededPackages.json | 6 + types/ldclient-js/index.d.ts | 238 ------------------------- types/ldclient-js/ldclient-js-tests.ts | 30 ---- types/ldclient-js/tsconfig.json | 24 --- types/ldclient-js/tslint.json | 79 -------- 5 files changed, 6 insertions(+), 371 deletions(-) delete mode 100644 types/ldclient-js/index.d.ts delete mode 100644 types/ldclient-js/ldclient-js-tests.ts delete mode 100644 types/ldclient-js/tsconfig.json delete mode 100644 types/ldclient-js/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 44abc21b6f..bac83690ae 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -408,6 +408,12 @@ "sourceRepoURL": "https://github.com/elitechance/lambda-phi", "asOfVersion": "1.0.1" }, + { + "libraryName": "ldclient-js", + "typingsPackageName": "ldclient-js", + "sourceRepoURL": "https://github.com/launchdarkly/js-client", + "asOfVersion": "1.1.11" + }, { "libraryName": "left-pad", "typingsPackageName": "left-pad", diff --git a/types/ldclient-js/index.d.ts b/types/ldclient-js/index.d.ts deleted file mode 100644 index 47792db29a..0000000000 --- a/types/ldclient-js/index.d.ts +++ /dev/null @@ -1,238 +0,0 @@ -// Type definitions for ldclient-js v1.1.2 -// Project: https://github.com/launchdarkly/js-client -// Definitions by: Isaac Sukin -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/** - * The LaunchDarkly JavaScript client interfaces. - * - * Documentation: http://docs.launchdarkly.com/docs/js-sdk-reference - */ -declare namespace LaunchDarkly { - /** - * The names of events to which users of the client can subscribe. - */ - export type LDEventName = 'ready' | 'change'; - - /** - * The types of values a feature flag can have. - * - * Flags can have any JSON-serializable value. - */ - export type LDFlagValue = any; - - /** - * A map of feature flags from their keys to their values. - */ - export type LDFlagSet = { - [key: string]: LDFlagValue, - }; - - /** - * A map of feature flag keys to objects holding changes in their values. - */ - export type LDFlagChangeset = { - [key: string]: { - current: LDFlagValue, - previous: LDFlagValue, - }, - }; - - /** - * The parameters required to (un)subscribe to/from LaunchDarkly events. - * - * See LDClient#on and LDClient#off. - */ - type LDEventSignature = ( - key: LDEventName, - callback: (current?: LDFlagValue | LDFlagChangeset, previous?: LDFlagValue) => void, - context?: any - ) => void; - - /** - * LaunchDarkly initialization options. - */ - export interface LDOptions { - /** - * The signed user key for Secure Mode. - * - * @see http://docs.launchdarkly.com/docs/js-sdk-reference#secure-mode - */ - hash: string; - - /** - * The initial set of flags to use until the remote set is retrieved. - * - * If "localStorage" is specified, the flags will be saved locally and - * retrieved from storage. Alternatively an LDFlagSet can be specified - * which will be used as the initial source of flag values. - */ - bootstrap?: 'localStorage' | LDFlagSet; - } - - /** - * A LaunchDarkly user object. - */ - export interface LDUser { - /** - * A unique string identifying a user. - */ - key: string; - - /** - * The user's name. - * - * You can search for users on the User page by name. - */ - name?: string; - - /** - * The user's first name. - */ - firstName?: string; - - /** - * The user's last name. - */ - lastName?: string; - - /** - * The user's email address. - * - * If an `avatar` URL is not provided, LaunchDarkly will use Gravatar - * to try to display an avatar for the user on the Users page. - */ - email?: string; - - /** - * An absolute URL to an avatar image for the user. - */ - avatar?: string; - - /** - * The user's IP address. - * - * If you provide an IP, LaunchDarkly will use a geolocation service to - * automatically infer a `country` for the user, unless you've already - * specified one. - */ - ip?: string; - - /** - * The country associated with the user. - */ - country?: string; - - /** - * Whether to show the user on the Users page in LaunchDarkly. - */ - anonymous?: boolean; - - /** - * Any additional attributes associated with the user. - */ - custom?: { - [key: string]: string | boolean | number | Array, - }; - } - - /** - * The LaunchDarkly client's instance interface. - * - * @see http://docs.launchdarkly.com/docs/js-sdk-reference - */ - export interface LDClient { - /** - * Identifies a user to LaunchDarkly. - * - * This only needs to be called if the user changes identities because - * normally the user's identity is set during client initialization. - * - * @param user - * A map of user options. Must contain at least the `key` property - * which identifies the user. - * @param hash - * The signed user key for Secure Mode; see - * http://docs.launchdarkly.com/docs/js-sdk-reference#secure-mode - * @param onDone - * A callback to invoke after the user is identified. - */ - identify: (user: LDUser, hash?: string, onDone?: () => void) => void; - - /** - * Retrieves a flag's value. - * - * @param key - * The key of the flag for which to retrieve the corresponding value. - * @param defaultValue - * The value to use if the flag is not available (for example, if the - * user is offline or a flag is requested that does not exist). - * - * @returns - * The flag's value. - */ - variation: (key: string, defaultValue?: LDFlagValue) => LDFlagValue; - - /** - * Registers an event listener. - * - * @param key - * The name of the event for which to listen. This can be "ready", - * "change", or "change:FLAG-KEY". - * @param callback - * The function to execute when the event fires. For the "change" - * event, the callback receives one parameter: an LDFlagChangeset - * describing the changes. For "change:FLAG-KEY" events, the callback - * receives two parameters: the current (new) value and the previous - * value of the relevant flag. - * @param context - * The "this" context to use for the callback. - */ - on: LDEventSignature; - - /** - * Deregisters an event listener. - * - * @param key - * The name of the event for which to stop listening. This can be - * "ready", "change", or "change:FLAG-KEY". - * @param callback - * The function to deregister. - * @param context - * The "this" context for the callback. - */ - off: LDEventSignature; - - /** - * Track page events to use in goals or A/B tests. - * - * LaunchDarkly automatically tracks pageviews and clicks that are - * specified in the Goals section of their dashboard. This can be used - * to track custom goals or other events that do not currently have - * goals. - * - * @param key - * The event to record. - * @param data - * Additional information to associate with the event. - */ - track: (key: string, data?: any) => void; - - /** - * Returns a map of all available flags to the current user's values. - */ - allFlags: () => LDFlagSet; - } - -} - -/** - * The LaunchDarkly static global. - */ -declare var LDClient: { - initialize: ( - key: string, - user: LaunchDarkly.LDUser, - options?: LaunchDarkly.LDOptions - ) => LaunchDarkly.LDClient; -}; diff --git a/types/ldclient-js/ldclient-js-tests.ts b/types/ldclient-js/ldclient-js-tests.ts deleted file mode 100644 index 3b7ea30125..0000000000 --- a/types/ldclient-js/ldclient-js-tests.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Implicitly calls LDClient#identify -const ldClient = LDClient.initialize( - 'ENV KEY', - { - key: 'USER KEY', - name: 'USER NAME', - custom: { - 'CUSTOM ATTRIBUTE': ['CUSTOM VALUE'], - }, - }, - { - hash: 'SECURE USER HASH', - } -); - -ldClient.on('ready', () => { - const defaultValue = false; - ldClient.variation('FLAG-KEY', defaultValue); - console.log('All flag values:', ldClient.allFlags()); -}); - -function changeCallback(changes: LaunchDarkly.LDFlagChangeset) { - console.log('Flags changed:', changes); -} - -ldClient.on('change', changeCallback); - -document.getElementById('disable-change-tracking')!.addEventListener('click', () => { - ldClient.off('change', changeCallback); -}); diff --git a/types/ldclient-js/tsconfig.json b/types/ldclient-js/tsconfig.json deleted file mode 100644 index a43d586229..0000000000 --- a/types/ldclient-js/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "ldclient-js-tests.ts" - ] -} \ No newline at end of file diff --git a/types/ldclient-js/tslint.json b/types/ldclient-js/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/ldclient-js/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From d0df8af318e457abf9a8f193f310b53e2feefb70 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 20 Dec 2017 15:33:01 -0800 Subject: [PATCH 285/298] pg-connection-string: Provides its own types (#22375) --- notNeededPackages.json | 6 +++++ types/pg-connection-string/index.d.ts | 17 -------------- .../pg-connection-string-tests.ts | 13 ----------- types/pg-connection-string/tsconfig.json | 23 ------------------- types/pg-connection-string/tslint.json | 1 - 5 files changed, 6 insertions(+), 54 deletions(-) delete mode 100644 types/pg-connection-string/index.d.ts delete mode 100644 types/pg-connection-string/pg-connection-string-tests.ts delete mode 100644 types/pg-connection-string/tsconfig.json delete mode 100644 types/pg-connection-string/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index bac83690ae..921fd414ce 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -552,6 +552,12 @@ "sourceRepoURL": "https://github.com/pillarjs/path-to-regexp", "asOfVersion": "1.7.0" }, + { + "libraryName": "pg-connection-string", + "typingsPackageName": "pg-connection-string", + "sourceRepoURL": "https://github.com/iceddev/pg-connection-string", + "asOfVersion": "2.0.0" + }, { "libraryName": "pg-promise", "typingsPackageName": "pg-promise", diff --git a/types/pg-connection-string/index.d.ts b/types/pg-connection-string/index.d.ts deleted file mode 100644 index fa79138728..0000000000 --- a/types/pg-connection-string/index.d.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Type definitions for pg-connection-string 0.1 -// Project: https://github.com/iceddev/pg-connection-string -// Definitions by: Bradley Ayers -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 - -export function parse(connectionString: string): { - host: string; - database: string | null; - port: string | null; - application_name?: string; - client_encoding?: string; - fallback_application_name?: string; - user?: string; - password?: string; - ssl?: boolean; -}; diff --git a/types/pg-connection-string/pg-connection-string-tests.ts b/types/pg-connection-string/pg-connection-string-tests.ts deleted file mode 100644 index bf9698a7b9..0000000000 --- a/types/pg-connection-string/pg-connection-string-tests.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { parse } from 'pg-connection-string'; - -const parts = parse('postgres://user:password@host:port/dbname'); - -parts.application_name; -parts.client_encoding; -parts.database; -parts.fallback_application_name; -parts.host; -parts.password; -parts.port; -parts.ssl; -parts.user; diff --git a/types/pg-connection-string/tsconfig.json b/types/pg-connection-string/tsconfig.json deleted file mode 100644 index c3b2765339..0000000000 --- a/types/pg-connection-string/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "pg-connection-string-tests.ts" - ] -} \ No newline at end of file diff --git a/types/pg-connection-string/tslint.json b/types/pg-connection-string/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/pg-connection-string/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } From 8b10461a433414587dd1e3ae32e1051d2c677b52 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 21 Dec 2017 07:23:39 -0800 Subject: [PATCH 286/298] Revert "Merge pull request #22107 from rafaelsouzaf/master" (#22417) This reverts commit fb68b21bea74048f69c7aa53bac60f91141725a3, reversing changes made to ae47b3c7d086659a3080e8aa91f7c77bcabca01a. --- .../definitions/plugin/plugin-registered.d.ts | 33 - types/hapi/definitions/plugin/plugin.d.ts | 47 - .../definitions/request/request-auth.d.ts | 27 - .../definitions/request/request-events.d.ts | 45 - .../definitions/request/request-info.d.ts | 41 - .../definitions/request/request-route.d.ts | 45 - types/hapi/definitions/request/request.d.ts | 216 -- .../definitions/response/response-events.d.ts | 24 - .../definitions/response/response-object.d.ts | 288 -- .../response/response-settings.d.ts | 33 - .../response/response-toolkit.d.ts | 133 - .../route/route-options-access-scope.d.ts | 28 - .../route/route-options-access.d.ts | 105 - .../route/route-options-cache.d.ts | 27 - .../definitions/route/route-options-cors.d.ts | 21 - .../route/route-options-payload.d.ts | 122 - .../definitions/route/route-options-pre.d.ts | 26 - .../route/route-options-response.d.ts | 84 - .../route/route-options-secure.d.ts | 43 - .../route/route-options-validate.d.ts | 92 - .../hapi/definitions/route/route-options.d.ts | 284 -- .../server/server-auth-scheme.d.ts | 68 - .../hapi/definitions/server/server-auth.d.ts | 82 - .../hapi/definitions/server/server-cache.d.ts | 42 - .../definitions/server/server-events.d.ts | 146 - types/hapi/definitions/server/server-ext.d.ts | 93 - .../hapi/definitions/server/server-info.d.ts | 55 - .../definitions/server/server-inject.d.ts | 50 - .../definitions/server/server-method.d.ts | 46 - .../server/server-options-cache.d.ts | 25 - .../definitions/server/server-options.d.ts | 188 -- .../hapi/definitions/server/server-realm.d.ts | 33 - .../definitions/server/server-register.d.ts | 32 - .../hapi/definitions/server/server-route.d.ts | 55 - .../server/server-state-options.d.ts | 61 - .../hapi/definitions/server/server-state.d.ts | 69 - types/hapi/definitions/server/server.d.ts | 546 ---- types/hapi/definitions/util/iron.d.ts | 88 - types/hapi/definitions/util/json.d.ts | 27 - types/hapi/definitions/util/lifecycle.d.ts | 59 - types/hapi/definitions/util/util.d.ts | 11 - types/hapi/index.d.ts | 2754 ++++++++++++++++- types/hapi/{v16 => }/test/connection/table.ts | 2 +- .../{v16 => }/test/continuation/errors.ts | 4 +- .../getting-started/01-creating-a-server.ts | 0 .../test/getting-started/02-adding-routes.ts | 0 .../03-serving-static-content.ts | 0 .../test/getting-started/04-using-plugins.ts | 0 types/hapi/{v16 => }/test/path/catch-all.ts | 2 +- types/hapi/{v16 => }/test/path/parameters.ts | 2 +- types/hapi/{v16 => }/test/plugins/options.ts | 2 +- types/hapi/{v16 => }/test/reply/continue.ts | 2 +- types/hapi/{v16 => }/test/reply/entity.ts | 2 +- types/hapi/{v16 => }/test/reply/redirect.ts | 2 +- types/hapi/{v16 => }/test/reply/reply.ts | 4 +- .../hapi/{v16 => }/test/reply/state_cookie.ts | 2 +- types/hapi/test/request/catch-all.ts | 15 - types/hapi/test/request/event-types.ts | 70 +- .../test/request/generate-response.ts | 2 +- types/hapi/test/request/get-log.ts | 33 +- types/hapi/{v16 => }/test/request/log.ts | 2 +- types/hapi/test/request/parameters.ts | 38 - types/hapi/test/request/query.ts | 27 +- .../hapi/{v16 => }/test/request/set-method.ts | 2 +- types/hapi/{v16 => }/test/request/set-url.ts | 4 +- types/hapi/{v16 => }/test/request/tail.ts | 2 +- types/hapi/test/response/continue.ts | 25 - .../test/response/error-representation.ts | 6 +- types/hapi/test/response/error.ts | 46 +- types/hapi/{v16 => }/test/response/events.ts | 2 +- .../{v16 => }/test/response/flow-control.ts | 2 +- types/hapi/test/response/redirect.ts | 20 - types/hapi/test/response/response-events.ts | 28 - types/hapi/test/response/response.ts | 37 - types/hapi/test/route/adding-routes.ts | 38 - .../test/route/additional-options.ts | 2 +- types/hapi/{v16 => }/test/route/auth.ts | 2 +- types/hapi/test/route/config.ts | 38 +- types/hapi/test/route/handler.ts | 13 +- types/hapi/{v16 => }/test/route/plugins.ts | 4 +- .../{v16 => }/test/route/prerequisites.ts | 2 +- .../{v16 => }/test/route/public-interface.ts | 2 +- types/hapi/test/route/route-options-pre.ts | 42 - types/hapi/test/route/route-options.ts | 167 - types/hapi/{v16 => }/test/route/validate.ts | 4 +- types/hapi/{v16 => }/test/server/app.ts | 2 +- types/hapi/{v16 => }/test/server/auth.ts | 4 +- types/hapi/{v16 => }/test/server/bind.ts | 2 +- types/hapi/{v16 => }/test/server/cache.ts | 2 +- .../test/server/connection-options.ts | 2 +- .../hapi/{v16 => }/test/server/connections.ts | 2 +- types/hapi/{v16 => }/test/server/decoder.ts | 2 +- types/hapi/{v16 => }/test/server/decorate.ts | 8 +- .../hapi/{v16 => }/test/server/dependency.ts | 2 +- types/hapi/{v16 => }/test/server/emit.ts | 2 +- types/hapi/{v16 => }/test/server/encoder.ts | 2 +- types/hapi/{v16 => }/test/server/event.ts | 2 +- types/hapi/{v16 => }/test/server/expose.ts | 2 +- types/hapi/{v16 => }/test/server/ext.ts | 2 +- types/hapi/{v16 => }/test/server/handler.ts | 4 +- types/hapi/{v16 => }/test/server/info.ts | 2 +- .../hapi/{v16 => }/test/server/initialize.ts | 4 +- types/hapi/{v16 => }/test/server/inject.ts | 2 +- types/hapi/{v16 => }/test/server/listener.ts | 2 +- types/hapi/{v16 => }/test/server/load.ts | 2 +- types/hapi/{v16 => }/test/server/log.ts | 2 +- types/hapi/{v16 => }/test/server/lookup.ts | 2 +- types/hapi/{v16 => }/test/server/match.ts | 2 +- types/hapi/{v16 => }/test/server/method.ts | 2 +- types/hapi/{v16 => }/test/server/methods.ts | 2 +- types/hapi/{v16 => }/test/server/mime.ts | 2 +- types/hapi/{v16 => }/test/server/new.ts | 4 +- types/hapi/{v16 => }/test/server/on.ts | 2 +- types/hapi/{v16 => }/test/server/once.ts | 2 +- types/hapi/{v16 => }/test/server/path.ts | 2 +- types/hapi/{v16 => }/test/server/plugins.ts | 2 +- types/hapi/{v16 => }/test/server/realm.ts | 2 +- types/hapi/{v16 => }/test/server/register.ts | 2 +- types/hapi/{v16 => }/test/server/route.ts | 2 +- types/hapi/{v16 => }/test/server/select.ts | 2 +- types/hapi/test/server/server-app.ts | 22 - types/hapi/test/server/server-auth-api.ts | 40 - types/hapi/test/server/server-auth-default.ts | 35 - types/hapi/test/server/server-auth-test.ts | 40 - types/hapi/test/server/server-bind.ts | 27 - .../test/server/server-cache-provision.ts | 19 - types/hapi/test/server/server-cache.ts | 23 - types/hapi/test/server/server-decoder.ts | 8 - types/hapi/test/server/server-decorations.ts | 15 - types/hapi/test/server/server-encoder.ts | 8 - types/hapi/test/server/server-events-once.ts | 24 - types/hapi/test/server/server-events.ts | 11 - types/hapi/test/server/server-expose.ts | 22 - types/hapi/test/server/server-info.ts | 10 - types/hapi/test/server/server-inject.ts | 20 - types/hapi/test/server/server-listener.ts | 14 - types/hapi/test/server/server-load.ts | 15 - types/hapi/test/server/server-lookup.ts | 20 - types/hapi/test/server/server-match.ts | 20 - types/hapi/test/server/server-method.ts | 26 - types/hapi/test/server/server-methods.ts | 11 - types/hapi/test/server/server-mime.ts | 22 - types/hapi/test/server/server-options.ts | 109 - types/hapi/test/server/server-path.ts | 30 - types/hapi/test/server/server-plugins.ts | 20 - types/hapi/test/server/server-settings.ts | 12 - types/hapi/test/server/server-start.ts | 11 - types/hapi/test/server/server-state.ts | 28 - types/hapi/test/server/server-stop.ts | 17 - types/hapi/test/server/server-table.ts | 22 - types/hapi/test/server/server-version.ts | 9 - types/hapi/{v16 => }/test/server/settings.ts | 2 +- types/hapi/{v16 => }/test/server/start.ts | 4 +- types/hapi/{v16 => }/test/server/state.ts | 2 +- types/hapi/{v16 => }/test/server/stop.ts | 2 +- types/hapi/{v16 => }/test/server/table.ts | 2 +- types/hapi/{v16 => }/test/server/version.ts | 2 +- types/hapi/tsconfig.json | 113 +- types/hapi/v16/index.d.ts | 2723 ---------------- types/hapi/v16/test/request/event-types.ts | 30 - types/hapi/v16/test/request/get-log.ts | 12 - types/hapi/v16/test/request/query.ts | 14 - types/hapi/v16/test/response/error.ts | 25 - types/hapi/v16/test/route/config.ts | 46 - types/hapi/v16/test/route/handler.ts | 10 - types/hapi/v16/tsconfig.json | 102 - types/hapi/v16/tslint.json | 79 - 167 files changed, 2924 insertions(+), 8031 deletions(-) delete mode 100644 types/hapi/definitions/plugin/plugin-registered.d.ts delete mode 100644 types/hapi/definitions/plugin/plugin.d.ts delete mode 100644 types/hapi/definitions/request/request-auth.d.ts delete mode 100644 types/hapi/definitions/request/request-events.d.ts delete mode 100644 types/hapi/definitions/request/request-info.d.ts delete mode 100644 types/hapi/definitions/request/request-route.d.ts delete mode 100644 types/hapi/definitions/request/request.d.ts delete mode 100644 types/hapi/definitions/response/response-events.d.ts delete mode 100644 types/hapi/definitions/response/response-object.d.ts delete mode 100644 types/hapi/definitions/response/response-settings.d.ts delete mode 100644 types/hapi/definitions/response/response-toolkit.d.ts delete mode 100644 types/hapi/definitions/route/route-options-access-scope.d.ts delete mode 100644 types/hapi/definitions/route/route-options-access.d.ts delete mode 100644 types/hapi/definitions/route/route-options-cache.d.ts delete mode 100644 types/hapi/definitions/route/route-options-cors.d.ts delete mode 100644 types/hapi/definitions/route/route-options-payload.d.ts delete mode 100644 types/hapi/definitions/route/route-options-pre.d.ts delete mode 100644 types/hapi/definitions/route/route-options-response.d.ts delete mode 100644 types/hapi/definitions/route/route-options-secure.d.ts delete mode 100644 types/hapi/definitions/route/route-options-validate.d.ts delete mode 100644 types/hapi/definitions/route/route-options.d.ts delete mode 100644 types/hapi/definitions/server/server-auth-scheme.d.ts delete mode 100644 types/hapi/definitions/server/server-auth.d.ts delete mode 100644 types/hapi/definitions/server/server-cache.d.ts delete mode 100644 types/hapi/definitions/server/server-events.d.ts delete mode 100644 types/hapi/definitions/server/server-ext.d.ts delete mode 100644 types/hapi/definitions/server/server-info.d.ts delete mode 100644 types/hapi/definitions/server/server-inject.d.ts delete mode 100644 types/hapi/definitions/server/server-method.d.ts delete mode 100644 types/hapi/definitions/server/server-options-cache.d.ts delete mode 100644 types/hapi/definitions/server/server-options.d.ts delete mode 100644 types/hapi/definitions/server/server-realm.d.ts delete mode 100644 types/hapi/definitions/server/server-register.d.ts delete mode 100644 types/hapi/definitions/server/server-route.d.ts delete mode 100644 types/hapi/definitions/server/server-state-options.d.ts delete mode 100644 types/hapi/definitions/server/server-state.d.ts delete mode 100644 types/hapi/definitions/server/server.d.ts delete mode 100644 types/hapi/definitions/util/iron.d.ts delete mode 100644 types/hapi/definitions/util/json.d.ts delete mode 100644 types/hapi/definitions/util/lifecycle.d.ts delete mode 100644 types/hapi/definitions/util/util.d.ts rename types/hapi/{v16 => }/test/connection/table.ts (94%) rename types/hapi/{v16 => }/test/continuation/errors.ts (95%) rename types/hapi/{v16 => }/test/getting-started/01-creating-a-server.ts (100%) rename types/hapi/{v16 => }/test/getting-started/02-adding-routes.ts (100%) rename types/hapi/{v16 => }/test/getting-started/03-serving-static-content.ts (100%) rename types/hapi/{v16 => }/test/getting-started/04-using-plugins.ts (100%) rename types/hapi/{v16 => }/test/path/catch-all.ts (89%) rename types/hapi/{v16 => }/test/path/parameters.ts (95%) rename types/hapi/{v16 => }/test/plugins/options.ts (95%) rename types/hapi/{v16 => }/test/reply/continue.ts (91%) rename types/hapi/{v16 => }/test/reply/entity.ts (93%) rename types/hapi/{v16 => }/test/reply/redirect.ts (84%) rename types/hapi/{v16 => }/test/reply/reply.ts (92%) rename types/hapi/{v16 => }/test/reply/state_cookie.ts (95%) delete mode 100644 types/hapi/test/request/catch-all.ts rename types/hapi/{v16 => }/test/request/generate-response.ts (93%) rename types/hapi/{v16 => }/test/request/log.ts (93%) delete mode 100644 types/hapi/test/request/parameters.ts rename types/hapi/{v16 => }/test/request/set-method.ts (91%) rename types/hapi/{v16 => }/test/request/set-url.ts (90%) rename types/hapi/{v16 => }/test/request/tail.ts (94%) delete mode 100644 types/hapi/test/response/continue.ts rename types/hapi/{v16 => }/test/response/error-representation.ts (84%) rename types/hapi/{v16 => }/test/response/events.ts (95%) rename types/hapi/{v16 => }/test/response/flow-control.ts (88%) delete mode 100644 types/hapi/test/response/redirect.ts delete mode 100644 types/hapi/test/response/response-events.ts delete mode 100644 types/hapi/test/response/response.ts delete mode 100644 types/hapi/test/route/adding-routes.ts rename types/hapi/{v16 => }/test/route/additional-options.ts (98%) rename types/hapi/{v16 => }/test/route/auth.ts (94%) rename types/hapi/{v16 => }/test/route/plugins.ts (92%) rename types/hapi/{v16 => }/test/route/prerequisites.ts (97%) rename types/hapi/{v16 => }/test/route/public-interface.ts (93%) delete mode 100644 types/hapi/test/route/route-options-pre.ts delete mode 100644 types/hapi/test/route/route-options.ts rename types/hapi/{v16 => }/test/route/validate.ts (96%) rename types/hapi/{v16 => }/test/server/app.ts (87%) rename types/hapi/{v16 => }/test/server/auth.ts (96%) rename types/hapi/{v16 => }/test/server/bind.ts (93%) rename types/hapi/{v16 => }/test/server/cache.ts (96%) rename types/hapi/{v16 => }/test/server/connection-options.ts (96%) rename types/hapi/{v16 => }/test/server/connections.ts (89%) rename types/hapi/{v16 => }/test/server/decoder.ts (90%) rename types/hapi/{v16 => }/test/server/decorate.ts (92%) rename types/hapi/{v16 => }/test/server/dependency.ts (93%) rename types/hapi/{v16 => }/test/server/emit.ts (90%) rename types/hapi/{v16 => }/test/server/encoder.ts (90%) rename types/hapi/{v16 => }/test/server/event.ts (90%) rename types/hapi/{v16 => }/test/server/expose.ts (92%) rename types/hapi/{v16 => }/test/server/ext.ts (96%) rename types/hapi/{v16 => }/test/server/handler.ts (94%) rename types/hapi/{v16 => }/test/server/info.ts (92%) rename types/hapi/{v16 => }/test/server/initialize.ts (72%) rename types/hapi/{v16 => }/test/server/inject.ts (93%) rename types/hapi/{v16 => }/test/server/listener.ts (95%) rename types/hapi/{v16 => }/test/server/load.ts (82%) rename types/hapi/{v16 => }/test/server/log.ts (89%) rename types/hapi/{v16 => }/test/server/lookup.ts (91%) rename types/hapi/{v16 => }/test/server/match.ts (91%) rename types/hapi/{v16 => }/test/server/method.ts (98%) rename types/hapi/{v16 => }/test/server/methods.ts (91%) rename types/hapi/{v16 => }/test/server/mime.ts (94%) rename types/hapi/{v16 => }/test/server/new.ts (96%) rename types/hapi/{v16 => }/test/server/on.ts (96%) rename types/hapi/{v16 => }/test/server/once.ts (91%) rename types/hapi/{v16 => }/test/server/path.ts (91%) rename types/hapi/{v16 => }/test/server/plugins.ts (90%) rename types/hapi/{v16 => }/test/server/realm.ts (86%) rename types/hapi/{v16 => }/test/server/register.ts (90%) rename types/hapi/{v16 => }/test/server/route.ts (93%) rename types/hapi/{v16 => }/test/server/select.ts (91%) delete mode 100644 types/hapi/test/server/server-app.ts delete mode 100644 types/hapi/test/server/server-auth-api.ts delete mode 100644 types/hapi/test/server/server-auth-default.ts delete mode 100644 types/hapi/test/server/server-auth-test.ts delete mode 100644 types/hapi/test/server/server-bind.ts delete mode 100644 types/hapi/test/server/server-cache-provision.ts delete mode 100644 types/hapi/test/server/server-cache.ts delete mode 100644 types/hapi/test/server/server-decoder.ts delete mode 100644 types/hapi/test/server/server-decorations.ts delete mode 100644 types/hapi/test/server/server-encoder.ts delete mode 100644 types/hapi/test/server/server-events-once.ts delete mode 100644 types/hapi/test/server/server-events.ts delete mode 100644 types/hapi/test/server/server-expose.ts delete mode 100644 types/hapi/test/server/server-info.ts delete mode 100644 types/hapi/test/server/server-inject.ts delete mode 100644 types/hapi/test/server/server-listener.ts delete mode 100644 types/hapi/test/server/server-load.ts delete mode 100644 types/hapi/test/server/server-lookup.ts delete mode 100644 types/hapi/test/server/server-match.ts delete mode 100644 types/hapi/test/server/server-method.ts delete mode 100644 types/hapi/test/server/server-methods.ts delete mode 100644 types/hapi/test/server/server-mime.ts delete mode 100644 types/hapi/test/server/server-options.ts delete mode 100644 types/hapi/test/server/server-path.ts delete mode 100644 types/hapi/test/server/server-plugins.ts delete mode 100644 types/hapi/test/server/server-settings.ts delete mode 100644 types/hapi/test/server/server-start.ts delete mode 100644 types/hapi/test/server/server-state.ts delete mode 100644 types/hapi/test/server/server-stop.ts delete mode 100644 types/hapi/test/server/server-table.ts delete mode 100644 types/hapi/test/server/server-version.ts rename types/hapi/{v16 => }/test/server/settings.ts (84%) rename types/hapi/{v16 => }/test/server/start.ts (76%) rename types/hapi/{v16 => }/test/server/state.ts (95%) rename types/hapi/{v16 => }/test/server/stop.ts (87%) rename types/hapi/{v16 => }/test/server/table.ts (89%) rename types/hapi/{v16 => }/test/server/version.ts (77%) delete mode 100644 types/hapi/v16/index.d.ts delete mode 100644 types/hapi/v16/test/request/event-types.ts delete mode 100644 types/hapi/v16/test/request/get-log.ts delete mode 100644 types/hapi/v16/test/request/query.ts delete mode 100644 types/hapi/v16/test/response/error.ts delete mode 100644 types/hapi/v16/test/route/config.ts delete mode 100644 types/hapi/v16/test/route/handler.ts delete mode 100644 types/hapi/v16/tsconfig.json delete mode 100644 types/hapi/v16/tslint.json diff --git a/types/hapi/definitions/plugin/plugin-registered.d.ts b/types/hapi/definitions/plugin/plugin-registered.d.ts deleted file mode 100644 index e83eb81a63..0000000000 --- a/types/hapi/definitions/plugin/plugin-registered.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverregistrations) - */ -export interface PluginsListRegistered { - [pluginName: string]: PluginRegistered; -} - -/** - * An object of the currently registered plugins where each key is a registered plugin name and the value is an - * object containing: - * * version - the plugin version. - * * name - the plugin name. - * * options - (optional) options passed to the plugin during registration. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverregistrations) - */ -export interface PluginRegistered { - - /** - * the plugin version. - */ - version: string; - - /** - * the plugin name. - */ - name: string; - - /** - * options used to register the plugin. - */ - options: object; - -} diff --git a/types/hapi/definitions/plugin/plugin.d.ts b/types/hapi/definitions/plugin/plugin.d.ts deleted file mode 100644 index 4340f804e1..0000000000 --- a/types/hapi/definitions/plugin/plugin.d.ts +++ /dev/null @@ -1,47 +0,0 @@ -import {Server, ServerRegisterOptions} from "hapi"; - -export interface PluginsStates { - [pluginName: string]: any; -} - -export interface PluginSpecificConfiguration { - -} - -/** - * Plugins provide a way to organize application code by splitting the server logic into smaller components. Each - * plugin can manipulate the server through the standard server interface, but with the added ability to sandbox - * certain properties. For example, setting a file path in one plugin doesn't affect the file path set - * in another plugin. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#plugins) - */ -export interface Plugin { - - /** - * (required) the registration function with the signature async function(server, options) where: - * * server - the server object with a plugin-specific server.realm. - * * options - any options passed to the plugin during registration via server.register(). - */ - register: (server: Server, options: ServerRegisterOptions) => void; - - /** - * (required) the plugin name string. The name is used as a unique key. Published plugins (e.g. published in the npm - * registry) should use the same name as the name field in their 'package.json' file. Names must be - * unique within each application. - */ - name: string; - - /** optional plugin version. The version is only used informatively to enable other plugins to find out the versions loaded. The version should be the same as the one specified in the plugin's 'package.json' file. */ - version?: string; - - /** (optional) if true, allows the plugin to be registered multiple times with the same server. Defaults to false. */ - multiple?: boolean; - - /** (optional) a string or an array of strings indicating a plugin dependency. Same as setting dependencies via server.dependency(). */ - dependencies?: string | string[]; - - /** once - (optional) if true, will only register the plugin once per server. If set, overrides the once option passed to server.register(). Defaults to no override. */ - once?: boolean; - -} - diff --git a/types/hapi/definitions/request/request-auth.d.ts b/types/hapi/definitions/request/request-auth.d.ts deleted file mode 100644 index 72dd69a4b4..0000000000 --- a/types/hapi/definitions/request/request-auth.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Authentication information: - * * artifacts - an artifact object received from the authentication strategy and used in authentication-related actions. - * * credentials - the credential object received during the authentication process. The presence of an object does not mean successful authentication. - * * error - the authentication error is failed and mode set to 'try'. - * * isAuthenticated - true if the request has been successfully authenticated, otherwise false. - * * isAuthorized - true is the request has been successfully authorized against the route authentication access configuration. If the route has not access rules defined or if the request failed authorization, set to false. - * * mode - the route authentication mode. - * * strategy - the name of the strategy used. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestauth) - */ -export interface RequestAuth { - /** an artifact object received from the authentication strategy and used in authentication-related actions. */ - artifacts: object; - /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ - credentials: any; - /** the authentication error is failed and mode set to 'try'. */ - error: Error; - /** true if the request has been successfully authenticated, otherwise false. */ - isAuthenticated: boolean; - /** true is the request has been successfully authorized against the route authentication access configuration. If the route has not access rules defined or if the request failed authorization, set to false. */ - isAuthorized: boolean; - /** the route authentication mode. */ - mode: string; - /** the name of the strategy used. */ - strategy: string; -} diff --git a/types/hapi/definitions/request/request-events.d.ts b/types/hapi/definitions/request/request-events.d.ts deleted file mode 100644 index c61b3ed65c..0000000000 --- a/types/hapi/definitions/request/request-events.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -import * as Podium from "podium"; - -/** - * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). - * 'finish' - emitted when the request payload finished reading. The event method signature is function (). - * 'disconnect' - emitted when a request errors or aborts unexpectedly. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) - */ -export type RequestEventType = "peek" | "finish" | "disconnect"; - -/** - * Access: read only and the public podium interface. - * The request.events supports the following events: - * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). - * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). - * * 'disconnect' - emitted when a request errors or aborts unexpectedly. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) - */ -export interface RequestEvents extends Podium { - - /** - * Access: read only and the public podium interface. - * The request.events supports the following events: - * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). - * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). - * * 'disconnect' - emitted when a request errors or aborts unexpectedly. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) - */ - on(criteria: RequestEventType, listener: Function): void; - - /** - * Access: read only and the public podium interface. - * The request.events supports the following events: - * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). - * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). - * * 'disconnect' - emitted when a request errors or aborts unexpectedly. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) - */ - once(criteria: RequestEventType, listener: Function): void; - - - - // TODO is it necessary to implement "emmit" event here? - -} diff --git a/types/hapi/definitions/request/request-info.d.ts b/types/hapi/definitions/request/request-info.d.ts deleted file mode 100644 index a4892438a2..0000000000 --- a/types/hapi/definitions/request/request-info.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Request information: - * * acceptEncoding - the request preferred encoding. - * * cors - if CORS is enabled for the route, contains the following: - * * isOriginMatch - true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. - * * host - content of the HTTP 'Host' header (e.g. 'example.com:8080'). - * * hostname - the hostname part of the 'Host' header (e.g. 'example.com'). - * * id - a unique request identifier (using the format '{now}:{connection.info.id}:{5 digits counter}'). - * * received - request reception timestamp. - * * referrer - content of the HTTP 'Referrer' (or 'Referer') header. - * * remoteAddress - remote client IP address. - * * remotePort - remote client port. - * * responded - request response timestamp (0 is not responded yet). - * Note that the request.info object is not meant to be modified. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestinfo) - */ -export interface RequestInfo { - /** the request preferred encoding. */ - acceptEncoding: string; - /** if CORS is enabled for the route, contains the following: */ - cors: { - /** - * true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. - */ - isOriginMatch?: boolean; - }; - /** content of the HTTP 'Host' header (e.g. 'example.com:8080'). */ - host: string; - /** the hostname part of the 'Host' header (e.g. 'example.com'). */ - hostname: string; - /** request reception timestamp. */ - received: number; - /** content of the HTTP 'Referrer' (or 'Referer') header. */ - referrer: string; - /** remote client IP address. */ - remoteAddress: string; - /** remote client port. */ - remotePort: string; - /** request response timestamp (0 is not responded yet). */ - responded: number; -} diff --git a/types/hapi/definitions/request/request-route.d.ts b/types/hapi/definitions/request/request-route.d.ts deleted file mode 100644 index fbafd033a6..0000000000 --- a/types/hapi/definitions/request/request-route.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -import {Request, RouteOptions, ServerRealm, Util} from "hapi"; - -/** - * The request route information object, where: - * * method - the route HTTP method. - * * path - the route path. - * * vhost - the route vhost option if configured. - * * realm - the active realm associated with the route. - * * settings - the route options object with all defaults applied. - * * fingerprint - the route internal normalized string representing the normalized path. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestroute) - */ -export interface RequestRoute { - - /** the route HTTP method. */ - method: Util.HTTP_METHODS_PARTIAL; - - /** the route path. */ - path: string; - - /** the route vhost option if configured. */ - vhost?: string | string[]; - - /** the active realm associated with the route.*/ - realm: ServerRealm; - - /** the route options object with all defaults applied. */ - settings: RouteOptions; - - /** the route internal normalized string representing the normalized path. */ - fingerprint: string; - - auth: { - /** - * Validates a request against the route's authentication access configuration, where: - * @param request - the request object. - * @return Return value: true if the request would have passed the route's access requirements. - * Note that the route's authentication mode and strategies are ignored. The only match is made between the request.auth.credentials scope and entity information and the route access configuration. - * If the route uses dynamic scopes, the scopes are constructed against the request.query, request.params, request.payload, and request.auth.credentials which may or may not match between the route and the request's route. If this method is called using a request that has not been authenticated (yet or not at all), it will return false if the route requires any authentication. - * [See docs](https://hapijs.com/api/17.0.1#-requestrouteauthaccessrequest) - */ - access(request: Request): boolean; - } - -} diff --git a/types/hapi/definitions/request/request.d.ts b/types/hapi/definitions/request/request.d.ts deleted file mode 100644 index a0605254a8..0000000000 --- a/types/hapi/definitions/request/request.d.ts +++ /dev/null @@ -1,216 +0,0 @@ -import * as stream from "stream"; -import * as url from "url"; -import * as http from "http"; -import * as Podium from "podium"; -import {PluginsStates, RequestAuth, RequestEvents, RequestInfo, RequestRoute, ResponseObject, Server, Util} from "hapi"; - -/** - * An object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestorig) - */ -export interface RequestOrig { - params: object; - query: object; - payload: object; -} - -/** - * The request object is created internally for each incoming request. It is not the same object received from the node - * HTTP server callback (which is available via [request.raw.req](https://github.com/hapijs/hapi/blob/master/API.md#request.raw)). The request properties change throughout - * the request [lifecycle](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle). - */ -export interface Request extends Podium { - - /** - * Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestapp) - */ - app: object; - - /** - * Authentication information: - * * artifacts - an artifact object received from the authentication strategy and used in authentication-related actions. - * * credentials - the credential object received during the authentication process. The presence of an object does not mean successful authentication. - * * error - the authentication error is failed and mode set to 'try'. - * * isAuthenticated - true if the request has been successfully authenticated, otherwise false. - * * isAuthorized - true is the request has been successfully authorized against the route authentication access configuration. If the route has not access rules defined or if the request failed authorization, set to false. - * * mode - the route authentication mode. - * * strategy - the name of the strategy used. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestauth) - */ - readonly auth: RequestAuth; - - /** - * Access: read only and the public podium interface. - * The request.events supports the following events: - * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). - * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). - * * 'disconnect' - emitted when a request errors or aborts unexpectedly. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestevents) - */ - events: RequestEvents; - - /** - * The raw request headers (references request.raw.req.headers). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestheaders) - */ - readonly headers: Util.Dictionary; - - /** - * Request information: - * * acceptEncoding - the request preferred encoding. - * * cors - if CORS is enabled for the route, contains the following: - * * isOriginMatch - true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. - * * host - content of the HTTP 'Host' header (e.g. 'example.com:8080'). - * * hostname - the hostname part of the 'Host' header (e.g. 'example.com'). - * * id - a unique request identifier (using the format '{now}:{connection.info.id}:{5 digits counter}'). - * * received - request reception timestamp. - * * referrer - content of the HTTP 'Referrer' (or 'Referer') header. - * * remoteAddress - remote client IP address. - * * remotePort - remote client port. - * * responded - request response timestamp (0 is not responded yet). - * Note that the request.info object is not meant to be modified. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestinfo) - */ - readonly info: RequestInfo; - - /** - * An array containing the logged request events. - * Note that this array will be empty if route log.collect is set to false. - */ - readonly logs: object[]; - - /** - * The request method in lower case (e.g. 'get', 'post'). - */ - readonly method: Util.HTTP_METHODS_PARTIAL_LOWERCASE; - - /** - * The parsed content-type header. Only available when payload parsing enabled and no payload error occurred. - */ - readonly mime: string; - - /** - * An object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. - */ - readonly orig: RequestOrig; - - /** - * An object where each key is a path parameter name with matching value as described in [Path parameters](https://github.com/hapijs/hapi/blob/master/API.md#path-parameters). - */ - readonly params: Util.Dictionary; - - /** - * An array containing all the path params values in the order they appeared in the path. - */ - readonly paramsArray: string[]; - - /** - * The request URI's pathname component. - */ - readonly path: string; - - /** - * The request payload based on the route payload.output and payload.parse settings. - * TODO check this typing and add references / links. - */ - readonly payload: stream.Readable | Buffer | string | object; - - /** - * Plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. - */ - plugins: PluginsStates; - - /** - * An object where each key is the name assigned by a route pre-handler methods function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. - */ - readonly pre: Util.Dictionary; - - /** - * Access: read / write (see limitations below). - * The response object when set. The object can be modified but must not be assigned another object. To replace the response with another from within an extension point, use reply(response) to override with a different response. Contains null when no response has been set (e.g. when a request terminates prematurely when the client disconnects). - */ - response: ResponseObject | null; - - /** - * Same as pre but represented as the response object created by the pre method. - */ - readonly preResponses: Util.Dictionary; - - /** - * By default the object outputted from node's URL parse() method. Might also be set indirectly via request.setUrl in which case it may be a string (if url is set to an object with the query attribute as an unparsed string). - */ - readonly query: any; - - /** - * An object containing the Node HTTP server objects. Direct interaction with these raw objects is not recommended. - * * req - the node request object. - * * res - the node response object. - */ - readonly raw: { - req: http.IncomingMessage; - res: http.ServerResponse; - }; - - /** - * The request route information object and method - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestroute) - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestrouteauthaccessrequest) - */ - readonly route: RequestRoute; - - /** - * Access: read only and the public server interface. - * The server object. - */ - server: Server; - - /** - * An object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. - */ - readonly state: Util.Dictionary; - - /** - * The parsed request URI. - */ - readonly url: url.Url; - - /** - * Returns a response which you can pass into the reply interface where: - * @param source - the value to set as the source of the reply interface, optional. - * @param options - options for the method, optional. - * @return ResponseObject - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestgenerateresponsesource-options) - */ - generateResponse(source: string | object | null, options?: {variety?: string; prepare?: Function; marshal?: Function; close?: Function; }): ResponseObject; - - /** - * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. The arguments are: - * @param tags - a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. - * @param data - (optional) an message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. - * Any logs generated by the server internally will be emitted only on the 'request-internal' channel and will include the event.internal flag set to true. - * @return void - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data) - */ - log(tags: string | string[], data?: string | object | (() => string | object)): void; - - /** - * Changes the request method before the router begins processing the request where: - * @param method - is the request HTTP method (e.g. 'GET'). - * @return void - * Can only be called from an 'onRequest' extension method. - * [See docs](https://hapijs.com/api/17.0.1#-requestsetmethodmethod) - */ - setMethod(method: Util.HTTP_METHODS_PARTIAL): void; - - /** - * Changes the request URI before the router begins processing the request where: - * Can only be called from an 'onRequest' extension method. - * @param url - the new request URI. If url is a string, it is parsed with node's URL parse() method with parseQueryString set to true. url can also be set to an object compatible with node's URL parse() method output. - * @param stripTrailingSlash - if true, strip the trailing slash from the path. Defaults to false. - * @return void - * [See docs](https://hapijs.com/api/17.0.1#-requestseturlurl-striptrailingslash) - */ - setUrl(url: string | url.URL, stripTrailingSlash?: boolean): void; - -} diff --git a/types/hapi/definitions/response/response-events.d.ts b/types/hapi/definitions/response/response-events.d.ts deleted file mode 100644 index 087b92cf37..0000000000 --- a/types/hapi/definitions/response/response-events.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -import * as Podium from "podium"; - -/** - * Access: read only and the public podium interface. - * The response.events object supports the following events: - * * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). - * * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). - * [See docs](https://hapijs.com/api/17.0.1#-responseevents) - */ -export interface ResponseEvents extends Podium { - - /** - * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). - * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). - */ - on(criteria: 'peek' | 'finish', listener: Function): void; - - /** - * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). - * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). - */ - once(criteria: 'peek' | 'finish', listener: Function): void; - -} diff --git a/types/hapi/definitions/response/response-object.d.ts b/types/hapi/definitions/response/response-object.d.ts deleted file mode 100644 index b9887c4ae6..0000000000 --- a/types/hapi/definitions/response/response-object.d.ts +++ /dev/null @@ -1,288 +0,0 @@ -import * as Podium from "podium"; -import {Json, Lifecycle, PluginsStates, ResponseEvents, ResponseSettings, ServerStateCookieOptions, Util} from "hapi"; - -/** - * Object where: - * * append - if true, the value is appended to any existing header value using separator. Defaults to false. - * * separator - string used as separator when appending to an existing value. Defaults to ','. - * * override - if false, the header value is not set if an existing value present. Defaults to true. - * * duplicate - if false, the header value is not modified if the provided value is already included. Does not apply when append is false or if the name is 'set-cookie'. Defaults to true. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheadername-value-options) - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#response-object) - */ -export interface ResponseObjectHeaderOptions { - append?: boolean; - separator?: string; - override?: boolean; - duplicate?: boolean; -} - -/** - * The response object contains the request response value along with various HTTP headers and flags. When a lifecycle - * method returns a value, the value is wrapped in a response object along with some default flags (e.g. 200 status - * code). In order to customize a response before it is returned, the h.response() method is provided. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#response-object) - * TODO, check extending from Podium is correct. Extending because of "The response object supports the following events" [See docs](https://hapijs.com/api/17.0.1#-responseevents) - */ -export interface ResponseObject extends Podium { - - /** - * Default value: {}. - * Application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseapp) - */ - app: object; - - /** - * Access: read only and the public podium interface. - * The response.events object supports the following events: - * * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). - * * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). - * [See docs](https://hapijs.com/api/17.0.1#-responseevents) - */ - readonly events: ResponseEvents; - - /** - * Default value: {}. - * An object containing the response headers where each key is a header field name and the value is the string header value or array of string. - * Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheaders) - */ - readonly headers: Util.Dictionary; - - /** - * Default value: {}. - * Plugin-specific state. Provides a place to store and pass request-level plugin data. plugins is an object where each key is a plugin name and the value is the state. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseplugins) - */ - plugins: PluginsStates; - - /** - * Object containing the response handling flags. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsesettings) - */ - readonly settings: ResponseSettings; - - /** - * The raw value returned by the lifecycle method. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsesource) - */ - readonly source: Lifecycle.ReturnValue; - - /** - * Default value: 200. - * The HTTP response status code. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsestatuscode) - */ - readonly statusCode: number; - - /** - * A string indicating the type of source with available values: - * * 'plain' - a plain response such as string, number, null, or simple object. - * * 'buffer' - a Buffer. - * * 'stream' - a Stream. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsevariety) - */ - readonly variety: 'plain' | 'buffer' | 'stream'; - - /** - * Sets the HTTP 'Content-Length' header (to avoid chunked transfer encoding) where: - * @param length - the header value. Must match the actual payload size. - * @return Return value: the current response object. - * [See docs](https://hapijs.com/api/17.0.1#-responsebyteslength) - */ - bytes(length: number): ResponseObject; - - /** - * Sets the 'Content-Type' HTTP header 'charset' property where: - * @param charset - the charset property value. - * @return Return value: the current response object. - * [See docs](https://hapijs.com/api/17.0.1#-responsecharsetcharset) - */ - charset(charset: string): ResponseObject; - - /** - * Sets the 'Content-Type' HTTP header 'charset' property where: - * $param charset - the charset property value. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsecodestatuscode) - */ - code(statusCode: number): ResponseObject; - - /** - * Sets the HTTP status message where: - * @param httpMessage - the HTTP status message (e.g. 'Ok' for status code 200). - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsemessagehttpmessage) - */ - message(httpMessage: string): ResponseObject; - - /** - * Sets the HTTP status code to Created (201) and the HTTP 'Location' header where: - * @param uri - an absolute or relative URI used as the 'Location' header value. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsecreateduri) - */ - created(uri: string): ResponseObject; - - /** - * Sets the string encoding scheme used to serial data into the HTTP payload where: - * @param encoding the encoding property value (see node Buffer encoding [See docs](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings)). - * * 'ascii' - for 7-bit ASCII data only. This encoding is fast and will strip the high bit if set. - * * 'utf8' - Multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8. - * * 'utf16le' - 2 or 4 bytes, little-endian encoded Unicode characters. Surrogate pairs (U+10000 to U+10FFFF) are supported. - * * 'ucs2' - Alias of 'utf16le'. - * * 'base64' - Base64 encoding. When creating a Buffer from a string, this encoding will also correctly accept "URL and Filename Safe Alphabet" as specified in RFC4648, Section 5. - * * 'latin1' - A way of encoding the Buffer into a one-byte encoded string (as defined by the IANA in RFC1345, page 63, to be the Latin-1 supplement block and C0/C1 control codes). - * * 'binary' - Alias for 'latin1'. - * * 'hex' - Encode each byte as two hexadecimal characters. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseencodingencoding) - */ - encoding(encoding: 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex'): ResponseObject; - - /** - * Sets the representation entity tag where: - * @param tag - the entity tag string without the double-quote. - * @param options - (optional) settings where: - * * weak - if true, the tag will be prefixed with the 'W/' weak signifier. Weak tags will fail to match identical tags for the purpose of determining 304 response status. Defaults to false. - * * vary - if true and content encoding is set or applied to the response (e.g 'gzip' or 'deflate'), the encoding name will be automatically added to the tag at transmission time (separated by a '-' character). Ignored when weak is true. Defaults to true. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseetagtag-options) - */ - etag(tag: string, options?: {weak: boolean, vary: boolean}): ResponseObject; - - /** - * Sets an HTTP header where: - * @param name - the header name. - * @param value - the header value. - * @param options - (optional) object where: - * * append - if true, the value is appended to any existing header value using separator. Defaults to false. - * * separator - string used as separator when appending to an existing value. Defaults to ','. - * * override - if false, the header value is not set if an existing value present. Defaults to true. - * * duplicate - if false, the header value is not modified if the provided value is already included. Does not apply when append is false or if the name is 'set-cookie'. Defaults to true. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseheadername-value-options) - */ - header(name: string, value: string, options?: ResponseObjectHeaderOptions): ResponseObject; - - /** - * Sets the HTTP 'Location' header where: - * @param uri - an absolute or relative URI used as the 'Location' header value. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responselocationuri) - */ - location(uri: string): ResponseObject; - - /** - * Sets an HTTP redirection response (302) and decorates the response with additional methods, where: - * @param uri - an absolute or relative URI used to redirect the client to another resource. - * @return Return value: the current response object. - * Decorates the response object with the response.temporary(), response.permanent(), and response.rewritable() methods to easily change the default redirection code (302). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseredirecturi) - */ - redirect(uri: string): ResponseObject; - - /** - * Sets the JSON.stringify() replacer argument where: - * @param method - the replacer function or array. Defaults to none. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsereplacermethod) - */ - replacer(method: Json.StringifyReplacer): ResponseObject; - - /** - * Sets the JSON.stringify() space argument where: - * @param count - the number of spaces to indent nested object keys. Defaults to no indentation. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsespacescount) - */ - spaces(count: number): ResponseObject; - - /** - * Sets an HTTP cookie where: - * @param name - the cookie name. - * @param value - the cookie value. If no options.encoding is defined, must be a string. See server.state() for supported encoding values. - * @param options - (optional) configuration. If the state was previously registered with the server using server.state(), the specified keys in options are merged with the default server definition. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsestatename-value-options) - */ - state(name: string, value: object, options?: ServerStateCookieOptions): ResponseObject; - - /** - * Sets a string suffix when the response is process via JSON.stringify() where: - * @param suffix - the string suffix. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsesuffixsuffix) - */ - suffix(suffix: string): ResponseObject; - - /** - * Overrides the default route cache expiration rule for this response instance where: - * @param msec - the time-to-live value in milliseconds. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsettlmsec) - */ - ttl(msec: number): ResponseObject; - - /** - * Sets the HTTP 'Content-Type' header where: - * @param mimeType - is the mime type. - * @return Return value: the current response object. - * Should only be used to override the built-in default for each response type. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsetypemimetype) - */ - type(mimeType: string): ResponseObject; - - /** - * Clears the HTTP cookie by setting an expired value where: - * @param name - the cookie name. - * @param options - (optional) configuration for expiring cookie. If the state was previously registered with the server using server.state(), the specified options are merged with the server definition. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responseunstatename-options) - */ - unstate(name: string, options?: ServerStateCookieOptions): ResponseObject; - - /** - * Adds the provided header to the list of inputs affected the response generation via the HTTP 'Vary' header where: - * @param header - the HTTP request header name. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsevaryheader) - */ - vary(header: string): ResponseObject; - - /** - * Marks the response object as a takeover response. - * @return Return value: the current response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsetakeover) - */ - takeover(): ResponseObject; - - /** - * Sets the status code to 302 or 307 (based on the response.rewritable() setting) where: - * @param isTemporary - if false, sets status to permanent. Defaults to true. - * @return Return value: the current response object. - * Only available after calling the response.redirect() method. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsetemporaryistemporary) - */ - temporary(isTemporary: boolean): ResponseObject; - - /** - * Sets the status code to 301 or 308 (based on the response.rewritable() setting) where: - * @param isPermanent - if false, sets status to temporary. Defaults to true. - * @return Return value: the current response object. - * Only available after calling the response.redirect() method. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsepermanentispermanent) - */ - permanent(isPermanent: boolean): ResponseObject; - - /** - * Sets the status code to 301/302 for rewritable (allows changing the request method from 'POST' to 'GET') or 307/308 for non-rewritable (does not allow changing the request method from 'POST' to 'GET'). Exact code based on the response.temporary() or response.permanent() setting. Arguments: - * @param isRewritable - if false, sets to non-rewritable. Defaults to true. - * @return Return value: the current response object. - * Only available after calling the response.redirect() method. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responserewritableisrewritable) - */ - rewritable(isRewritable: boolean): ResponseObject; - -} diff --git a/types/hapi/definitions/response/response-settings.d.ts b/types/hapi/definitions/response/response-settings.d.ts deleted file mode 100644 index 0926878d1c..0000000000 --- a/types/hapi/definitions/response/response-settings.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -import {Json} from "hapi"; - -/** - * Object containing the response handling flags. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-responsesettings) - */ -export interface ResponseSettings { - - /** - * Defaults value: true. - * If true and source is a Stream, copies the statusCode and headers properties of the stream object to the outbound response. - */ - readonly passThrough: boolean; - - /** - * Default value: null (use route defaults). - * Override the route json options used when source value requires stringification. - */ - readonly stringify: Json.StringifyArguments; - - /** - * Default value: null (use route defaults). - * If set, overrides the route cache with an expiration value in milliseconds. - */ - readonly ttl: number; - - /** - * Default value: false. - * If true, a suffix will be automatically added to the 'ETag' header at transmission time (separated by a '-' character) when the HTTP 'Vary' header is present. - */ - varyEtag: boolean; - -} diff --git a/types/hapi/definitions/response/response-toolkit.d.ts b/types/hapi/definitions/response/response-toolkit.d.ts deleted file mode 100644 index 7496b4cee2..0000000000 --- a/types/hapi/definitions/response/response-toolkit.d.ts +++ /dev/null @@ -1,133 +0,0 @@ -import {ResponseObject, ServerRealm, ServerStateCookieOptions} from "hapi"; - -/** - * See more about Lifecycle - * https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle - * - */ - - -/** - * The response toolkit is a collection of properties and utilities passed to every [lifecycle method](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) - * It is somewhat hard to define as it provides both utilities for manipulating responses as well as other information. Since the - * toolkit is passed as a function argument, developers can name it whatever they want. For the purpose of this - * document the h notation is used. It is named in the spirit of the RethinkDB r method, with h for hapi. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#response-toolkit) - */ -export interface ResponseToolkit { - - /** - * A response symbol. When returned by a lifecycle method, the request lifecycle skips to the finalizing step - * without further interaction with the node response stream. It is the developer's responsibility to write - * and end the response directly via [request.raw.res](https://github.com/hapijs/hapi/blob/master/API.md#request.raw). - */ - readonly abandon: Object; - - /** - * A response symbol. When returned by a lifecycle method, the request lifecycle skips to the finalizing step after - * calling request.raw.res.end()) to close the the node response stream. - */ - readonly close: Object; - - /** - * A response symbol. Provides access to the route or server context set via the route [bind](https://github.com/hapijs/hapi/blob/master/API.md#route.options.bind) - * option or [server.bind()](https://github.com/hapijs/hapi/blob/master/API.md#server.bind()). - */ - readonly context: any; - - /** - * A response symbol. When returned by a lifecycle method, the request lifecycle continues without changing the response. - */ - readonly continue: Object; - - /** - * The [server realm](https://github.com/hapijs/hapi/blob/master/API.md#server.realm) associated with the matching - * route. Defaults to the root server realm in the onRequest step. - */ - readonly realm: ServerRealm; - - /** - * Access: read only and public request interface. - * The [request] object. This is a duplication of the request lifecycle method argument used by - * [toolkit decorations](https://github.com/hapijs/hapi/blob/master/API.md#server.decorate()) to access the current request. - */ - request: object; // TODO needs review - - /** - * Used by the [authentication] method to pass back valid credentials where: - * @param data - an object with: - * * credentials - (required) object representing the authenticated entity. - * * artifacts - (optional) authentication artifacts object specific to the authentication scheme. - * @return Return value: an internal authentication object. - */ - authenticated(data: {credentials: object, artifacts?: object}): object; - - /** - * Sets the response 'ETag' and 'Last-Modified' headers and checks for any conditional request headers to decide if - * the response is going to qualify for an HTTP 304 (Not Modified). If the entity values match the request - * conditions, h.entity() returns a response object for the lifecycle method to return as its value which will - * set a 304 response. Otherwise, it sets the provided entity headers and returns undefined. - * The method argumetns are: - * @param options - a required configuration object with: - * * etag - the ETag string. Required if modified is not present. Defaults to no header. - * * modified - the Last-Modified header value. Required if etag is not present. Defaults to no header. - * * vary - same as the response.etag() option. Defaults to true. - * @return Return value: - a response object if the response is unmodified. - undefined if the response has changed. - * If undefined is returned, the developer must return a valid lifecycle method value. If a response is returned, - * it should be used as the return value (but may be customize using the response methods). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hentityoptions) - */ - entity(options?: {etag?: string, modified?: string, vary?: boolean}): ResponseObject | undefined; - - /** - * Redirects the client to the specified uri. Same as calling h.response().redirect(uri). - * @param url - * @return Returns a response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hredirecturi) - */ - redirect(uri?: string): ResponseObject; - - /** - * Wraps the provided value and returns a response object which allows customizing the response - * (e.g. setting the HTTP status code, custom headers, etc.), where: - * @param value - (optional) return value. Defaults to null. - * @return Returns a response object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hresponsevalue) - */ - response(value?: string | object): ResponseObject; - - /** - * Sets a response cookie using the same arguments as response.state(). - * @param name of the cookie - * @param value of the cookie - * @param (optional) ServerStateCookieOptions object. - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hstatename-value-options) - */ - state(name: string, value: string, options?: ServerStateCookieOptions): void; - - /** - * Used by the [authentication] method to indicate authentication failed and pass back the credentials received where: - * @param error - (required) the authentication error. - * @param data - (optional) an object with: - * * credentials - (required) object representing the authenticated entity. - * * artifacts - (optional) authentication artifacts object specific to the authentication scheme. - * @return void. - * The method is used to pass both the authentication error and the credentials. For example, if a request included - * expired credentials, it allows the method to pass back the user information (combined with a 'try' - * authentication mode) for error customization. - * There is no difference between throwing the error or passing it with the h.unauthenticated() method is no credentials are passed, but it might still be helpful for code clarity. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hunauthenticatederror-data) - */ - unauthenticated(error: Error, data?: {credentials: object, artifacts?: object}): void; - - /** - * Clears a response cookie using the same arguments as - * @param name of the cookie - * @param options (optional) ServerStateCookieOptions object. - * @return void. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-hunstatename-options) - */ - unstate(name: string, options?: ServerStateCookieOptions): void; - -} diff --git a/types/hapi/definitions/route/route-options-access-scope.d.ts b/types/hapi/definitions/route/route-options-access-scope.d.ts deleted file mode 100644 index 4ed76fe9c6..0000000000 --- a/types/hapi/definitions/route/route-options-access-scope.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import {RouteOptionsAccessEntity} from "hapi"; - -/** - * Each rule is evaluated against an incoming request and access is granted if at least one of the rules matches. - * Each rule object must include at least one of [scope](https://github.com/hapijs/hapi/blob/master/API.md#route.options.auth.access.scope) or [entity](https://github.com/hapijs/hapi/blob/master/API.md#route.options.auth.access.entity). - */ -export interface RouteOptionsAccessObject { - - /** - * Default value: false (no scope requirements). - * The application scope required to access the route. Value can be a scope string or an array of scope strings. When authenticated, the credentials object scope property must contain at least one of the scopes defined to access the route. - * If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' scope must not include 'a', must include 'b', and must include one of 'c' or 'd'. - * You may also access properties on the request object (query, params, payload, and credentials) to populate a dynamic scope by using the '{' and '}' characters around the property name, such as 'user-{params.id}'. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessscope) - */ - scope?: false | string | string[]; - - /** - * Default value: 'any'. - * The required authenticated entity type. If set, must match the entity value of the request authenticated credentials. Available values: - * * 'any' - the authentication can be on behalf of a user or application. - * * 'user' - the authentication must be on behalf of a user which is identified by the presence of a 'user' attribute in the credentials object returned by the authentication strategy. - * * 'app' - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessentity) - */ - entity?: RouteOptionsAccessEntity; - -} diff --git a/types/hapi/definitions/route/route-options-access.d.ts b/types/hapi/definitions/route/route-options-access.d.ts deleted file mode 100644 index 57cd13e405..0000000000 --- a/types/hapi/definitions/route/route-options-access.d.ts +++ /dev/null @@ -1,105 +0,0 @@ -/** - * The required authenticated entity type. If set, must match the entity value of the request authenticated credentials. Available values: - * * 'any' - the authentication can be on behalf of a user or application. - * * 'user' - the authentication must be on behalf of a user which is identified by the presence of a 'user' attribute in the credentials object returned by the authentication strategy. - * * 'app' - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessentity) - */ -export enum RouteOptionsAccessEntity { - Any = 'any', - User = 'user', - App = 'app' -} - -/** - * The authentication mode. Available values: - * * 'required' - authentication is required. - * * 'optional' - authentication is optional - the request must include valid credentials or no credentials at all. - * * 'try' - similar to 'optional', any request credentials are attempted authentication, but if the credentials are invalid, the request proceeds regardless of the authentication error. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthmode) - */ -export enum RouteOptionsAccessMode { - Required = 'required', - Optional = 'optional', - Try = 'try', -} - -/** - * Available values: - * * false - no payload authentication. - * * 'required' - payload authentication required. - * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthpayload) - */ -export enum RouteOptionsAccessPayload { - Required = 'required', - Optional = 'optional', -} - -/** - * Route Authentication Options - */ -export interface RouteOptionsAccess { - - /** - * Default value: none. - * An object or array of objects specifying the route access rules. Each rule is evaluated against an incoming request and access is granted if at least one of the rules matches. Each rule object must include at least one of scope or entity. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccess) - */ - access?: object | object[]; - - /** - * Default value: false (no scope requirements). - * The application scope required to access the route. Value can be a scope string or an array of scope strings. When authenticated, the credentials object scope property must contain at least one of the scopes defined to access the route. - * If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' scope must not include 'a', must include 'b', and must include one of 'c' or 'd'. - * You may also access properties on the request object (query, params, payload, and credentials) to populate a dynamic scope by using the '{' and '}' characters around the property name, such as 'user-{params.id}'. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessscope) - */ - scope?: false | string | string[]; - - /** - * Default value: 'any'. - * The required authenticated entity type. If set, must match the entity value of the request authenticated credentials. Available values: - * * 'any' - the authentication can be on behalf of a user or application. - * * 'user' - the authentication must be on behalf of a user which is identified by the presence of a 'user' attribute in the credentials object returned by the authentication strategy. - * * 'app' - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthaccessentity) - */ - entity?: RouteOptionsAccessEntity; - - /** - * Default value: 'required'. - * The authentication mode. Available values: - * * 'required' - authentication is required. - * * 'optional' - authentication is optional - the request must include valid credentials or no credentials at all. - * * 'try' - similar to 'optional', any request credentials are attempted authentication, but if the credentials are invalid, the request proceeds regardless of the authentication error. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthmode) - */ - mode?: RouteOptionsAccessMode; - - /** - * Default value: false, unless the scheme requires payload authentication. - * If set, the incoming request payload is authenticated after it is processed. Requires a strategy with payload authentication support (e.g. Hawk). Cannot be set to a value other than 'required' when the scheme sets the authentication options.payload to true. - * Available values: - * * false - no payload authentication. - * * 'required' - payload authentication required. - * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthpayload) - */ - payload?: false | RouteOptionsAccessPayload; - - /** - * Default value: the default strategy set via server.auth.default(). - * An array of string strategy names in the order they should be attempted. Cannot be used together with strategy. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthstrategies) - */ - strategies?: string[]; - - /** - * Default value: the default strategy set via server.auth.default(). - * A string strategy names. Cannot be used together with strategies. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsauthstrategy) - */ - strategy?: string; - -} diff --git a/types/hapi/definitions/route/route-options-cache.d.ts b/types/hapi/definitions/route/route-options-cache.d.ts deleted file mode 100644 index 91df550ad4..0000000000 --- a/types/hapi/definitions/route/route-options-cache.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Values are: - * * * 'default' - no privacy flag. - * * * 'public' - mark the response as suitable for public caching. - * * * 'private' - mark the response as suitable only for private caching. - * * expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. - * * expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. - * * statuses - an array of HTTP response status code numbers (e.g. 200) which are allowed to include a valid caching directive. - * * otherwise - a string with the value of the 'Cache-Control' header when caching is disabled. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscache) - */ -export type RouteOptionsCache = { - privacy?: 'default' | 'public' | 'private'; - statuses?: number[]; - otherwise?: string; -} & ( - { - expiresIn?: number; - expiresAt?: undefined; - } | { - expiresIn?: undefined; - expiresAt?: string; - } | { - expiresIn?: undefined; - expiresAt?: undefined; - } -); diff --git a/types/hapi/definitions/route/route-options-cors.d.ts b/types/hapi/definitions/route/route-options-cors.d.ts deleted file mode 100644 index d19e6a5774..0000000000 --- a/types/hapi/definitions/route/route-options-cors.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Default value: false (no CORS headers). - * The Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. To enable, set cors to true, or to an object with the following options: - * * origin - an array of allowed origin servers strings ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a wildcard '*' character, or a single '*' origin string. If set to 'ignore', any incoming Origin header is ignored (present or not) and the 'Access-Control-Allow-Origin' header is set to '*'. Defaults to any origin ['*']. - * * maxAge - number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. Defaults to 86400 (one day). - * * headers - a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match']. - * * additionalHeaders - a strings array of additional headers to headers. Use this to keep the default headers in place. - * * exposedHeaders - a strings array of exposed headers ('Access-Control-Expose-Headers'). Defaults to ['WWW-Authenticate', 'Server-Authorization']. - * * additionalExposedHeaders - a strings array of additional headers to exposedHeaders. Use this to keep the default headers in place. - * * credentials - if true, allows user credentials to be sent ('Access-Control-Allow-Credentials'). Defaults to false. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscors) - */ -export interface RouteOptionsCors { - origin?: string[] | '*'| 'ignore'; - maxAge?: number; - headers?: string[]; - additionalHeaders?: string[]; - exposedHeaders?: string[]; - additionalExposedHeaders?: string[]; - credentials?: boolean; -} diff --git a/types/hapi/definitions/route/route-options-payload.d.ts b/types/hapi/definitions/route/route-options-payload.d.ts deleted file mode 100644 index a13db35c32..0000000000 --- a/types/hapi/definitions/route/route-options-payload.d.ts +++ /dev/null @@ -1,122 +0,0 @@ -import {Lifecycle, Util} from "hapi"; - -/** - * The value must be one of: - * * 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, a raw Buffer is returned. - * * 'stream' - the incoming payload is made available via a Stream.Readable interface. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are provided as streams. File streams from a 'multipart/form-data' upload will also have a hapi property containing the filename and headers properties. Note that payload streams for multipart payloads are a synthetic interface created on top of the entire mutlipart content loaded into memory. To avoid loading large multipart payloads into memory, set parse to false and handle the multipart payload in the handler using a streaming parser (e.g. pez). - * * 'file' - the incoming payload is written to temporary file in the directory specified by the uploads settings. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are saved to disk. Note that it is the sole responsibility of the application to clean up the files generated by the framework. This can be done by keeping track of which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform cleanup. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadoutput) - */ -export type PayloadOutput = 'data' | 'stream' | 'file'; - -/** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) - */ -export type PayloadCompressionDecoderSettings = object; - -/** - * Determines how the request payload is processed. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayload) - */ -export interface RouteOptionsPayload { - - /** - * Default value: allows parsing of the following mime types: - * * application/json - * * application/*+json - * * application/octet-stream - * * application/x-www-form-urlencoded - * * multipart/form-data - * * text/* - * A string or an array of strings with the allowed mime types for the endpoint. Use this settings to limit the set of allowed mime types. Note that allowing additional mime types not listed above will not enable them to be parsed, and if parse is true, the request will result in an error response. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadallow) - */ - allow?: string | string[]; - - /** - * Default value: none. - * An object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in compression. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadcompression) - */ - compression?: Util.Dictionary; - - /** - * Default value: 'application/json'. - * The default content type if the 'Content-Type' request header is missing. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloaddefaultcontenttype) - */ - defaultContentType?: string; - - /** - * Default value: 'error' (return a Bad Request (400) error response). - * A failAction value which determines how to handle payload parsing errors. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadfailaction) - */ - failAction?: Lifecycle.FailAction; - - /** - * Default value: 1048576 (1MB). - * Limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadmaxbytes) - */ - maxBytes?: number; - - /** - * Default value: none. - * Overrides payload processing for multipart requests. Value can be one of: - * * false - disable multipart processing. - * an object with the following required options: - * * output - same as the output option with an additional value option: - * * * annotated - wraps each multipart part in an object with the following keys: // TODO type this? - * * * * headers - the part headers. - * * * * filename - the part file name. - * * * * payload - the processed part payload. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadmultipart) - */ - multipart?: false | { - output: PayloadOutput | 'annotated'; - }; - - /** - * Default value: 'data'. - * The processed payload format. The value must be one of: - * * 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, a raw Buffer is returned. - * * 'stream' - the incoming payload is made available via a Stream.Readable interface. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are provided as streams. File streams from a 'multipart/form-data' upload will also have a hapi property containing the filename and headers properties. Note that payload streams for multipart payloads are a synthetic interface created on top of the entire mutlipart content loaded into memory. To avoid loading large multipart payloads into memory, set parse to false and handle the multipart payload in the handler using a streaming parser (e.g. pez). - * * 'file' - the incoming payload is written to temporary file in the directory specified by the uploads settings. If the payload is 'multipart/form-data' and parse is true, field values are presented as text while files are saved to disk. Note that it is the sole responsibility of the application to clean up the files generated by the framework. This can be done by keeping track of which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform cleanup. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadoutput) - */ - output?: PayloadOutput; - - /** - * Default value: none. - * A mime type string overriding the 'Content-Type' header value received. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadoverride) - */ - override?: string; - - /** - * Default value: true. - * Determines if the incoming payload is processed or presented raw. Available values: - * * true - if the request 'Content-Type' matches the allowed mime types set by allow (for the whole payload as well as parts), the payload is converted into an object when possible. If the format is unknown, a Bad Request (400) error response is sent. Any known content encoding is decoded. - * * false - the raw payload is returned unmodified. - * * 'gunzip' - the raw payload is returned unmodified after any known content encoding is decoded. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadparse) - */ - parse?: boolean | 'gunzip'; - - /** - * Default value: to 10000 (10 seconds). - * Payload reception timeout in milliseconds. Sets the maximum time allowed for the client to transmit the request payload (body) before giving up and responding with a Request Timeout (408) error response. - * Set to false to disable. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloadtimeout) - */ - timeout?: false | number; - - /** - * Default value: os.tmpdir(). - * The directory used for writing file uploads. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayloaduploads) - */ - uploads?: string; - -} diff --git a/types/hapi/definitions/route/route-options-pre.d.ts b/types/hapi/definitions/route/route-options-pre.d.ts deleted file mode 100644 index 1cd980fc16..0000000000 --- a/types/hapi/definitions/route/route-options-pre.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import {Lifecycle} from "hapi"; - -/** - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre) - */ -export type RouteOptionsPreArray = RouteOptionsPreAllOptions[]; - -/** - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre) - */ -export type RouteOptionsPreAllOptions = RouteOptionsPreObject | RouteOptionsPreObject[] | Lifecycle.Method; - -/** - * An object with: - * * method - a lifecycle method. - * * assign - key name used to assign the response of the method to in request.pre and request.preResponses. - * * failAction - A failAction value which determine what to do when a pre-handler method throws an error. If assign is specified and the failAction setting is not 'error', the error will be assigned. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre) - */ -export interface RouteOptionsPreObject { - method: Lifecycle.Method; - assign: string; - failAction?: Lifecycle.FailAction; -} - - diff --git a/types/hapi/definitions/route/route-options-response.d.ts b/types/hapi/definitions/route/route-options-response.d.ts deleted file mode 100644 index fa3c8f8560..0000000000 --- a/types/hapi/definitions/route/route-options-response.d.ts +++ /dev/null @@ -1,84 +0,0 @@ -import {Lifecycle, Util} from "hapi"; -import {ValidationOptions} from "joi"; - -/** - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseemptystatuscode) - */ -export enum EmptyStatusCode { - HTTP_200 = 200, - HTTP_204 = 204, -} - -export type RouteOptionsResponseSchema = boolean | ValidationOptions | ((value: object, options: object) => any); - -/** - * Processing rules for the outgoing response. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponse) - */ -export interface RouteOptionsResponse { - - /** - * Default value: 200. - * The default HTTP status code when the payload is considered empty. Value can be 200 or 204. Note that a 200 status code is converted to a 204 only at the time of response transmission (the response status code will remain 200 throughout the request lifecycle unless manually set). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseemptystatuscode) - */ - emptyStatusCode?: EmptyStatusCode; - - /** - * Default value: 'error' (return an Internal Server Error (500) error response). - * A failAction value which defines what to do when a response fails payload validation. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsefailaction) - */ - failAction?: Lifecycle.FailAction; - - /** - * Default value: false. - * If true, applies the validation rule changes to the response payload. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsemodify) - */ - modify?: boolean; - - /** - * Default value: none. - * [joi](http://github.com/hapijs/joi) options object pass to the validation function. Useful to set global options such as stripUnknown or abortEarly (the complete list is available here). If a custom validation function is defined via schema or status then options can an arbitrary object that will be passed to this function as the second argument. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseoptions) - */ - options?: ValidationOptions; // TODO needs validation - - /** - * Default value: true. - * If false, payload range support is disabled. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseranges) - */ - ranges?: boolean; - - /** - * Default value: 100 (all responses). - * The percent of response payloads validated (0 - 100). Set to 0 to disable all validation. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsesample) - */ - sample?: number; - - /** - * Default value: true (no validation). - * The default response payload validation rules (for all non-error responses) expressed as one of: - * * true - any payload allowed (no validation). - * * false - no payload allowed. - * * a joi validation object. The options along with the request context ({ headers, params, query, payload, app, auth }) are passed to the validation function. - * * a validation function using the signature async function(value, options) where: - * * * value - the pending response payload. - * * * options - The options along with the request context ({ headers, params, query, payload, app, auth }). - * * * if the function returns a value and modify is true, the value is used as the new response. If the original response is an error, the return value is used to override the original error output.payload. If an error is thrown, the error is processed according to failAction. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponseschema) - */ - schema?: RouteOptionsResponseSchema; - - /** - * Default value: none. - * Validation schemas for specific HTTP status codes. Responses (excluding errors) not matching the listed status codes are validated using the default schema. - * status is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponsestatus) - */ - status?: Util.Dictionary; - -} diff --git a/types/hapi/definitions/route/route-options-secure.d.ts b/types/hapi/definitions/route/route-options-secure.d.ts deleted file mode 100644 index 8c68f25dfe..0000000000 --- a/types/hapi/definitions/route/route-options-secure.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Default value: false (security headers disabled). - * Sets common security headers. To enable, set security to true or to an object with the following options: - * * hsts - controls the 'Strict-Transport-Security' header, where: - * * * true - the header will be set to max-age=15768000. This is the default value. - * * * a number - the maxAge parameter will be set to the provided value. - * * * an object with the following fields: - * * * * maxAge - the max-age portion of the header, as a number. Default is 15768000. - * * * * includeSubDomains - a boolean specifying whether to add the includeSubDomains flag to the header. - * * * * preload - a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. - * * xframe - controls the 'X-Frame-Options' header, where: - * * * true - the header will be set to 'DENY'. This is the default value. - * * * 'deny' - the headers will be set to 'DENY'. - * * * 'sameorigin' - the headers will be set to 'SAMEORIGIN'. - * * * an object for specifying the 'allow-from' rule, where: - * * * * rule - one of: - * * * * * 'deny' - * * * * * 'sameorigin' - * * * * * 'allow-from' - * * * * source - when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. - * * xss - boolean that controls the 'X-XSS-PROTECTION' header for Internet Explorer. Defaults to true which sets the header to equal '1; mode=block'. - * Note: this setting can create a security vulnerability in versions of Internet Exploere below 8, as well as unpatched versions of IE8. See here and here for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. - * * noOpen - boolean controlling the 'X-Download-Options' header for Internet Explorer, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. - * * noSniff - boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff'. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionssecurity) - */ -export interface RouteOptionsSecureObject { - hsts?: boolean | number | { - maxAge: number; - includeSubdomains: boolean; - preload: boolean; - }; - xframe?: true | 'deny' | 'sameorigin' | { - rule: 'deny' | 'sameorigin' | 'allow-from'; - source: string; - }; - xss: boolean; - noOpen?: boolean; - noSniff?: boolean; -} - - -export type RouteOptionsSecure = boolean | RouteOptionsSecureObject; diff --git a/types/hapi/definitions/route/route-options-validate.d.ts b/types/hapi/definitions/route/route-options-validate.d.ts deleted file mode 100644 index 7fa61d5bef..0000000000 --- a/types/hapi/definitions/route/route-options-validate.d.ts +++ /dev/null @@ -1,92 +0,0 @@ -import {Lifecycle, RouteOptionsResponseSchema} from "hapi"; -import {ValidationOptions} from "joi"; - -/** - * Default value: { headers: true, params: true, query: true, payload: true, failAction: 'error' }. - * Request input validation rules for various request components. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidate) - */ -export interface RouteOptionsValidate { - - /** - * Default value: none. - * An optional object with error fields copied into every validation error response. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateerrorfields) - */ - errorFields?: object; - - /** - * Default value: 'error' (return a Bad Request (400) error response). - * A failAction value which determines how to handle failed validations. When set to a function, the err argument includes the type of validation error under err.output.payload.validation.source. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidatefailaction) - */ - failAction?: Lifecycle.FailAction; - - /** - * Default value: true (no validation). - * Validation rules for incoming request headers: - * * true - any headers allowed (no validation performed). - * * a joi validation object. - * * a validation function using the signature async function(value, options) where: - * * * value - the request.headers object containing the request headers. - * * * options - options. - * * * if a value is returned, the value is used as the new request.headers value and the original value is stored in request.orig.headers. Otherwise, the headers are left unchanged. If an error is thrown, the error is handled according to failAction. - * Note that all header field names must be in lowercase to match the headers normalized by node. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateheaders) - */ - headers?: RouteOptionsResponseSchema; - - /** - * Default value: none. - * An options object passed to the joi rules or the custom validation methods. Used for setting global options such as stripUnknown or abortEarly (the complete list is available here). - * If a custom validation function (see headers, params, query, or payload above) is defined then options can an arbitrary object that will be passed to this function as the second parameter. - * The values of the other inputs (i.e. headers, query, params, payload, app, and auth) are added to the options object under the validation context (accessible in rules as Joi.ref('$query.key')). - * Note that validation is performed in order (i.e. headers, params, query, and payload) and if type casting is used (e.g. converting a string to a number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. - * If the validation rules for headers, params, query, and payload are defined at both the server routes level and at the route level, the individual route settings override the routes defaults (the rules are not merged). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateparams) - */ - options?: ValidationOptions | object; - - /** - * Default value: true (no validation). - * Validation rules for incoming request path parameters, after matching the path against the route, extracting any parameters, and storing them in request.params, where: - * * true - any path parameter value allowed (no validation performed). - * * a joi validation object. - * * a validation function using the signature async function(value, options) where: - * * * value - the request.params object containing the request path parameters. - * * * options - options. - * if a value is returned, the value is used as the new request.params value and the original value is stored in request.orig.params. Otherwise, the path parameters are left unchanged. If an error is thrown, the error is handled according to failAction. - * Note that failing to match the validation rules to the route path parameters definition will cause all requests to fail. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidateparams) - */ - params?: RouteOptionsResponseSchema; - - /** - * Default value: true (no validation). - * Validation rules for incoming request payload (request body), where: - * * true - any payload allowed (no validation performed). false - no payload allowed. - * * a joi validation object. Note that empty payloads are represented by a null value. If a validation schema is provided and empty payload are allowed, the schema must be explicitly defined by setting the rule to a joi schema with null allowed (e.g. Joi.object({ keys here }).allow(null)). - * * a validation function using the signature async function(value, options) where: - * * * value - the request.query object containing the request query parameters. - * * * options - options. - * if a value is returned, the value is used as the new request.payload value and the original value is stored in request.orig.payload. Otherwise, the payload is left unchanged. If an error is thrown, the error is handled according to failAction. - * Note that validating large payloads and modifying them will cause memory duplication of the payload (since the original is kept), as well as the significant performance cost of validating large amounts of data. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidatepayload) - */ - payload?: RouteOptionsResponseSchema; - - /** - * Default value: true (no validation). - * Validation rules for incoming request URI query component (the key-value part of the URI between '?' and '#'). The query is parsed into its individual key-value pairs, decoded, and stored in request.query prior to validation. Where: - * * true - any query parameter value allowed (no validation performed). false - no query parameter value allowed. - * * a joi validation object. - * * a validation function using the signature async function(value, options) where: - * * * value - the request.query object containing the request query parameters. - * * * options - options. - * if a value is returned, the value is used as the new request.query value and the original value is stored in request.orig.query. Otherwise, the query parameters are left unchanged. If an error is thrown, the error is handled according to failAction. - * Note that changes to the query parameters will not be reflected in request.url. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidatequery) - */ - query?: RouteOptionsResponseSchema; - -} diff --git a/types/hapi/definitions/route/route-options.d.ts b/types/hapi/definitions/route/route-options.d.ts deleted file mode 100644 index 2bc2542f4a..0000000000 --- a/types/hapi/definitions/route/route-options.d.ts +++ /dev/null @@ -1,284 +0,0 @@ -import { - Json, - Lifecycle, - PluginSpecificConfiguration, - RouteOptionsAccess, - RouteOptionsCache, - RouteOptionsCors, - RouteOptionsPayload, - RouteOptionsPreArray, - RouteOptionsResponse, - RouteOptionsSecure, - RouteOptionsValidate, - Util -} from "hapi"; - -/** - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression) - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder) - */ -export type RouteCompressionEncoderSettings = object; - -/** - * Each route can be customized to change the default behavior of the request lifecycle. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#route-options) - */ -export interface RouteOptions { - - /** - * Application-specific route configuration state. Should not be used by plugins which should use options.plugins[name] instead. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsapp) - */ - app?: any; - - /** - * Route authentication configuration. Value can be: - * false to disable authentication if a default strategy is set. - * a string with the name of an authentication strategy registered with server.auth.strategy(). The strategy will be set to 'required' mode. - * an authentication configuration object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsapp) - */ - auth?: false | string | RouteOptionsAccess; - - /** - * Default value: null. - * An object passed back to the provided handler (via this) when called. Ignored if the method is an arrow function. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsbind) - */ - bind?: object; - - /** - * Default value: { privacy: 'default', statuses: [200], otherwise: 'no-cache' }. - * If the route method is 'GET', the route can be configured to include HTTP caching directives in the response. Caching can be customized using an object with the following options: - * privacy - determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are: - * * * 'default' - no privacy flag. - * * * 'public' - mark the response as suitable for public caching. - * * * 'private' - mark the response as suitable only for private caching. - * * expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. - * * expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. - * * statuses - an array of HTTP response status code numbers (e.g. 200) which are allowed to include a valid caching directive. - * * otherwise - a string with the value of the 'Cache-Control' header when caching is disabled. - * The default Cache-Control: no-cache header can be disabled by setting cache to false. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscache) - */ - cache?: false | RouteOptionsCache; - - /** - * An object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in compression. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscompression) - */ - compression?: Util.Dictionary; - - /** - * Default value: false (no CORS headers). - * The Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. To enable, set cors to true, or to an object with the following options: - * * origin - an array of allowed origin servers strings ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a wildcard '*' character, or a single '*' origin string. If set to 'ignore', any incoming Origin header is ignored (present or not) and the 'Access-Control-Allow-Origin' header is set to '*'. Defaults to any origin ['*']. - * * maxAge - number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. Defaults to 86400 (one day). - * * headers - a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match']. - * * additionalHeaders - a strings array of additional headers to headers. Use this to keep the default headers in place. - * * exposedHeaders - a strings array of exposed headers ('Access-Control-Expose-Headers'). Defaults to ['WWW-Authenticate', 'Server-Authorization']. - * * additionalExposedHeaders - a strings array of additional headers to exposedHeaders. Use this to keep the default headers in place. - * * credentials - if true, allows user credentials to be sent ('Access-Control-Allow-Credentials'). Defaults to false. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionscors) - */ - cors?: false | RouteOptionsCors; - - /** - * Default value: none. - * Route description used for generating documentation (string). - * This setting is not available when setting server route defaults using server.options.routes. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsdescription) - */ - description?: string; - - /** - * Default value: none. - * Route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the server.ext(events) event argument. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsext) - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) - */ - ext?: object; - - /** - * Default value: { relativeTo: '.' }. - * Defines the behavior for accessing files: - * * relativeTo - determines the folder relative paths are resolved against. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsfiles) - */ - files?: { - relativeTo: string; - } - - /** - * Default value: none. - * The route handler function performs the main business logic of the route and sets the response. handler can be assigned: - * * a lifecycle method. - * * an object with a single property using the name of a handler type registred with the server.handler() method. The matching property value is passed as options to the registered handler generator. - * Note: handlers using a fat arrow style function cannot be bound to any bind property. Instead, the bound context is available under h.context. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionshandler) - */ - handler?: Lifecycle.Method | object; - - /** - * Default value: none. - * An optional unique identifier used to look up the route using server.lookup(). Cannot be assigned to routes added with an array of methods. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsid) - */ - id?: string; - - /** - * Default value: false. - * If true, the route cannot be accessed through the HTTP listener but only through the server.inject() interface with the allowInternals option set to true. Used for internal routes that should not be accessible to the outside world. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsisinternal) - */ - isInternal?: boolean; - - /** - * Default value: none. - * Optional arguments passed to JSON.stringify() when converting an object or error response to a string payload or escaping it after stringification. Supports the following: - * * replacer - the replacer function or array. Defaults to no action. - * * space - number of spaces to indent nested object keys. Defaults to no indentation. - * * suffix - string suffix added after conversion to JSON string. Defaults to no suffix. - * * escape - calls Hoek.jsonEscape() after conversion to JSON string. Defaults to false. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsjson) - */ - json?: Json.StringifyArguments; - - /** - * Default value: none. - * Enables JSONP support by setting the value to the query parameter name containing the function name used to wrap the response payload. - * For example, if the value is 'callback', a request comes in with 'callback=me', and the JSON response is '{ "a":"b" }', the payload will be 'me({ "a":"b" });'. Cannot be used with stream responses. - * The 'Content-Type' response header is set to 'text/javascript' and the 'X-Content-Type-Options' response header is set to 'nosniff', and will override those headers even if explicitly set by response.type(). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsjsonp) - */ - jsonp?: string; - - /** - * Default value: { collect: false }. - * Request logging options: - * collect - if true, request-level logs (both internal and application) are collected and accessible via request.logs. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionslog) - */ - log?: { - collect: boolean; - } - - /** - * Default value: none. - * Route notes used for generating documentation (string or array of strings). - * This setting is not available when setting server route defaults using server.options.routes. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsnotes) - */ - notes?: string | string[]; - - /** - * Determines how the request payload is processed. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspayload) - */ - payload?: RouteOptionsPayload; - - /** - * Default value: {}. - * Plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsplugins) - */ - plugins?: Util.Dictionary; - - /** - * Default value: none. - * The pre option allows defining methods for performing actions before the handler is called. These methods allow breaking the handler logic into smaller, reusable components that can be shared ascross routes, as well as provide a cleaner error handling of prerequisite operations (e.g. load required reference data from a database). - * pre is assigned an ordered array of methods which are called serially in order. If the pre array contains another array of methods as one of its elements, those methods are called in parallel. Note that during parallel execution, if any of the methods error, return a takeover response, or abort signal, the other parallel methods will continue to execute but will be ignored once completed. - * pre can be assigned a mixed array of: - * * an array containing the elements listed below, which are executed in parallel. - * * an object with: - * * * method - a lifecycle method. - * * * assign - key name used to assign the response of the method to in request.pre and request.preResponses. - * * * failAction - A failAction value which determine what to do when a pre-handler method throws an error. If assign is specified and the failAction setting is not 'error', the error will be assigned. - * * a method function - same as including an object with a single method key. - * Note that pre-handler methods do not behave the same way other lifecycle methods do when a value is returned. Instead of the return value becoming the new response payload, the value is used to assign the corresponding request.pre and request.preResponses properties. Otherwise, the handling of errors, takeover response response, or abort signal behave the same as any other lifecycle methods. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre) - */ - pre?: RouteOptionsPreArray; - - /** - * Processing rules for the outgoing response. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsresponse) - */ - response?: RouteOptionsResponse; - - /** - * Default value: false (security headers disabled). - * Sets common security headers. To enable, set security to true or to an object with the following options: - * * hsts - controls the 'Strict-Transport-Security' header, where: - * * * true - the header will be set to max-age=15768000. This is the default value. - * * * a number - the maxAge parameter will be set to the provided value. - * * * an object with the following fields: - * * * * maxAge - the max-age portion of the header, as a number. Default is 15768000. - * * * * includeSubDomains - a boolean specifying whether to add the includeSubDomains flag to the header. - * * * * preload - a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. - * * xframe - controls the 'X-Frame-Options' header, where: - * * * true - the header will be set to 'DENY'. This is the default value. - * * * 'deny' - the headers will be set to 'DENY'. - * * * 'sameorigin' - the headers will be set to 'SAMEORIGIN'. - * * * an object for specifying the 'allow-from' rule, where: - * * * * rule - one of: - * * * * * 'deny' - * * * * * 'sameorigin' - * * * * * 'allow-from' - * * * * source - when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. - * * xss - boolean that controls the 'X-XSS-PROTECTION' header for Internet Explorer. Defaults to true which sets the header to equal '1; mode=block'. - * Note: this setting can create a security vulnerability in versions of Internet Exploere below 8, as well as unpatched versions of IE8. See here and here for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. - * * noOpen - boolean controlling the 'X-Download-Options' header for Internet Explorer, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. - * * noSniff - boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff'. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionssecurity) - */ - security?: RouteOptionsSecure; - - /** - * Default value: { parse: true, failAction: 'error' }. - * HTTP state management (cookies) allows the server to store information on the client which is sent back to the server with every request (as defined in RFC 6265). state supports the following options: - * parse - determines if incoming 'Cookie' headers are parsed and stored in the request.state object. - * failAction - A failAction value which determines how to handle cookie parsing errors. Defaults to 'error' (return a Bad Request (400) error response). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsstate) - */ - state?: { - parse?: boolean; - failAction?: Lifecycle.FailAction; - } - - /** - * Default value: none. - * Route tags used for generating documentation (array of strings). - * This setting is not available when setting server route defaults using server.options.routes. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionstags) - */ - tags?: string[]; - - /** - * Default value: { server: false }. - * Timeouts for processing durations. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionstimeout) - */ - timeout?: { - - /** - * Response timeout in milliseconds. Sets the maximum time allowed for the server to respond to an incoming request before giving up and responding with a Service Unavailable (503) error response. - */ - server?: boolean | number; - - /** - * Default value: none (use node default of 2 minutes). - * By default, node sockets automatically timeout after 2 minutes. Use this option to override this behavior. Set to false to disable socket timeouts. - */ - socket?: boolean | number; - - }; - - /** - * Default value: { headers: true, params: true, query: true, payload: true, failAction: 'error' }. - * Request input validation rules for various request components. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsvalidate) - */ - validate?: RouteOptionsValidate; - -} diff --git a/types/hapi/definitions/server/server-auth-scheme.d.ts b/types/hapi/definitions/server/server-auth-scheme.d.ts deleted file mode 100644 index e8a4d2adbe..0000000000 --- a/types/hapi/definitions/server/server-auth-scheme.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -import {Lifecycle, Request, ResponseToolkit, Server} from "hapi"; - -/** - * The scheme options argument passed to server.auth.strategy() when instantiation a strategy. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme) - */ -export type ServerAuthSchemeOptions = object; - -/** - * the method implementing the scheme with signature function(server, options) where: - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme) - * @param server - a reference to the server object the scheme is added to. - * @param options - (optional) the scheme options argument passed to server.auth.strategy() when instantiation a strategy. - */ -export interface ServerAuthScheme { - (server: Server, options?: ServerAuthSchemeOptions): ServerAuthSchemeObject; -} - -/** - * The scheme method must return an object with the following - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#authentication-scheme) - */ -export interface ServerAuthSchemeObject { - - /** - * optional object which is exposed via the [server.auth.api](https://github.com/hapijs/hapi/blob/master/API.md#server.auth.api) object. - */ - api?: object; - - /** - * A lifecycle method function called for each incoming request configured with the authentication scheme. The - * method is provided with two special toolkit methods for returning an authenticated or an unauthenticate result: - * * h.authenticated() - indicate request authenticated successfully. - * * h.unauthenticated() - indicate request failed to authenticate. - * @param request the request object. - * @param h the ResponseToolkit - * @return the Lifecycle.ReturnValue - */ - authenticate(request: Request, h: ResponseToolkit): Lifecycle.ReturnValue; - - /** - * A lifecycle method to authenticate the request payload. - * When the scheme payload() method returns an error with a message, it means payload validation failed due to bad - * payload. If the error has no message but includes a scheme name (e.g. Boom.unauthorized(null, 'Custom')), - * authentication may still be successful if the route auth.payload configuration is set to 'optional'. - * @param request the request object. - * @param h the ResponseToolkit - * @return the Lifecycle.ReturnValue - */ - payload?(request: Request, h: ResponseToolkit): Lifecycle.ReturnValue; - - /** - * A lifecycle method to decorate the response with authentication headers before the response headers or payload is written. - * @param request the request object. - * @param h the ResponseToolkit - * @return the Lifecycle.ReturnValue - */ - response?(request: Request, h: ResponseToolkit): Lifecycle.ReturnValue; - - /** - * An object with the following keys: - * * payload - if true, requires payload validation as part of the scheme and forbids routes from disabling payload auth validation. Defaults to false. - */ - options?: { - payload?: boolean; - }; - -} diff --git a/types/hapi/definitions/server/server-auth.d.ts b/types/hapi/definitions/server/server-auth.d.ts deleted file mode 100644 index 0b082c2872..0000000000 --- a/types/hapi/definitions/server/server-auth.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -import {Request, RouteOptionsAccess, ServerAuthScheme, Util} from "hapi"; - -/** - * An authentication configuration object using the same format as the route auth handler options. - * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions) - */ -export interface ServerAuthConfig extends RouteOptionsAccess { - -} - -export interface ServerAuth { - - /** - * An object where each key is an authentication strategy name and the value is the exposed strategy API. - * Available only when the authentication scheme exposes an API by returning an api key in the object - * returned from its implementation function. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi) - */ - api: Util.Dictionary; - - /** - * Contains the default authentication configuration is a default strategy was set via - * [server.auth.default()](https://github.com/hapijs/hapi/blob/master/API.md#server.auth.default()). - */ - readonly settings: { - default: ServerAuthConfig; - } - - /** - * Sets a default strategy which is applied to every route where: - * @param options - one of: - * * a string with the default strategy name - * * an authentication configuration object using the same format as the route auth handler options. - * @return void. - * The default does not apply when a route config specifies auth as false, or has an authentication strategy - * configured (contains the strategy or strategies authentication settings). Otherwise, the route authentication - * config is applied to the defaults. - * Note that if the route has authentication configured, the default only applies at the time of adding the route, - * not at runtime. This means that calling server.auth.default() after adding a route with some authentication - * config will have no impact on the routes added prior. However, the default will apply to routes added - * before server.auth.default() is called if those routes lack any authentication config. - * The default auth strategy configuration can be accessed via server.auth.settings.default. To obtain the active - * authentication configuration of a route, use server.auth.lookup(request.route). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions) - */ - default(options: string | ServerAuthConfig): void; - - /** - * Registers an authentication scheme where: - * @param name the scheme name. - * @param scheme - the method implementing the scheme with signature function(server, options) where: - * * server - a reference to the server object the scheme is added to. - * * options - (optional) the scheme options argument passed to server.auth.strategy() when instantiation a strategy. - * @return void. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme) - */ - scheme(name: string, scheme: ServerAuthScheme): void; - - /** - * Registers an authentication strategy where: - * @param name - the strategy name. - * @param scheme - the scheme name (must be previously registered using server.auth.scheme()). - * @param options - scheme options based on the scheme requirements. - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverauthstrategyname-scheme-options) - */ - strategy(name: string, scheme: string, options?: object): void; - - /** - * Tests a request against an authentication strategy where: - * @param strategy - the strategy name registered with server.auth.strategy(). - * @param request - the request object. - * @return Return value: the authentication credentials object if authentication was successful, otherwise throws an error. - * Note that the test() method does not take into account the route authentication configuration. It also does not - * perform payload authentication. It is limited to the basic strategy authentication execution. It does not - * include verifying scope, entity, or other route properties. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverauthteststrategy-request) - */ - test(strategy: string, request: Request): any; - -} - diff --git a/types/hapi/definitions/server/server-cache.d.ts b/types/hapi/definitions/server/server-cache.d.ts deleted file mode 100644 index d21d3c2613..0000000000 --- a/types/hapi/definitions/server/server-cache.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -import * as catbox from "catbox"; -import {ServerOptionsCache} from "hapi"; - -/** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) - */ -export interface ServerCache { - - /** - * Provisions a cache segment within the server cache facility where: - * @param options - [catbox policy](https://github.com/hapijs/catbox#policy) configuration where: - * * expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. - * * expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records expire. Uses local time. Cannot be used together with expiresIn. - * * generateFunc - a function used to generate a new cache item if one is not found in the cache when calling get(). The method's signature is async function(id, flags) where: - * - `id` - the `id` string or object provided to the `get()` method. - * - `flags` - an object used to pass back additional flags to the cache where: - * - `ttl` - the cache ttl value in milliseconds. Set to `0` to skip storing in the cache. Defaults to the cache global policy. - * * staleIn - number of milliseconds to mark an item stored in cache as stale and attempt to regenerate it when generateFunc is provided. Must be less than expiresIn. - * * staleTimeout - number of milliseconds to wait before checking if an item is stale. - * * generateTimeout - number of milliseconds to wait before returning a timeout error when the generateFunc function takes too long to return a value. When the value is eventually returned, it is stored in the cache for future requests. Required if generateFunc is present. Set to false to disable timeouts which may cause all get() requests to get stuck forever. - * * generateOnReadError - if false, an upstream cache read error will stop the cache.get() method from calling the generate function and will instead pass back the cache error. Defaults to true. - * * generateIgnoreWriteError - if false, an upstream cache write error when calling cache.get() will be passed back with the generated value when calling. Defaults to true. - * * dropOnError - if true, an error or timeout in the generateFunc causes the stale value to be evicted from the cache. Defaults to true. - * * pendingGenerateTimeout - number of milliseconds while generateFunc call is in progress for a given id, before a subsequent generateFunc call is allowed. Defaults to 0 (no blocking of concurrent generateFunc calls beyond staleTimeout). - * * cache - the cache name configured in server.cache. Defaults to the default cache. - * * segment - string segment name, used to isolate cached items within the cache partition. When called within a plugin, defaults to '!name' where 'name' is the plugin name. When called within a server method, defaults to '#name' where 'name' is the server method name. Required when called outside of a plugin. - * * shared - if true, allows multiple cache provisions to share the same segment. Default to false. - * @return Catbox Policy. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) - */ - (options: ServerOptionsCache): catbox.Policy; - - /** - * Provisions a server cache as described in server.cache where: - * @param options - same as the server cache configuration options. - * @return Return value: none. - * Note that if the server has been initialized or started, the cache will be automatically started to match the state of any other provisioned server cache. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions) - */ - provision(options: ServerOptionsCache): void; - -} diff --git a/types/hapi/definitions/server/server-events.d.ts b/types/hapi/definitions/server/server-events.d.ts deleted file mode 100644 index 5eb7bdc283..0000000000 --- a/types/hapi/definitions/server/server-events.d.ts +++ /dev/null @@ -1,146 +0,0 @@ -import * as Podium from "podium"; - -/** - * an event name string. - * an event options object. - * a podium emitter object. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents) - */ -export type ServerEventsApplication = string | ServerEventsApplicationObject | Podium; - -/** - * Object that it will be used in Event - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents) - */ -export interface ServerEventsApplicationObject { - /** the event name string (required). */ - name: string; - /** a string or array of strings specifying the event channels available. Defaults to no channel restrictions (event updates can specify a channel or not). */ - channels?: string | string[]; - /** if true, the data object passed to server.events.emit() is cloned before it is passed to the listeners (unless an override specified by each listener). Defaults to false (data is passed as-is). */ - clone?: boolean; - /** if true, the data object passed to server.event.emit() must be an array and the listener method is called with each array element passed as a separate argument (unless an override specified by each listener). This should only be used when the emitted data structure is known and predictable. Defaults to false (data is emitted as a single argument regardless of its type). */ - spread?: boolean; - /** if true and the criteria object passed to server.event.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end. A configuration override can be set by each listener. Defaults to false. */ - tags?: boolean; - /** if true, the same event name can be registered multiple times where the second registration is ignored. Note that if the registration config is changed between registrations, only the first configuration is used. Defaults to false (a duplicate registration will throw an error). */ - shared?: boolean; -} - -/** - * A criteria object with the following optional keys (unless noted otherwise): - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncriteria-listener) - */ -export interface ServerEventCriteria { - /** (required) the event name string. */ - name: string; - /** a string or array of strings specifying the event channels to subscribe to. If the event registration specified a list of allowed channels, the channels array must match the allowed channels. If channels are specified, event updates without any channel designation will not be included in the subscription. Defaults to no channels filter. */ - channels?: string | string[]; - /** if true, the data object passed to server.event.emit() is cloned before it is passed to the listener method. Defaults to the event registration option (which defaults to false). */ - clone?: boolean; - /** a positive integer indicating the number of times the listener can be called after which the subscription is automatically removed. A count of 1 is the same as calling server.events.once(). Defaults to no limit. */ - count?: number; - /** - * filter - the event tags (if present) to subscribe to which can be one of: - * * a tag string. - * * an array of tag strings. - * * an object with the following: - * * * tags - a tag string or array of tag strings. - * * * all - if true, all tags must be present for the event update to match the subscription. Defaults to false (at least one matching tag). - */ - filter?: string | string[] | {tags: string | string[], all?: boolean}; - /** if true, and the data object passed to server.event.emit() is an array, the listener method is called with each array element passed as a separate argument. This should only be used when the emitted data structure is known and predictable. Defaults to the event registration option (which defaults to false). */ - spread?: boolean; - /** if true and the criteria object passed to server.event.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end. Defaults to the event registration option (which defaults to false). */ - tags?: boolean; -} - -/** - * Access: podium public interface. - * The server events emitter. Utilizes the podium with support for event criteria validation, channels, and filters. - * Use the following methods to interact with server.events: - * [server.event(events)](https://github.com/hapijs/hapi/blob/master/API.md#server.event()) - register application events. - * [server.events.emit(criteria, data)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.emit()) - emit server events. - * [server.events.on(criteria, listener)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) - subscribe to all events. - * [server.events.once(criteria, listener)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.once()) - subscribe to - * Other methods include: server.events.removeListener(name, listener), server.events.removeAllListeners(name), and server.events.hasListeners(name). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) - */ -export interface ServerEvents extends Podium { - - /** - * Emits a custom application event to all the subscribed listeners where: - * @param criteria - the event update criteria which must be one of: - * * the event name string. - * * an object with the following optional keys (unless noted otherwise): - * * * name - the event name string (required). - * * * channel - the channel name string. - * * * tags - a tag string or array of tag strings. - * @param data - the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. - * @return Return value: none. - * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsemitcriteria-data) - */ - emit(criteria: string, data: any | Function): void; - emit(criteria: {name: string, channel?: string, tags?: string | string[]}, data: any): void; - - /** - * Subscribe to an event where: - * @param criteria - the subscription criteria which must be one of: - * * event name string which can be any of the built-in server events - * * a custom application event registered with server.event(). - * * a criteria object - * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncriteria-listener) - * See ['log' event](https://github.com/hapijs/hapi/blob/master/API.md#-log-event) - * See ['request' event](https://github.com/hapijs/hapi/blob/master/API.md#-request-event) - * See ['response' event](https://github.com/hapijs/hapi/blob/master/API.md#-response-event) - * See ['route' event](https://github.com/hapijs/hapi/blob/master/API.md#-route-event) - * See ['start' event](https://github.com/hapijs/hapi/blob/master/API.md#-start-event) - * See ['stop' event](https://github.com/hapijs/hapi/blob/master/API.md#-stop-event) - */ - on(criteria: string | ServerEventsApplicationObject | ServerEventCriteria, listener: Function): void; - - /** - * Same as calling [server.events.on()](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) with the count option set to 1. - * @param criteria - the subscription criteria which must be one of: - * * event name string which can be any of the built-in server events - * * a custom application event registered with server.event(). - * * a criteria object - * @param listener - the handler method set to receive event updates. The function signature depends on the event argument, and the spread and tags options. - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener) - */ - once(criteria: string | ServerEventsApplicationObject | ServerEventCriteria, listener: Function): void; - - /** - * Same as calling server.events.on() with the count option set to 1. - * @param criteria - the subscription criteria which must be one of: - * * event name string which can be any of the built-in server events - * * a custom application event registered with server.event(). - * * a criteria object - * @return Return value: a promise that resolves when the event is emitted. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-servereventsoncecriteria) - */ - once(criteria: string | ServerEventsApplicationObject | ServerEventCriteria): any; - - /** - * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumremovelistenername-listener) - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) - */ - removeListener(name: string, listener: Podium.Listener): Podium; - - /** - * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumremovealllistenersname) - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) - */ - removeAllListeners(name: string): Podium; - - /** - * The follow method is only mentioned in Hapi API. The doc about that method can be found [here](https://github.com/hapijs/podium/blob/master/API.md#podiumhaslistenersname) - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) - */ - hasListeners(name: string): boolean; - -} diff --git a/types/hapi/definitions/server/server-ext.d.ts b/types/hapi/definitions/server/server-ext.d.ts deleted file mode 100644 index 809f4ddc61..0000000000 --- a/types/hapi/definitions/server/server-ext.d.ts +++ /dev/null @@ -1,93 +0,0 @@ -import {Lifecycle, Server} from "hapi"; - -/** - * The extension point event name. The available extension points include the request extension points as well as the following server extension points: - * 'onPreStart' - called before the connection listeners are started. - * 'onPostStart' - called after the connection listeners are started. - * 'onPreStop' - called before the connection listeners are stopped. - * 'onPostStop' - called after the connection listeners are stopped. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) - */ -export type ServerExtType = 'onRequest' | 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'| 'onPreResponse'; - -/** - * The extension point event name for Request - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#request-lifecycle) - */ -export type ServerExtRequestType = 'onRequest'; - -/** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) - * Registers an extension function in one of the request lifecycle extension points where: - * @param events - an object or array of objects with the following: - * * type - (required) the extension point event name. The available extension points include the request extension points as well as the following server extension points: - * * * 'onPreStart' - called before the connection listeners are started. - * * * 'onPostStart' - called after the connection listeners are started. - * * * 'onPreStop' - called before the connection listeners are stopped. - * * * 'onPostStop' - called after the connection listeners are stopped. - * * method - (required) a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is: - * * * server extension points: async function(server) where: - * * * * server - the server object. - * * * * this - the object provided via options.bind or the current active context set with server.bind(). - * * * request extension points: a lifecycle method. - * * options - (optional) an object with the following: - * * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. - * * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. - * * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. - * * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. - * @return void - */ -export interface ServerExtEventsObject { - type: ServerExtType; - method: ServerExtPointFunction | ServerExtPointFunction[] | Function; - options?: ServerExtOptions; -} - -/** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) - * Registers an extension function in one of the request lifecycle extension points where: - * @param events - an object or array of objects with the following: - * * type - (required) the extension point event name. The available extension points include the request extension points as well as the following server extension points: - * * * 'onPreStart' - called before the connection listeners are started. - * * * 'onPostStart' - called after the connection listeners are started. - * * * 'onPreStop' - called before the connection listeners are stopped. - * * * 'onPostStop' - called after the connection listeners are stopped. - * * method - (required) a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is: - * * * server extension points: async function(server) where: - * * * * server - the server object. - * * * * this - the object provided via options.bind or the current active context set with server.bind(). - * * * request extension points: a lifecycle method. - * * options - (optional) an object with the following: - * * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. - * * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. - * * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. - * * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. - * @return void - */ -export interface ServerExtEventsRequestObject { - type: ServerExtRequestType; - method: Lifecycle.Method | Lifecycle.Method[]; - options?: ServerExtOptions; -} - -export interface ServerExtPointFunction { - (server: Server): void; -} - -/** - * An object with the following: - * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. - * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. - * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. - * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) - */ -export interface ServerExtOptions { - before: string | string[]; - after: string | string[]; - bind: object; - sandbox?: 'server' | 'plugin'; -} - diff --git a/types/hapi/definitions/server/server-info.d.ts b/types/hapi/definitions/server/server-info.d.ts deleted file mode 100644 index 399543e08e..0000000000 --- a/types/hapi/definitions/server/server-info.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -/** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo) - * An object containing information about the server where: - */ -export interface ServerInfo { - - /** - * a unique server identifier (using the format '{hostname}:{pid}:{now base36}'). - */ - id: string; - - /** - * server creation timestamp. - */ - created: number; - - /** - * server start timestamp (0 when stopped). - */ - started: number; - - /** - * the connection [port](https://github.com/hapijs/hapi/blob/master/API.md#server.options.port) based on the following rules: - * * before the server has been started: the configured port value. - * * after the server has been started: the actual port assigned when no port is configured or was set to 0. - */ - port: number | string; - - /** - * The [host](https://github.com/hapijs/hapi/blob/master/API.md#server.options.host) configuration value. - */ - host: string; - - /** - * the active IP address the connection was bound to after starting. Set to undefined until the server has been - * started or when using a non TCP port (e.g. UNIX domain socket). - */ - address: undefined | string; - - /** - * the protocol used: - * * 'http' - HTTP. - * * 'https' - HTTPS. - * * 'socket' - UNIX domain socket or Windows named pipe. - */ - protocol: 'http' | 'https' | 'socket'; - - /** - * a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains - * the uri value if set, otherwise constructed from the available settings. If no port is configured or is set - * to 0, the uri will not include a port component until the server is started. - */ - uri: string; - -} diff --git a/types/hapi/definitions/server/server-inject.d.ts b/types/hapi/definitions/server/server-inject.d.ts deleted file mode 100644 index d034bbf0a0..0000000000 --- a/types/hapi/definitions/server/server-inject.d.ts +++ /dev/null @@ -1,50 +0,0 @@ -import {PluginsStates, Request} from "hapi"; -import * as Shot from "shot"; - -/** - * An object with: - * * method - (optional) the request HTTP method (e.g. 'POST'). Defaults to 'GET'. - * * url - (required) the request URL. If the URI includes an authority (e.g. 'example.com:8080'), it is used to automatically set an HTTP 'Host' header, unless one was specified in headers. - * * headers - (optional) an object with optional request headers where each key is the header name and the value is the header content. Defaults to no additions to the default shot headers. - * * payload - (optional) an string, buffer or object containing the request payload. In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided. - * * credentials - (optional) an credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials. - * * artifacts - (optional) an artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts. - * * app - (optional) sets the initial value of request.app, defaults to {}. - * * plugins - (optional) sets the initial value of request.plugins, defaults to {}. - * * allowInternals - (optional) allows access to routes with config.isInternal set to true. Defaults to false. - * * remoteAddress - (optional) sets the remote address for the incoming connection. - * * simulate - (optional) an object with options used to simulate client request stream conditions for testing: - * * error - if true, emits an 'error' event after payload transmission (if any). Defaults to false. - * * close - if true, emits a 'close' event after payload transmission (if any). Defaults to false. - * * end - if false, does not end the stream. Defaults to true. - * * split - indicates whether the request payload will be split into chunks. Defaults to undefined, meaning payload will not be chunked. - * * validate - (optional) if false, the options inputs are not validated. This is recommended for run-time usage of inject() to make it perform faster where input validation can be tested separately. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions) - * For context [Shot module](https://github.com/hapijs/shot) - */ -export interface ServerInjectOptions extends Shot.RequestOptions { - credentials?: any; - artifacts?: object; - app?: any; - plugins?: PluginsStates; - allowInternals?: boolean; -} - -/** - * A response object with the following properties: - * * statusCode - the HTTP status code. - * * headers - an object containing the headers set. - * * payload - the response payload string. - * * rawPayload - the raw response payload buffer. - * * raw - an object with the injection request and response objects: - * * req - the simulated node request object. - * * res - the simulated node response object. - * * result - the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the internal objects returned (instead of parsing the response string). - * * request - the request object. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions) - * For context [Shot module](https://github.com/hapijs/shot) - */ -export interface ServerInjectResponse extends Shot.ResponseObject { - result: object | undefined; - request: Request; -} diff --git a/types/hapi/definitions/server/server-method.d.ts b/types/hapi/definitions/server/server-method.d.ts deleted file mode 100644 index af6f5b79ff..0000000000 --- a/types/hapi/definitions/server/server-method.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -import * as catbox from "catbox"; - -/** - * The method function with a signature async function(...args, [flags]) where: - * * ...args - the method function arguments (can be any number of arguments or none). - * * flags - when caching is enabled, an object used to set optional method result flags: - * * * ttl - 0 if result is valid but cannot be cached. Defaults to cache policy. - * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) - */ -export type ServerMethod = (...args: any[]) => any; - -/** - * The same cache configuration used in server.cache(). - * The generateTimeout option is required. - * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) - * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) - */ -export interface ServerMethodCache extends catbox.PolicyOptions { - generateTimeout: number | false; -} - -/** - * Configuration object: - * * bind - a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. Ignored if the method is an arrow function. - * * cache - the same cache configuration used in server.cache(). The generateTimeout option is required. - * * generateKey - a function used to generate a unique key (for caching) from the arguments passed to the method function (the flags argument is not passed as input). The server will automatically generate a unique key if the function's arguments are all of types 'string', 'number', or 'boolean'. However if the method uses other types of arguments, a key generation function must be provided which takes the same arguments as the function and returns a unique string (or null if no key can be generated). - * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) - */ -export interface ServerMethodOptions { - bind?: object; - cache?: ServerMethodCache; - generateKey?: Function; -} - -/** - * An object or an array of objects where each one contains: - * * name - the method name. - * * method - the method function. - * * options - (optional) settings. - * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodmethods) - */ -export interface ServerMethodConfigurationObject { - name: string; - method: ServerMethod; - options?: ServerMethodOptions; -} diff --git a/types/hapi/definitions/server/server-options-cache.d.ts b/types/hapi/definitions/server/server-options-cache.d.ts deleted file mode 100644 index 1e75ebe857..0000000000 --- a/types/hapi/definitions/server/server-options-cache.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import * as Catbox from "catbox"; - -/** - * hapi uses catbox for its cache implementation which includes support for common storage solutions (e.g. Redis, - * MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-cache) - */ -export interface ServerOptionsCache extends Catbox.PolicyOptions { - - /** a class, a prototype function, or a catbox engine object. */ - engine?: Catbox.EnginePrototypeOrObject; - - /** an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. */ - name?: string; - - /** if true, allows multiple cache users to share the same segment (e.g. multiple methods using the same cache storage container). Default to false. */ - shared?: boolean; - - /** (optional) string used to isolate cached data. Defaults to 'hapi-cache'. */ - partition?: string; - - /** other options passed to the catbox strategy used. Other options are only passed to catbox when engine above is a class or function and ignored if engine is a catbox engine object). */ - [s: string]: any; - -} diff --git a/types/hapi/definitions/server/server-options.d.ts b/types/hapi/definitions/server/server-options.d.ts deleted file mode 100644 index 606dd701ba..0000000000 --- a/types/hapi/definitions/server/server-options.d.ts +++ /dev/null @@ -1,188 +0,0 @@ -import * as http from "http"; -import * as https from "https"; -import * as catbox from "catbox"; -import {MimosOptions} from "mimos"; -import {PluginSpecificConfiguration, RouteOptions, ServerOptionsCache} from "hapi"; - -/** - * he server options control the behavior of the server object. Note that the options object is deeply cloned - * (with the exception of listener which is shallowly copied) and should not contain any values that are unsafe to perform deep copy on. - * All options are optionals. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-server-options) - */ -export interface ServerOptions { - - /** - * Default value: '0.0.0.0' (all available network interfaces). - * Sets the hostname or IP address the server will listen on. If not configured, defaults to host if present, otherwise to all available network interfaces. Set to '127.0.0.1' or 'localhost' to restrict the server to only those coming from the same host. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsaddress) - */ - address?: string; - - /** - * Default value: {}. - * Provides application-specific configuration which can later be accessed via server.settings.app. The framework does not interact with this object. It is simply a reference made available anywhere a server reference is provided. - * Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsapp) - */ - app?: any; - - /** - * Default value: true. - * Used to disable the automatic initialization of the listener. When false, indicates that the listener will be started manually outside the framework. - * Cannot be set to true along with a port value. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsautolisten) - */ - autoListen?: boolean; - - /** - * Default value: { engine: require('catbox-memory' }. - * Sets up server-side caching providers. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and capabilities. - * hapi uses catbox for its cache implementation which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. - * The server cache configuration only defines the storage container itself. The configuration can be assigned one or more (array): - * * a class or prototype function (usually obtained by calling require() on a catbox strategy such as require('catbox-redis')). A new catbox client will be created internally using this function. - * * a configuration object with the following: - * * * engine - a class, a prototype function, or a catbox engine object. - * * * name - an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. - * * * shared - if true, allows multiple cache users to share the same segment (e.g. multiple methods using the same cache storage container). Default to false. - * * * partition - (optional) string used to isolate cached data. Defaults to 'hapi-cache'. - * * * other options passed to the catbox strategy used. Other options are only passed to catbox when engine above is a class or function and ignored if engine is a catbox engine object). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionscache) - */ - cache?: catbox.EnginePrototype | ServerOptionsCache | ServerOptionsCache[]; - - /** - * Default value: { minBytes: 1024 }. - * Defines server handling of content encoding requests. If false, response content encoding is disabled and no compression is performed by the server. - */ - compression?: boolean | object; - - /** - * Default value: '1024'. - * Sets the minimum response payload size in bytes that is required for content encoding compression. If the payload size is under the limit, no compression is performed. - */ - minBytes?: number; - - /** - * Default value: { request: ['implementation'] }. - * Determines which logged events are sent to the console. This should only be used for development and does not affect which events are actually logged internally and recorded. Set to false to disable all console logging, or to an object with: - * * log - a string array of server log tags to be displayed via console.error() when the events are logged via server.log() as well as internally generated server logs. Defaults to no output. - * * request - a string array of request log tags to be displayed via console.error() when the events are logged via request.log() as well as internally generated request logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. To display all request logs, set it to '*'. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. - * For example, to display all errors, set the log or request to ['error']. To turn off all output set the log or request to false. To display all server logs, set the log or request to '*'. To disable all debug information, set debug to false. - */ - debug?: false | { - log?: string[] | false; - request?: string[] | false; - }; - - /** - * Default value: the operating system hostname and if not available, to 'localhost'. - * The public hostname or IP address. Used to set server.info.host and server.info.uri and as address is none provided. - */ - host?: string; - - /** - * Default value: none. - * An optional node HTTP (or HTTPS) http.Server object (or an object with a compatible interface). - * If the listener needs to be manually started, set autoListen to false. - * If the listener uses TLS, set tls to true. - */ - listener?: http.Server; - - /** - * Default value: { sampleInterval: 0 }. - * Server excessive load handling limits where: - * * sampleInterval - the frequency of sampling in milliseconds. When set to 0, the other load options are ignored. Defaults to 0 (no sampling). - * * maxHeapUsedBytes - maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). - * * maxRssBytes - maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). - * * maxEventLoopDelay - maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). - */ - load?: { - /** the frequency of sampling in milliseconds. When set to 0, the other load options are ignored. Defaults to 0 (no sampling). */ - sampleInterval?: number; - /** maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ - maxHeapUsedBytes?: number; - /** maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).*/ - maxRssBytes?: number; - /** maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit).*/ - maxEventLoopDelay?: number; - }; - - /** - * Default value: none. - * Options passed to the mimos module when generating the mime database used by the server (and accessed via server.mime): - * * override - an object hash that is merged into the built in mime information specified here. Each key value pair represents a single mime object. Each override value must contain: - * * key - the lower-cased mime-type string (e.g. 'application/javascript'). - * * value - an object following the specifications outlined here. Additional values include: - * * * type - specify the type value of result objects, defaults to key. - * * * predicate - method with signature function(mime) when this mime type is found in the database, this function will execute to allows customizations. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsmime) - */ - mime?: MimosOptions; - - /** - * Default value: {}. - * Plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state. - */ - plugins?: PluginSpecificConfiguration; - - /** - * Default value: 0 (an ephemeral port). - * The TCP port the server will listen to. Defaults the next available port when the server is started (and assigned to server.info.port). - * If port is a string containing a '/' character, it is used as a UNIX domain socket path. If it starts with '\.\pipe', it is used as a Windows named pipe. - */ - port?: number | string; - - /** - * Default value: { isCaseSensitive: true, stripTrailingSlash: false }. - * Controls how incoming request URIs are matched against the routing table: - * * isCaseSensitive - determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true. - * * stripTrailingSlash - removes trailing slashes on incoming paths. Defaults to false. - */ - router?: { - isCaseSensitive?: boolean; - stripTrailingSlash?: boolean; - }; - - /** - * Default value: none. - * A route options object used as the default configuration for every route. - */ - routes?: RouteOptions; - - /** - Default value: - { - strictHeader: true, - ignoreErrors: false, - isSecure: true, - isHttpOnly: true, - isSameSite: 'Strict', - encoding: 'none' - } - Sets the default configuration for every state (cookie) set explicitly via server.state() or implicitly (without definition) using the state configuration object. - */ - // TODO I am not sure if I need to use all the server.state() definition (like the default value) OR only the options below. The v16 use "any" here. - // state?: ServerStateCookieOptions; - state?: { - strictHeader?: boolean, - ignoreErrors?: boolean, - isSecure?: boolean, - isHttpOnly?: boolean, - isSameSite?: false | 'Strict' | 'Lax', - encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron' - }; - - /** - * Default value: none. - * Used to create an HTTPS connection. The tls object is passed unchanged to the node HTTPS server as described in the node HTTPS documentation. - */ - tls?: true | https.RequestOptions; - - /** - * Default value: constructed from runtime server information. - * The full public URI without the path (e.g. 'http://example.com:8080'). If present, used as the server server.info.uri, otherwise constructed from the server settings. - */ - uri?: string; - -} diff --git a/types/hapi/definitions/server/server-realm.d.ts b/types/hapi/definitions/server/server-realm.d.ts deleted file mode 100644 index cfab9b75b7..0000000000 --- a/types/hapi/definitions/server/server-realm.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -import {PluginsStates} from "hapi"; - -/** - * The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When registering a plugin or an authentication scheme, a server object reference is provided with a new server.realm container specific to that registration. It allows each plugin to maintain its own settings without leaking and affecting other plugins. - * For example, a plugin can set a default file path for local resources without breaking other plugins' configured paths. When calling server.bind(), the active realm's settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). - */ -export interface ServerRealm { - /** when the server object is provided as an argument to the plugin register() method, modifiers provides the registration preferences passed the server.register() method and includes: */ - modifiers: { - /** routes preferences: */ - route: { - /** the route path prefix used by any calls to server.route() from the server. Note that if a prefix is used and the route path is set to '/', the resulting path will not include the trailing slash. */ - prefix: string; - /** the route virtual host settings used by any calls to server.route() from the server. */ - vhost: string; - } - }; - /** the realm of the parent server object, or null for the root server. */ - parent: object | null; - /** the active plugin name (empty string if at the server root). */ - plugin: string; - /** the plugin options object passed at registration. */ - pluginOptions: object; - /** plugin-specific state to be shared only among activities sharing the same active state. plugins is an object where each key is a plugin name and the value is the plugin state. */ - plugins: PluginsStates; - /** settings overrides */ - settings: { - files: { - relativeTo: string; - }; - bind: object; - }; -} diff --git a/types/hapi/definitions/server/server-register.d.ts b/types/hapi/definitions/server/server-register.d.ts deleted file mode 100644 index a16db4547b..0000000000 --- a/types/hapi/definitions/server/server-register.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -import {Plugin} from "hapi"; - -/** - * Registration options (different from the options passed to the registration function): - * * once - if true, subsequent registrations of the same plugin are skipped without error. Cannot be used with plugin options. Defaults to false. If not set to true, an error will be thrown the second time a plugin is registered on the server. - * * routes - modifiers applied to each route added by the plugin: - * * * prefix - string added as prefix to any route path (must begin with '/'). If a plugin registers a child plugin the prefix is passed on to the child or is added in front of the child-specific prefix. - * * * vhost - virtual host string (or array of strings) applied to every route. The outer-most vhost overrides the any nested configuration. - * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options) - */ -export interface ServerRegisterOptions { - once?: boolean; - routes?: { - prefix: string; - vhost: string | string[]; - }; -} - -/** - * An object with the following: - * * plugin - a plugin object. - * * options - (optional) options passed to the plugin during registration. - * * once - if true, subsequent registrations of the same plugin are skipped without error. Cannot be used with plugin options. Defaults to false. If not set to true, an error will be thrown the second time a plugin is registered on the server. - * * routes - modifiers applied to each route added by the plugin: - * * * prefix - string added as prefix to any route path (must begin with '/'). If a plugin registers a child plugin the prefix is passed on to the child or is added in front of the child-specific prefix. - * * * vhost - virtual host string (or array of strings) applied to every route. The outer-most vhost overrides the any nested configuration. - * For reference [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options) - */ -export interface ServerRegisterPluginObject extends ServerRegisterOptions { - plugin: Plugin; - options?: object; -} diff --git a/types/hapi/definitions/server/server-route.d.ts b/types/hapi/definitions/server/server-route.d.ts deleted file mode 100644 index 763f70ccf2..0000000000 --- a/types/hapi/definitions/server/server-route.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -import {Lifecycle, Server, Util} from "hapi"; - -export interface ServerRouteConfig { -} - -/** - * A route configuration object or an array of configuration objects where each object contains: - * * path - (required) the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the server's router configuration. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. - * * method - (required) the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. - * * vhost - (optional) a domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. - * * handler - (required when handler is not set) the route handler function called to generate the response after successful authentication and validation. - * * options - additional route options. The options value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. - * * rules - route custom rules object. The object is passed to each rules processor registered with server.rules(). Cannot be used if route.options.rules is defined. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrouteroute) - */ -export interface ServerRoute { - - /** - * (required) the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the server's router configuration. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrouteroute) - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#path-parameters) - */ - path: string; - - /** - * (required) the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. - */ - method: Util.HTTP_METHODS_PARTIAL | Util.HTTP_METHODS_PARTIAL[] | string | string[]; - - /** - * (optional) a domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. - */ - vhost?: string | string[]; - - /** - * (required when handler is not set) the route handler function called to generate the response after successful authentication and validation. - */ - handler?: Lifecycle.Method | object; - - /** - * additional route options. The options value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. - */ - options?: object | ((server: Server) => object); - - /** - * route custom rules object. The object is passed to each rules processor registered with server.rules(). Cannot be used if route.options.rules is defined. - */ - rules?: object; - - /** - * Missing documentation. Exist only in examples and test files. - */ - config?: ServerRouteConfig; - -} diff --git a/types/hapi/definitions/server/server-state-options.d.ts b/types/hapi/definitions/server/server-state-options.d.ts deleted file mode 100644 index cddc15c37e..0000000000 --- a/types/hapi/definitions/server/server-state-options.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -import {Iron, Request} from "hapi"; - -/** - * Optional cookie settings - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverstatename-options) - */ -export interface ServerStateCookieOptions { - /** time-to-live in milliseconds. Defaults to null (session time-life - cookies are deleted when the browser is closed). */ - ttl?: number | null; - /** sets the 'Secure' flag. Defaults to true. */ - isSecure?: boolean; - /** sets the 'HttpOnly' flag. Defaults to true. */ - isHttpOnly?: boolean; - /** - * sets the 'SameSite' flag. The value must be one of: - * * false - no flag. - * * 'Strict' - sets the value to 'Strict' (this is the default value). - * * 'Lax' - sets the value to 'Lax'. - */ - isSameSite?: false | 'Strict' | 'Lax'; - /** the path scope. Defaults to null (no path). */ - path?: string | null; - /** the domain scope. Defaults to null (no domain). */ - domain?: string | null; - /** - * if present and the cookie was not received from the client or explicitly set by the route handler, the - * cookie is automatically added to the response with the provided value. The value can be - * a function with signature async function(request) where: - */ - autoValue?(request: Request): void; - /** - * encoding performs on the provided value before serialization. Options are: - * * 'none' - no encoding. When used, the cookie value must be a string. This is the default value. - * * 'base64' - string value is encoded using Base64. - * * 'base64json' - object value is JSON-stringified then encoded using Base64. - * * 'form' - object value is encoded using the x-www-form-urlencoded method. - * * 'iron' - Encrypts and sign the value using iron. - */ - encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron'; - /** - * an object used to calculate an HMAC for cookie integrity validation. This does not provide privacy, only a mean to verify that the cookie value was generated by the server. Redundant when 'iron' encoding is used. Options are: - * * integrity - algorithm options. Defaults to require('iron').defaults.integrity. - * * password - password used for HMAC key generation (must be at least 32 characters long). - */ - sign?: { - integrity?: Iron.ISomething; - password: string; - }; - /** password used for 'iron' encoding (must be at least 32 characters long). */ - password?: string; - /** options for 'iron' encoding. Defaults to require('iron').defaults. */ - iron?: Iron.ISealOptions; - /** if true, errors are ignored and treated as missing cookies. */ - ignoreErrors?: boolean; - /** if true, automatically instruct the client to remove invalid cookies. Defaults to false. */ - clearInvalid?: boolean; - /** if false, allows any cookie value including values in violation of RFC 6265. Defaults to true. */ - strictHeader?: boolean; - /** used by proxy plugins (e.g. h2o2). */ - passThrough?: any; -} diff --git a/types/hapi/definitions/server/server-state.d.ts b/types/hapi/definitions/server/server-state.d.ts deleted file mode 100644 index 74842abd78..0000000000 --- a/types/hapi/definitions/server/server-state.d.ts +++ /dev/null @@ -1,69 +0,0 @@ -import {ServerStateCookieOptions, Util} from "hapi"; - -/** - * A single object or an array of object where each contains: - * * name - the cookie name. - * * value - the cookie value. - * * options - cookie configuration to override the server settings. - */ -export interface ServerStateFormat { - name: string; - value: string; - options: ServerStateCookieOptions; -} - -/** - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverstatename-options) - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptionsstate) - */ -export interface ServerState { - - /** - * The server cookies manager. - * Access: read only and statehood public interface. - */ - readonly states: object; - - /** - * The server cookies manager settings. The settings are based on the values configured in [server.options.state](https://github.com/hapijs/hapi/blob/master/API.md#server.options.state). - */ - readonly settings: ServerStateCookieOptions; - - /** - * An object containing the configuration of each cookie added via [server.state()](https://github.com/hapijs/hapi/blob/master/API.md#server.state()) where each key is the - * cookie name and value is the configuration object. - */ - readonly cookies: object; - - /** - * An array containing the names of all configued cookies. - */ - readonly names: string[]; - - /** - * Same as calling [server.state()](https://github.com/hapijs/hapi/blob/master/API.md#server.state()). - */ - add(name: string, options?: ServerStateCookieOptions): void; - - /** - * Formats an HTTP 'Set-Cookie' header based on the server.options.state where: - * @param cookies - a single object or an array of object where each contains: - * * name - the cookie name. - * * value - the cookie value. - * * options - cookie configuration to override the server settings. - * @return Return value: a header string. - * Note that this utility uses the server configuration but does not change the server state. It is provided for manual cookie formating (e.g. when headers are set manually). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-async-serverstatesformatcookies) - */ - format(cookies: ServerStateFormat | ServerStateFormat[]): string; - - /** - * Parses an HTTP 'Cookies' header based on the server.options.state where: - * @param header - the HTTP header. - * @return Return value: an object where each key is a cookie name and value is the parsed cookie. - * Note that this utility uses the server configuration but does not change the server state. It is provided for manual cookie parsing (e.g. when server parsing is disabled). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-async-serverstatesparseheader) - */ - parse(header: string): Util.Dictionary; - -} diff --git a/types/hapi/definitions/server/server.d.ts b/types/hapi/definitions/server/server.d.ts deleted file mode 100644 index 01d5fcc062..0000000000 --- a/types/hapi/definitions/server/server.d.ts +++ /dev/null @@ -1,546 +0,0 @@ -import * as http from "http"; -import * as zlib from "zlib"; -import * as Podium from "podium"; -import { - Lifecycle, - PayloadCompressionDecoderSettings, - Plugin, - PluginsListRegistered, - Request, - RequestRoute, - ResponseToolkit, - RouteCompressionEncoderSettings, - ServerAuth, - ServerCache, - ServerEvents, - ServerEventsApplication, - ServerExtEventsObject, - ServerExtEventsRequestObject, - ServerExtOptions, - ServerExtPointFunction, - ServerExtType, - ServerInfo, - ServerInjectOptions, - ServerInjectResponse, - ServerMethod, - ServerMethodConfigurationObject, - ServerMethodOptions, - ServerOptions, - ServerRealm, - ServerRegisterOptions, - ServerRegisterPluginObject, - ServerRoute, - ServerState, - ServerStateCookieOptions, - Util, -} from "hapi"; - -/** - * The server object is the main application container. The server manages all incoming requests along with all - * the facilities provided by the framework. Each server supports a single connection (e.g. listen to port 80). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#server) - */ -export class Server extends Podium { - - /** - * Creates a new server object - * @constructor - */ - constructor(); - - /** - * Creates a new server object where: - * @constructor - * @param options server configuration object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serveroptions) - */ - constructor(options: ServerOptions); - - /** - * Provides a safe place to store server-specific run-time application data without potential conflicts with - * the framework internals. The data can be accessed whenever the server is accessible. - * Initialized with an empty object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverapp) - */ - app?: any; - - /** - * Server Auth: properties and methods - */ - auth: ServerAuth; - - /** - * Provides access to the decorations already applied to various framework interfaces. The object must not be - * modified directly, but only through server.decorate. Contains: - * * request - decorations on the request object. - * * toolkit - decorations on the response toolkit. - * * server - decorations on the server object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecorations) - */ - readonly decorations: { - request: Request, - toolkit: ResponseToolkit, - server: Server - }; - - /** - * Register custom application events where: - * @param events must be one of: - * * an event name string. - * * an event options object with the following optional keys (unless noted otherwise): - * * * name - the event name string (required). - * * * channels - a string or array of strings specifying the event channels available. Defaults to no channel restrictions (event updates can specify a channel or not). - * * * clone - if true, the data object passed to server.events.emit() is cloned before it is passed to the listeners (unless an override specified by each listener). Defaults to false (data is passed as-is). - * * * spread - if true, the data object passed to server.event.emit() must be an array and the listener method is called with each array element passed as a separate argument (unless an override specified by each listener). This should only be used when the emitted data structure is known and predictable. Defaults to false (data is emitted as a single argument regardless of its type). - * * * tags - if true and the criteria object passed to server.event.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end. A configuration override can be set by each listener. Defaults to false. - * * * shared - if true, the same event name can be registered multiple times where the second registration is ignored. Note that if the registration config is changed between registrations, only the first configuration is used. Defaults to false (a duplicate registration will throw an error). - * * a podium emitter object. - * * an array containing any of the above. - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) - */ - event(events: ServerEventsApplication | ServerEventsApplication[]): void; - - /** - * Access: podium public interface. - * The server events emitter. Utilizes the podium with support for event criteria validation, channels, and filters. - * Use the following methods to interact with server.events: - * [server.events.emit(criteria, data)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.emit()) - emit server events. - * [server.events.on(criteria, listener)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.on()) - subscribe to all events. - * [server.events.once(criteria, listener)](https://github.com/hapijs/hapi/blob/master/API.md#server.events.once()) - subscribe to - * Other methods include: server.events.removeListener(name, listener), server.events.removeAllListeners(name), and server.events.hasListeners(name). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverevents) - */ - events: ServerEvents; - - /** - * An object containing information about the server where: - * * id - a unique server identifier (using the format '{hostname}:{pid}:{now base36}'). - * * created - server creation timestamp. - * * started - server start timestamp (0 when stopped). - * * port - the connection port based on the following rules: - * * host - The host configuration value. - * * address - the active IP address the connection was bound to after starting. Set to undefined until the server has been started or when using a non TCP port (e.g. UNIX domain socket). - * * protocol - the protocol used: - * * 'http' - HTTP. - * * 'https' - HTTPS. - * * 'socket' - UNIX domain socket or Windows named pipe. - * * uri - a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains the uri value if set, otherwise constructed from the available settings. If no port is configured or is set to 0, the uri will not include a port component until the server is started. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo) - */ - readonly info: ServerInfo; - - /** - * Access: read only and listener public interface. - * The node HTTP server object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverlistener) - */ - listener: http.Server; - - /** - * An object containing the process load metrics (when load.sampleInterval is enabled): - * * eventLoopDelay - event loop delay milliseconds. - * * heapUsed - V8 heap usage. - * * rss - RSS memory usage. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverload) - */ - readonly load: { - eventLoopDelay: number; - heapUsed: number; - rss: number; - }; - - /** - * Server methods are functions registered with the server and used throughout the application as a common utility. - * Their advantage is in the ability to configure them to use the built-in cache and share across multiple request - * handlers without having to create a common module. - * sever.methods is an object which provides access to the methods registered via server.method() where each - * server method name is an object property. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethods - */ - readonly methods: Util.Dictionary; - - /** - * Provides access to the server MIME database used for setting content-type information. The object must not be - * modified directly but only through the [mime](https://github.com/hapijs/hapi/blob/master/API.md#server.options.mime) server setting. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermime) - */ - mime: any; - - /** - * An object containing the values exposed by each registered plugin where each key is a plugin name and the values - * are the exposed properties by each plugin using server.expose(). Plugins may set the value of - * the server.plugins[name] object directly or via the server.expose() method. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins) - */ - plugins: any; - - /** - * The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When - * registering a plugin or an authentication scheme, a server object reference is provided with a new server.realm - * container specific to that registration. It allows each plugin to maintain its own settings without leaking - * and affecting other plugins. - * For example, a plugin can set a default file path for local resources without breaking other plugins' configured - * paths. When calling server.bind(), the active realm's settings.bind property is set which is then used by - * routes and extensions added at the same level (server root or plugin). - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrealm) - */ - readonly realm: ServerRealm; - - /** - * An object of the currently registered plugins where each key is a registered plugin name and the value is - * an object containing: - * * version - the plugin version. - * * name - the plugin name. - * * options - (optional) options passed to the plugin during registration. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverregistrations) - */ - readonly registrations: PluginsListRegistered; - - /** - * The server configuration object after defaults applied. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serversettings) - */ - readonly settings: ServerOptions; - - /** - * The server cookies manager. - * Access: read only and statehood public interface. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverstates) - */ - readonly states: ServerState; - - /** - * A string indicating the listener type where: - * * 'socket' - UNIX domain socket or Windows named pipe. - * * 'tcp' - an HTTP listener. - */ - readonly type: 'socket' | 'tcp'; - - /** - * The hapi module version number. - */ - readonly version: string; - - /** - * Sets a global context used as the default bind object when adding a route or an extension where: - * @param context - the object used to bind this in lifecycle methods such as the route handler and extension methods. The context is also made available as h.context. - * @return Return value: none. - * When setting a context inside a plugin, the context is applied only to methods set up by the plugin. Note that the context applies only to routes and extensions added after it has been set. Ignored if the method being bound is an arrow function. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverbindcontext) - */ - bind(context: object): void; - - /** - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions) - */ - cache: ServerCache; - - /** - * Registers a custom content decoding compressor to extend the built-in support for 'gzip' and 'deflate' where: - * @param encoding - the decoder name string. - * @param decoder - a function using the signature function(options) where options are the encoding specific options configured in the route payload.compression configuration option, and the return value is an object compatible with the output of node's zlib.createGunzip(). - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoderencoding-decoder) - */ - decoder(encoding: string, decoder: ((options: PayloadCompressionDecoderSettings) => zlib.Gunzip)): void; - - /** - * Extends various framework interfaces with custom methods where: - * @param type - the interface being decorated. Supported types: - * 'handler' - adds a new handler type to be used in routes handlers. - * 'request' - adds methods to the Request object. - * 'server' - adds methods to the Server object. - * 'toolkit' - adds methods to the response toolkit. - * @param property - the object decoration key name. - * @param method - the extension function or other value. - * @param options - (optional) supports the following optional settings: - * apply - when the type is 'request', if true, the method function is invoked using the signature function(request) where request is the current request object and the returned value is assigned as the decoration. - * extend - if true, overrides an existing decoration. The method must be a function with the signature function(existing) where: - * existing - is the previously set decoration method value. - * must return the new decoration function or value. - * cannot be used to extend handler decorations. - * @return void; - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options) - */ - decorate(type: 'request', property: string, method: ((request: Request) => Function), options?: {apply: true; extend: false} ): void; - decorate(type: 'handler' | 'request' | 'server' | 'toolkit', property: string, method: Function, options?: {apply: boolean; extend: boolean} ): void; - - /** - * Used within a plugin to declare a required dependency on other plugins where: - * @param dependencies - a single string or an array of plugin name strings which must be registered in order for this plugin to operate. Plugins listed must be registered before the server is initialized or started. - * @param after - (optional) a function that is called after all the specified dependencies have been registered and before the server starts. The function is only called if the server is initialized or started. The function signature is async function(server) where: - * server - the server the dependency() method was called on. - * @return Return value: none. - * The after method is identical to setting a server extension point on 'onPreStart'. - * If a circular dependency is detected, an exception is thrown (e.g. two plugins each has an after function to be called after the other). - * The method does not provide version dependency which should be implemented using npm peer dependencies. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverdependencydependencies-after) - */ - dependency(dependencies: string | string[], after?: ((server: Server) => void)): void; - - /** - * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' where: - * @param encoding - the encoder name string. - * @param encoder - a function using the signature function(options) where options are the encoding specific options configured in the route compression option, and the return value is an object compatible with the output of node's zlib.createGzip(). - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder) - */ - encoder(encoding: string, encoder: ((options: RouteCompressionEncoderSettings) => zlib.Gzip)): void; - - /** - * Used within a plugin to expose a property via server.plugins[name] where: - * @param key - the key assigned (server.plugins[name][key]). - * @param value - the value assigned. - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposekey-value) - */ - expose(key: string, value: any): void; - - /** - * Merges an object into to the existing content of server.plugins[name] where: - * @param obj - the object merged into the exposed properties container. - * @return Return value: none. - * Note that all the properties of obj are deeply cloned into server.plugins[name], so avoid using this method - * for exposing large objects that may be expensive to clone or singleton objects such as database client - * objects. Instead favor server.expose(key, value), which only copies a reference to value. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverexposeobj) - */ - expose(obj: object): void; - - /** - * Registers an extension function in one of the request lifecycle extension points where: - * @param events - an object or array of objects with the following: - * * type - (required) the extension point event name. The available extension points include the request extension points as well as the following server extension points: - * * * 'onPreStart' - called before the connection listeners are started. - * * * 'onPostStart' - called after the connection listeners are started. - * * * 'onPreStop' - called before the connection listeners are stopped. - * * * 'onPostStop' - called after the connection listeners are stopped. - * * method - (required) a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is: - * * * server extension points: async function(server) where: - * * * * server - the server object. - * * * * this - the object provided via options.bind or the current active context set with server.bind(). - * * * request extension points: a lifecycle method. - * * options - (optional) an object with the following: - * * * before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. - * * * after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. - * * * bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. - * * * sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'server' which applies to any route added to the server the extension is added to. - * @return void - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevents) - */ - ext(events: ServerExtEventsObject | ServerExtEventsObject[]): void; - ext(events: ServerExtEventsRequestObject | ServerExtEventsRequestObject[]): void; - - /** - * Registers a single extension event using the same properties as used in server.ext(events), but passed as arguments. - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options) - */ - ext(event: ServerExtType, method: ServerExtPointFunction | Lifecycle.Method | Function, options?: ServerExtOptions): void; - - /** - * Initializes the server (starts the caches, finalizes plugin registration) but does not start listening on the connection port. - * @return Return value: none. - * Note that if the method fails and throws an error, the server is considered to be in an undefined state and - * should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and - * other event listeners will get confused by repeated attempts to start the server or make assumptions about the - * healthy state of the environment. It is recommended to abort the process when the server fails to start properly. - * If you must try to resume after an error, call server.stop() first to reset the server state. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinitialize) - */ - initialize(): void; - - /** - * Injects a request into the server simulating an incoming HTTP request without making an actual socket connection. Injection is useful for testing purposes as well as for invoking routing logic internally without the overhead and limitations of the network stack. - * The method utilizes the shot module for performing injections, with some additional options and response properties: - * @param options - can be assigned a string with the requested URI, or an object with: - * * method - (optional) the request HTTP method (e.g. 'POST'). Defaults to 'GET'. - * * url - (required) the request URL. If the URI includes an authority (e.g. 'example.com:8080'), it is used to automatically set an HTTP 'Host' header, unless one was specified in headers. - * * headers - (optional) an object with optional request headers where each key is the header name and the value is the header content. Defaults to no additions to the default shot headers. - * * payload - (optional) an string, buffer or object containing the request payload. In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided. - * * credentials - (optional) an credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials. - * * artifacts - (optional) an artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts. - * * app - (optional) sets the initial value of request.app, defaults to {}. - * * plugins - (optional) sets the initial value of request.plugins, defaults to {}. - * * allowInternals - (optional) allows access to routes with config.isInternal set to true. Defaults to false. - * * remoteAddress - (optional) sets the remote address for the incoming connection. - * * simulate - (optional) an object with options used to simulate client request stream conditions for testing: - * * error - if true, emits an 'error' event after payload transmission (if any). Defaults to false. - * * close - if true, emits a 'close' event after payload transmission (if any). Defaults to false. - * * end - if false, does not end the stream. Defaults to true. - * * split - indicates whether the request payload will be split into chunks. Defaults to undefined, meaning payload will not be chunked. - * * validate - (optional) if false, the options inputs are not validated. This is recommended for run-time usage of inject() to make it perform faster where input validation can be tested separately. - * @return Return value: a response object with the following properties: - * * statusCode - the HTTP status code. - * * headers - an object containing the headers set. - * * payload - the response payload string. - * * rawPayload - the raw response payload buffer. - * * raw - an object with the injection request and response objects: - * * req - the simulated node request object. - * * res - the simulated node response object. - * * result - the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the internal objects returned (instead of parsing the response string). - * * request - the request object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions) - */ - inject(options: string | ServerInjectOptions): ServerInjectResponse; - - /** - * Logs server events that cannot be associated with a specific request. When called the server emits a 'log' event which can be used by other listeners or plugins to record the information or output to the console. The arguments are: - * @param tags - (required) a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. Any logs generated by the server internally include the 'hapi' tag along with event-specific information. - * @param data - (optional) an message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. - * @param timestamp - (optional) an timestamp expressed in milliseconds. Defaults to Date.now() (now). - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverlogtags-data-timestamp) - */ - log(tags: string | string[], data?: string | object | (() => any), timestamp?: number): void; - - /** - * Looks up a route configuration where: - * @param id - the route identifier. - * @return Return value: the route information if found, otherwise null. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverlookupid) - */ - lookup(id: string): RequestRoute | null; - - /** - * Looks up a route configuration where: - * @param method - the HTTP method (e.g. 'GET', 'POST'). - * @param path - the requested path (must begin with '/'). - * @param host - (optional) hostname (to match against routes with vhost). - * @return Return value: the route information if found, otherwise null. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermatchmethod-path-host) - */ - match(method: Util.HTTP_METHODS, path: string, host?: string): RequestRoute | null; - - /** - * Registers a server method where: - * @param name - a unique method name used to invoke the method via server.methods[name]. - * @param method - the method function with a signature async function(...args, [flags]) where: - * * ...args - the method function arguments (can be any number of arguments or none). - * * flags - when caching is enabled, an object used to set optional method result flags: - * * * ttl - 0 if result is valid but cannot be cached. Defaults to cache policy. - * @param options - (optional) configuration object: - * * bind - a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. Ignored if the method is an arrow function. - * * cache - the same cache configuration used in server.cache(). The generateTimeout option is required. - * * generateKey - a function used to generate a unique key (for caching) from the arguments passed to the method function (the flags argument is not passed as input). The server will automatically generate a unique key if the function's arguments are all of types 'string', 'number', or 'boolean'. However if the method uses other types of arguments, a key generation function must be provided which takes the same arguments as the function and returns a unique string (or null if no key can be generated). - * @return Return value: none. - * Method names can be nested (e.g. utils.users.get) which will automatically create the full path under server.methods (e.g. accessed via server.methods.utils.users.get). - * When configured with caching enabled, server.methods[name].cache is assigned an object with the following properties and methods: - await drop(...args) - a function that can be used to clear the cache for a given key. - stats - an object with cache statistics, see catbox for stats documentation. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodname-method-options) - */ - method(name: string, method: ServerMethod, options?: ServerMethodOptions): void; - - /** - * Registers a server method function as described in server.method() using a configuration object where: - * @param methods - an object or an array of objects where each one contains: - * * name - the method name. - * * method - the method function. - * * options - (optional) settings. - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servermethodmethods) - */ - method(methods: ServerMethodConfigurationObject | ServerMethodConfigurationObject[]): void; - - /** - * Sets the path prefix used to locate static resources (files and view templates) when relative paths are used where: - * @param relativeTo - the path prefix added to any relative file path starting with '.'. - * @return Return value: none. - * Note that setting a path within a plugin only applies to resources accessed by plugin methods. If no path is set, the server default route configuration files.relativeTo settings is used. The path only applies to routes added after it has been set. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverpathrelativeto) - */ - path(relativeTo: string): void; - - /** - * Registers a plugin where: - * @param plugins - one or an array of: - * * a plugin object. - * * an object with the following: - * * * plugin - a plugin object. - * * * options - (optional) options passed to the plugin during registration. - * * * once, routes - (optional) plugin-specific registration options as defined below. - * @param options - (optional) registration options (different from the options passed to the registration function): - * * once - if true, subsequent registrations of the same plugin are skipped without error. Cannot be used with plugin options. Defaults to false. If not set to true, an error will be thrown the second time a plugin is registered on the server. - * * routes - modifiers applied to each route added by the plugin: - * * * prefix - string added as prefix to any route path (must begin with '/'). If a plugin registers a child plugin the prefix is passed on to the child or is added in front of the child-specific prefix. - * * * vhost - virtual host string (or array of strings) applied to every route. The outer-most vhost overrides the any nested configuration. - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverregisterplugins-options) - */ - register(plugins: Plugin | Plugin[], options?: ServerRegisterOptions): void; - register(plugins: ServerRegisterPluginObject | ServerRegisterPluginObject[], options?: ServerRegisterOptions): void; - - /** - * Adds a route where: - * @param route - a route configuration object or an array of configuration objects where each object contains: - * * path - (required) the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the server's router configuration. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. - * * method - (required) the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. - * * vhost - (optional) a domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. - * * handler - (required when handler is not set) the route handler function called to generate the response after successful authentication and validation. - * * options - additional route options. The options value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. - * * rules - route custom rules object. The object is passed to each rules processor registered with server.rules(). Cannot be used if route.options.rules is defined. - * @return Return value: none. - * Note that the options object is deeply cloned (with the exception of bind which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrouteroute) - */ - route(route: ServerRoute | ServerRoute[]): void; - - /** - * Defines a route rules processor for converting route rules object into route configuration where: - * @param processor - a function using the signature function(rules, info) where: - * * rules - - * * info - an object with the following properties: - * * * method - the route method. - * * * path - the route path. - * * * vhost - the route virtual host (if any defined). - * * returns a route config object. - * @param options - optional settings: - * * validate - rules object validation: - * * * schema - joi schema. - * * * options - optional joi validation options. Defaults to { allowUnknown: true }. - * Note that the root server and each plugin server instance can only register one rules processor. If a route is added after the rules are configured, it will not include the rules config. Routes added by plugins apply the rules to each of the parent realms' rules from the root to the route's realm. This means the processor defined by the plugin override the config generated by the root processor if they overlap. The route config overrides the rules config if the overlap. - * @return void - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverrulesprocessor-options) - */ - rules(processor: (rules: object, info: {method: string, path: string, vhost?: string}) => object, options?: {validate: object}): void; // TODO needs implementation - - /** - * Starts the server by listening for incoming requests on the configured port (unless the connection was configured with autoListen set to false). - * @return Return value: none. - * Note that if the method fails and throws an error, the server is considered to be in an undefined state and should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and other event listeners will get confused by repeated attempts to start the server or make assumptions about the healthy state of the environment. It is recommended to abort the process when the server fails to start properly. If you must try to resume after an error, call server.stop() first to reset the server state. - * If a started server is started again, the second call to server.start() is ignored. No events will be emitted and no extension points invoked. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstart) - */ - start(): void; - - /** - * HTTP state management uses client cookies to persist a state across multiple requests. - * @param name - the cookie name string. - * @param options - are the optional cookie settings - * @return Return value: none. - * State defaults can be modified via the server default state configuration option. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-serverstatename-options) - */ - state(name: string, options?: ServerStateCookieOptions): void; - - /** - * Stops the server's listener by refusing to accept any new connections or requests (existing connections will continue until closed or timeout), where: - * @param options - (optional) object with: - * * timeout - overrides the timeout in millisecond before forcefully terminating a connection. Defaults to 5000 (5 seconds). - * @return Return value: none. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstopoptions) - */ - stop(options?: {timeout: number}): void; - - /** - * Returns a copy of the routing table where: - * @param host - (optional) host to filter routes matching a specific virtual host. Defaults to all virtual hosts. - * @return Return value: an array of routes where each route contains: - * * settings - the route config with defaults applied. - * * method - the HTTP method in lower case. - * * path - the route path. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost) - */ - table(host?: string): {settings: ServerRoute; method: Util.HTTP_METHODS_PARTIAL_LOWERCASE, path: string}[]; // TODO I am not sure if the ServerRoute is the object expected here - -} diff --git a/types/hapi/definitions/util/iron.d.ts b/types/hapi/definitions/util/iron.d.ts deleted file mode 100644 index 5f3d711803..0000000000 --- a/types/hapi/definitions/util/iron.d.ts +++ /dev/null @@ -1,88 +0,0 @@ -/** - * iron is a cryptographic utility for sealing a JSON object using symmetric key encryption with message integrity - * verification. Or in other words, it lets you encrypt an object, send it around (in cookies, authentication - * credentials, etc.), then receive it back and decrypt it. The algorithm ensures that the message was not tampered - * with, and also provides a simple mechanism for password rotation. - * [See docs](https://github.com/hueniverse/iron) - * @author typings wrote by SimonSchick - */ -export namespace Iron { - - export interface ISomething { - saltBits: number; - algorithm: string; - iterations: number; - minPasswordlength: number; - } - - export interface ISealOptions { - encryption: ISomething; - integrity: ISomething; - - ttl: number; - timestampSkewSec: number; - localtimeOffsetMsec: number; - } - - /** - * iron provides a few options for customizing the key deriviation algorithm used to generate encryption and - * integrity verification keys as well as the algorithms and salt sizes used. The 'seal()' and 'unseal()' - * methods take an options object with the following required keys: - * * encryption - defines the options used by the encryption process. - * * integrity - defines the options used by the HMAC integrity verification process. - * Each of these option objects includes the following required keys: - * * saltBits - the size of the salt (random buffer used to ensure that two identical objects will generate a different encrypted result. - * * algorithm - the algorithm used ('aes-256-cbc' for encryption and 'sha256' for integrity are the only two supported at this time). - * * iterations - the number of iterations used to derive a key from the password. Set to 1 by default. The number of ideal iterations to use is dependent on your application's performance requirements. More iterations means it takes longer to generate the key. - * The 'seal()' and 'unseal()' methods also take the following optional options keys: - * * ttl - sealed object lifetime in milliseconds where 0 means forever. Defaults to 0. - * * timestampSkewSec - number of seconds of permitted clock skew for incoming expirations. Defaults to 60 seconds. - * * localtimeOffsetMsec - local clock time offset, expressed in number of milliseconds (positive or negative). Defaults to 0. - * [See docs](https://github.com/hueniverse/iron#options) - */ - export const defaults: ISealOptions; - - export const algorithms: { - 'aes-128-ctr': { - keyBits: number; - ivBits: number; - }; - 'aes-256-cbc': { - keyBits: number; - ivBits: number; - }; - 'sha256': { - keyBits: number; - }; - }; - - export const macFormatVersion: string; - export const macPrefix: string; - - export interface IGenerateKeyOptions extends Pick { - saltBits?: number; - salt?: string; - iv?: string; - } - - export interface IKey { - key: Buffer; - salt: string; - iv: string; - } - - export function generateKey (password: string, options: IGenerateKeyOptions): Promise; - export function encrypt (password: string, options: IGenerateKeyOptions, data: string): Promise<{ data: Buffer, key: IKey }>; - export function decrypt (password: string, options: IGenerateKeyOptions, data: string): Promise; - - export interface IHMacResult { - digest: string; - salt: string; - } - - export function hmacWithPassword(password: string, options: IGenerateKeyOptions, data: string): Promise; - - export function seal (obj: object, password: string, options: ISealOptions): Promise; - export function unseal (data: string, password: string, options: ISealOptions): Promise; - -} diff --git a/types/hapi/definitions/util/json.d.ts b/types/hapi/definitions/util/json.d.ts deleted file mode 100644 index 116f6bdf9a..0000000000 --- a/types/hapi/definitions/util/json.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -export namespace Json { - - /** - * @see {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter} - */ - export type StringifyReplacer = ((key: string, value: any) => any) | (string | number)[] | undefined; - - /** - * Any value greater than 10 is truncated. - */ - export type StringifySpace = number | string; - - /** - * For context [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionsjson) - */ - export interface StringifyArguments { - /** the replacer function or array. Defaults to no action. */ - replacer?: StringifyReplacer; - /** number of spaces to indent nested object keys. Defaults to no indentation. */ - space?: StringifySpace; - /** tring suffix added after conversion to JSON string. Defaults to no suffix. **/ - suffix?: string; - /** calls Hoek.jsonEscape() after conversion to JSON string. Defaults to false. **/ - escape?: boolean; - } - -} diff --git a/types/hapi/definitions/util/lifecycle.d.ts b/types/hapi/definitions/util/lifecycle.d.ts deleted file mode 100644 index 35f347dcd5..0000000000 --- a/types/hapi/definitions/util/lifecycle.d.ts +++ /dev/null @@ -1,59 +0,0 @@ -import * as Boom from "boom"; -import * as stream from "stream"; -import {Request, ResponseToolkit} from "hapi"; - -export namespace Lifecycle { - - /** - * Lifecycle methods are the interface between the framework and the application. Many of the request lifecycle steps: - * extensions, authentication, handlers, pre-handler methods, and failAction function values are lifecyle methods - * provided by the developer and executed by the framework. - * Each lifecycle method is a function with the signature await function(request, h, [err]) where: - * * request - the request object. - * * h - the response toolkit the handler must call to set a response and return control back to the framework. - * * err - an error object availble only when the method is used as a failAction value. - */ - export interface Method { - (request: Request, h: ResponseToolkit): ReturnValue; - (request: Request, h: ResponseToolkit, err: Error): ReturnValue; - } - - /** - * Each lifecycle method must return a value or a promise that resolves into a value. If a lifecycle method returns - * without a value or resolves to an undefined value, an Internal Server Error (500) error response is sent. - * The return value must be one of: - * * Plain value: null, string, number, boolean - * * Buffer object - * * Error object: plain Error OR a Boom object. - * * Stream object - * * any object or array - * * a toolkit signal: - * * a toolkit method response: - * * a promise object that resolve to any of the above values - * For more info please [See docs](https://github.com/hapijs/hapi/blob/master/API.md#lifecycle-methods) - */ - export type ReturnValue = ReturnValueTypes | (Promise); - export type ReturnValueTypes = - (null | string | number | boolean) | - (Buffer) | - (Error | Boom.BoomError) | - (stream.Stream) | - (object | object[]) | - Object | - ResponseToolkit; - - /** - * Various configuration options allows defining how errors are handled. For example, when invalid payload is received or malformed cookie, instead of returning an error, the framework can be configured to perform another action. When supported the failAction option supports the following values: - * * 'error' - return the error object as the response. - * * 'log' - report the error but continue processing the request. - * * 'ignore' - take no action and continue processing the request. - * * a lifecycle method with the signature async function(request, h, err) where: - * * * request - the request object. - * * * h - the response toolkit. - * * * err - the error object. - * [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-failaction-configuration) - */ - export type FailAction = 'error' | 'log' | 'ignore' | Method; - -} - diff --git a/types/hapi/definitions/util/util.d.ts b/types/hapi/definitions/util/util.d.ts deleted file mode 100644 index f92b23bb4d..0000000000 --- a/types/hapi/definitions/util/util.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export namespace Util { - - export interface Dictionary { - [key: string]: T; - } - - export type HTTP_METHODS_PARTIAL_LOWERCASE = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; - export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_LOWERCASE; - export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; - -} diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index 58d84ba89f..a97a9f1edb 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -1,7 +1,6 @@ -// Type definitions for hapi 17.0 +// Type definitions for hapi 16.1 // Project: https://github.com/hapijs/hapi -// Definitions by: Marc Bornträger -// Rafael Souza Fijalkowski +// Definitions by: Jason Swearingen , AJP // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -13,59 +12,2712 @@ + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * + * + * Removal of IPromise replaced with Promise + * Removal of IReplyStrict<> + * Removal of IReply replaced with different interfaces like: + * ReplyWithContinue + * ReplyNoContinue, etc. + * Renaming of all interfaces to remove preceding I in preparation of dtslint + */ /// -/** PLUGIN */ -export * from './definitions/plugin/plugin' -export * from './definitions/plugin/plugin-registered' +import Events = require("events"); +import stream = require("stream"); +import http = require("http"); +import https = require("https"); +import url = require("url"); +import zlib = require("zlib"); +import domain = require("domain"); -/** REQUEST */ -export * from './definitions/request/request' -export * from './definitions/request/request-auth' -export * from './definitions/request/request-events' -export * from './definitions/request/request-info' -export * from './definitions/request/request-route' +import * as Boom from 'boom'; +import { + ValidationOptions as JoiValidationOptions, + SchemaMap as JoiSchemaMap, + Schema as JoiSchema, +} from 'joi'; +// TODO check JoiValidationObject is correct for "a Joi validation object" +type JoiValidationObject = JoiSchema | JoiSchemaMap | (JoiSchema | JoiSchemaMap)[]; -/** RESPONSE */ -export * from './definitions/response/response-events' -export * from './definitions/response/response-object' -export * from './definitions/response/response-settings' -export * from './definitions/response/response-toolkit' +import * as Catbox from 'catbox'; +import { MimosOptions } from 'mimos'; +import Podium = require('podium'); +import * as Shot from 'shot'; -/** ROUTE */ -export * from './definitions/route/route-options' -export * from './definitions/route/route-options-access' -export * from './definitions/route/route-options-access-scope' -export * from './definitions/route/route-options-cache' -export * from './definitions/route/route-options-cors' -export * from './definitions/route/route-options-payload' -export * from './definitions/route/route-options-pre' -export * from './definitions/route/route-options-response' -export * from './definitions/route/route-options-secure' -export * from './definitions/route/route-options-validate' +export interface Dictionary { + [key: string]: T; +} -/** SERVER */ -export * from './definitions/server/server' -export * from './definitions/server/server-auth' -export * from './definitions/server/server-auth-scheme' -export * from './definitions/server/server-cache' -export * from './definitions/server/server-events' -export * from './definitions/server/server-ext' -export * from './definitions/server/server-info' -export * from './definitions/server/server-inject' -export * from './definitions/server/server-method' -export * from './definitions/server/server-options' -export * from './definitions/server/server-options-cache' -export * from './definitions/server/server-realm' -export * from './definitions/server/server-register' -export * from './definitions/server/server-route' -export * from './definitions/server/server-state' -export * from './definitions/server/server-state-options' +/** + * Server + * The Server object is the main application container. The server manages all incoming connections along with all the facilities provided by the framework. A server can contain more than one connection (e.g. listen to port 80 and 8080). + * [See docs](https://hapijs.com/api/16.1.1#server) + * [See docs](https://hapijs.com/api/16.1.1#server-properties) + * [See docs](https://hapijs.com/api/16.1.1#server-events) + */ +export class Server extends Podium { + /** + * Creates a new Server object + */ + constructor(options?: ServerOptions); -/** UTIL */ -export * from './definitions/util/iron' -export * from './definitions/util/json' -export * from './definitions/util/lifecycle' -export * from './definitions/util/util' + /** + * Provides a safe place to store server-specific run-time application data without potential conflicts with the framework internals. The data can be accessed whenever the server is accessible. Initialized with an empty object. + * [See docs](https://hapijs.com/api/16.1.1#serverapp) + */ + app?: any; + /** + * An array containing the server's connections. When the server object is returned from server.select(), the connections array only includes the connections matching the selection criteria. + * [See docs](https://hapijs.com/api/16.1.1#serverconnections) + */ + connections: ServerConnection[]; + /** + * When the server contains exactly one connection, info is an object containing information about the sole connection + * When the server contains more than one connection, each server.connections array member provides its own connection.info. + * [See docs](https://hapijs.com/api/16.1.1#serverinfo) + */ + info: ServerConnectionInfo | null; + /** + * An object containing the process load metrics (when load.sampleInterval is enabled): + * [See docs](https://hapijs.com/api/16.1.1#serverload) + */ + load: { + /** event loop delay milliseconds. */ + eventLoopDelay: number; + /** V8 heap usage. */ + heapUsed: number; + /** RSS memory usage. */ + rss: number; + }; + /** + * When the server contains exactly one connection, listener is the node HTTP server object of the sole connection. + * When the server contains more than one connection, each server.connections array member provides its own connection.listener. + * [See docs](https://hapijs.com/api/16.1.1#serverlistener) + */ + listener: ServerListener | null; + /** + * An object providing access to the server methods cs://hapijs.com/api/16.1.1#servermethodname-method-options} where each server method name is an object property. + * [See docs](https://hapijs.com/api/16.1.1#servermethods) + */ + methods: Dictionary; + /** + * Provides access to the server MIME database used for setting content-type information. The object must not be modified directly but only through the mime server setting. + * [See docs](https://hapijs.com/api/16.1.1#servermime) + */ + readonly mime: {path(path: string): {type: string}}; + /** + * An object containing the values exposed by each plugin registered where each key is a plugin name and the values are the exposed properties by each plugin using server.expose(). Plugins may set the value of the server.plugins[name] object directly or via the server.expose() method. + * [See docs](https://hapijs.com/api/16.1.1#serverplugins) + */ + plugins: PluginsStates; + /** + * The realm object contains server-wide or plugin-specific state that can be shared across various methods. For example, when calling server.bind(), the active realm settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). Realms are a limited version of a sandbox where plugins can maintain state used by the framework when adding routes, extensions, and other properties. + * [See docs](https://hapijs.com/api/16.1.1#serverrealm) + */ + readonly realm: ServerRealm; + /** + * When the server contains exactly one connection, registrations is an object where each key is a registered plugin name + * When the server contains more than one connection, each server.connections array member provides its own connection.registrations. + * TODO check and offer PR to update Hapi docs: Assuming readonly. + * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) + */ + readonly registrations: ServerRegisteredPlugins; + /** + * The root server object containing all the connections and the root server methods (e.g. start(), stop(), connection()). + * TODO, check and offer PR to update Hapi docs: Marked as optional as presumably root server does not reference itself. + * [See docs](https://hapijs.com/api/16.1.1#serverroot) + */ + root?: Server; + /** + * The server configuration object after defaults applied. + * [See docs](https://hapijs.com/api/16.1.1#serversettings) + */ + settings: ServerOptions; + /** + * The hapi module version number. + * [See docs](https://hapijs.com/api/16.1.1#serverversion) + */ + version: string; + + /** + * [See docs](https://hapijs.com/api/16.1.1#serverauthapi) + * [See docs](https://hapijs.com/api/16.1.1#serverauthdefaultoptions) + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) + * [See docs](https://hapijs.com/api/16.1.1#serverauthstrategyname-scheme-mode-options) + * [See docs](https://hapijs.com/api/16.1.1#serverauthteststrategy-request-next) + */ + auth: ServerAuth; + + /** + * Sets a global context used as the default bind object when adding a route or an extension + * When setting context inside a plugin, the context is applied only to methods set up by the plugin. Note that the context applies only to routes and extensions added after it has been set. Ignored if the method being bound is an arrow function. + * @param context the object used to bind this in handler and extension methods. + * [See docs](https://hapijs.com/api/16.1.1#serverbindcontext) + */ + bind(context: any): void; + /** + * [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) + * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) + */ + cache: ServerCacheMethod; + /** + * Adds an incoming server connection + * Returns a server object with the new connections selected. + * Must be called before any other server method that modifies connections is called for it to apply to the new connection (e.g. server.state()) + * Note that the options object is deeply cloned (with the exception of listener which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on. + * + * [See docs](https://hapijs.com/api/16.1.1#serverconnectionoptions) for various advantage topics covering usage and caveats around use of the function in plugin register(), connectionless plugins calling connection(), etc. + * @param connection a connection configuration object or array of objects + */ + connection(options?: ServerConnectionOptions[]): Server; + connection(options?: ServerConnectionOptions): Server; + // connection: (options: ServerConnectionOptions[] | ServerConnectionOptions) => Server; + /** + * Registers a custom content decoding compressor to extend the built-in support for 'gzip' and 'deflate' + * [See docs](https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder) + * @param encoding the decoder name string. + * @param decoder a function using the signature function(options) where options are the encoding specific options configured in the route payload.compression configuration option, and the return value is an object compatible with the output of node's zlib.createGunzip(). + */ + decoder(encoding: string, decoder: ((options: CompressionDecoderSettings) => zlib.Gunzip)): void; + /** + * Extends various framework interfaces with custom methods + * Note that decorations apply to the entire server and all its connections regardless of current selection. + * [See docs](https://hapijs.com/api/16.1.1#serverdecoratetype-property-method-options) + * + * NOTE: it's not possible to type the result of this action. + * It's advised that in a custom definition file, you extend the ReplyNoContinue + * and ReplyWithContinue functions. See Inert `.file` for an example. + * Or if it is not part of a library / plugin then you use a namespace within + * your code to type the request, server and or reply. See + * [tests/server/decorate.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hapi/tests/server/decorate.ts) + * for examples. + * @param type the interface being decorated. Supported types: + * * 'request' - adds methods to the Request object. + * * 'reply' - adds methods to the reply interface. + * * 'server' - adds methods to the Server object. + * @param property the object decoration key name. + * @param method the extension function or other value. + * @param options if the type is 'request', supports the following optional settings: + * * apply - if true, the method function is invoked using the signature function(request) where request is the current request object and the returned value is assigned as the decoration. + */ + decorate(type: 'request' | 'reply' | 'server', property: string, method: Function): void; + decorate(type: 'request', property: string, method: Function, options?: {apply: false}): void; + decorate(type: 'request', property: string, method: (request: Request) => Function, options: {apply: true}): void; + /** + * The server.decorate('server', ...) method can modify this prototype/interface. + * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts + * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) + */ + // [index: string]: any; + /** + * Used within a plugin to declare a required dependency on other plugins + * The after method is identical to setting a server extension point on 'onPreStart'. Connectionless plugins (those with attributes.connections set to false) can only depend on other connectionless plugins (server initialization will fail even of the dependency is loaded but is not connectionless). + * Dependencies can also be set via the register attributes property (does not support setting after). + * [See docs](https://hapijs.com/api/16.1.1#serverdependencydependencies-after) + * @param dependencies a single string or array of plugin name strings which must be registered in order for this plugin to operate. Plugins listed must be registered before the server is initialized or started. Does not provide version dependency which should be implemented using npm peer dependencies. + * @param after an optional function called after all the specified dependencies have been registered and before the server starts. The function is only called if the server is initialized or started. If a circular dependency is detected, an exception is thrown (e.g. two plugins each has an after function to be called after the other). The function signature is function(server, next) + */ + dependency(dependencies: string | string[], after?: AfterDependencyLoadCallback): void; + /** + * Emits a custom application event update to all the subscribed listeners + * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. + * [See docs](https://hapijs.com/api/16.1.1#serveremitcriteria-data-callback) + * @param criteria the event update criteria which if an object can have the following optional keys (unless noted otherwise): + * * name - the event name string (required). + * * channel - the channel name string. + * * tags - a tag string or array of tag strings. + * @param data the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. + * @param callback an optional callback method invoked when all subscribers have been notified using the signature function(). The callback is called only after all the listeners have been notified, including any event updates emitted earlier (the order of event updates are guaranteed to be in the order they were emitted). + */ + emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: any, callback?: () => void): void; + /** + * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' + * [See docs](https://hapijs.com/api/16.1.1#serverencoderencoding-encoder) + * @param encoding the encoder name string. + * @param encoder a function using the signature function(options) where options are the encoding specific options configured in the route compression configuration option, and the return value is an object compatible with the output of node's zlib.createGzip(). + */ + encoder(encoding: string, encoder: ((options: CompressionEncoderSettings) => zlib.Gzip)): void; + /** + * Register custom application events + * [See docs](https://hapijs.com/api/16.1.1#servereventevents) + * @param events see ApplicationEvent + */ + event(events: ApplicationEvent[]): void; + event(events: ApplicationEvent): void; + /** + * Used within a plugin to expose a property via server.plugins[name] + * [See docs](https://hapijs.com/api/16.1.1#serverexposekey-value) + * @param key the key assigned (server.plugins[name][key]). + * @param value the value assigned. + */ + expose(key: string, value: any): void; + /** + * Merges an object into to the existing content of server.plugins[name] + * Note that all properties of obj are deeply cloned into server.plugins[name], so you should avoid using this method for exposing large objects that may be expensive to clone or singleton objects such as database client objects. Instead favor the server.expose(key, value) form, which only copies a reference to value. + * [See docs](https://hapijs.com/api/16.1.1#serverexposeobj) + * @param obj the object merged into the exposed properties container. + */ + expose(obj: Object): void; + /** + * Registers an extension function in one of the available extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * @param events see @ServerExtConfigurationObject + */ + ext(events: ServerStartExtConfigurationObject): void; + ext(events: ServerStartExtConfigurationObject[]): void; + ext(events: ServerRequestExtConfigurationObjectWithRequest): void; + ext(events: ServerRequestExtConfigurationObjectWithRequest[]): void; + /** + * Registers a single extension event using the same properties as used in server.ext(events), but passed as arguments. + * [See docs](https://hapijs.com/api/16.1.1#serverextevent-method-options) + * @param event the extension point event name. + * @param method a function or an array of functions to be executed at a specified point during request processing. + * @param options + */ + ext(event: ServerStartExtPoints, method: ServerExtFunction[], options?: ServerExtOptions): void; + ext(event: ServerStartExtPoints, method: ServerExtFunction, options?: ServerExtOptions): void; + ext(event: ServerRequestExtPoints, method: ServerExtRequestHandler[], options?: ServerExtOptions): void; + ext(event: ServerRequestExtPoints, method: ServerExtRequestHandler, options?: ServerExtOptions): void; + /** + * Registers a new handler type to be used in routes + * The method function can have a defaults object or function property. If the property is set to an object, that object is used as the default route config for routes using this handler. If the property is set to a function, the function uses the signature function(method) and returns the route default configuration. + * [See docs](https://hapijs.com/api/16.1.1#serverhandlername-method) + * @param name string name for the handler being registered. Cannot override any previously registered type. + * @param method the function used to generate the route handler using the signature function(route, options) where: + * * route - the route public interface object. + * * options - the configuration object provided in the handler config. + */ + handler(name: string, method: MakeRouteHandler): void; + /** + * Initializes the server (starts the caches, finalizes plugin registration) but does not start listening on the connection ports + * Note that if the method fails and the callback includes an error, the server is considered to be in an undefined state and should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and other event listeners will get confused by repeated attempts to start the server or make assumptions about the healthy state of the environment. It is recommended to assert that no error has been returned after calling initialize() to abort the process when the server fails to start properly. If you must try to resume after an error, call server.stop() first to reset the server state. + * [See docs](https://hapijs.com/api/16.1.1#serverinitializecallback) + * @param callback the callback method when server initialization is completed or failed with the signature function(err) + */ + initialize(callback: (err: Error) => void): void; + initialize(): Promise; + /** + * When the server contains exactly one connection, injects a request into the sole connection simulating an incoming HTTP request without making an actual socket connection. Injection is useful for testing purposes as well as for invoking routing logic internally without the overhead or limitations of the network stack. Utilizes the shot module for performing injections, with some additional options and response properties + * If no callback is provided, a Promise object is returned. + * When the server contains more than one connection, each server.connections array member provides its own connection.inject(). + * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) + * @param options can be assigned a string with the requested URI, or an object + * @param callback the callback function with signature function(res) + */ + inject(options: string | InjectedRequestOptions, callback: (res: InjectedResponseObject) => void): void; + inject(options: string | InjectedRequestOptions, ): Promise; + /** + * Logs server events that cannot be associated with a specific request. When called the server emits a 'log' event which can be used by other listeners or plugins to record the information or output to the console. + * [See docs](https://hapijs.com/api/16.1.1#serverlogtags-data-timestamp) + * @param tags a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. Any logs generated by the server internally include the 'hapi' tag along with event-specific information. + * @param data an optional message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. + * @param timestamp an optional timestamp expressed in milliseconds. Defaults to Date.now() (now). + */ + log(tags: string | string[], data?: string | Object | Function, timestamp?: number): void; + /** + * When the server contains exactly one connection, looks up a route configuration. + * When the server contains more than one connection, each server.connections array member provides its own connection.lookup() method. + * [See docs](https://hapijs.com/api/16.1.1#serverlookupid) + * @param id the route identifier as set in the route options. + * @return the route public interface object if found, otherwise null. + */ + lookup(id: string): RoutePublicInterface | null; + /** + * When the server contains exactly one connection, looks up a route configuration + * When the server contains more than one connection, each server.connections array member provides its own connection.match() method. + * [See docs](https://hapijs.com/api/16.1.1#servermatchmethod-path-host) + * @param method the HTTP method (e.g. 'GET', 'POST'). TODO check if it allows HEAD + * @param path the requested path (must begin with '/'). + * @param host optional hostname (to match against routes with vhost). + * @return the route public interface object if found, otherwise null. + */ + match(method: HTTP_METHODS, path: string, host?: string): RoutePublicInterface | null; + /** + * Registers a server method. Server methods are functions registered with the server and used throughout the application as a common utility. Their advantage is in the ability to configure them to use the built-in cache and share across multiple request handlers without having to create a common module. + * [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) + * @param name a unique method name used to invoke the method via server.methods[name]. Supports using nested names such as utils.users.get which will automatically create the missing path under server.methods and can be accessed for the previous example via server.methods.utils.users.get. When configured with caching enabled, server.methods[name].cache will be an object see ServerMethodNameCacheObject + * @param method the method function + * @param options optional configuration + */ + method(name: string, method: ServerMethod, options?: ServerMethodOptions): void; + /** + * Registers a server method function as described in server.method() using a configuration object + * [See docs](https://hapijs.com/api/16.1.1#servermethodmethods) + */ + method(methods: ServerMethodConfigurationObject[]): void; + method(methods: ServerMethodConfigurationObject): void; + /** + * Subscribe a handler to an event + * [See docs](https://hapijs.com/api/16.1.1#serveroncriteria-listener) + * @param criteria the subscription criteria which can be an event name string which can be any of the built-in server events or a custom application event registered with server.event(events). + * Or an see ServerEventCriteria. + * If 'start' - emitted when the server is started using server.start(). + * If 'stop' - emitted when the server is stopped using server.stop(). + * @param listener + */ + on(criteria: 'start' | 'stop' | string | ServerEventCriteria, listener: Function): void; + /** + * The 'log' event includes the event object and a tags object (where each tag is a key with the value true) + * [See docs](https://hapijs.com/api/16.1.1#server-events) + */ + on(criteria: 'log', listener: (event: ServerEventObject, tags: Podium.Tags) => void): void; + /** + * The 'request' and 'request-internal' events include the request object, the event object, and a tags object (where each tag is a key with the value true) + * [See docs](https://hapijs.com/api/16.1.1#server-events) + * TODO submit issue to TypeScript. Using 'request' | 'request-internal' removes the type + * interference when using code like: `server.on('request', (request, event, tags) => {...}` + * Same for 'response' | 'tail'. + */ + on(criteria: 'request', listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void): void; + on(criteria: 'request-internal', listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void): void; + /** + * The 'request-error' event includes the request object and the causing error err object + * [See docs](https://hapijs.com/api/16.1.1#server-events) + */ + on(criteria: 'request-error', listener: (request: Request, err: Error) => void): void; + /** + * The 'response' and 'tail' events include the request object + * [See docs](https://hapijs.com/api/16.1.1#server-events) + * See 'request' and 'request-internal' + */ + on(criteria: 'response', listener: (request: Request) => void): void; + on(criteria: 'tail', listener: (request: Request) => void): void; + /** + * The 'route' event includes the route public interface, the connection, and the server object used to add the route (e.g. the result of a plugin select operation) + * [See docs](https://hapijs.com/api/16.1.1#server-events) + */ + on(criteria: 'route', listener: (route: RoutePublicInterface, connection: ServerConnection, server: Server) => void): void; + /** + * Same as calling server.on() with the count option set to 1. + * TODO type this to copy the server.on specific types for 'route', 'tail', etc. + * [See docs](https://hapijs.com/api/16.1.1#serveroncecriteria-listener) + * @param criteria + * @param listener + */ + once(criteria: string | ServerEventCriteria, listener: Function): void; + /** + * Sets the path prefix used to locate static resources (files and view templates) when relative paths are used + * Note that setting a path within a plugin only applies to resources accessed by plugin methods. If no path is set, the connection files.relativeTo configuration is used. The path only applies to routes added after it has been set. + * [See docs](https://hapijs.com/api/16.1.1#serverpathrelativeto) + * @param relativeTo the path prefix added to any relative file path starting with '.'. + */ + path(relativeTo: string): void; + /** + * Registers a plugin + * If no callback is provided, a Promise object is returned. + * Note that plugin registration are recorded on each of the available connections. When plugins express a dependency on other plugins, both have to be loaded into the same connections for the dependency requirement to be fulfilled. It is recommended that plugin registration happen after all the server connections are created via server.connection(). + * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) + * @param plugins + * @param options + * @param callback with signature function(err) where err an error returned from the registration function. Note that exceptions thrown by the registration function are not handled by the framework. + * A note on typings. Common use case is: + * register(Plugin, (err) => {// do more stuff}) + * so these typings save passing empty `options` object or having to + * explicity type the Error in the Callback e.g.: + * register(Plugin, {}, (err) => {// do more stuff}) or + * register(Plugin, (err: Error) => {// do more stuff}) + */ + register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, callback: (err: Error | null) => void): void; + register(plugins: Array<(PluginFunction | PluginRegistrationObject)>): Promise; + register(plugins: PluginFunction | PluginRegistrationObject, callback: (err: Error | null) => void): void; + register(plugins: PluginFunction | PluginRegistrationObject): Promise; + register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, options: PluginRegistrationOptions, callback: (err: Error | null) => void): void; + register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, options: PluginRegistrationOptions): Promise; + register(plugins: PluginFunction | PluginRegistrationObject, options: PluginRegistrationOptions, callback: (err: Error | null) => void): void; + register(plugins: PluginFunction | PluginRegistrationObject, options: PluginRegistrationOptions): Promise; + /** + * Adds a connection route + * [See docs](https://hapijs.com/api/16.1.1#serverrouteoptions) + * @param options a route configuration object [See docs](https://hapijs.com/api/16.1.1#route-configuration) or an array of configuration objects. + */ + route(options: RouteConfiguration[]): void; + route(options: RouteConfiguration): void; + /** + * Selects a subset of the server's connections + * Returns a server object with connections set to the requested subset. Selecting again on a selection operates as a logic AND statement between the individual selections. + * [See docs](https://hapijs.com/api/16.1.1#serverselectlabels) + * @param labels a single string or array of strings of labels used as a logical OR statement to select all the connections with matching labels in their configuration. + */ + select(labels: string | string[]): Server; + /** + * Starts the server connections by listening for incoming requests on the configured port of each listener (unless the connection was configured with autoListen set to false) + * If no callback is provided, a Promise object is returned. + * Note that if the method fails and the callback includes an error, the server is considered to be in an undefined state and should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and other event listeners will get confused by repeated attempts to start the server or make assumptions about the healthy state of the environment. It is recommended to assert that no error has been returned after calling start() to abort the process when the server fails to start properly. If you must try to resume after a start error, call server.stop() first to reset the server state. + * If a started server is started again, the second call to start() will only start new connections added after the initial start() was called. No events will be emitted and no extension points invoked. + * [See docs](https://hapijs.com/api/16.1.1#serverstartcallback) + * @param callback the callback method when server startup is completed or failed with the signature function(err) where: + * * err - any startup error condition. + */ + start(callback: (err?: Error) => void): void; + start(): Promise; + /** + * HTTP state management [See docs](https://tools.ietf.org/html/rfc6265) uses client cookies to persist a state across multiple requests. Registers a cookie definitions + * [See docs](https://hapijs.com/api/16.1.1#serverstatename-options) + * @param name the cookie name string. + * @param options optional cookie settings + */ + state(name: string, options?: ServerStateCookieConfiguationObject): void; + /** + * Stops the server's connections by refusing to accept any new connections or requests (existing connections will continue until closed or timeout) + * If no callback is provided, a Promise object is returned. + * [See docs](https://hapijs.com/api/16.1.1#serverstopoptions-callback) + * @param options options object with: + * * timeout - overrides the timeout in millisecond before forcefully terminating a connection. Defaults to 5000 (5 seconds). + * @param callback optional callback method which is called once all the connections have ended and it is safe to exit the process with signature function(err) where: + * * err - any termination error condition. + */ + stop(options: {timeout: number} | null, callback: (err?: Error) => void): void; + stop(options?: {timeout: number}): Promise; + /** + * Returns a copy of the routing table + * Note that if the server has not been started and multiple connections use port 0, the table items will override each other and will produce an incomplete result. + * When calling connection.table() directly on each connection, the return value is the same as the array table item value of an individual connection + * [See docs](https://hapijs.com/api/16.1.1#servertablehost) + * @param host optional host to filter routes matching a specific virtual host. Defaults to all virtual hosts. + */ + table(host?: string): RoutingTableEntry[]; +} + +export interface PluginSpecificConfiguration {} + +/** + * Server Options + * Note that the options object is deeply cloned and cannot contain any values that are unsafe to perform deep copy on. + * [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) + */ +export interface ServerOptions { + /** app - application-specific configuration which can later be accessed via server.settings.app. Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. Defaults to {}. */ + app?: any; + /** + * cache - sets up server-side caching. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and capabilities. hapi uses catbox for its cache which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. The server cache configuration only defines the storage container itself. cache can be assigned: + * * a prototype function (usually obtained by calling require() on a catbox strategy such as require('catbox-redis')). A new catbox client will be created internally using this function. + * * a CatboxServerOptionsCacheConfiguration configuration object + * * an array of the above object for configuring multiple cache instances, each with a unique name. When an array of objects is provided, multiple cache connections are established and each array item (except one) must include a name. + */ + cache?: Catbox.EnginePrototype | CatboxServerOptionsCacheConfiguration | CatboxServerOptionsCacheConfiguration[]; + /** sets the default connections configuration which can be overridden by each connection */ + connections?: ConnectionConfigurationServerDefaults; + /** determines which logged events are sent to the console (this should only be used for development and does not affect which events are actually logged internally and recorded). Set to false to disable all console logging, or to an object with: */ + debug?: false | { + /** a string array of server log tags to be displayed via console.error() when the events are logged via server.log() as well as internally generated server logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. */ + log?: string[] | false; + /** a string array of request log tags to be displayed via console.error() when the events are logged via request.log() as well as internally generated request logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. */ + request?: string[] | false; + }; + /** process load monitoring */ + load?: { + /** the frequency of sampling in milliseconds. Defaults to 0 (no sampling). */ + sampleInterval?: number; + }; + /** options passed to the mimos module (https://github.com/hapijs/mimos) when generating the mime database used by the server and accessed via server.mime. */ + mime?: MimosOptions; + /** plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state. Defaults to {}. */ + plugins?: PluginSpecificConfiguration; + /** if false, will not use node domains to protect against exceptions thrown in handlers and other external code. Defaults to true. */ + useDomains?: boolean; +} + +/** + * The server event object + * [See docs](https://hapijs.com/api/16.1.1#server-events) + */ +export interface ServerEventObject { + /** the event timestamp. */ + timestamp: number; + /** if the event relates to a request, the request id. */ + request: string; + /** if the event relates to a server, the server.info.uri. */ + server: string; + /** an array of tags (e.g. ['error', 'http']). */ + tags: string[]; + /** optional event-specific information. */ + data: any; + /** true if the event was generated internally by the framework. */ + internal: boolean; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serveroncriteria-listener) + */ +export interface ServerEventCriteria { + /** the event name string (required). */ + name: string; + /** if true, the listener method receives an additional callback argument which must be called when the method completes. No other event will be emitted until the callback methods is called. The method signature is function(). If block is set to a positive integer, the value is used to set a timeout after which any pending events will be emitted, ignoring the eventual call to callback. Defaults to false (non blocking). */ + block?: boolean; + /** a string or array of strings specifying the event channels to subscribe to. If the event registration specified a list of allowed channels, the channels array must match the allowed channels. If channels are specified, event updates without any channel designation will not be included in the subscription. Defaults to no channels filter. */ + channels?: string | string[]; + /** if true, the data object passed to server.emit() is cloned before it is passed to the listener method. Defaults to the event registration option (which defaults to false). */ + clone?: boolean; + /** a positive integer indicating the number of times the listener can be called after which the subscription is automatically removed. A count of 1 is the same as calling server.once(). Defaults to no limit. */ + count?: number; + /** + * the event tags (if present) to subscribe to + * If the object is given: + * * tags - a tag string or array of tag strings. + * * all - if true, all tags must be present for the event update to match the subscription. Defaults to false (at least one matching tag). + */ + filter?: string | string[] | {tags: string | string[], all?: boolean}; + /** if true, and the data object passed to server.emit() is an array, the listener method is called with each array element passed as a separate argument. This should only be used when the emitted data structure is known and predictable. Defaults to the event registration option (which defaults to false). */ + spread?: boolean; + /** if true and the criteria object passed to server.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end (but before the callback argument if block is set). Defaults to the event registration option (which defaults to false). */ + tags?: boolean; +} + +/** + * Server methods, user configured + * Related to [See docs](https://hapijs.com/api/16.1.1#servermethods) + * Related to [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) + */ +export interface ServerMethod { + /** the method must return a value (result, Error, or a promise) or throw an Error. */ + (...args: any[]): any | Error | Promise; + /** Not possible to improve this typing due to this unresolvable issue: https://github.com/Microsoft/TypeScript/issues/15190 */ + (...args: (any | ServerMethodNext)[]): void; + /** When configured with caching enabled, server.methods[name].cache will be an object see ServerMethodNameCacheObject */ + cache?: ServerMethodNameCacheObject; +} + +/** + * Related to [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) + * @param err error response if the method failed. + * @param result the return value. + * @param ttl 0 if result is valid but cannot be cached. Defaults to cache policy. + */ +export interface ServerMethodNext { + (err: Error | null, result: any, ttl?: number): void; +} + +/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) */ +export interface ServerMethodNameCacheObject { + /** + * function that can be used to clear the cache for a given key. + * @param ...args any number of string, number or boolean. If other types then generateKey function must be specified. + * @param callback last argument is a callback. + * Not possible to improve this typing due to this unresolvable issue: https://github.com/Microsoft/TypeScript/issues/15190 + */ + drop(...args: (any | Function)[]): void; + /** an object with cache statistics, see stats documentation for catbox. */ + stats: Catbox.CacheStatisticsObject; +} + +/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) */ +export interface ServerMethodOptions { + /** a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. Ignored if the method is an arrow function. */ + bind?: any; + /** the same cache configuration used in server.cache(). The generateTimeout option is required. */ + cache?: CatboxServerCacheConfiguration; + /** + * if false, expects the method to be a synchronous function. Note that using a synchronous function with caching will convert the method interface to require a callback as an additional argument with the signature function(err, result, cached, report) since the cache interface cannot return values synchronously. Defaults to true. + * TODO: understand and type "an additional argument with the signature function(err, result, cached, report)" if appropriate. + */ + callback?: boolean; + /** a function used to generate a unique key (for caching) from the arguments passed to the method function (the callback argument is not passed as input). The server will automatically generate a unique key if the function's arguments are all of types 'string', 'number', or 'boolean'. However if the method uses other types of arguments, a key generation function must be provided which takes the same arguments as the function and returns a unique string (or null if no key can be generated). */ + generateKey?(args: any[]): string | null; +} + +/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodmethods) */ +export interface ServerMethodConfigurationObject { + name: string; + method: ServerMethod; + options: ServerMethodOptions; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Caching with Catbox + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * TODO confirm this is the same as CatboxServerCacheConfiguration + * + * ** + * Server instantiation options configuration for Catbox cache + * TODO: check it extends Catbox.PolicyOptions and this is what "other options passed to the catbox strategy used." means. + * For context [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) under: options > cache > a configuration object + * ** + * export interface CatboxServerOptionsCacheConfiguration extends Catbox.IPolicyOptions { + * // a prototype function or catbox engine object. + * engine: Catbox.EnginePrototypeOrObject; + * // an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. + * name?: string; + * // if true, allows multiple cache users to share the same segment (e.g. multiple methods using the same cache storage container). Default to false. + * shared?: boolean; + * } + */ +export type CatboxServerOptionsCacheConfiguration = CatboxServerCacheConfiguration; + +/** + * Server cache method configuration for Catbox cache + * Used for "Provisions a cache segment within the server cache facility" + * For context [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) + * Also used in [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) > options.cache + */ +export interface CatboxServerCacheConfiguration extends Catbox.PolicyOptions { + /** the cache name configured in server.cache. Defaults to the default cache. */ + cache?: string; + /** string segment name, used to isolate cached items within the cache partition. When called within a plugin, defaults to '!name' where 'name' is the plugin name. When called within a server method, defaults to '#name' where 'name' is the server method name. Required when called outside of a plugin. */ + segment?: string; + /** if true, allows multiple cache provisions to share the same segment. Default to false. */ + shared?: boolean; + /** + * a prototype function or catbox engine object. + * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) example code includes use of `engine` option. But server.cache.provision of `options` says "same as the server cache configuration options.". + * TODO confirm once PR to hapi docs accepted / rejected. + */ + engine?: Catbox.EnginePrototypeOrObject; + /** + * an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. + * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) example code includes use of `name` option. But server.cache.provision of `options` says "same as the server cache configuration options.". + */ + name?: string; + /** + * Additional options to be passed to the Catbox strategy + */ + [s: string]: any; +} + +/** + * Additional notes + * payload - In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided. + * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) + */ +export interface InjectedRequestOptions extends Shot.RequestOptions { + /** an optional credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials. */ + credentials?: any; + /** an optional artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts. */ + artifacts?: any; + /** sets the initial value of request.app. */ + app?: any; + /** sets the initial value of request.plugins. */ + plugins?: PluginsStates; + /** allows access to routes with config.isInternal set to true. Defaults to false. */ + allowInternals?: boolean; +} + +/** + * the response object from server.inject + * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) + */ +export interface InjectedResponseObject extends Shot.ResponseObject { + /** the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the internal objects returned (instead of parsing the response string). */ + result: Object | string; + /** the request object. */ + request: InjectedRequestOptions; +} + +/** + * For context [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) under: options > connections + */ +export interface ConnectionConfigurationServerDefaults { + /** application-specific connection configuration which can be accessed via connection.settings.app. Provides a safe place to store application configuration without potential conflicts with the framework internals. Should not be used to configure plugins which should use plugins[name]. Note the difference between connection.settings.app which is used to store configuration values and connection.app which is meant for storing run-time state. */ + app?: any; + /** if false, response content encoding is disabled. Defaults to true */ + compression?: boolean; + /** connection load limits configuration where: */ + load?: { + /** maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ + maxHeapUsedBytes?: number; + /** maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ + maxRssBytes?: number; + /** maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ + maxEventLoopDelay?: number; + }; + /** plugin-specific configuration which can later be accessed via connection.settings.plugins. Provides a place to store and pass connection-specific plugin configuration. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between connection.settings.plugins which is used to store configuration values and connection.plugins which is meant for storing run-time state. */ + plugins?: PluginSpecificConfiguration; + /** controls how incoming request URIs are matched against the routing table: */ + router?: { + /** determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true. */ + isCaseSensitive?: boolean; + /** removes trailing slashes on incoming paths. Defaults to false. */ + stripTrailingSlash?: boolean; + }; + /** a route options object used to set the default configuration for every route. */ + routes?: RouteAdditionalConfigurationOptions; + /** sets the default configuration for every state (cookie) set explicitly via server.state() or implicitly (without definition) using the [state configuration object](https://hapijs.com/api/16.1.1#serverstatename-options). */ + state?: ServerStateCookieConfiguationObject; +} + +/** + * a connection configuration object or array of objects with the following optional keys. + * Any connections configuration server defaults can be included to override and customize the individual connection. + * [See docs](https://hapijs.com/api/16.1.1#serverconnectionoptions) + */ +export interface ServerConnectionOptions extends ConnectionConfigurationServerDefaults { + /** host - the public hostname or IP address. Used only to set server.info.host and server.info.uri. If not configured, defaults to the operating system hostname and if not available, to 'localhost'. */ + host?: string; + /** address - sets the host name or IP address the connection will listen on. If not configured, defaults to host if present, otherwise to all available network interfaces (i.e. '0.0.0.0'). Set to 127.0.0.1 or localhost to restrict connection to only those coming from the same machine. */ + address?: string; + /** port - the TCP port the connection will listen to. Defaults to an ephemeral port (0) which uses an available port when the server is started (and assigned to server.info.port). If port is a string containing a '/' character, it is used as a UNIX domain socket path and if it starts with '\.\pipe' as a Windows named pipe. */ + port?: string | number; + /** uri - the full public URI without the path (e.g. 'http://example.com:8080'). If present, used as the connection info.uri otherwise constructed from the connection settings. */ + uri?: string; + /** listener - optional node.js HTTP (or HTTPS) http.Server object or any compatible object. If the listener needs to be manually started, set autoListen to false. If the listener uses TLS, set tls to true. */ + listener?: http.Server; + /** autoListen - indicates that the connection.listener will be started manually outside the framework. Cannot be specified with a port setting. Defaults to true. */ + autoListen?: boolean; + /** labels - a string or string array of labels used to server.select() specific connections matching the specified labels. Defaults to an empty array [] (no labels). */ + labels?: string | string[]; + /** tls - used to create an HTTPS connection. The tls object is passed unchanged as options to the node.js HTTPS server as described in the node.js HTTPS [documentation](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener}) . Set to true when passing a listener object that has been configured to use TLS directly. */ + tls?: true | https.RequestOptions; +} + +/** + * For context see RouteAdditionalConfigurationOptions > compression + * For context [See docs](https://hapijs.com/api/16.1.1#serverencoderencoding-encoder) + */ +export type CompressionEncoderSettings = any; + +/** + * For context see RouteAdditionalConfigurationOptions > payload > compression + * For context [See docs](https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder) + */ +export type CompressionDecoderSettings = any; + +/** + * an optional function called after all the specified dependencies have been registered and before the server starts. The function is only called if the server is initialized or started. If a circular dependency is detected, an exception is thrown (e.g. two plugins each has an after function to be called after the other). The function signature is function(server, next) where: + * [See docs](https://hapijs.com/api/16.1.1#serverdependencydependencies-after) + * Also see Server.dependency + * @param server the server the dependency() method was called on. + * @param next the callback function the method must call to return control over to the application and complete the registration process. The function signature is function(err) where: + * * err - internal error condition, which is returned back via the server.initialize() or server.start() callback. + */ +export interface AfterDependencyLoadCallback { + (server: Server, next: (err?: Error) => void): void; +} + +/** For context see RouteAdditionalConfigurationOptions > auth */ +export interface AuthOptions { + /** + * the authentication mode. Defaults to 'required' if a server authentication strategy is configured, otherwise defaults to no authentication. Available values: + * * 'required' - authentication is required. + * * 'optional' - authentication is optional (must be valid if present). + * * 'try' - same as 'optional' but allows for invalid authentication. + */ + mode?: 'required' | 'optional' | 'try'; + /** a string array of strategy names in order they should be attempted. If only one strategy is used, strategy can be used instead with the single string value. Defaults to the default authentication strategy which is available only when a single strategy is configured. */ + strategies?: string[]; + strategy?: string; + /** + * if set, the payload (in requests other than 'GET' and 'HEAD') is authenticated after it is processed. Requires a strategy with payload authentication support (e.g. Hawk). Cannot be set to a value other than 'required' when the scheme sets the options.payload to true. Available values: + * * false - no payload authentication. This is the default value. + * * 'required' - payload authentication required. This is the default value when the scheme sets options.payload to true. + * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). + */ + payload?: false | 'required' | 'optional'; + /** specifying the route access rules. */ + access?: RouteAuthAccessConfiguationObject | RouteAuthAccessConfiguationObject[]; + /** (undocumented) Convenience way of setting access.scope, will over write all values in `access` */ + scope?: false | string | string[]; + /** (undocumented) Convenience way of setting access.entity, will over write all values in `access` */ + entity?: 'any' | 'user' | 'app'; +} + +/** + * Each rule is evaluated against an incoming request and access is granted if at least one rule matches. Each rule object must include at least one of: + * For context see RouteAdditionalConfigurationOptions > auth > an object > access + */ +export interface RouteAuthAccessConfiguationObject { + /** the application scope required to access the route. Value can be a scope string or an array of scope strings. The authenticated credentials object scope property must contain at least one of the scopes defined to access the route. If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' scope must not include 'a', must include 'b', and must include one of 'c' or 'd'. You may also access properties on the request object (query and params) to populate a dynamic scope by using {} characters around the property name, such as 'user-{params.id}'. Defaults to false (no scope requirements). */ + scope?: false | string | string[]; + /** + * the required authenticated entity type. If set, must match the entity value of the authentication credentials. Available values: + * * any - the authentication can be on behalf of a user or application. This is the default value. + * * user - the authentication must be on behalf of a user which is identified by the presence of a user attribute in the credentials object returned by the authentication strategy. + * * app - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. + */ + entity?: 'any' | 'user' | 'app'; +} + +/** + * For context see RouteAdditionalConfigurationOptions > cache + */ +export type RouteCacheOptions = { + /** + * determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are: + * * 'default' - no privacy flag. This is the default setting. + * * 'public' - mark the response as suitable for public caching. + * * 'private' - mark the response as suitable only for private caching. + */ + privacy?: 'default' | 'public' | 'private'; + /** an array of HTTP response status codes (e.g. 200) which are allowed to include a valid caching directive. Defaults to [200]. */ + statuses?: number[]; + /** a string with the value of the 'Cache-Control' header when caching is disabled. Defaults to 'no-cache'. */ + otherwise?: string; +} & ({ + /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ + expiresIn?: number; + /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ + expiresAt?: undefined; +} | { + /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ + expiresIn?: undefined; + /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ + expiresAt?: string; +} | { + /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ + expiresIn?: undefined; + /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ + expiresAt?: undefined; +}); + +/** + * For context see RouteAdditionalConfigurationOptions > cors + */ +export interface CorsConfigurationObject { + /** a strings array of allowed origin servers ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a wildcard '*' character, or a single '*' origin string. Defaults to any origin ['*']. */ + origin?: string[] | '*'; + /** number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. Defaults to 86400 (one day). */ + maxAge?: number; + /** a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match'] */ + headers?: string[]; + /** a strings array of additional headers to headers. Use this to keep the default headers in place. */ + additionalHeaders?: string[]; + /** a strings array of exposed headers ('Access-Control-Expose-Headers'). Defaults to ['WWW-Authenticate', 'Server-Authorization']. */ + exposedHeaders?: string[]; + /** a strings array of additional headers to exposedHeaders. Use this to keep the default headers in place. */ + additionalExposedHeaders?: string[]; + /** if true, allows user credentials to be sent ('Access-Control-Allow-Credentials'). Defaults to false. */ + credentials?: boolean; +} + +/** + * An object describing the extension function used whilst registering the extension function in one of the available extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * For context see RouteAdditionalConfigurationOptions > ext + */ +export interface ServerStartExtConfigurationObject { + /** the extension point event name. */ + type: ServerStartExtPoints; + /** + * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler + */ + method: ServerExtFunction | ServerExtFunction[]; + options?: ServerExtOptions; +} + +/** + * An object describing the extension function used whilst registering the extension function in one of the available extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * For context see RouteAdditionalConfigurationOptions > ext + */ +export interface ServerRequestExtConfigurationObject { + /** the extension point event name. */ + type: ServerRequestExtPointsBase; + /** + * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler + */ + method: ServerExtRequestHandler | ServerExtRequestHandler[] + options?: ServerExtOptions; +} + +/** + * An object describing the extension function used whilst registering the extension function in one of the available extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * For context see RouteAdditionalConfigurationOptions > ext + */ +export interface ServerRequestExtConfigurationObjectWithRequest { + /** the extension point event name. */ + type: ServerRequestExtPoints; + /** + * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler + */ + method: ServerExtRequestHandler | ServerExtRequestHandler[]; + options?: ServerExtOptions; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#route-configuration) > ext + */ +export type RouteExtConfigurationObject = ServerStartExtConfigurationObject | ServerRequestExtConfigurationObject; + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > method + */ +export type ServerExtMethod = ServerExtFunction | ServerExtRequestHandler; + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > options + */ +export interface ServerExtOptions { + /** before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. */ + before: string | string[]; + /** after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. */ + after: string | string[]; + /** bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. */ + bind: any; + /** sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'connection' which applies to any route added to the connection the extension is added to. */ + sandbox?: 'connection' | 'plugin'; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > type + * * 'onPreStart' - called before the connection listeners are started. + * * 'onPostStart' - called after the connection listeners are started. + * * 'onPreStop' - called before the connection listeners are stopped. + * * 'onPostStop' - called after the connection listeners are stopped. + */ +export type ServerStartExtPoints = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; +/** + * [See docs](https://hapijs.com/api/16.1.1#request-lifecycle) + * * The available extension points include the request extension points as well as the following server extension points: + */ +export type ServerRequestExtPointsBase = 'onPreResponse' | 'onPreAuth' | 'onPostAuth' | 'onPreHandler' | 'onPostHandler' | 'onPreResponse'; + +export type ServerRequestExtPoints = ServerRequestExtPointsBase | 'onRequest'; + +/** + * Server extension function registered an one of the server extension points + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * For context see ServerExtConfigurationObject + * @param server - the server object. + * @param next - the continuation method with signature function(err). + * @param this - the object provided via options.bind or the current active context set with server.bind(). + */ +export interface ServerExtFunction { + (server: Server, next: ContinuationFunction): void; +} + +/** + * For context see RouteAdditionalConfigurationOptions > payload + */ +export interface RoutePayloadConfigurationObject { + /** + * the type of payload representation requested. The value must be one of: + * * 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, the raw Buffer is returned. This is the default value except when a proxy handler is used. + * * 'stream' - the incoming payload is made available via a Stream.Readable interface. If the payload is 'multipart/form-data' and parse is true, fields values are presented as text while files are provided as streams. File streams from a 'multipart/form-data' upload will also have a property hapi containing filename and headers properties. + * * 'file' - the incoming payload is written to temporary file in the directory specified by the server's payload.uploads settings. If the payload is 'multipart/form-data' and parse is true, fields values are presented as text while files are saved. Note that it is the sole responsibility of the application to clean up the files generated by the framework. This can be done by keeping track of which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform any needed cleanup. + */ + output?: PayLoadOutputOption; + /** + * can be true, false, or gunzip; determines if the incoming payload is processed or presented raw. true and gunzip includes gunzipping when the appropriate 'Content-Encoding' is specified on the received request. If parsing is enabled and the 'Content-Type' is known (for the whole payload as well as parts), the payload is converted into an object when possible. If the format is unknown, a Bad Request (400) error response is sent. Defaults to true, except when a proxy handler is used. The supported mime types are: + * * 'application/json' + * * 'application/x-www-form-urlencoded' + * * 'application/octet-stream' + * * 'text/*' + * * 'multipart/form-data' + */ + parse?: 'gunzip' | boolean; + /** + * overrides payload processing for multipart requests. Value can be one of: + * * false - disables multipart processing. + * * object with the following required options: + * * output - same as the payload.output option with an additional value option: + * * annotated - wraps each multipart part in an object with the following keys: // TODO type this? + * * headers - the part headers. + * * filename - the part file name. + * * payload - the processed part payload. + */ + multipart?: false | { + output: PayLoadOutputOption | 'annotated'; + }; + /** a string or an array of strings with the allowed mime types for the endpoint. Defaults to any of the supported mime types listed above. Note that allowing other mime types not listed will not enable them to be parsed, and that if parsing mode is 'parse', the request will result in an error response. */ + allow?: string | string[]; + /** a mime type string overriding the 'Content-Type' header value received. Defaults to no override. */ + override?: string; + /** limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory. Defaults to 1048576 (1MB). */ + maxBytes?: number; + /** payload reception timeout in milliseconds. Sets the maximum time allowed for the client to transmit the request payload (body) before giving up and responding with a Request Timeout (408) error response. Set to false to disable. Defaults to 10000 (10 seconds). */ + timeout?: number | false; + /** the directory used for writing file uploads. Defaults to os.tmpdir(). */ + uploads?: string; + /** + * determines how to handle payload parsing errors. Allowed values are: + * * 'error' - return a Bad Request (400) error response. This is the default value. + * * 'log' - report the error but continue processing the request. + * * 'ignore' - take no action and continue processing the request. + */ + failAction?: 'error' | 'log' | 'ignore'; + /** the default 'Content-Type' HTTP header value is not present. Defaults to 'application/json'. */ + defaultContentType?: string; + /** an object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in the root option compression. */ + compression?: Dictionary; +} + +export type PayLoadOutputOption = 'data' | 'stream' | 'file'; + +/** + * events must be one of: + * * an event name string. + * * an event options object see ApplicationEventOptionsObject + * * a podium [See docs](https://github.com/hapijs/podium) emitter object. + * For context [See docs](https://hapijs.com/api/16.1.1#servereventevents) > events parameter + */ +export type ApplicationEvent = string | ApplicationEventOptionsObject | Podium; + +/** + * an event options object + * For context see ApplicationEvent + * For context [See docs](https://hapijs.com/api/16.1.1#servereventevents) > events parameter + */ +export interface ApplicationEventOptionsObject { + /** the event name string (required). */ + name: string; + /** a string or array of strings specifying the event channels available. Defaults to no channel restrictions (event updates can specify a channel or not). */ + channels?: string | string[]; + /** if true, the data object passed to server.emit() is cloned before it is passed to the listeners (unless an override specified by each listener). Defaults to false (data is passed as-is). */ + clone?: boolean; + /** if true, the data object passed to server.emit() must be an array and the listener method is called with each array element passed as a separate argument (unless an override specified by each listener). This should only be used when the emitted data structure is known and predictable. Defaults to false (data is emitted as a single argument regardless of its type). */ + spread?: boolean; + /** if true and the criteria object passed to server.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end (but before the callback argument if block is set). A configuration override can be set by each listener. Defaults to false. */ + tags?: boolean; + /** if true, the same event name can be registered multiple times where the second registration is ignored. Note that if the registration config is changed between registrations, only the first configuration is used. Defaults to false (a duplicate registration will throw an error). */ + shared?: boolean; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Route + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Route configuration + * The route configuration object + * + * [See docs](https://hapijs.com/api/16.1.1#route-configuration) + * + * TODO typings check that the following refers to RouteAdditionalConfigurationOptions "Note that the options object is deeply cloned (with the exception of bind which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on." + */ +export interface RouteConfiguration { + /** the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the connection router configuration option. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. */ + path: string; + /** the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. */ + method: HTTP_METHODS_PARTIAL | '*' | (HTTP_METHODS_PARTIAL | '*')[]; + /** an optional domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. */ + vhost?: string; + /** the function called to generate the response after successful authentication and validation. The handler function is described in Route handler. If set to a string, the value is parsed the same way a prerequisite server method string shortcut is processed. Alternatively, handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler. */ + handler?: string | RouteHandler | RouteHandlerPlugins; + /** additional route options. The config value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. */ + config?: RouteAdditionalConfigurationOptions | ((server: Server) => RouteAdditionalConfigurationOptions); +} + +/** + * Route options + * Each route can be customize to change the default behavior of the request lifecycle using the following options: + * [See docs](https://hapijs.com/api/16.1.1#route-options) + */ +export interface RouteAdditionalConfigurationOptions { + /** application specific configuration.Should not be used by plugins which should use plugins[name] instead. */ + app?: any; + /** + * Authentication configuration. Value can be: + * * false to disable authentication if a default strategy is set. + * * a string with the name of an authentication strategy registered with server.auth.strategy(). + * * an object + */ + auth?: false | string | AuthOptions; + /** an object passed back to the provided handler (via this) when called. Ignored if the method is an arrow function. */ + bind?: any; + /** + * Route cache options + * if the route method is 'GET', the route can be configured to include caching directives in the response. The default Cache-Control: no-cache header can be disabled by setting cache to false. Caching can be customized using an object + * TODO check: the default is to have 'Cache-Control: no-cache', but on first reading is a contridiction as you can disabled cache and disabled no-cache by setting RouteCacheOptions to false? + */ + cache?: boolean | RouteCacheOptions; + /** an object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in payload.compression. */ + compression?: Dictionary; + /** the Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. CORS headers are disabled by default (false). To enable, set cors to true, or to an object */ + cors?: boolean | CorsConfigurationObject; + /** defined a route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the [server.ext(events)](https://hapijs.com/api/16.1.1#serverextevents) event argument. */ + ext?: RouteExtConfigurationObject | RouteExtConfigurationObject[]; + /** defines the behavior for accessing files: */ + files?: { + /** determines the folder relative paths are resolved against. */ + relativeTo: string; + }; + /** an alternative location for the route.handler option. */ + handler?: string | RouteHandler; + /** an optional unique identifier used to look up the route using server.lookup(). Cannot be assigned to routes with an array of methods. */ + id?: string; + /** if true, the route cannot be accessed through the HTTP connection but only through the server.inject() interface with the allowInternals option set to true. Used for internal routes that should not be accessible to the outside world. Defaults to false. */ + isInternal?: boolean; + /** optional arguments passed to JSON.stringify() when converting an object or error response to a string payload. Supports the following: */ + json?: Json.StringifyArguments & { + /** string suffix added after conversion to JSON string. Defaults to no suffix. */ + suffix?: string; + }; + /** enables JSONP support by setting the value to the query parameter name containing the function name used to wrap the response payload. For example, if the value is 'callback', a request comes in with 'callback=me', and the JSON response is '{ "a":"b" }', the payload will be 'me({ "a":"b" });'. Does not work with stream responses. Headers content-type and x-content-type-options are set to text/javascript and nosniff respectively, and will override those headers even if explicitly set by response.type() */ + jsonp?: string; + /** if true, request level logging is enabled (accessible via request.getLog()). */ + log?: boolean; + /** + * determines how the request payload is processed + * [See docs](https://hapijs.com/api/16.1.1#route-options) + */ + payload?: RoutePayloadConfigurationObject; + /** plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. */ + plugins?: PluginSpecificConfiguration; + /** an array with [route prerequisites](https://hapijs.com/api/16.1.1#route-prerequisites) methods which are executed in serial or in parallel before the handler is called. */ + pre?: RoutePrerequisitesArray; + /** processing rules for the outgoing response */ + response?: RouteResponseConfigurationObject; + /** sets common security headers (disabled by default). To enable set security to true or to an object with the following options: See RouteSecurityConfigurationObject */ + security?: boolean | RouteSecurityConfigurationObject; + /** HTTP state management (cookies) allows the server to store information on the client which is sent back to the server with every request (as defined in RFC 6265). state supports the following options: */ + state?: { + /** determines if incoming 'Cookie' headers are parsed and stored in the request.state object. Defaults to true. */ + parse?: boolean; + /** + * determines how to handle cookie parsing errors. Allowed values are: + * * 'error' - return a Bad Request (400) error response. This is the default value. + * * 'log' - report the error but continue processing the request. + * * 'ignore' - take no action. + */ + failAction: 'error' | 'log' | 'ignore'; + }; + /** request input validation rules for various request components. When using a Joi validation object, the values of the other inputs (i.e. headers, query, params, payload, and auth) are made available under the validation context (accessible in rules as Joi.ref('$query.key')). Note that validation is performed in order (i.e. headers, params, query, payload) and if type casting is used (converting a string to number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. If the validation rules for headers, params, query, and payload are defined at both the routes defaults level and an individual route, the individual route settings override the routes defaults (the rules are not merged). The validate object supports: */ + validate?: RouteValidationConfigurationObject; + /** define timeouts for processing durations: */ + timeout?: { + /** response timeout in milliseconds. Sets the maximum time allowed for the server to respond to an incoming client request before giving up and responding with a Service Unavailable (503) error response. Disabled by default (false). */ + server?: boolean | number; + /** by default, node sockets automatically timeout after 2 minutes. Use this option to override this behavior. Defaults to undefined which leaves the node default unchanged. Set to false to disable socket timeouts. */ + socket?: boolean | number; + }; + + /** + * TODO decide on moving these to an extended interface of RouteAdditionalConfigurationOptions + */ + /** + * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). + * route description used for generating documentation + */ + description?: string; + /** + * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). + * route notes used for generating documentation + */ + notes?: string | string[]; + /** + * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). + * route tags used for generating documentation + */ + tags?: string[]; +} + +/** + * Route public interface + * When route information is returned or made available as a property, it is an object with the following: + * [See docs](https://hapijs.com/api/16.1.1#route-public-interface) + */ +export interface RoutePublicInterface { + /** the route HTTP method. */ + method: string; + /** the route path. */ + path: string; + /** the route vhost option if configured. */ + vhost?: string | string[]; + /** the [active realm] [See docs](https://hapijs.com/api/16.1.1#serverrealm) associated with the route.*/ + realm: ServerRealm; + /** the [route options] [See docs](https://hapijs.com/api/16.1.1#route-options) object with all defaults applied. */ + settings: RouteAdditionalConfigurationOptions; + /** the route internal normalized string representing the normalized path. */ + fingerprint: string; + /** route authentication utilities: */ + auth: { + /** authenticates the passed request argument against the route's authentication access configuration. Returns true if the request would have passed the route's access requirements. Note that the route's authentication mode and strategies are ignored. The only match is made between the request.auth.credentials scope and entity information and the route access configuration. Also, if the route uses dynamic scopes, the scopes are constructed against the request.query and request.params which may or may not match between the route and the request's route. If this method is called using a request that has not been authenticated (yet or at all), it will return false if the route requires any authentication. */ + access(request: Request): boolean; + }; +} + +export type RouteHandlerConfig = any; + +/** + * For context [See docs](https://hapijs.com/api/16.1.1#serverhandlername-method) + * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/handler.js#L103) + * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/route.js#L56-L60) + * TODO check the type of `RouteHandlerConfig` is correct for `defaults`. + */ +export interface MakeRouteHandler { + (route: RoutePublicInterface, options: RouteHandlerConfig): RouteHandler; + defaults?: RouteHandlerConfig | ((method: HTTP_METHODS_PARTIAL_lowercase) => RouteHandlerConfig); +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#servertablehost) > return value + */ +export interface RoutingTableEntry { + /** the connection.info the connection the table was generated for. */ + info: ServerConnectionInfo; + /** the connection labels. */ + labels: string[]; + /** an array of routes where each route contains: */ + table: Route[]; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#servertablehost) > return value + * For source [See source](https://github.com/hapijs/hapi/blob/v16.1.1/lib/route.js#L71) + */ +export interface Route { + /** + * the route config with defaults applied. + * TODO check type of RouteConfiguration here is correct + */ + settings: RouteAdditionalConfigurationOptions; + /** + * the HTTP method in lower case. + * TODO, check if it can contain 'head' or not. + */ + method: HTTP_METHODS_PARTIAL_lowercase; + /** the route path. */ + path: string; + + params: string[]; + + connection: ServerConnection; + + fingerprint: string; + + plugin?: any; + + public: RoutePublicInterface; + + server: Server; +} + +/** + * Route Prerequisites + * It is often necessary to perform prerequisite actions before the handler is called (e.g. load required reference data from a database). The route pre option allows defining such pre-handler methods. The methods are called in order. If the pre array contains another array, those methods are called in parallel. pre can be assigned a mixed array of: + * * arrays containing the elements listed below, which are executed in parallel. + * * objects see RoutePrerequisiteObjects + * * functions - same as including an object with a single method key. + * * strings - special short-hand notation for registered server methods using the format 'name(args)' (e.g. 'user(params.id)') where: + * * 'name' - the method name. The name is also used as the default value of assign. + * * 'args' - the method arguments (excluding next) where each argument is a property of the request object + * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) + * For context see RouteAdditionalConfigurationOptions > pre + * + * TODO follow up on "server methods" in "special short-hand notation for registered server methods" at https://hapijs.com/api/16.1.1#servermethodname-method-options + * TODO follow up on "request object" in "each argument is a property of the request object" at https://hapijs.com/api/16.1.1#request-object + */ +export type RoutePrerequisitesArray = RoutePrerequisitesPart[] | (RoutePrerequisitesPart[] | RoutePrerequisitesPart)[]; +export type RoutePrerequisitesPart = RoutePrerequisiteObjects | RoutePrerequisiteRequestHandler | string; + +/** + * see RoutePrerequisites > objects + */ +export interface RoutePrerequisiteObjects { + /** the function to call (or short-hand method string as described below [see RoutePrerequisitesArray]). the function signature is identical to a route handler as described in Route handler. */ + method: RoutePrerequisiteRequestHandler | string; + /** key name to assign the result of the function to within request.pre. */ + assign: string; + /* + * determines how to handle errors returned by the method. Allowed values are: + * * 'error' - returns the error response back to the client. This is the default value. + * * 'log' - logs the error but continues processing the request. If assign is used, the error will be assigned. + * * 'ignore' - takes no special action. If assign is used, the error will be assigned. + */ + failAction?: 'error' | 'log' | 'ignore'; +} + +/** + * For context see RouteAdditionalConfigurationOptions > response + */ +export interface RouteResponseConfigurationObject { + /** the default HTTP status code when the payload is empty. Value can be 200 or 204. Note that a 200 status code is converted to a 204 only at the time or response transmission (the response status code will remain 200 throughout the request lifecycle unless manually set). Defaults to 200. */ + emptyStatusCode?: number; + /** + * defines what to do when a response fails payload validation. Options are: + * * 'error' - return an Internal Server Error (500) error response. This is the default value. + * * 'log' - log the error but send the response. + * * a custom error handler function with the signature function(request, reply, source, error) where: + * * 'request' - the request object. + * * 'reply' - the continuation reply interface. + * * 'error' - the error returned from the validation schema. + * TODO update type of source once PR to hapi is concluded. + */ + failAction?: 'error' | 'log' | ((request: Request, reply: ReplyWithContinue, source: string, error: Boom.BoomError) => void); + /** if true, applies the validation rule changes to the response payload. Defaults to false. */ + modify?: boolean; + /** + * options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is available [here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback) ). + * If a custom validation function (see `schema` or `status` below) is defined then `options` can an arbitrary object that will be passed to this function as the second parameter. + * Defaults to no options. + */ + options?: ValidationOptions; + /** if false, payload range support is disabled. Defaults to true. */ + ranges?: boolean; + /** the percent of response payloads validated (0 - 100). Set to 0 to disable all validation. Defaults to 100 (all response payloads). */ + sample?: number; + /** the default response payload validation rules (for all non-error responses) */ + schema?: RouteResponseConfigurationScheme; + /** HTTP status-code-specific payload validation rules. The status key is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. If a response status code is not present in the status object, the schema definition is used, except for errors which are not validated by default. */ + status?: Dictionary>; +} + +/** + * the default response payload validation rules (for all non-error responses) expressed as one of: + * * true - any payload allowed (no validation performed). This is the default. + * * false - no payload allowed. + * * a Joi validation object. This will receive the request's headers, params, query, payload, and auth credentials and isAuthenticated flags as context. + * * a validation function + * + * TODO check JoiValidationObject is correct for "a Joi validation object" + * + * For context see RouteAdditionalConfigurationOptions > response > schema + * and + * For context see RouteAdditionalConfigurationOptions > response > status + */ +export type RouteResponseConfigurationScheme = boolean | JoiValidationObject | ValidationFunctionForRouteResponse; + +/** + * see RouteResponseConfigurationScheme + * + * a validation function using the signature function(value, options, next) where: + * * value - the value of the response passed to `reply(value)` in the handler. + * * options - the server validation options, merged with an object containing the request's headers, params, payload, and auth credentials object and `isAuthenticated` flag. + * * next([err, [value]]) - the callback function called when validation is completed. `value` will be used as the response value when `err` is falsy, when `value` is not `undefined`, and when `route.settings.response.modify` is `true`. If the response is already a `Boom` error it will be set as its `message` value. + */ +export interface ValidationFunctionForRouteResponse { + (value: any, options: RouteResponseValidationContext & ValidationOptions, next: ContinuationValueFunction): void; +} + +/** + * A context for route input validation via a Joi schema or validation function. + * + * This object is merged with the route response options and passed into the validation function. + * + * See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L217 + */ +export interface RouteResponseValidationContext { + context: { + /** The request headers */ + headers: Dictionary; + /** The request path parameters */ + params: any; + /** The request query parameters */ + query: any; + /** The request payload parameters */ + payload: any; + + /** Partial request authentication information */ + auth: { + /** true if the request has been successfully authenticated, otherwise false. */ + isAuthenticated: boolean; + /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ + credentials: AuthenticatedCredentials; + }; + } +} + +/** + * For context see RouteAdditionalConfigurationOptions > security + */ +export interface RouteSecurityConfigurationObject { + /** controls the 'Strict-Transport-Security' header. If set to true the header will be set to max-age=15768000, if specified as a number the maxAge parameter will be set to that number. Defaults to true. You may also specify an object with the following fields: */ + hsts?: boolean | number | { + /** the max-age portion of the header, as a number. Default is 15768000. */ + maxAge?: number; + /** a boolean specifying whether to add the includeSubDomains flag to the header. */ + includeSubdomains?: boolean; + /** a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. */ + preload?: boolean; + }; + /** controls the 'X-Frame-Options' header. When set to true the header will be set to DENY, you may also specify a string value of 'deny' or 'sameorigin'. Defaults to true. To use the 'allow-from' rule, you must set this to an object with the following fields: */ + xframe?: true | 'deny' | 'sameorigin' | { + /** may also be 'deny' or 'sameorigin' but set directly as a string for xframe */ + rule: 'allow-from'; + /** when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. */ + source: string; + }; + /** boolean that controls the 'X-XSS-PROTECTION' header for IE. Defaults to true which sets the header to equal '1; mode=block'. NOTE: This setting can create a security vulnerability in versions of IE below 8, as well as unpatched versions of IE8. See [here](https://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities/) and [here](https://technet.microsoft.com/library/security/ms10-002) for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. [Kept typing non optional to force this security related documentation to be read.] */ + xss: boolean; + /** boolean controlling the 'X-Download-Options' header for IE, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. */ + noOpen?: boolean; + /** boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff' */ + noSniff?: boolean; +} + +/** + * request input validation rules for various request components. When using a Joi validation object, the values of the other inputs (i.e. headers, query, params, payload, and auth) are made available under the validation context (accessible in rules as Joi.ref('$query.key')). Note that validation is performed in order (i.e. headers, params, query, payload) and if type casting is used (converting a string to number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. If the validation rules for headers, params, query, and payload are defined at both the routes defaults level and an individual route, the individual route settings override the routes defaults (the rules are not merged). The validate object supports: + * For context see RouteAdditionalConfigurationOptions > validate + * TODO check JoiValidationObject is correct for "a Joi validation object" + */ +export interface RouteValidationConfigurationObject { + /** + * validation rules for incoming request headers (note that all header field names must be in lowercase to match the headers normalized by node). Values allowed: + * * true - any headers allowed (no validation performed). This is the default. + * * false - no headers allowed (this will cause all valid HTTP requests to fail). + * * a Joi validation object. + * * a validation function using the signature function(value, options, next) where: + * * value - the object containing the request headers. + * * options - the server validation options. + * * next(err, value) - the callback function called when validation is completed. `value` will be used as the `headers` value when `err` is falsy. If `next` is called with `undefined` or no arguments then the original value of `value` will be used. + */ + headers?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; + /** + * validation rules for incoming request path parameters, after matching the path against the route and extracting any parameters then stored in request.params. Values allowed: + * Same as `headers`, see above. + */ + params?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; + /** + * validation rules for an incoming request URI query component (the key-value part of the URI between '?' and '#'). The query is parsed into its individual key-value pairs and stored in request.query prior to validation. Values allowed: + * Same as `headers`, see above. + */ + query?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; + /** + * validation rules for an incoming request payload (request body). Values allowed: + * Same as `headers`, see above, with the addition that: + * * a Joi validation object. Note that empty payloads are represented by a null value. If a validation schema is provided and empty payload are supported, it must be explicitly defined by setting the payload value to a joi schema with null allowed (e.g. Joi.object({ /* keys here * / }).allow(null)). + */ + payload?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; + /** an optional object with error fields copied into every validation error response. */ + errorFields?: any; + /** + * determines how to handle invalid requests. Allowed values are: + * * 'error' - return a Bad Request (400) error response. This is the default value. + * * 'log' - log the error but continue processing the request. + * * 'ignore' - take no action. + * * a custom error handler function with the signature function(request, reply, source, error) see RouteFailFunction + */ + failAction?: 'error' | 'log' | 'ignore' | RouteFailFunction; + /** + * options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is [available here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback)). + * If a custom validation function (see `headers`, `params`, `query`, or `payload` above) is defined then `options` can an arbitrary object that will be passed to this function as the second parameter. + * Defaults to no options. + */ + options?: ValidationOptions; +} + +/** + * a validation function using the signature function(value, options, next) where: + * For context see RouteAdditionalConfigurationOptions > validate (RouteValidationConfigurationObject) + * + * Also see ValidationFunctionForRouteResponse + * @param value - the object containing the request headers, query, path params or payload. + * @param options - the server validation options. + * @param next([err, [value]]) - the callback function called when validation is completed. + */ +export interface ValidationFunctionForRouteInput { + (value: any, options: RouteInputValidationContext & ValidationOptions, next: ContinuationValueFunction): void; +} + +/** + * A context for route input validation via a Joi schema or validation function. + * + * This object is merged with the route validation options and passed into the validation function. + * + * See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L122 + */ +export interface RouteInputValidationContext { + context: { + // These are only set when *not* validating the respective source (e.g. params, query and payload are set when validating headers): + // See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L132 + headers?: Dictionary; + params?: any; + query?: any; + payload?: any; + + /** The request authentication information */ + auth: RequestAuthenticationInformation; + } +} + +/** + * a custom error handler function with the signature 'function(request, reply, source, error)` + * @param request - the request object. + * @param reply - the continuation reply interface. + * @param source - the source of the invalid field (e.g. 'headers', 'params', 'query', 'payload'). + * @param error - the error object prepared for the client response (including the validation function error under error.data). + */ +export interface RouteFailFunction { + (request: Request, reply: ReplyWithContinue, source: string, error: any): void; +} + +/** + * optional cookie settings + * [See docs](https://hapijs.com/api/16.1.1#serverstatename-options) + * Related to see ConnectionConfigurationServerDefaults + */ +export interface ServerStateCookieConfiguationObject { + /** time-to-live in milliseconds. Defaults to null (session time-life - cookies are deleted when the browser is closed). */ + ttl?: number | null; + /** sets the 'Secure' flag. Defaults to true. */ + isSecure?: boolean; + /** sets the 'HttpOnly' flag. Defaults to true. */ + isHttpOnly?: boolean; + /** + * sets the 'SameSite' flag where the value must be one of: + * * false - no flag. + * * 'Strict' - sets the value to 'Strict' (this is the default value). + * * 'Lax' - sets the value to 'Lax'. + */ + isSameSite?: false | 'Strict' | 'Lax'; + /** the path scope. Defaults to null (no path). */ + path?: string | null; + /** the domain scope. Defaults to null (no domain). */ + domain?: string | null; + /** + * if present and the cookie was not received from the client or explicitly set by the route handler, the cookie is automatically added to the response with the provided value. The value can be a function with signature function(request, next) where: + * * request - the request object. + * * next - the continuation function using the function(err, value) signature. + */ + autoValue?(request: Request, next: ContinuationValueFunction): void; + /** + * encoding performs on the provided value before serialization. Options are: + * * 'none' - no encoding. When used, the cookie value must be a string. This is the default value. + * * 'base64' - string value is encoded using Base64. + * * 'base64json' - object value is JSON-stringified then encoded using Base64. + * * 'form' - object value is encoded using the x-www-form-urlencoded method. + * * 'iron' - Encrypts and sign the value using iron. + */ + encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron'; + /** + * an object used to calculate an HMAC for cookie integrity validation. This does not provide privacy, only a mean to verify that the cookie value was generated by the server. Redundant when 'iron' encoding is used. Options are: + * * integrity - algorithm options. Defaults to require('iron').defaults.integrity. + * * password - password used for HMAC key generation (must be at least 32 characters long). + */ + sign?: { + integrity?: any; // TODO make iron definitions and getting typing from iron + password: string; + }; + /** password used for 'iron' encoding (must be at least 32 characters long). */ + password?: string; + /** options for 'iron' encoding. Defaults to require('iron').defaults. */ + iron?: any; // TODO make iron definitions and getting typing from iron + /** if true, errors are ignored and treated as missing cookies. */ + ignoreErrors?: boolean; + /** if true, automatically instruct the client to remove invalid cookies. Defaults to false. */ + clearInvalid?: boolean; + /** if false, allows any cookie value including values in violation of RFC 6265. Defaults to true. */ + strictHeader?: boolean; + /** used by proxy plugins (e.g. h2o2). */ + passThrough?: any; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverconnections) + */ +export interface ServerConnection { + /** settings - the connection configuration object passed to server.connection() after applying the server defaults. */ + settings: ServerConnectionOptions; + /** server - the connection's Server object. */ + server: Server; + /** type - set to 'tcp' is the connection is listening on a TCP port, otherwise to 'socket'(a UNIX domain socket or a Windows named pipe). */ + type: 'tcp' | 'socket'; + /** + * registrations + * Described [See docs](https://hapijs.com/api/16.1.1#serverregistrations) "When the server contains more than one connection, each server.connections array member provides its own connection.registrations." + */ + registrations: ServerRegisteredPlugins; + /** states - TODO contribute docs to hapi if they want, and then update type here */ + states: any; + /** auth - TODO contribute docs to hapi if they want, and then update type here */ + auth: any; + /** + * plugins + * TODO contribute docs to hapi if they want. Assuming similar to `registrations`, `listener`, `info`, etc + */ + plugins: PluginsStates; + /** + * app + * TODO contribute docs to hapi if they want. Assuming similar to `registrations`, `listener`, `info`, etc + */ + app: any; + /** Described in server.listener [See docs](https://hapijs.com/api/16.1.1#serverlistener) */ + listener: ServerListener; + /** Described in server.info [See docs](https://hapijs.com/api/16.1.1#serverinfo) */ + info: ServerConnectionInfo; + /** Described in server.inject [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) */ + inject(options: string | InjectedRequestOptions, callback: (res: InjectedResponseObject) => void): void; + inject(options: string | InjectedRequestOptions, ): Promise; + /** Mentioned but not documented under server.connections [See docs](https://hapijs.com/api/16.1.1#serverconnections) */ + table(host?: string): Route[]; + /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#serverlookupid) */ + lookup(id: string): RoutePublicInterface | null; + /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#servermatchmethod-path-host) */ + match(method: HTTP_METHODS, path: string, host?: string): RoutePublicInterface | null; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverinfo) + */ +export interface ServerConnectionInfo { + /** a unique connection identifier (using the format '{hostname}:{pid}:{now base36}'). */ + id: string; + /** the connection creation timestamp. */ + created: number; + /** the connection start timestamp (0 when stopped). */ + started: number; + /** + * the connection port based on the following rules: + * * the configured port value before the server has been started. + * * the actual port assigned when no port is configured or set to 0 after the server has been started. + * TODO check this type. What happens when socket is a UNIX domain socket or Windows named pipe? + */ + port: number | string; + /** the host name the connection was configured to. Defaults to the operating system hostname when available, otherwise 'localhost'. */ + host: string; + /** the active IP address the connection was bound to after starting. Set to undefined until the server has been started or when using a non TCP port (e.g. UNIX domain socket). */ + address: undefined | string; + /** the protocol used. 'socket' when UNIX domain socket or Windows named pipe. */ + protocol: 'http' | 'https' | 'socket'; + /** a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains the uri setting if provided, otherwise constructed from the available settings. If no port is available or set to 0, the uri will not include a port component. */ + uri: string; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverlistener) + */ +export type ServerListener = http.Server; + +/** + * server.realm + * The realm object contains server-wide or plugin-specific state that can be shared across various methods. For example, when calling server.bind(), the active realm settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). Realms are a limited version of a sandbox where plugins can maintain state used by the framework when adding routes, extensions, and other properties. + * [See docs](https://hapijs.com/api/16.1.1#serverrealm) + */ +export interface ServerRealm { + /** when the server object is provided as an argument to the plugin register() method, modifiers provides the registration preferences passed the server.register() method and includes: */ + modifiers: { + /** routes preferences: */ + route: { + /** the route path prefix used by any calls to server.route() from the server. Note that if a prefix is used and the route path is set to '/', the resulting path will not include the trailing slash. */ + prefix: string; + /** the route virtual host settings used by any calls to server.route() from the server. */ + vhost: string; + } + }; + /** the active plugin name (empty string if at the server root). */ + plugin: string; + /** the plugin options object passed at registration. */ + pluginOptions: any; // OptionsPassedToPlugin; + /** plugin-specific state to be shared only among activities sharing the same active state. plugins is an object where each key is a plugin name and the value is the plugin state. */ + plugins: PluginsStates; + /** settings overrides (from RouteAdditionalConfigurationOptions) */ + settings: { + files: { + relativeTo: string; + }; + bind: any; + }; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) + */ +export interface ServerRegisteredPlugins { + [pluginName: string]: ServerRegisteredPlugin; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) + */ +export interface ServerRegisteredPlugin { + /** the plugin version. */ + version: string; + /** the plugin name. */ + name: string; + /** + * options used to register the plugin. + * TODO update with outcome of: https://github.com/hapijs/hapi/pull/3479 + */ + options: any; // OptionsPassedToPlugin; + /** plugin registration attributes. */ + attributes: PluginAttributes; +} + +export interface ServerAuth { + /** + * server.auth.api + * An object where each key is a strategy name and the value is the exposed strategy API. Available on when the authentication scheme exposes an API by returning an api key in the object returned from its implementation function. + * When the server contains more than one connection, each server.connections array member provides its own connection.auth.api object. + * [See docs](https://hapijs.com/api/16.1.1#serverauthapi) + */ + api: Dictionary; + /** + * server.auth.default + * Sets a default strategy which is applied to every route + * The default does not apply when the route config specifies auth as false, or has an authentication strategy configured (contains the strategy or strategies authentication settings). Otherwise, the route authentication config is applied to the defaults. + * Note that if the route has authentication config, the default only applies at the time of adding the route, not at runtime. This means that calling default() after adding a route with some authentication config will have no impact on the routes added prior. However, the default will apply to routes added before default() is called if those routes lack any authentication config. + * The default auth strategy configuration can be accessed via connection.auth.settings.default. To obtain the active authentication configuration of a route, use connection.auth.lookup(request.route). + * [See docs](https://hapijs.com/api/16.1.1#serverauthdefaultoptions) + */ + default(options: string | AuthOptions): void; + /** + * server.auth.scheme + * Registers an authentication scheme + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) + * @param name the scheme name. + * @param scheme the method implementing the scheme with signature function(server, options) see ServerAuthScheme + */ + scheme(name: string, scheme: ServerAuthScheme): void; + /** + * Registers an authentication strategy + * [See docs](https://hapijs.com/api/16.1.1#serverauthstrategyname-scheme-mode-options) + * @param name the strategy name. + * @param scheme the scheme name (must be previously registered using server.auth.scheme()). + * @param mode if set to true (which is the same as 'required') or to a valid authentication mode ('required', 'optional', 'try'), the scheme is automatically assigned as the default strategy for any route without an auth config. Can only be assigned to a single server strategy. Defaults to false (no default settings). + * @param options scheme options based on the scheme requirements. + */ + strategy(name: string, scheme: string, options?: any): void; + strategy(name: string, scheme: string, mode: boolean | 'required' | 'optional' | 'try', options?: any): void; + /** + * Tests a request against an authentication strategy + * Note that the test() method does not take into account the route authentication configuration. It also does not perform payload authentication. It is limited to the basic strategy authentication execution. It does not include verifying scope, entity, or other route properties. + * [See docs](https://hapijs.com/api/16.1.1#serverauthteststrategy-request-next) + * @param strategy - the strategy name registered with server.auth.strategy(). + * @param request - the request object. + * @param next - the callback function with signature function(err, credentials) where: + * * err - the error if authentication failed. + * * credentials - the authentication credentials object if authentication was successful. + */ + test(strategy: string, request: Request, next: (err: Error | null, credentials: AuthenticatedCredentials) => void): void; +} + +export type Strategy = any; +export type SchemeSettings = any; + +/** + * the method implementing the scheme with signature function(server, options) where: + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) + * @param server a reference to the server object the scheme is added to. + * @param options optional scheme settings used to instantiate a strategy. + */ +export interface ServerAuthScheme { + (server: Server, options: SchemeSettings): SchemeMethodResult; +} + +/** + * The scheme method must return an object with the following + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) + */ +export interface SchemeMethodResult { + /** optional object which is exposed via the server.auth.api object. */ + api?: Strategy; + /** + * required function called on each incoming request configured with the authentication scheme + * When the scheme authenticate() method implementation calls reply() with an error condition, the specifics of the error affect whether additional authentication strategies will be attempted (if configured for the route). If the err passed to the reply() method includes a message, no additional strategies will be attempted. If the err does not include a message but does include the scheme name (e.g. Boom.unauthorized(null, 'Custom')), additional strategies will be attempted in the order of preference (defined in the route configuration). If authentication fails the scheme names will be present in the 'WWW-Authenticate' header. + * @param request the request object. + * @param reply the reply interface the authentication method must call when done authenticating the request + */ + authenticate(request: Request, reply: ReplySchemeAuth): void; + /** + * optional function called to authenticate the request payload + * When the scheme payload() method returns an error with a message, it means payload validation failed due to bad payload. If the error has no message but includes a scheme name (e.g. Boom.unauthorized(null, 'Custom')), authentication may still be successful if the route auth.payload configuration is set to 'optional'. + * @param request the request object. + * @param reply is called if authentication failed + */ + payload?(request: Request, reply: ReplySchemeAuthOfPayload): void; + /** + * optional function called to decorate the response with authentication headers before the response headers or payload is written where: + * @param request the request object. + * @param reply is called if an error occured + */ + response?(request: Request, reply: ReplySchemeAuthDecorateResponse): void; + /** an optional object with the following keys: */ + options?: { + /** if true, requires payload validation as part of the scheme and forbids routes from disabling payload auth validation. Defaults to false. */ + payload?: boolean; + }; +} + +export interface ServerCacheMethod { + /** + * Provisions a cache segment within the server cache facility + * [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) + */ + (options: CatboxServerCacheConfiguration): Catbox.Policy; + /** + * Provisions a server cache as described in server.cache + * If no callback is provided, a Promise object is returned. + * Note that if the server has been initialized or started, the cache will be automatically started to match the state of any other provisioned server cache. + * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) + * @param options same as the server cache configuration options. + * @param callback the callback method when cache provisioning is completed or failed with the signature function(err) where: + * * err - any cache startup error condition. + */ + provision(options: CatboxServerCacheConfiguration): Promise; + provision(options: CatboxServerCacheConfiguration, callback: (err?: Error) => void): void; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Request + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Request object + * The request object is created internally for each incoming request. It is different from the node.js request object received from the HTTP server callback (which is available in request.raw.req). The request object methods and properties change throughout the request lifecycle. + * [See docs](https://hapijs.com/api/16.1.1#request-object) + * [See docs](https://hapijs.com/api/16.1.1#request-properties) + */ +export class Request extends Podium { + /** application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. */ + app: any; + /** authentication information */ + auth: RequestAuthenticationInformation; + /** the connection the request was received by. */ + connection: ServerConnection; + /** the node domain object used to protect against exceptions thrown in extensions, handlers and route prerequisites. Can be used to manually bind callback functions otherwise bound to other domains. Set to null when the server useDomains options is false. */ + domain: domain.Domain | null; + /** the raw request headers (references request.raw.headers). */ + headers: Dictionary; + /** a unique request identifier (using the format '{now}:{connection.info.id}:{5 digits counter}').*/ + id: string; + /** request information */ + info: { + /** the request preferred encoding. */ + acceptEncoding: string; + /** if CORS is enabled for the route, contains the following: */ + cors: { + /** + * true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. + * Note: marking as optional as "... this is only available after ..." + */ + isOriginMatch?: boolean; + }; + /** content of the HTTP 'Host' header (e.g. 'example.com:8080'). */ + host: string; + /** the hostname part of the 'Host' header (e.g. 'example.com'). */ + hostname: string; + /** request reception timestamp. */ + received: number; + /** content of the HTTP 'Referrer' (or 'Referer') header. */ + referrer: string; + /** remote client IP address. */ + remoteAddress: string; + /** + * remote client port. + * Set to string in casethey're requesting from a UNIX domain socket. + * TODO, what type does Hapi return, should this be number | string? + */ + remotePort: string; + /** request response timestamp (0 is not responded yet). */ + responded: number; + }; + /** the request method in lower case (e.g. 'get', 'post'). */ + method: string; + /** the parsed content-type header. Only available when payload parsing enabled and no payload error occurred. */ + mime: string; + /** an object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. */ + orig: { + params: any; + query: any; + payload: any; + }; + /** an object where each key is a path parameter name with matching value as described in Path parameters [See docs](https://hapijs.com/api/16.1.1#path-parameters). */ + params: Dictionary; + /** an array containing all the path params values in the order they appeared in the path. */ + paramsArray: string[]; + /** the request URI's pathname [See docs](https://nodejs.org/api/url.html#url_urlobject_pathname) component. */ + path: string; + /** + * the request payload based on the route payload.output and payload.parse settings. + * TODO check this typing and add references / links. + */ + payload: stream.Readable | Buffer | any; + /** plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. */ + plugins: PluginsStates; + /** an object where each key is the name assigned by a route prerequisites function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. */ + pre: Object; + /** the response object when set. The object can be modified but must not be assigned another object. To replace the response with another from within an extension point, use reply(response) to override with a different response. Contains null when no response has been set (e.g. when a request terminates prematurely when the client disconnects). */ + response: Response | null; + /** same as pre but represented as the response object created by the pre method. */ + preResponses: Object; + /** + * by default the object outputted from [node's URL parse()](https://nodejs.org/docs/latest/api/url.html#url_urlobject_query) method. + * Might also be set indirectly via [request.setUrl](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17354#requestseturlurl-striptrailingslash) in which case it may be + * a string (if url is set to an object with the query attribute as an unparsed string). + */ + query: any; + /** an object containing the Node HTTP server objects. **Direct interaction with these raw objects is not recommended.** */ + raw: { + req: http.IncomingMessage; // Or http.ClientRequest http://www.apetuts.com/tutorial/node-js-http-client-request-class/ ? + res: http.ServerResponse; + }; + /** + * the route public interface. + * Optional due to "request.route is not yet populated at this point." [See docs](https://hapijs.com/api/16.1.1#request-lifecycle) + */ + route?: RoutePublicInterface; + /** the server object. */ + server: Server; + /** an object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. */ + state: Dictionary; + /** the parsed request URI */ + url: url.Url; + + /** + * request.setUrl(url, [stripTrailingSlash]) + * Available only in 'onRequest' extension methods. + * Changes the request URI before the router begins processing the request + * [See docs](https://hapijs.com/api/16.1.1#requestseturlurl-striptrailingslash) + * @param url the new request URI. If url is a string, it is parsed with node's URL parse() method. url can also be set to an object compatible with node's URL parse() method output. + * @param stripTrailingSlash if true, strip the trailing slash from the path. Defaults to false. + */ + setUrl(url: string | url.Url, stripTrailingSlash?: boolean): void; + /** + * request.setMethod(method) + * Available only in 'onRequest' extension methods. + * Changes the request method before the router begins processing the request + * [See docs](https://hapijs.com/api/16.1.1#requestsetmethodmethod) + * @param method is the request HTTP method (e.g. 'GET'). + */ + setMethod(method: HTTP_METHODS): void; + /** + * request.generateResponse(source, [options]) + * Always available. + * Returns a response which you can pass into the reply interface where: + * [See docs](https://hapijs.com/api/16.1.1#requestgenerateresponsesource-options) + * @param source the object to set as the source of the reply interface. TODO, submit a PR to clarify this doc, from the source code it's clear that "the object to set" refers to something of type `ReplyValue` i.e. that can be null, string, number, object, Stream, Promise, or Buffer. + * @param options options for the method, optional. Not documented yet, perhaps not very important. + */ + generateResponse(source?: ReplyValue, options?: {marshal?: any; prepare?: any; close?: any; variety?: any}): Response; + /** + * request.log(tags, [data, [timestamp]]) + * Always available. + * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. + * Any logs generated by the server internally will be emitted only on the 'request-internal' channel and will include the event.internal flag set to true. + * [See docs](https://hapijs.com/api/16.1.1#requestlogtags-data-timestamp) + * @param tags a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. + * @param data an optional message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. + * @param timestamp an optional timestamp expressed in milliseconds. Defaults to Date.now() (now). + */ + log(tags: string | string[], data?: string | Object | (() => string | Object), timestamp?: number): void; + /** + * request.getLog([tags], [internal]) + * Always available. + * Returns an array containing the events matching any of the tags specified (logical OR) + * Note that this methods requires the route log configuration set to true. + * [See docs](https://hapijs.com/api/16.1.1#requestgetlogtags-internal) + * @param tags is a single tag string or array of tag strings. If no tags specified, returns all events. + * @param internal filters the events to only those with a matching event.internal value. If true, only internal logs are included. If false, only user event are included. Defaults to all events (undefined). + */ + getLog(tags?: string | string[], internal?: boolean): string[]; + getLog(internal?: boolean): string[]; + /** + * request.tail([name]) + * Available until immediately after the 'response' event is emitted. + * Adds a request tail which has to complete before the request lifecycle is complete. + * Returns a tail function which must be called when the tail activity is completed. + * Tails are actions performed throughout the request lifecycle, but which may end after a response is sent back to the client. For example, a request may trigger a database update which should not delay sending back a response. However, it is still desirable to associate the activity with the request when logging it (or an error associated with it). + * When all tails completed, the server emits a 'tail' event. + * [See docs](https://hapijs.com/api/16.1.1#requesttailname) + * @param name an optional tail name used for logging purposes. + */ + tail(name?: string): (() => void); + /** + * The server.decorate('request', ...) method can modify this prototype/interface. + * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts + * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) + */ + // [index: string]: any; +} + +export interface RequestAuthenticationInformation { + /** true if the request has been successfully authenticated, otherwise false. */ + isAuthenticated: boolean; + /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ + credentials: any; + /** an artifact object received from the authentication strategy and used in authentication-related actions. */ + artifacts: any; + /** the route authentication mode. */ + mode: string; + /** the authentication error is failed and mode set to 'try'. */ + error: Error; +} + +export type HTTP_METHODS_PARTIAL_lowercase = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; +export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_lowercase; +export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; + +/** + * Request events + * The request object supports the following events: + * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). + * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). + * * 'disconnect' - emitted when a request errors or aborts unexpectedly. + * [See docs](https://hapijs.com/api/16.1.1#request-events) + */ +export type RequestEventTypes = 'peek' | 'finish' | 'disconnect'; + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Handler functions + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Extending RouteConfiguration.handler + * + * The hapi documentation allows for the RouteConfiguration.handler type to have + * `{[pluginName: string]: pluginOptions}` + * "handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler" + * This can be provided by extending the hapi module definition as follows, + * see h2o2 for example: + * + * declare module 'hapi' { + * interface RouteHandlerPlugins { + * proxy?: ... + */ +export interface RouteHandlerPlugins { +} +/** + * The route handler function uses the signature function(request, reply) (NOTE: do not use a fat arrow style function for route handlers as they do not allow context binding and will cause problems when used in conjunction with server.bind) where: + * * request - is the incoming request object (this is not the node.js request object). + * * reply - the reply interface the handler must call to set a response and return control back to the framework. + * [See docs](https://hapijs.com/api/16.1.1#route-handler) + * Same function signature used by request extension point used in server.ext(event), see ServerExtConfigurationObject.method + */ +export interface RouteHandler { + (request: Request, reply: ReplyNoContinue): void; + // (request: Request, reply: StrictReply): void; +} + +/** + * "the function to call, the function signature is identical to a route handler as described in Route handler." + * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) Route prerequisites + */ +export type RoutePrerequisiteRequestHandler = RouteHandler; + +/** + * request extension points: function(request, reply) where + * this - the object provided via options.bind or the current active context set with server.bind(). + * [See docs](https://hapijs.com/api/16.1.1#serverextevents) + * @param request the request object. + * @param reply the reply interface which is used to return control back to the framework. To continue normal execution of the request lifecycle, reply.continue() must be called. If the extension type is 'onPostHandler' or 'onPreResponse', a single argument passed to reply.continue() will override the current set response (including all headers) but will not stop the request lifecycle execution. To abort processing and return a response to the client, call reply(value) where value is an error or any other valid response. + */ +export interface ServerExtRequestHandler { + (request: Request, reply: ReplyWithContinue): void; +} + +/** + * Used by various extensions to handle a request and + * synchronously return a result of some form. + * + * Left in for backwards compatibility of typings but according to the + * [DefinitelyTyped Readme under common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes) + * it talks about not using generic types unless the type was used in typing one + * or more of the function arguments. Using it to type the return was suggested + * to be the same as a type assertion. + */ +export interface RequestHandler { + (request: Request): T; +} + +/** + * Used by server extension points + * err can be `Boom` error or Error that will be wrapped as a `Boom` error + * For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/reply.js#L109-L118) + * For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65) + */ +export interface ContinuationFunction { + (err?: Boom.BoomError): void; +} +/** + * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65) + * TODO Can value be typed with a useful generic? + */ +export interface ContinuationValueFunction { + (err: Boom.BoomError): void; + (err: null | undefined, value: any): void; + (): void; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Reply functions + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Typings listed explicitly here [See docs](https://hapijs.com/api/16.1.1#replyerr-result) + * Typings also described in part here [See docs](https://hapijs.com/api/16.1.1#response-object) + */ +export type ReplyValue = _ReplyValue | Promise<_ReplyValue>; +export type _ReplyValue = null | undefined | string | number | boolean | Buffer | Error | stream.Stream | Object; // | array; + +/** + * Reply interface + * reply([err], [result]) + * Concludes the handler activity by setting a response and returning control over to the framework + * When reply() is called with an error or result response, that value is used as the response sent to the client. When reply() is called within a prerequisite, the value is saved for future use and is not used as the response. In all other places except for the handler, calling reply() will be considered an error and will abort the request lifecycle, jumping directly to the 'onPreResponse' event. + * To return control to the framework within an extension or other places other than the handler, without setting a response, the method reply.continue() must be called. Except when used within an authentication strategy, or in an 'onPostHandler' or 'onPreResponse' extension, the reply.continue() must not be passed any argument or an exception is thrown. + * [See docs](https://hapijs.com/api/16.1.1#reply-interface) + * [See docs](https://hapijs.com/api/16.1.1#replyerr-result) + * + * NOTE: modules should extend this interface to expose reply.Nnn methods + */ +export interface Base_Reply { + (err?: ReplyValue): Response; + (err: null, result?: ReplyValue): Response; + /** the active realm associated with the route. */ + realm: ServerRealm; + /** the request object */ + request: Request; + + /** + * reply.entity(options) + * Sets the response 'ETag' and 'Last-Modified' headers and checks for any conditional request headers to decide if the response is going to qualify for an HTTP 304 (Not Modified). If the entity values match the request conditions, reply.entity() returns control back to the framework with a 304 response. Otherwise, it sets the provided entity headers and returns null. + * Returns a response object if the reply is unmodified or null if the response has changed. If null is returned, the developer must call reply() to continue execution. If the response is not null, the developer must not call reply(). + * [See docs](https://hapijs.com/api/16.1.1#replyentityoptions) + * @param options a required configuration object with: + * * etag - the ETag string. Required if modified is not present. Defaults to no header. + * * modified - the Last-Modified header value. Required if etag is not present. Defaults to no header. + * * vary - same as the response.etag() option. Defaults to true. + */ + entity(options: {etag?: string, modified?: string, vary?: boolean}): Response | null; + /** + * reply.close([options]) + * Concludes the handler activity by returning control over to the router and informing the router that a response has already been sent back directly via request.raw.res and that no further response action is needed. Supports the following optional options: + * The response flow control rules do not apply. + * [See docs](https://hapijs.com/api/16.1.1#replycloseoptions) + * @param options options object: + * * end - if false, the router will not call request.raw.res.end()) to ensure the response was ended. Defaults to true. + */ + close(options?: {end?: boolean}): void; + /** + * reply.redirect(uri) + * Redirects the client to the specified uri. Same as calling reply().redirect(uri). + * The response flow control rules apply. + * Sets an HTTP redirection response (302) and decorates the response with additional methods for + * changing to a permanent or non-rewritable redirect is also available see response object redirect for more information. + * [See docs](https://hapijs.com/api/16.1.1#replyredirecturi) + * @param uri an absolute or relative URI used to redirect the client to another resource. + */ + redirect(uri: string): ResponseRedirect; + /** + * reply.response(result) + * Shorthand for calling `reply(null, result)`, replies with the response set to `result`. + * [See docs](https://hapijs.com/api/16.1.1#replyresponseresult) + * TODO likely to change. Await approval of pull request to Hapi docs. + */ + response(result: ReplyValue): Response; + /** + * Sets a cookie on the response + * [See docs](https://hapijs.com/api/16.1.1#reply) + * TODO likely to change. Await approval of pull request to Hapi docs. + */ + state(name: string, value: any, options?: any): void; + /** + * Clears a cookie on the response + * [See docs](https://hapijs.com/api/16.1.1#reply) + * TODO likely to change. Await approval of pull request to Hapi docs. + */ + unstate(name: string, options?: any): void; + /** + * The server.decorate('reply', ...) method can modify this prototype/interface. + * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts + * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) + */ + // [index: string]: any; +} +/** + * reply.continue([result]) + * Returns control back to the framework without ending the request lifecycle + * [See docs](https://hapijs.com/api/16.1.1#replycontinueresult) + * [See docs](https://hapijs.com/api/16.1.1#replyerr-result) "With the exception of the handler function, all other methods provide the reply.continue() method which instructs the framework to continue processing the request without setting a response." + * @param result if called in the handler, prerequisites, or extension points other than the 'onPreHandler' and 'onPreResponse', the result argument is not allowed and will throw an exception if present. If called within an authentication strategy, it sets the authenticated credentials. If called by the 'onPreHandler' or 'onPreResponse' extensions, the result argument overrides the current response including all headers, and returns control back to the framework to continue processing any remaining extensions. + */ +export interface Continue_Reply { + continue(result?: ReplyValue): Response | undefined; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > authenticate. + * Also [See docs](https://hapijs.com/api/16.1.1#replyerr-result). + * TODO check it has Base_Reply methods and properties + */ +export interface ReplySchemeAuth extends Base_Reply { + /** + * This function is called if authentication failed. + * TODO, check type the `response` parameter. In https://hapijs.com/api/16.1.1#replyerr-result it is referred to as "null" but this seems to be for a third scenario where it is "used to return both an error and credentials in the authentication methods" then "reply() must be called with three arguments function(err, null, data)" + * @param err any authentication error. + * @param response any authentication response action such as redirection. Ignored if err is present, otherwise required. + * @param result an object containing: + * * credentials the authenticated credentials. + * * artifacts optional authentication artifacts. + */ + (err: Error | null, response: AnyAuthenticationResponseAction | null, result: AuthenticationResult): void; + /** + * is called if authentication succeeded + * @param result same object as result above. + */ + continue(result: AuthenticationResult): void; +} +/** + * Typing as any as it's not yet clear what type this argument takes. + * "any authentication response action such as redirection" is it equivalent to + * `ReplyValue` ? + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) + * TODO research hapi source and type this. + */ +export type AnyAuthenticationResponseAction = any; +/** [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) */ +export interface AuthenticationResult { + credentials?: AuthenticatedCredentials; + artifacts?: any; +} +export interface AuthenticatedCredentials { + // Disabled to allow typing within a project + // [index: string]: any; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > payload + * TODO check it has Base_Reply methods and properties + */ +export interface ReplySchemeAuthOfPayload extends Base_Reply { + /** + * function called to authenticate the request payload where: + * @param err any authentication error. + * @param response any authentication response action such as redirection. Ignored if err is present, otherwise required. + */ + (err: Error | null, response: AnyAuthenticationResponseAction): void; + /** is called if payload authentication succeeded */ + continue(): void; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > response + * TODO check it has Base_Reply methods and properties + */ +export interface ReplySchemeAuthDecorateResponse extends Base_Reply { + /** + * is called if an error occurred + * @param err any authentication error. + * @param response any authentication response to send instead of the current response. Ignored if err is present, otherwise required. + */ + (err?: Error, response?: ReplyValue): void; + /** is called if the operation succeeded. */ + continue(): void; +} + +export interface ReplyWithContinue extends Continue_Reply, Base_Reply {} + +export interface ReplyNoContinue extends Base_Reply {} + +// TODO assess use and usefulness of StrictReply + +// Concludes the handler activity by setting a response and returning control over to the framework where: +// erran optional error response. +// result an optional response payload. +// Since an request can only have one response regardless if it is an error or success, the reply() method can only result in a single response value. This means that passing both an err and result will only use the err. There is no requirement for either err or result to be (or not) an Error object. The framework will simply use the first argument if present, otherwise the second. The method supports two arguments to be compatible with the common callback pattern of error first. +// FLOW CONTROL: +// When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() +/** + * + */ +// export interface Reply { // extends ReplyMethods { +// (err: Error, +// result?: string | number | boolean | Buffer | stream.Stream | Promise | T, +// /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ +// credentialData?: any): BoomError; +// /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ +// (result: string | number | boolean | Buffer | stream.Stream | Promise | T): Response; +// } + +/** Concludes the handler activity by setting a response and returning control over to the framework where: + erran optional error response. + result an optional response payload. + Since an request can only have one response regardless if it is an error or success, the reply() method can only result in a single response value. This means that passing both an err and result will only use the err. There is no requirement for either err or result to be (or not) an Error object. The framework will simply use the first argument if present, otherwise the second. The method supports two arguments to be compatible with the common callback pattern of error first. + FLOW CONTROL: + When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() */ +// export interface StrictReply extends ReplyMethods { +// (err: Error, +// result?: Promise | T, +// /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ +// credentialData?: any): BoomError; +// /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ +// (result: Promise | T): Response; +// } + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Response + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Response object + * [See docs](https://hapijs.com/api/16.1.1#response-object) + * + * TODO, check extending from Podium is correct. Extending because of "The response object supports the following events" [See docs](https://hapijs.com/api/16.1.1#response-events) + * * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). + * * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). + */ +export interface Response extends Podium { + /** the HTTP response status code. Defaults to 200 (except for errors). */ + statusCode: number; + /** an object containing the response headers where each key is a header field name. Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission. */ + headers: Dictionary; + /** the value provided using the reply interface. */ + source: ReplyValue; + /** + * a string indicating the type of source with available values: + * * 'plain' - a plain response such as string, number, null, or simple object (e.g. not a Stream, Buffer, or view). + * * 'buffer' - a Buffer. + * * 'stream' - a Stream. + * * 'promise' - a Promise object. + */ + variety: 'plain' | 'buffer' | 'stream' | 'promise'; + /** application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. */ + app: any; + /** plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. */ + plugins: PluginsStates; + /** response handling flags: */ + settings: { + /** the 'Content-Type' HTTP header 'charset' property. Defaults to 'utf-8'. */ + charset: string; + /** the string encoding scheme used to serial data into the HTTP payload when source is a string or marshals into a string. Defaults to 'utf8'. */ + encoding: string; + /** if true and source is a Stream, copies the statusCode and headers of the stream to the outbound response. Defaults to true. */ + passThrough: boolean; + /** options used for source value requiring stringification. Defaults to no replacer and no space padding. */ + stringify: Json.StringifyArguments; + /** if set, overrides the route cache expiration milliseconds value set in the route config. Defaults to no override. */ + ttl: number | null; + /** if true, a suffix will be automatically added to the 'ETag' header at transmission time (separated by a '-' character) when the HTTP 'Vary' header is present. */ + varyEtag: boolean; + }; + + /** + * The following attribute is present in one or more of the examples + * TODO update once Hapi docs describes explicitly + */ + isBoom?: boolean; + /** + * The following attribute is present in one or more of the examples + * TODO update once Hapi docs describes explicitly + */ + isMissing?: boolean; + /** + * The following attribute is present in one or more of the examples + * TODO update once Hapi docs describes explicitly + */ + output?: Boom.Output; + + /** + * sets the HTTP 'Content-Length' header (to avoid chunked transfer encoding) + * @param length the header value. Must match the actual payload size. + */ + bytes(length: number): Response; + /** + * sets the 'Content-Type' HTTP header 'charset' property + * @param charset the charset property value. + */ + charset(charset: string): Response; + /** + * sets the HTTP status code + * @param statusCode the HTTP status code (e.g. 200). + */ + code(statusCode: number): Response; + /** + * sets the HTTP status message + * @param httpMessage the HTTP status message (e.g. 'Ok' for status code 200). + */ + message(httpMessage: string): Response; + /** + * sets the HTTP status code to Created (201) and the HTTP 'Location' header + * @param uri an absolute or relative URI used as the 'Location' header value. + */ + created(uri: string): Response; + /** + * sets the string encoding scheme used to serial data into the HTTP payload + * @param encoding the encoding property value (see node Buffer encoding [See docs](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings)). + * * 'ascii' - for 7-bit ASCII data only. This encoding is fast and will strip the high bit if set. + * * 'utf8' - Multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8. + * * 'utf16le' - 2 or 4 bytes, little-endian encoded Unicode characters. Surrogate pairs (U+10000 to U+10FFFF) are supported. + * * 'ucs2' - Alias of 'utf16le'. + * * 'base64' - Base64 encoding. When creating a Buffer from a string, this encoding will also correctly accept "URL and Filename Safe Alphabet" as specified in RFC4648, Section 5. + * * 'latin1' - A way of encoding the Buffer into a one-byte encoded string (as defined by the IANA in RFC1345, page 63, to be the Latin-1 supplement block and C0/C1 control codes). + * * 'binary' - Alias for 'latin1'. + * * 'hex' - Encode each byte as two hexadecimal characters. + */ + encoding(encoding: 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex'): Response; + /** + * sets the representation entity tag + * @param tag the entity tag string without the double-quote. + * @param options options object + * * weak - if true, the tag will be prefixed with the 'W/' weak signifier. Weak tags will fail to match identical tags for the purpose of determining 304 response status. Defaults to false. + * * vary - if true and content encoding is set or applied to the response (e.g 'gzip' or 'deflate'), the encoding name will be automatically added to the tag at transmission time (separated by a '-' character). Ignored when weak is true. Defaults to true. + */ + etag(tag: string, options?: {weak: boolean, vary: boolean}): Response; + /** + * sets an HTTP header + * @param name the header name. + * @param value the header value. + */ + header(name: string, value: string, options?: ResponseHeaderOptionsObject): Response; + /** + * sets the HTTP 'Location' header + * @param uri an absolute or relative URI used as the 'Location' header value. + */ + location(uri: string): Response; + /** + * sets an HTTP redirection response (302) and decorates the response with additional methods listed below, + * @param uri an absolute or relative URI used to redirect the client to another resource. + */ + redirect(uri: string): Response; + /** + * sets the JSON.stringify() replacer argument + * @param method the replacer function or array. Defaults to none. + */ + replacer(method: Json.StringifyReplacer): Response; + /** + * sets the JSON.stringify() space argument + * @param count the number of spaces to indent nested object keys. Defaults to no indentation. + */ + spaces(count: Json.StringifySpace): Response; + /** + * sets an HTTP cookie + * @param name the cookie name. + * @param value the cookie value. If no encoding is defined, must be a string. + * @param options optional configuration. If the state was previously registered with the server using server.state(), the specified keys in options override those same keys in the server definition (but not others). + */ + state(name: string, value: string | Object | any[], options?: ServerStateCookieConfiguationObject): Response; + /** + * sets a string suffix when the response is process via JSON.stringify(). + */ + suffix(suffix: string): Response; + /** + * overrides the default route cache expiration rule for this response instance + * @param msec the time-to-live value in milliseconds. + */ + ttl(msec: number): Response; + /** + * sets the HTTP 'Content-Type' header + * @param mimeType is the mime type. Should only be used to override the built-in default for each response type. + */ + type(mimeType: string): Response; + /** + * clears the HTTP cookie by setting an expired value + * @param name the cookie name. + * @param options optional configuration for expiring cookie. If the state was previously registered with the server using server.state(), the specified keys in options override those same keys in the server definition (but not others). + */ + unstate(name: string, options?: ServerStateCookieConfiguationObject): Response; + /** + * adds the provided header to the list of inputs affected the response generation via the HTTP 'Vary' header + * @param header the HTTP request header name. + */ + vary(header: string): Response; + + /** + * Flow control - hold() + * When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: + * puts the response on hold until response.send() is called. Available only after reply() is called and until response.hold() is invoked once. + * [See docs](https://hapijs.com/api/16.1.1#flow-control) + */ + hold(): Response; + /** + * Flow control - send() + * When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: + * immediately resume the response. Available only after response.hold() is called and until response.send() is invoked once. + * [See docs](https://hapijs.com/api/16.1.1#flow-control) + */ + send(): Response; + + /** + * Mentioned here: "Note that prerequisites do not follow the same rules of the normal reply interface. In all other cases, calling reply() with or without a value will use the result as the response sent back to the client. In a prerequisite method, calling reply() will assign the returned value to the provided assign key. If the returned value is an error, the failAction setting determines the behavior. To force the return value as the response and skip any other prerequisites and the handler, use the reply().takeover() method." + * TODO prepare documentation PR and submit to hapi. + * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) + */ + takeover(): Response; +} + +/** + * Response Object Redirect Methods + * When using the redirect() method, the response object provides these additional methods: + * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) + */ +export interface ResponseRedirect extends Response { + /** + * temporary + * sets the status code to 302 or 307 (based on the rewritable() setting) where: + * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) + * @param isTemporary if false, sets status to permanent. Defaults to true. + */ + temporary(isTemporary: boolean): Response; + /** + * permanent + * sets the status code to 301 or 308 (based on the rewritable() setting) where: + * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) + * @param isPermanent if false, sets status to temporary. Defaults to true. + */ + permanent(isPermanent: boolean): Response; + /** + * rewritable + * sets the status code to 301/302 for rewritable (allows changing the request method from 'POST' to 'GET') or 307/308 for non-rewritable (does not allow changing the request method from 'POST' to 'GET'). Exact code based on the temporary() or permanent() setting. Arguments: + * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) + * @param isRewritable if false, sets to non-rewritable. Defaults to true. + */ + rewritable(isRewritable: boolean): Response; +} + +/** + * [See docs](https://hapijs.com/api/16.1.1#response-object) under "response object provides the following methods" > header > options + */ +export interface ResponseHeaderOptionsObject { + /** if true, the value is appended to any existing header value using separator. Defaults to false. */ + append?: boolean; + /** string used as separator when appending to an existing value. Defaults to ','. */ + separator?: string; + /** if false, the header value is not set if an existing value present. Defaults to true. */ + override?: boolean; + /** if false, the header value is not modified if the provided value is already included. Does not apply when append is false or if the name is 'set-cookie'. Defaults to true. */ + duplicate?: boolean; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Plugins and register + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// TODO: move to separate file http://stackoverflow.com/questions/43276921 + +/** + * Plugins + * Plugins provide a way to organize the application code by splitting the server logic into smaller components. Each plugin can manipulate the server and its connections through the standard server interface, but with the added ability to sandbox certain properties. + * [See docs](https://hapijs.com/api/16.1.1#plugins) + * @param server the server object the plugin is being registered to. + * @param options an options object passed to the plugin during registration. + * @param next a callback method the function must call to return control back to the framework to complete the registration process with signature function(err) + */ +export interface PluginFunction { + (server: Server, options: OptionsPassedToPlugin, next: (err?: Error) => void): void; + /** + * Note attributes is NOT optional but this type is easier to use. + */ + attributes?: PluginAttributes; +} + +/** + * see Plugin + * [See docs](https://hapijs.com/api/16.1.1#plugins) + */ +export interface PluginAttributes { + /** + * required plugin name string. The name is used as a unique key. Published plugins should use the same name as the name field in the 'package.json' file. Names must be unique within each application. + * NOTE: marked as optional as `pkg` can be used instead. + */ + name?: string; + /** optional plugin version. The version is only used informatively to enable other plugins to find out the versions loaded. The version should be the same as the one specified in the plugin's 'package.json' file. */ + version?: string; + /** Alternatively, the name and version can be included via the pkg attribute containing the 'package.json' file for the module which already has the name and version included */ + pkg?: any; + /** if true, allows the plugin to be registered multiple times with the same server. Defaults to false. */ + multiple?: boolean; + /** optional string or array of string indicating a plugin dependency. Same as setting dependencies via server.dependency(). */ + dependencies?: string | string[]; + /** if false, does not allow the plugin to call server APIs that modify the connections such as adding a route or configuring state. This flag allows the plugin to be registered before connections are added and to pass dependency requirements. When set to 'conditional', the mode is based on the presence of selected connections (if the server has connections, it is the same as true, but if no connections are available, it is the same as false). Defaults to true. */ + connections?: boolean | 'conditional'; + /** if true, will only register the plugin once per connection (or once per server for a connectionless plugin). If set, overrides the once option passed to server.register(). Defaults to undefined (registration will be based on the server.register() option once). */ + once?: boolean; +} + +/** + * Plugins State + * Related [See docs](https://hapijs.com/api/16.1.1#serverplugins) + * Related [See docs](https://hapijs.com/api/16.1.1#serverrealm) + */ +export interface PluginsStates { + [pluginName: string]: any; +} + +/** + * once, select, routes - optional plugin-specific registration options as defined see PluginRegistrationOptions + * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) + */ +export interface PluginRegistrationObject extends PluginRegistrationOptions { + /** the plugin registration function. */ + register: PluginFunction; + /** optional options passed to the registration function when called. */ + options?: OptionsPassedToPlugin; +} + +/** + * registration options (different from the options passed to the registration function): + * * once - if true, the registration is skipped for any connection already registered with. Cannot be used with plugin options. If the plugin does not have a connections attribute set to false and the registration selection is empty, registration will be skipped as no connections are available to register once. Defaults to false. + * * routes - modifiers applied to each route added by the plugin: + * * prefix - string added as prefix to any route path (must begin with '/'). If a plugin registers a child plugin the prefix is passed on to the child or is added in front of the child-specific prefix. + * * vhost - virtual host string (or array of strings) applied to every route. The outer-most vhost overrides the any nested configuration. + * * select - a string or array of string labels used to pre-select connections for plugin registration. + * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) + */ +export interface PluginRegistrationOptions { + once?: boolean; + routes?: {prefix?: string, vhost?: string | string[]}; + select?: string | string[]; +} + +/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JSON + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ +// This was in a seperate file and perhaps should move to some of the lib typings? +// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/16065#issuecomment-299443673 +// +// json/json-tests.ts +// +// import * as JSON from './index'; +// +// var a: JSON.StringifyReplacer = function(key, value) { +// if (key === "do not include") { +// return undefined; +// } +// return value; +// }; +// + +export namespace Json { + /** + * @see {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter} + */ + export type StringifyReplacer = ((key: string, value: any) => any) | (string | number)[] | undefined; + + /** + * Any value greater than 10 is truncated. + */ + export type StringifySpace = number | string; + + export interface StringifyArguments { + /** the replacer function or array. Defaults to no action. */ + replacer?: StringifyReplacer; + /** number of spaces to indent nested object keys. Defaults to no indentation. */ + space?: StringifySpace; + } +} diff --git a/types/hapi/v16/test/connection/table.ts b/types/hapi/test/connection/table.ts similarity index 94% rename from types/hapi/v16/test/connection/table.ts rename to types/hapi/test/connection/table.ts index 3ead170c90..24eaa28ddc 100644 --- a/types/hapi/v16/test/connection/table.ts +++ b/types/hapi/test/connection/table.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servertablehost -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80, host: 'example.com' }); server.route({ method: 'GET', path: '/example', handler: function (request, reply) { return reply(); } }); diff --git a/types/hapi/v16/test/continuation/errors.ts b/types/hapi/test/continuation/errors.ts similarity index 95% rename from types/hapi/v16/test/continuation/errors.ts rename to types/hapi/test/continuation/errors.ts index 6bce66c58e..165e5214df 100644 --- a/types/hapi/v16/test/continuation/errors.ts +++ b/types/hapi/test/continuation/errors.ts @@ -1,6 +1,6 @@ -import * as Hapi from '../../'; -import * as Boom from '../../../../boom'; +import * as Hapi from 'hapi'; +import * as Boom from 'boom'; // Assignment of a typical function to ContinuationValueFunction is possible const handleError: Hapi.ContinuationValueFunction = (err?: Boom.BoomError | null, value?: any) => { diff --git a/types/hapi/v16/test/getting-started/01-creating-a-server.ts b/types/hapi/test/getting-started/01-creating-a-server.ts similarity index 100% rename from types/hapi/v16/test/getting-started/01-creating-a-server.ts rename to types/hapi/test/getting-started/01-creating-a-server.ts diff --git a/types/hapi/v16/test/getting-started/02-adding-routes.ts b/types/hapi/test/getting-started/02-adding-routes.ts similarity index 100% rename from types/hapi/v16/test/getting-started/02-adding-routes.ts rename to types/hapi/test/getting-started/02-adding-routes.ts diff --git a/types/hapi/v16/test/getting-started/03-serving-static-content.ts b/types/hapi/test/getting-started/03-serving-static-content.ts similarity index 100% rename from types/hapi/v16/test/getting-started/03-serving-static-content.ts rename to types/hapi/test/getting-started/03-serving-static-content.ts diff --git a/types/hapi/v16/test/getting-started/04-using-plugins.ts b/types/hapi/test/getting-started/04-using-plugins.ts similarity index 100% rename from types/hapi/v16/test/getting-started/04-using-plugins.ts rename to types/hapi/test/getting-started/04-using-plugins.ts diff --git a/types/hapi/v16/test/path/catch-all.ts b/types/hapi/test/path/catch-all.ts similarity index 89% rename from types/hapi/v16/test/path/catch-all.ts rename to types/hapi/test/path/catch-all.ts index e38a67ec96..c9002392b1 100644 --- a/types/hapi/v16/test/path/catch-all.ts +++ b/types/hapi/test/path/catch-all.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#catch-all-route -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/path/parameters.ts b/types/hapi/test/path/parameters.ts similarity index 95% rename from types/hapi/v16/test/path/parameters.ts rename to types/hapi/test/path/parameters.ts index 6bbba522db..62bbfcc638 100644 --- a/types/hapi/v16/test/path/parameters.ts +++ b/types/hapi/test/path/parameters.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#path-parameters -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/plugins/options.ts b/types/hapi/test/plugins/options.ts similarity index 95% rename from types/hapi/v16/test/plugins/options.ts rename to types/hapi/test/plugins/options.ts index 7f6ad6c13c..cd192f1996 100644 --- a/types/hapi/v16/test/plugins/options.ts +++ b/types/hapi/test/plugins/options.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverinfo -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; // added in addition to code from docs interface PluginOptions { diff --git a/types/hapi/v16/test/reply/continue.ts b/types/hapi/test/reply/continue.ts similarity index 91% rename from types/hapi/v16/test/reply/continue.ts rename to types/hapi/test/reply/continue.ts index 5f23cb039a..de6994fbd0 100644 --- a/types/hapi/v16/test/reply/continue.ts +++ b/types/hapi/test/reply/continue.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#replycontinueresult -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/reply/entity.ts b/types/hapi/test/reply/entity.ts similarity index 93% rename from types/hapi/v16/test/reply/entity.ts rename to types/hapi/test/reply/entity.ts index 5cb187fa1e..cfcce6de25 100644 --- a/types/hapi/v16/test/reply/entity.ts +++ b/types/hapi/test/reply/entity.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#replyentityoptions -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/reply/redirect.ts b/types/hapi/test/reply/redirect.ts similarity index 84% rename from types/hapi/v16/test/reply/redirect.ts rename to types/hapi/test/reply/redirect.ts index 934092868b..5baf892ac1 100644 --- a/types/hapi/v16/test/reply/redirect.ts +++ b/types/hapi/test/reply/redirect.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#replyredirecturi -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const handler: Hapi.RouteHandler = function (request, reply) { return reply.redirect('http://example.com'); diff --git a/types/hapi/v16/test/reply/reply.ts b/types/hapi/test/reply/reply.ts similarity index 92% rename from types/hapi/v16/test/reply/reply.ts rename to types/hapi/test/reply/reply.ts index bf92621986..31f3bff9b4 100644 --- a/types/hapi/v16/test/reply/reply.ts +++ b/types/hapi/test/reply/reply.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#replyerr-result -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; // verbose notation @@ -19,4 +19,4 @@ const handler2: Hapi.RouteHandler = function (request, reply) { return reply('success') .type('text/plain') .header('X-Custom', 'some-value'); -}; +}; \ No newline at end of file diff --git a/types/hapi/v16/test/reply/state_cookie.ts b/types/hapi/test/reply/state_cookie.ts similarity index 95% rename from types/hapi/v16/test/reply/state_cookie.ts rename to types/hapi/test/reply/state_cookie.ts index 8a0be7da34..bf94219311 100644 --- a/types/hapi/v16/test/reply/state_cookie.ts +++ b/types/hapi/test/reply/state_cookie.ts @@ -1,7 +1,7 @@ // from https://hapijs.com/tutorials/cookies?lang=en_US -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/request/catch-all.ts b/types/hapi/test/request/catch-all.ts deleted file mode 100644 index 1917cd8fff..0000000000 --- a/types/hapi/test/request/catch-all.ts +++ /dev/null @@ -1,15 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#catch-all-route -import {Request, ResponseToolkit, Server, ServerOptions} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; -const server = new Server(options); - -const handler = (request: Request, h: ResponseToolkit) => { - return h.response('The page was not found').code(404); -}; -server.route({ method: '*', path: '/{p*}', handler }); - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/test/request/event-types.ts b/types/hapi/test/request/event-types.ts index 894e4dcf39..0946f0a0ed 100644 --- a/types/hapi/test/request/event-types.ts +++ b/types/hapi/test/request/event-types.ts @@ -1,76 +1,30 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents -// https://github.com/hapijs/hapi/blob/master/API.md#-requestevents -import { - Lifecycle, - Request, - ResponseToolkit, - RouteOptions, - Server, - ServerOptions, - ServerRoute -} from "hapi"; -import * as Crypto from 'crypto'; -const options: ServerOptions = { - port: 8000, -}; +// From https://hapijs.com/api/16.1.1#requestsetmethodmethod -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - } -}; +import * as Hapi from 'hapi'; +const Crypto = require('crypto'); +const server = new Hapi.Server(); +server.connection({ port: 80 }); -const onRequest: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { +const onRequest: Hapi.ServerExtRequestHandler = function (request, reply) { - /* - * Server events - */ - request.server.events.on('request', (request: Request, event: any, tags: any) => { - console.log(request.paramsArray); - console.log(event); - console.log(tags); - }); - - request.server.events.on('response', (request: Request) => { - console.log('Response sent for request: ' + request.path); - }); - - request.server.events.on('start', (route: RouteOptions) => { - console.log('Server started'); - }); - - request.server.events.once('stop', (route: RouteOptions) => { - console.log('Server stoped'); - }); - - /* - * Request events - */ const hash = Crypto.createHash('sha1'); + request.on('peek', (chunk) => { - request.events.on("peek", (chunk: any) => { hash.update(chunk); }); - request.events.once("finish", () => { + request.once('finish', () => { + console.log(hash.digest('hex')); }); - request.events.once("disconnect", () => { + request.once('disconnect', () => { + console.error('request aborted'); }); - return h.continue; - + return reply.continue(); }; -const server = new Server(options); -server.route(serverRoute); server.ext('onRequest', onRequest); - -server.start(); -console.log('Server started at: ' + server.info.uri); - diff --git a/types/hapi/v16/test/request/generate-response.ts b/types/hapi/test/request/generate-response.ts similarity index 93% rename from types/hapi/v16/test/request/generate-response.ts rename to types/hapi/test/request/generate-response.ts index f731961a68..c30c3a7be5 100644 --- a/types/hapi/v16/test/request/generate-response.ts +++ b/types/hapi/test/request/generate-response.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#requestgenerateresponsesource-options -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; // Added in addition to code from docs function promiseMethod() { diff --git a/types/hapi/test/request/get-log.ts b/types/hapi/test/request/get-log.ts index 007d396fe5..289bdd3282 100644 --- a/types/hapi/test/request/get-log.ts +++ b/types/hapi/test/request/get-log.ts @@ -1,29 +1,12 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-requestlogtags-data -import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; -const options: ServerOptions = { - port: 8000, -}; +// From https://hapijs.com/api/16.1.1#requestgetlogtags-internal -const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { - request.log(['test', 'error'], 'Test event'); - return 'path: ' + request.path; -}; +import * as Hapi from 'hapi'; -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: handler -}; +var request: Hapi.Request = {}; -const server = new Server(options); -server.route(serverRoute); -server.start(); -console.log('Server started at: ' + server.info.uri); - -server.events.on('request', (request: Request, event: any, tags: any) => { - console.log(tags); - if (tags.error) { - console.log(event); - } -}); +request.getLog(); +request.getLog('error'); +request.getLog(['error', 'auth']); +request.getLog(['error'], true); +request.getLog(false); diff --git a/types/hapi/v16/test/request/log.ts b/types/hapi/test/request/log.ts similarity index 93% rename from types/hapi/v16/test/request/log.ts rename to types/hapi/test/request/log.ts index f9b044eafc..1c2da1f3b0 100644 --- a/types/hapi/v16/test/request/log.ts +++ b/types/hapi/test/request/log.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#requestlogtags-data-timestamp -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80, routes: { log: true, security: false } }); diff --git a/types/hapi/test/request/parameters.ts b/types/hapi/test/request/parameters.ts deleted file mode 100644 index 43259ea4fb..0000000000 --- a/types/hapi/test/request/parameters.ts +++ /dev/null @@ -1,38 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-requestparams -import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; - -// Example 1 -// http://localhost:8000/album-name/song-optional -const getAlbum: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { - console.log(request.params); - return 'ok: ' + request.path; -} -const serverRoute1: ServerRoute = { - path: '/{album}/{song?}', - method: 'GET', - handler: getAlbum -} - -// Example 2 -// http://localhost:8000/person/rafael/fijalkowski -const getPerson: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { - const nameParts = request.params.name.split('/'); - return { first: nameParts[0], last: nameParts[1] }; -} -const serverRoute2: ServerRoute = { - path: '/person/{name*2}', - method: 'GET', - handler: getPerson -} - - -const server = new Server(options); -server.route(serverRoute1); -server.route(serverRoute2); - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/test/request/query.ts b/types/hapi/test/request/query.ts index b5a950e2ad..c6507c2da0 100644 --- a/types/hapi/test/request/query.ts +++ b/types/hapi/test/request/query.ts @@ -1,27 +1,14 @@ // Added test in addition to docs, for request.query -import {Lifecycle, Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; -const options: ServerOptions = { - port: 8000, -}; - -const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { - const query = request.query as GetThingQuery; - // http://localhost:8000/?name=test - return `You asked for ${query.name}` -}; - -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: handler -}; +import * as Hapi from 'hapi'; interface GetThingQuery { name: string; } -const server = new Server(options); -server.route(serverRoute); -server.start(); -console.log('Server started at: ' + server.info.uri); +const handler: Hapi.RouteHandler = function (request, reply) { + + const query = request.query as GetThingQuery; + + return reply(`You asked for ${query.name}`); +}; diff --git a/types/hapi/v16/test/request/set-method.ts b/types/hapi/test/request/set-method.ts similarity index 91% rename from types/hapi/v16/test/request/set-method.ts rename to types/hapi/test/request/set-method.ts index aa78eeaecf..7269e6255f 100644 --- a/types/hapi/v16/test/request/set-method.ts +++ b/types/hapi/test/request/set-method.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#requestsetmethodmethod -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/request/set-url.ts b/types/hapi/test/request/set-url.ts similarity index 90% rename from types/hapi/v16/test/request/set-url.ts rename to types/hapi/test/request/set-url.ts index 1c3a0a047b..4add3c5a17 100644 --- a/types/hapi/v16/test/request/set-url.ts +++ b/types/hapi/test/request/set-url.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#requestseturlurl-striptrailingslash -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); @@ -17,7 +17,7 @@ server.ext('onRequest', onRequest); // Example 2 const Url = require('url'); -const Qs = require('../../../../qs'); +const Qs = require('qs'); onRequest = function (request, reply) { diff --git a/types/hapi/v16/test/request/tail.ts b/types/hapi/test/request/tail.ts similarity index 94% rename from types/hapi/v16/test/request/tail.ts rename to types/hapi/test/request/tail.ts index 426c0cd835..9c68ccb8f2 100644 --- a/types/hapi/v16/test/request/tail.ts +++ b/types/hapi/test/request/tail.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#requestsetmethodmethod -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/test/response/continue.ts b/types/hapi/test/response/continue.ts deleted file mode 100644 index 4839b4b6e2..0000000000 --- a/types/hapi/test/response/continue.ts +++ /dev/null @@ -1,25 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverextevent-method-options -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; - -const serverRoute: ServerRoute = { - path: '/test', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - } -}; - -const server = new Server(options); -server.route(serverRoute); - -server.ext("onRequest", (request: Request, h: ResponseToolkit) => { - request.setUrl('/test'); - return h.continue; -}); - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v16/test/response/error-representation.ts b/types/hapi/test/response/error-representation.ts similarity index 84% rename from types/hapi/v16/test/response/error-representation.ts rename to types/hapi/test/response/error-representation.ts index 7eacfdfaf3..f0fb62eb30 100644 --- a/types/hapi/v16/test/response/error-representation.ts +++ b/types/hapi/test/response/error-representation.ts @@ -1,13 +1,13 @@ // From https://hapijs.com/api/16.1.1#error-transformation -import * as Hapi from '../../'; -import Vision from '../../../../vision'; +import * as Hapi from 'hapi'; +import Vision from 'vision'; const server = new Hapi.Server(); server.register(Vision, {}, (err) => { server.views({ engines: { - html: require('../../../../handlebars') + html: require('handlebars') } }); }); diff --git a/types/hapi/test/response/error.ts b/types/hapi/test/response/error.ts index 6cc92acbdb..0ef503df12 100644 --- a/types/hapi/test/response/error.ts +++ b/types/hapi/test/response/error.ts @@ -1,31 +1,25 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#errors -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; -import * as Boom from "boom"; -const options: ServerOptions = { - port: 8000, -}; +// From https://hapijs.com/api/16.1.1#error-response -const serverRoutes: ServerRoute[] = [ - { - path: '/badRequest', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - throw Boom.badRequest('Unsupported parameter'); - } - }, - { - path: '/internal', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - throw new Error('unexpect error'); - } - }, -]; +import * as Hapi from 'hapi'; +const Boom = require('boom'); +const server = new Hapi.Server(); -const server = new Server(options); -server.route(serverRoutes); +server.route({ + method: 'GET', + path: '/badRequest', + handler: function (request, reply) { -server.start(); -console.log('Server started at: ' + server.info.uri); + return reply(Boom.badRequest('Unsupported parameter')); + } +}); + +server.route({ + method: 'GET', + path: '/internal', + handler: function (request, reply) { + + return reply(new Error('unexpect error')); + } +}); diff --git a/types/hapi/v16/test/response/events.ts b/types/hapi/test/response/events.ts similarity index 95% rename from types/hapi/v16/test/response/events.ts rename to types/hapi/test/response/events.ts index 07d4e0a65b..2d1658087b 100644 --- a/types/hapi/v16/test/response/events.ts +++ b/types/hapi/test/response/events.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#response-events -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const Crypto = require('crypto'); const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/response/flow-control.ts b/types/hapi/test/response/flow-control.ts similarity index 88% rename from types/hapi/v16/test/response/flow-control.ts rename to types/hapi/test/response/flow-control.ts index 321d198825..bc18a36aff 100644 --- a/types/hapi/v16/test/response/flow-control.ts +++ b/types/hapi/test/response/flow-control.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#flow-control -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const handler = function (request: Hapi.Request, reply: Hapi.ReplyWithContinue) { diff --git a/types/hapi/test/response/redirect.ts b/types/hapi/test/response/redirect.ts deleted file mode 100644 index 3cb6addba7..0000000000 --- a/types/hapi/test/response/redirect.ts +++ /dev/null @@ -1,20 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-hredirecturi -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; - -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return h.redirect('http://example.com'); - } -} - -const server = new Server(options); -server.route(serverRoute); - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/test/response/response-events.ts b/types/hapi/test/response/response-events.ts deleted file mode 100644 index 06c6d6bfa8..0000000000 --- a/types/hapi/test/response/response-events.ts +++ /dev/null @@ -1,28 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-responseevents -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute, ResponseObject} from "hapi"; -import * as Crypto from "crypto"; - -const preResponse = (request: Request, h: ResponseToolkit) => { - - const response:ResponseObject = request.response; - - const hash = Crypto.createHash('sha1'); - response.events.on('peek', (chunk:any) => { - hash.update(chunk); - }); - - response.events.once('finish', () => { - console.log(hash.digest('hex')); - }); - - return h.continue; -}; - -const server = new Server({ - port: 8000, -}); - -server.ext('onPreResponse', preResponse); - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/test/response/response.ts b/types/hapi/test/response/response.ts deleted file mode 100644 index 66b11b352f..0000000000 --- a/types/hapi/test/response/response.ts +++ /dev/null @@ -1,37 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-hresponsevalue -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; - -const serverRoutes: ServerRoute[] = [ - // Detailed notation - { - path: '/test1', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - const response = h.response('success'); - response.type('text/plain'); - response.header('X-Custom', 'some-value'); - return response; - } - }, - // Chained notation - { - path: '/test2', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return h.response('success') - .type('text/plain') - .header('X-Custom', 'some-value'); - } - }, -]; - - -const server = new Server(options); -server.route(serverRoutes); - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/test/route/adding-routes.ts b/types/hapi/test/route/adding-routes.ts deleted file mode 100644 index 8136c6508b..0000000000 --- a/types/hapi/test/route/adding-routes.ts +++ /dev/null @@ -1,38 +0,0 @@ -// from https://hapijs.com/tutorials/getting-started#adding-routes -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; - -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - } -}; - -const serverRoutes: ServerRoute[] = [ - { - path: '/test1', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - } - }, - { - path: '/test2', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - } - }, -]; - -const server = new Server(options); -server.route(serverRoute); -server.route(serverRoutes); - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/v16/test/route/additional-options.ts b/types/hapi/test/route/additional-options.ts similarity index 98% rename from types/hapi/v16/test/route/additional-options.ts rename to types/hapi/test/route/additional-options.ts index ccbb36af15..189dc488de 100644 --- a/types/hapi/v16/test/route/additional-options.ts +++ b/types/hapi/test/route/additional-options.ts @@ -1,6 +1,6 @@ 'use strict'; -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; var authConfig: Hapi.RouteAdditionalConfigurationOptions = { app: {}, diff --git a/types/hapi/v16/test/route/auth.ts b/types/hapi/test/route/auth.ts similarity index 94% rename from types/hapi/v16/test/route/auth.ts rename to types/hapi/test/route/auth.ts index e8d41cf47d..e5239322da 100644 --- a/types/hapi/v16/test/route/auth.ts +++ b/types/hapi/test/route/auth.ts @@ -1,6 +1,6 @@ 'use strict'; -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; var routeMoreConfig: Hapi.RouteAdditionalConfigurationOptions = { auth: false, diff --git a/types/hapi/test/route/config.ts b/types/hapi/test/route/config.ts index 1f36cd51b3..16457395f8 100644 --- a/types/hapi/test/route/config.ts +++ b/types/hapi/test/route/config.ts @@ -1,52 +1,46 @@ -import {Request, ResponseToolkit, RouteOptions, Server, ServerOptions, ServerRoute} from "hapi"; +'use strict'; -const options: ServerOptions = { - port: 8000, -}; +import * as Hapi from 'hapi'; // different methods -var routeConfig: ServerRoute = { +var routeConfig: Hapi.RouteConfiguration = { path: '/signin', method: 'PUT', vhost: 'site.coms', }; -var routeConfig: ServerRoute = { +var routeConfig: Hapi.RouteConfiguration = { path: '/signin', method: '*' }; -var routeConfig: ServerRoute = { +var routeConfig: Hapi.RouteConfiguration = { path: '/signin', method: ['OPTIONS', '*'] }; // different handlers -var routeConfig: ServerRoute = { +var routeConfig: Hapi.RouteConfiguration = { path: '/signin', method: 'PUT', - handler: (request: Request, h: ResponseToolkit) => { - return 'ok'; - } + handler: 'some registered handler' }; -var routeConfig: ServerRoute = { +var routeConfig: Hapi.RouteConfiguration = { path: '/signin', method: 'PUT', - handler: (request: Request, h: ResponseToolkit) => { - return 'ok'; + handler: function (request, reply) { + return reply('ok'); } }; -const server = new Server(options); +const server = new Hapi.Server(); server.route(routeConfig); // Handler in config -const user: RouteOptions = { +const user: Hapi.RouteAdditionalConfigurationOptions = { cache: { expiresIn: 5000 }, - handler: (request: Request, h: ResponseToolkit) => { - return { name: 'John' }; + handler: function (request, reply) { + + return reply({ name: 'John' }); } }; -server.route({method: 'GET', path: '/user', options: user }); - -server.start(); -console.log('Server started at: ' + server.info.uri); +server.route({method: 'GET', path: '/user', config: user }); diff --git a/types/hapi/test/route/handler.ts b/types/hapi/test/route/handler.ts index e3bea54939..c66d17018e 100644 --- a/types/hapi/test/route/handler.ts +++ b/types/hapi/test/route/handler.ts @@ -1,9 +1,10 @@ -import {Lifecycle, Request, ResponseToolkit} from "hapi"; +'use strict'; -const handler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { - return 'success'; -} +import * as Hapi from 'hapi'; -const strictHandler: Lifecycle.Method = (request: Request, h: ResponseToolkit) => { - return 123; +var handler: Hapi.RouteHandler = function(request, reply) { + reply('success'); +} +var strictHandler: Hapi.RouteHandler = function(request, reply) { + reply(123); } diff --git a/types/hapi/v16/test/route/plugins.ts b/types/hapi/test/route/plugins.ts similarity index 92% rename from types/hapi/v16/test/route/plugins.ts rename to types/hapi/test/route/plugins.ts index ba7abdb777..2449fc84c0 100644 --- a/types/hapi/v16/test/route/plugins.ts +++ b/types/hapi/test/route/plugins.ts @@ -1,9 +1,9 @@ // Added in addition to code from https://hapijs.com/api/16.1.1#route-options > plugins -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; // In the plugin code -declare module '../../' { +declare module 'hapi' { interface PluginSpecificConfiguration { coolPlugin: { optionA: string; diff --git a/types/hapi/v16/test/route/prerequisites.ts b/types/hapi/test/route/prerequisites.ts similarity index 97% rename from types/hapi/v16/test/route/prerequisites.ts rename to types/hapi/test/route/prerequisites.ts index 15a16af2c0..c4ca7650fa 100644 --- a/types/hapi/v16/test/route/prerequisites.ts +++ b/types/hapi/test/route/prerequisites.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#route-prerequisites -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/route/public-interface.ts b/types/hapi/test/route/public-interface.ts similarity index 93% rename from types/hapi/v16/test/route/public-interface.ts rename to types/hapi/test/route/public-interface.ts index f3878cea48..e61fb8275f 100644 --- a/types/hapi/v16/test/route/public-interface.ts +++ b/types/hapi/test/route/public-interface.ts @@ -1,6 +1,6 @@ 'use strict'; -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; var route = {}; diff --git a/types/hapi/test/route/route-options-pre.ts b/types/hapi/test/route/route-options-pre.ts deleted file mode 100644 index fedfab4c45..0000000000 --- a/types/hapi/test/route/route-options-pre.ts +++ /dev/null @@ -1,42 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-routeoptionspre -import {Server, Request, ResponseToolkit} from "hapi"; - -const server = new Server({ - port: 8000, -}); - -const pre1 = (request: Request, h: ResponseToolkit) => { - return 'Hello'; -}; - -const pre2 = (request: Request, h: ResponseToolkit) => { - return 'World'; -}; - -const pre3 = (request: Request, h: ResponseToolkit) => { - return request.pre.m1 + ' ' + request.pre.m2; -}; - -server.route({ - method: 'GET', - path: '/', - config: { - pre: [ - [ - // m1 and m2 executed in parallel - { method: pre1, assign: 'm1' }, - { method: pre2, assign: 'm2' } - ], - { method: pre3, assign: 'm3' }, - ], - handler: (request: Request, h: ResponseToolkit) => { - return request.pre.m3 + '!\n'; - } - } -}); - -server.start(); - -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); -}); diff --git a/types/hapi/test/route/route-options.ts b/types/hapi/test/route/route-options.ts deleted file mode 100644 index 5e2506684f..0000000000 --- a/types/hapi/test/route/route-options.ts +++ /dev/null @@ -1,167 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#route-options -import { - EmptyStatusCode, - Request, - ResponseToolkit, - RouteOptions, - RouteOptionsAccess, - RouteOptionsAccessEntity, - RouteOptionsAccessMode, - RouteOptionsAccessPayload, - RouteOptionsCors, - RouteOptionsPayload, - RouteOptionsResponse, - RouteOptionsValidate, - Server -} from "hapi"; - -const routeOptionsAccess: RouteOptionsAccess = { - access: {}, - scope: false, - entity: RouteOptionsAccessEntity.User, - mode: RouteOptionsAccessMode.Optional, - payload: RouteOptionsAccessPayload.Optional, - strategies: ['', ''], - strategy: '' -}; - -const corsOption: RouteOptionsCors = { - origin: 'ignore', - maxAge: 5000, - headers: ['test', 'test', 'test'], - additionalHeaders: ['test', 'test', 'test'], - exposedHeaders: ['test', 'test', 'test'], - additionalExposedHeaders: ['test', 'test', 'test'], - credentials: false -}; - -const payloadOptions: RouteOptionsPayload = { - allow: 'string', - compression: { - test1: { - test: 2 - } - }, - defaultContentType: 'application/json', - failAction: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - }, - maxBytes: 1048576, - multipart: { - output: 'annotated' - }, - output: 'stream', - override: '', - parse: 'gunzip', - timeout: 5000, - uploads: 'dir/' -}; - -const pre1 = (request: Request, h: ResponseToolkit) => { - return 'Hello'; -}; - -const pre2 = (request: Request, h: ResponseToolkit) => { - return 'World'; -}; - -const pre3 = (request: Request, h: ResponseToolkit) => { - return request.pre.m1 + ' ' + request.pre.m2; -}; - -const routeOptionsResponse:RouteOptionsResponse = { - emptyStatusCode: EmptyStatusCode.HTTP_200, - failAction: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - }, - modify: false, - options: null, - ranges: true, - sample: 100, - schema: true, - status: { - '200': true, - '302': true, - '404': false, - } -}; - -const routeOptionsValidate: RouteOptionsValidate = { - errorFields: {}, - failAction: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - }, - headers: false, - options: {}, - params: false, - payload: true, - query: true, -}; - -const routeOptions: RouteOptions = { - - app: {}, - auth: routeOptionsAccess, - bind: null, - cache: { - privacy: 'default', - statuses: [200], - otherwise: 'no-cache' - }, - compression: { - test1: { - test: 2 - } - }, - cors: corsOption, - description: 'description here', - ext: null, - files: { relativeTo: '.' }, - handler: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - }, - id: 'test', - isInternal: false, - json: null, - jsonp: 'callback', - log: { collect: false }, - notes: ['test', 'test', 'test'], - payload: payloadOptions, - plugins: { - plugin1: {}, - plugin2: {}, - }, - pre: [ - [ - // m1 and m2 executed in parallel - { method: pre1, assign: 'm1' }, - { method: pre2, assign: 'm2' } - ], - { method: pre3, assign: 'm3' }, - ], - response: routeOptionsResponse, - security: false, - state: { - parse: true, - failAction: (request: Request, h: ResponseToolkit) => { - return 'ok: ' + request.path; - }, - }, - tags: ['test', 'test', 'test'], - timeout: { - server: 10000, - socket: false - }, - validate: routeOptionsValidate - -}; - -const server = new Server({ - port: 8000, - routes: routeOptions -}); -server.start(); - -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); -}); diff --git a/types/hapi/v16/test/route/validate.ts b/types/hapi/test/route/validate.ts similarity index 96% rename from types/hapi/v16/test/route/validate.ts rename to types/hapi/test/route/validate.ts index 06fefcc62e..cb5c5527ee 100644 --- a/types/hapi/v16/test/route/validate.ts +++ b/types/hapi/test/route/validate.ts @@ -1,8 +1,8 @@ // Added from: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/16065#issuecomment-302216131 -import * as Hapi from '../../'; -import * as Joi from '../../../../joi'; +import * as Hapi from 'hapi'; +import * as Joi from 'joi'; const validate: Hapi.RouteValidationConfigurationObject = { headers: true, diff --git a/types/hapi/v16/test/server/app.ts b/types/hapi/test/server/app.ts similarity index 87% rename from types/hapi/v16/test/server/app.ts rename to types/hapi/test/server/app.ts index 7ed57fe6e8..dac8921c20 100644 --- a/types/hapi/v16/test/server/app.ts +++ b/types/hapi/test/server/app.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverapp -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; var server = new Hapi.Server(); server.app.key = 'value'; diff --git a/types/hapi/v16/test/server/auth.ts b/types/hapi/test/server/auth.ts similarity index 96% rename from types/hapi/v16/test/server/auth.ts rename to types/hapi/test/server/auth.ts index c699a63c1b..3f28732d42 100644 --- a/types/hapi/v16/test/server/auth.ts +++ b/types/hapi/test/server/auth.ts @@ -1,8 +1,8 @@ // From https://hapijs.com/api/16.1.1#serverauthapi -import * as Hapi from '../../'; -import * as Boom from '../../../../boom'; +import * as Hapi from 'hapi'; +import * as Boom from 'boom'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/bind.ts b/types/hapi/test/server/bind.ts similarity index 93% rename from types/hapi/v16/test/server/bind.ts rename to types/hapi/test/server/bind.ts index c8e0ba0016..2741e16c82 100644 --- a/types/hapi/v16/test/server/bind.ts +++ b/types/hapi/test/server/bind.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverbindcontext -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; interface HandlerThis { message: string; diff --git a/types/hapi/v16/test/server/cache.ts b/types/hapi/test/server/cache.ts similarity index 96% rename from types/hapi/v16/test/server/cache.ts rename to types/hapi/test/server/cache.ts index 18d7cbbd3a..4cb9eaa4b7 100644 --- a/types/hapi/v16/test/server/cache.ts +++ b/types/hapi/test/server/cache.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servercacheoptions -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/connection-options.ts b/types/hapi/test/server/connection-options.ts similarity index 96% rename from types/hapi/v16/test/server/connection-options.ts rename to types/hapi/test/server/connection-options.ts index e4b5582598..3a526307db 100644 --- a/types/hapi/v16/test/server/connection-options.ts +++ b/types/hapi/test/server/connection-options.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverconnectionoptions -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); const web = server.connection({ port: 8000, host: 'example.com', labels: ['web'] }); diff --git a/types/hapi/v16/test/server/connections.ts b/types/hapi/test/server/connections.ts similarity index 89% rename from types/hapi/v16/test/server/connections.ts rename to types/hapi/test/server/connections.ts index 0674c3b72f..fb2f9f303e 100644 --- a/types/hapi/v16/test/server/connections.ts +++ b/types/hapi/test/server/connections.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverconnections -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; var server = new Hapi.Server(); server.connection({ port: 80, labels: 'a' }); server.connection({ port: 8080, labels: 'b' }); diff --git a/types/hapi/v16/test/server/decoder.ts b/types/hapi/test/server/decoder.ts similarity index 90% rename from types/hapi/v16/test/server/decoder.ts rename to types/hapi/test/server/decoder.ts index 7a9eadd1e6..edd52485ea 100644 --- a/types/hapi/v16/test/server/decoder.ts +++ b/types/hapi/test/server/decoder.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; import * as Zlib from 'zlib'; const server = new Hapi.Server(); server.connection({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } }); diff --git a/types/hapi/v16/test/server/decorate.ts b/types/hapi/test/server/decorate.ts similarity index 92% rename from types/hapi/v16/test/server/decorate.ts rename to types/hapi/test/server/decorate.ts index d946f6132e..540e29c951 100644 --- a/types/hapi/v16/test/server/decorate.ts +++ b/types/hapi/test/server/decorate.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverdecoratetype-property-method-options -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); @@ -12,7 +12,7 @@ const success = function (this: Hapi.ReplyNoContinue) { server.decorate('reply', 'success', success); -declare module '../../' { +declare module 'hapi' { interface Base_Reply { success: () => Response; } @@ -36,7 +36,7 @@ server.decorate('request', 'some_request_method', (request) => { } }, {apply: true}); -declare module '../../' { +declare module 'hapi' { interface Request { some_request_method(): void; } @@ -59,7 +59,7 @@ server.decorate('server', 'some_server_method', (server: Hapi.Server) => { } }); -declare module '../../' { +declare module 'hapi' { interface Server { some_server_method(arg1: number): string; } diff --git a/types/hapi/v16/test/server/dependency.ts b/types/hapi/test/server/dependency.ts similarity index 93% rename from types/hapi/v16/test/server/dependency.ts rename to types/hapi/test/server/dependency.ts index 175b3242b9..1d63397cf2 100644 --- a/types/hapi/v16/test/server/dependency.ts +++ b/types/hapi/test/server/dependency.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverdependencydependencies-after -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const after: Hapi.AfterDependencyLoadCallback = function (server, next) { diff --git a/types/hapi/v16/test/server/emit.ts b/types/hapi/test/server/emit.ts similarity index 90% rename from types/hapi/v16/test/server/emit.ts rename to types/hapi/test/server/emit.ts index 0f1f37de2d..d248f7d4ab 100644 --- a/types/hapi/v16/test/server/emit.ts +++ b/types/hapi/test/server/emit.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serveremitcriteria-data-callback -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/encoder.ts b/types/hapi/test/server/encoder.ts similarity index 90% rename from types/hapi/v16/test/server/encoder.ts rename to types/hapi/test/server/encoder.ts index cacc5f2c8b..f35102b776 100644 --- a/types/hapi/v16/test/server/encoder.ts +++ b/types/hapi/test/server/encoder.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverencoderencoding-encoder -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; import * as Zlib from 'zlib'; const server = new Hapi.Server(); server.connection({ port: 80, routes: { compression: { special: { chunkSize: 16 * 1024 } } } }); diff --git a/types/hapi/v16/test/server/event.ts b/types/hapi/test/server/event.ts similarity index 90% rename from types/hapi/v16/test/server/event.ts rename to types/hapi/test/server/event.ts index cbe7128de3..f0c2215f12 100644 --- a/types/hapi/v16/test/server/event.ts +++ b/types/hapi/test/server/event.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servereventevents -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/expose.ts b/types/hapi/test/server/expose.ts similarity index 92% rename from types/hapi/v16/test/server/expose.ts rename to types/hapi/test/server/expose.ts index abaade677c..effbc1ae49 100644 --- a/types/hapi/v16/test/server/expose.ts +++ b/types/hapi/test/server/expose.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverexposekey-value -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; var register: Hapi.PluginFunction<{}> = function (server, options, next) { server.expose('util', function () { console.log('something'); }); diff --git a/types/hapi/v16/test/server/ext.ts b/types/hapi/test/server/ext.ts similarity index 96% rename from types/hapi/v16/test/server/ext.ts rename to types/hapi/test/server/ext.ts index 318fe3fe0b..500ac1d4af 100644 --- a/types/hapi/v16/test/server/ext.ts +++ b/types/hapi/test/server/ext.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverextevents -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/handler.ts b/types/hapi/test/server/handler.ts similarity index 94% rename from types/hapi/v16/test/server/handler.ts rename to types/hapi/test/server/handler.ts index 20fb003ce4..713fe7f114 100644 --- a/types/hapi/v16/test/server/handler.ts +++ b/types/hapi/test/server/handler.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverhandlername-method -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ host: 'localhost', port: 8000 }); @@ -20,7 +20,7 @@ interface TestPluginConfig { msg: string; } -declare module '../../' { +declare module 'hapi' { interface RouteHandlerPlugins { test?: TestPluginConfig; } diff --git a/types/hapi/v16/test/server/info.ts b/types/hapi/test/server/info.ts similarity index 92% rename from types/hapi/v16/test/server/info.ts rename to types/hapi/test/server/info.ts index aa0bc7014d..eaf1b39747 100644 --- a/types/hapi/v16/test/server/info.ts +++ b/types/hapi/test/server/info.ts @@ -2,7 +2,7 @@ // From https://hapijs.com/api/16.1.1#serverinfo import assert = require('assert'); -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); var options: Hapi.ServerConnectionOptions = { port: 80 }; server.connection(options); diff --git a/types/hapi/v16/test/server/initialize.ts b/types/hapi/test/server/initialize.ts similarity index 72% rename from types/hapi/v16/test/server/initialize.ts rename to types/hapi/test/server/initialize.ts index f7a1482fac..7ef4b51527 100644 --- a/types/hapi/v16/test/server/initialize.ts +++ b/types/hapi/test/server/initialize.ts @@ -1,8 +1,8 @@ // From https://hapijs.com/api/16.1.1#serverinitializecallback -import * as Hapi from '../../'; -const Hoek = require('../../../../hoek'); +import * as Hapi from 'hapi'; +const Hoek = require('hoek'); const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/inject.ts b/types/hapi/test/server/inject.ts similarity index 93% rename from types/hapi/v16/test/server/inject.ts rename to types/hapi/test/server/inject.ts index a9fc0bdf5e..7010faa3dc 100644 --- a/types/hapi/v16/test/server/inject.ts +++ b/types/hapi/test/server/inject.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverinjectoptions-callback -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/listener.ts b/types/hapi/test/server/listener.ts similarity index 95% rename from types/hapi/v16/test/server/listener.ts rename to types/hapi/test/server/listener.ts index 85ddb18bc6..d7bb6fc5ea 100644 --- a/types/hapi/v16/test/server/listener.ts +++ b/types/hapi/test/server/listener.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverlistener -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; import SocketIO = require('socket.io'); const server = new Hapi.Server(); diff --git a/types/hapi/v16/test/server/load.ts b/types/hapi/test/server/load.ts similarity index 82% rename from types/hapi/v16/test/server/load.ts rename to types/hapi/test/server/load.ts index 7ecb25fce7..ee204c864f 100644 --- a/types/hapi/v16/test/server/load.ts +++ b/types/hapi/test/server/load.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverload -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server({ load: { sampleInterval: 1000 } }); var d: number = server.load.rss; diff --git a/types/hapi/v16/test/server/log.ts b/types/hapi/test/server/log.ts similarity index 89% rename from types/hapi/v16/test/server/log.ts rename to types/hapi/test/server/log.ts index 1a89b2149b..4507358d60 100644 --- a/types/hapi/v16/test/server/log.ts +++ b/types/hapi/test/server/log.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverlogtags-data-timestamp -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/lookup.ts b/types/hapi/test/server/lookup.ts similarity index 91% rename from types/hapi/v16/test/server/lookup.ts rename to types/hapi/test/server/lookup.ts index 2d3729b210..89ce852700 100644 --- a/types/hapi/v16/test/server/lookup.ts +++ b/types/hapi/test/server/lookup.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverlookupid -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection(); server.route({ diff --git a/types/hapi/v16/test/server/match.ts b/types/hapi/test/server/match.ts similarity index 91% rename from types/hapi/v16/test/server/match.ts rename to types/hapi/test/server/match.ts index f446dd0e7e..f322a31494 100644 --- a/types/hapi/v16/test/server/match.ts +++ b/types/hapi/test/server/match.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servermatchmethod-path-host -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection(); server.route({ diff --git a/types/hapi/v16/test/server/method.ts b/types/hapi/test/server/method.ts similarity index 98% rename from types/hapi/v16/test/server/method.ts rename to types/hapi/test/server/method.ts index 9e3efbf7c7..e1cc2ce487 100644 --- a/types/hapi/v16/test/server/method.ts +++ b/types/hapi/test/server/method.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servermethodname-method-options -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/methods.ts b/types/hapi/test/server/methods.ts similarity index 91% rename from types/hapi/v16/test/server/methods.ts rename to types/hapi/test/server/methods.ts index 0595d522de..1e2060c3e8 100644 --- a/types/hapi/v16/test/server/methods.ts +++ b/types/hapi/test/server/methods.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servermethods -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); const add = function (a: number, b: number, next: (err: Error | null, result: number) => void) { diff --git a/types/hapi/v16/test/server/mime.ts b/types/hapi/test/server/mime.ts similarity index 94% rename from types/hapi/v16/test/server/mime.ts rename to types/hapi/test/server/mime.ts index a97af5de7a..e2dd25529b 100644 --- a/types/hapi/v16/test/server/mime.ts +++ b/types/hapi/test/server/mime.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servermime -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const options: Hapi.ServerOptions = { mime: { diff --git a/types/hapi/v16/test/server/new.ts b/types/hapi/test/server/new.ts similarity index 96% rename from types/hapi/v16/test/server/new.ts rename to types/hapi/test/server/new.ts index 59f0a8f189..95f1ce9006 100644 --- a/types/hapi/v16/test/server/new.ts +++ b/types/hapi/test/server/new.ts @@ -1,6 +1,6 @@ 'use strict'; -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; new Hapi.Server(); new Hapi.Server({ @@ -45,7 +45,7 @@ new Hapi.Server({ }); //+ Code added in addition to docs -declare module '../../' { +declare module 'hapi' { interface PluginSpecificConfiguration { // Set this to non optional if plugin config is non optional 'some-plugin-name'?: {options: string;}; diff --git a/types/hapi/v16/test/server/on.ts b/types/hapi/test/server/on.ts similarity index 96% rename from types/hapi/v16/test/server/on.ts rename to types/hapi/test/server/on.ts index 301cc0b423..08802fda96 100644 --- a/types/hapi/v16/test/server/on.ts +++ b/types/hapi/test/server/on.ts @@ -2,7 +2,7 @@ // From https://hapijs.com/api/16.1.1#serveroncriteria-listener // From https://hapijs.com/api/16.1.1#server-events -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/once.ts b/types/hapi/test/server/once.ts similarity index 91% rename from types/hapi/v16/test/server/once.ts rename to types/hapi/test/server/once.ts index 59465a41ec..55fdb08ec2 100644 --- a/types/hapi/v16/test/server/once.ts +++ b/types/hapi/test/server/once.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serveroncecriteria-listener -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/path.ts b/types/hapi/test/server/path.ts similarity index 91% rename from types/hapi/v16/test/server/path.ts rename to types/hapi/test/server/path.ts index cdbf8a14a9..20479a795f 100644 --- a/types/hapi/v16/test/server/path.ts +++ b/types/hapi/test/server/path.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverpathrelativeto -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; var register: Hapi.PluginFunction<{}> = function (server, options, next) { diff --git a/types/hapi/v16/test/server/plugins.ts b/types/hapi/test/server/plugins.ts similarity index 90% rename from types/hapi/v16/test/server/plugins.ts rename to types/hapi/test/server/plugins.ts index 02488a1d5a..2ce13ffb2f 100644 --- a/types/hapi/v16/test/server/plugins.ts +++ b/types/hapi/test/server/plugins.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverplugins -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; var registerFunction: Hapi.PluginFunction<{}> = function(server, options, next) { diff --git a/types/hapi/v16/test/server/realm.ts b/types/hapi/test/server/realm.ts similarity index 86% rename from types/hapi/v16/test/server/realm.ts rename to types/hapi/test/server/realm.ts index 4a2eceffd0..31f764b7ef 100644 --- a/types/hapi/v16/test/server/realm.ts +++ b/types/hapi/test/server/realm.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverrealm -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; var registerFunction: Hapi.PluginFunction<{}> = function(server, options, next) { diff --git a/types/hapi/v16/test/server/register.ts b/types/hapi/test/server/register.ts similarity index 90% rename from types/hapi/v16/test/server/register.ts rename to types/hapi/test/server/register.ts index 1d0ab5a2e7..c04e0b16bc 100644 --- a/types/hapi/v16/test/server/register.ts +++ b/types/hapi/test/server/register.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); diff --git a/types/hapi/v16/test/server/route.ts b/types/hapi/test/server/route.ts similarity index 93% rename from types/hapi/v16/test/server/route.ts rename to types/hapi/test/server/route.ts index 0fa9fd8cc8..0402fd3e89 100644 --- a/types/hapi/v16/test/server/route.ts +++ b/types/hapi/test/server/route.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverrouteoptions -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/select.ts b/types/hapi/test/server/select.ts similarity index 91% rename from types/hapi/v16/test/server/select.ts rename to types/hapi/test/server/select.ts index 03af599fcc..8a25f45abd 100644 --- a/types/hapi/v16/test/server/select.ts +++ b/types/hapi/test/server/select.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverselectlabels -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80, labels: ['a', 'b'] }); server.connection({ port: 8080, labels: ['a', 'c'] }); diff --git a/types/hapi/test/server/server-app.ts b/types/hapi/test/server/server-app.ts deleted file mode 100644 index b70a83c301..0000000000 --- a/types/hapi/test/server/server-app.ts +++ /dev/null @@ -1,22 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverapp -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; - -const server = new Server(options); -server.app.key = 'value2'; - -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return 'key: ' + request.server.app.key; - } -} - -server.route(serverRoute); - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/test/server/server-auth-api.ts b/types/hapi/test/server/server-auth-api.ts deleted file mode 100644 index 9f2bc5da3b..0000000000 --- a/types/hapi/test/server/server-auth-api.ts +++ /dev/null @@ -1,40 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthapi -import { - Request, - ResponseToolkit, - Server, - ServerAuthScheme, - ServerAuthSchemeObject, - ServerAuthSchemeOptions -} from "hapi"; -import * as Boom from "boom"; - -const scheme:ServerAuthScheme = (server:Server, options:ServerAuthSchemeOptions): ServerAuthSchemeObject => { - - return { - api: { - settings: { - x: 5 - } - }, - authenticate: (request: Request, h: ResponseToolkit) => { - - const authorization = request.headers.authorization; - if (!authorization) { - throw Boom.unauthorized(null, 'Custom'); - } - - return h.authenticated({ credentials: { user: 'john' } }); - } - }; - -}; - -const server = new Server({ - port: 8000, -}); -server.auth.scheme('custom', scheme); -server.auth.strategy('default', 'custom'); -server.start(); - -console.log(server.auth.api.default.settings.x); // 5 diff --git a/types/hapi/test/server/server-auth-default.ts b/types/hapi/test/server/server-auth-default.ts deleted file mode 100644 index 3287da5ab8..0000000000 --- a/types/hapi/test/server/server-auth-default.ts +++ /dev/null @@ -1,35 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthdefaultoptions -// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme -import {Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions} from "hapi"; -import * as Boom from "boom"; - -const server = new Server({ - port: 8000, -}); - -const scheme:ServerAuthScheme = (server:Server, options:ServerAuthSchemeOptions) => { - return { - authenticate: (request:Request, h:ResponseToolkit) => { - const req = request.raw.req; - const authorization = req.headers.authorization; - if (!authorization) { - throw Boom.unauthorized(null, 'Custom'); - } - return h.authenticated({ credentials: { user: 'john' } }); - } - }; -}; - -server.auth.scheme('custom', scheme); -server.auth.strategy('default', 'custom'); -server.auth.default('default'); - -server.route({ - method: 'GET', - path: '/', - handler: (request:Request, h:ResponseToolkit) => { - return request.auth.credentials.user; - } -}); - -server.start(); diff --git a/types/hapi/test/server/server-auth-test.ts b/types/hapi/test/server/server-auth-test.ts deleted file mode 100644 index 668fb27994..0000000000 --- a/types/hapi/test/server/server-auth-test.ts +++ /dev/null @@ -1,40 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverauthteststrategy-request -// https://github.com/hapijs/hapi/blob/master/API.md#-serverauthschemename-scheme -import {Request, ResponseToolkit, Server, ServerAuthScheme, ServerAuthSchemeOptions} from "hapi"; -import * as Boom from "boom"; - -const server = new Server({ - port: 8000, -}); - -const scheme:ServerAuthScheme = (server:Server, options:ServerAuthSchemeOptions) => { - return { - authenticate: (request:Request, h:ResponseToolkit) => { - const req = request.raw.req; - const authorization = req.headers.authorization; - if (!authorization) { - throw Boom.unauthorized(null, 'Custom'); - } - return h.authenticated({ credentials: { user: 'john' } }); - } - }; -}; - -server.auth.scheme('custom', scheme); -server.auth.strategy('default', 'custom'); - -server.route({ - method: 'GET', - path: '/', - handler: (request:Request, h:ResponseToolkit) => { - try { - const credentials = request.server.auth.test('default', request); - return { status: true, user: credentials.name }; - } - catch (err) { - return { status: false }; - } - } -}); - -server.start(); diff --git a/types/hapi/test/server/server-bind.ts b/types/hapi/test/server/server-bind.ts deleted file mode 100644 index ebd071fb63..0000000000 --- a/types/hapi/test/server/server-bind.ts +++ /dev/null @@ -1,27 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverbindcontext -import {Plugin, Request, ResponseToolkit, Server, ServerRegisterOptions} from "hapi"; - -const server = new Server({ - port: 8000, -}); -const handler = (request:Request, h:ResponseToolkit) => { - return h.context.message; // Or h.context.message -}; - -const plugin:Plugin = { - name: 'example', - register: (server:Server, options:ServerRegisterOptions) => { - const bind = { - message: 'hello' - }; - server.bind(bind); - server.route({ method: 'GET', path: '/', handler }); - } -}; - -server.start(); -server.register(plugin); - -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); -}); diff --git a/types/hapi/test/server/server-cache-provision.ts b/types/hapi/test/server/server-cache-provision.ts deleted file mode 100644 index 19938b4212..0000000000 --- a/types/hapi/test/server/server-cache-provision.ts +++ /dev/null @@ -1,19 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-await-servercacheprovisionoptions -import {Server} from "hapi"; -import * as catbox from "catbox"; - -const server = new Server({ - port: 8000, -}); -server.initialize(); -server.cache.provision({engine: require('catbox-memory'), name: 'countries' }); - -const cache:catbox.Policy = server.cache({segment: 'countries', cache: 'countries', expiresIn: 60 * 60 * 1000 }); -cache.set('norway', 'oslo', 10 * 1000, null); -const value = cache.get('norway', null); - -server.start(); - -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); -}); diff --git a/types/hapi/test/server/server-cache.ts b/types/hapi/test/server/server-cache.ts deleted file mode 100644 index df92a45038..0000000000 --- a/types/hapi/test/server/server-cache.ts +++ /dev/null @@ -1,23 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servercacheoptions -import {Server, ServerOptionsCache} from "hapi"; -import * as catbox from "catbox"; - -const server = new Server({ - port: 8000, -}); - -const catboxOptions:ServerOptionsCache = { - segment: 'countries', - expiresIn: 60 * 60 * 1000 -} -const cache:catbox.Policy = server.cache(catboxOptions); -cache.set('norway', 'oslo', 10 * 1000, null); - -const value = cache.get('norway', null); -console.log("Value: " + value); - -server.start(); - -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); -}); diff --git a/types/hapi/test/server/server-decoder.ts b/types/hapi/test/server/server-decoder.ts deleted file mode 100644 index 67e0a3abaa..0000000000 --- a/types/hapi/test/server/server-decoder.ts +++ /dev/null @@ -1,8 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoderencoding-decoder -import {Server} from "hapi"; -import * as Zlib from "zlib"; - -const server = new Server({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } }); -server.decoder('special', (options) => Zlib.createGunzip(options)); - -server.start(); diff --git a/types/hapi/test/server/server-decorations.ts b/types/hapi/test/server/server-decorations.ts deleted file mode 100644 index a5a5f3d69f..0000000000 --- a/types/hapi/test/server/server-decorations.ts +++ /dev/null @@ -1,15 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverdecoratetype-property-method-options -import {ResponseToolkit, Server} from "hapi"; - -const server = new Server({ - port: 8000, -}); - -const success = (h: ResponseToolkit) => { - return h.response({ status: 'ok' }); -}; - -server.start(); -server.decorate('toolkit', 'success', success); - -console.log(server.decorations.toolkit); // ['success'] diff --git a/types/hapi/test/server/server-encoder.ts b/types/hapi/test/server/server-encoder.ts deleted file mode 100644 index 920ade785b..0000000000 --- a/types/hapi/test/server/server-encoder.ts +++ /dev/null @@ -1,8 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverencoderencoding-encoder -import {Server} from "hapi"; -import * as Zlib from "zlib"; - -const server = new Server({ port: 80, routes: { payload: { compression: { special: { chunkSize: 16 * 1024 } } } } }); -server.encoder('special', (options) => Zlib.createGzip(options)); - -server.start(); diff --git a/types/hapi/test/server/server-events-once.ts b/types/hapi/test/server/server-events-once.ts deleted file mode 100644 index 18f9fe2fd3..0000000000 --- a/types/hapi/test/server/server-events-once.ts +++ /dev/null @@ -1,24 +0,0 @@ -// from https://github.com/hapijs/hapi/blob/master/API.md#-servereventsoncecriteria-listener -import {Request, ResponseToolkit, Server, ServerRoute} from "hapi"; - -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return 'oks: ' + request.path; - } -}; - -const server = new Server({ - port: 8000, -}); -server.route(serverRoute); -server.event('test1'); -server.event('test2'); -server.events.once('test1', (update: any) => {console.log(update);}); -server.events.once('test2', (...args: any[]) => {console.log(args);}); -server.events.emit('test1', 'hello-1'); -server.events.emit('test2', 'hello-2'); // Ignored - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/test/server/server-events.ts b/types/hapi/test/server/server-events.ts deleted file mode 100644 index 32deb7c8e6..0000000000 --- a/types/hapi/test/server/server-events.ts +++ /dev/null @@ -1,11 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servereventevents -import {Server} from "hapi"; - -const server = new Server({ - port: 8000, -}); -server.event('test'); -server.events.on('test', (update:any) => console.log(update)); -server.events.emit('test', 'hello'); - -server.start(); diff --git a/types/hapi/test/server/server-expose.ts b/types/hapi/test/server/server-expose.ts deleted file mode 100644 index c35e3c1d78..0000000000 --- a/types/hapi/test/server/server-expose.ts +++ /dev/null @@ -1,22 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins -import {Plugin, Server, ServerRegisterOptions} from "hapi"; - -const plugin1:Plugin = { - name: 'example1', - register: (server:Server, options:ServerRegisterOptions) => { - server.expose('util', () => console.log('something')); - } -}; -const plugin2:Plugin = { - name: 'example2', - register: (server:Server, options:ServerRegisterOptions) => { - server.expose('util', () => console.log('something')); - } -}; - -const server = new Server({ - port: 8000, -}); -server.start(); -server.register(plugin1); -server.register(plugin2); diff --git a/types/hapi/test/server/server-info.ts b/types/hapi/test/server/server-info.ts deleted file mode 100644 index 6f7ed24912..0000000000 --- a/types/hapi/test/server/server-info.ts +++ /dev/null @@ -1,10 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverinfo -import {Server} from "hapi"; - -const server = new Server({ - port: 8000, -}); -server.start(); - -console.log(server.info); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/test/server/server-inject.ts b/types/hapi/test/server/server-inject.ts deleted file mode 100644 index 1f55f803b9..0000000000 --- a/types/hapi/test/server/server-inject.ts +++ /dev/null @@ -1,20 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverinjectoptions -import {Request, ResponseToolkit, Server, ServerRoute} from "hapi"; - -const server = new Server({ - port: 8000, -}); -const serverRoute: ServerRoute = { - path: '/', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return 'Success!'; - } -}; - -server.route(serverRoute); -server.start(); - -const res = server.inject('/'); -console.log(res.result); - diff --git a/types/hapi/test/server/server-listener.ts b/types/hapi/test/server/server-listener.ts deleted file mode 100644 index b4cdcc47ed..0000000000 --- a/types/hapi/test/server/server-listener.ts +++ /dev/null @@ -1,14 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverlistener -import {Server} from "hapi"; -import * as SocketIO from "socket.io" - -const server = new Server({ - port: 8000, -}); - -const io = SocketIO.listen(server.listener); -io.sockets.on('connection', (socket) => { - socket.emit('welcome'); -}); - -server.start(); diff --git a/types/hapi/test/server/server-load.ts b/types/hapi/test/server/server-load.ts deleted file mode 100644 index e53f8e8546..0000000000 --- a/types/hapi/test/server/server-load.ts +++ /dev/null @@ -1,15 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverload -import {Server} from "hapi"; - -const server = new Server({ - port: 8000, - load: { sampleInterval: 1000 } -}); -server.start(); - -setTimeout(() => { - console.log(server.load.rss); - console.log(server.load.eventLoopDelay); - console.log(server.load.heapUsed); -}, 5 * 1000); - diff --git a/types/hapi/test/server/server-lookup.ts b/types/hapi/test/server/server-lookup.ts deleted file mode 100644 index 45e8ef304c..0000000000 --- a/types/hapi/test/server/server-lookup.ts +++ /dev/null @@ -1,20 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverlookupid -import {RequestRoute, Server} from "hapi"; - -const server = new Server({ - port: 8000, -}); - -server.route({ - path: '/', - method: 'GET', - config: { - id: 'root', - handler: () => 'ok' - } -}); - -const route:RequestRoute = server.lookup('root'); -console.log(route); - -server.start(); diff --git a/types/hapi/test/server/server-match.ts b/types/hapi/test/server/server-match.ts deleted file mode 100644 index 8da8ba6220..0000000000 --- a/types/hapi/test/server/server-match.ts +++ /dev/null @@ -1,20 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servermatchmethod-path-host -import {RequestRoute, Server} from "hapi"; - -const server = new Server({ - port: 8000, -}); - -server.route({ - path: '/', - method: 'GET', - config: { - id: 'root', - handler: () => 'ok' - } -}); - -const route:RequestRoute = server.match('get', '/'); -console.log(route.path); - -server.start(); diff --git a/types/hapi/test/server/server-method.ts b/types/hapi/test/server/server-method.ts deleted file mode 100644 index 396cfa62d8..0000000000 --- a/types/hapi/test/server/server-method.ts +++ /dev/null @@ -1,26 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servermethodmethods -import {Server, ServerMethodConfigurationObject} from "hapi"; - -const server = new Server({ - port: 8000, -}); -server.start(); - -const add = (a:any, b:any) => { - return a + b; -}; - -const methodObject:ServerMethodConfigurationObject = { - name: 'sum', - method: add, - options: { - cache: { - expiresIn: 2000, - generateTimeout: 100 - } - } -} - -server.method(methodObject); - - diff --git a/types/hapi/test/server/server-methods.ts b/types/hapi/test/server/server-methods.ts deleted file mode 100644 index 4ce4b8ceaf..0000000000 --- a/types/hapi/test/server/server-methods.ts +++ /dev/null @@ -1,11 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servermethods -import {Server} from "hapi"; - -const server = new Server({ - port: 8000, -}); -server.start(); - -server.method('add', (a, b) => (a + b)); -const result = server.methods.add(1, 2); // 3 -console.log(result); diff --git a/types/hapi/test/server/server-mime.ts b/types/hapi/test/server/server-mime.ts deleted file mode 100644 index ad8922d0b5..0000000000 --- a/types/hapi/test/server/server-mime.ts +++ /dev/null @@ -1,22 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servermime -import {Server, ServerOptions} from "hapi"; - -const options:ServerOptions = { - port: 8000, - mime: { - override: { - 'node/module': { - source: 'steve', - compressible: false, - extensions: ['node', 'module', 'npm'], - type: 'node/module' - } - } - } -}; - -const server = new Server(options); -console.log(server.mime.path('code.js').type) // 'application/javascript' -console.log(server.mime.path('file.npm').type) // 'node/module' - -server.start(); diff --git a/types/hapi/test/server/server-options.ts b/types/hapi/test/server/server-options.ts deleted file mode 100644 index 49d567eee8..0000000000 --- a/types/hapi/test/server/server-options.ts +++ /dev/null @@ -1,109 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-server-options -import {Server, ServerOptions, Plugin, ServerRegisterOptions, RouteOptions} from "hapi"; -import {MimosOptions, MimosOptionsValue} from "mimos"; - -const CatboxMemory = require('catbox-memory'); - -const mimeOptions: MimosOptions = { - override: { - 'node/module': { - source: 'iana', - compressible: true, - extensions: ['node', 'modsule', 'npm'], - type: 'node/module' - }, - 'application/javascript': { - source: 'iana', - charset: 'UTF-8', - compressible: true, - extensions: ['js', 'javascript'], - type: 'text/javascript' - }, - 'text/html': { - predicate: (mime:MimosOptionsValue) => { - if (1 == 1) { - //mime.foo = 'test'; - } - else { - //mime.foo = 'bar'; - } - return mime; - } - } - } -}; - -const plugin: Plugin = { - name: 'example', - register: (server:Server, options:ServerRegisterOptions) => { - server.expose('key', 'value'); - server.plugins.example.other = 'other'; - console.log(server.plugins.example.key); // 'value' - console.log(server.plugins.example.other); // 'other' - } -}; - -const routeOptions: RouteOptions = { - compression: { - test: { - some: 'option' - } - }, - files: { - relativeTo: __dirname - }, - cors: { - origin: ['http://test.example.com', 'http://www.example.com', 'http://*.a.com'] - }, -}; - -const options: ServerOptions = { - address: '0.0.0.0', - app: { - key1: 'value1', - key2: 'value2', - any_thing: 'any_value', - }, - autoListen: true, - cache: { - engine: CatboxMemory, - name: 'test', - shared: true, - partition: 'hapi-cache', - any_thing_1: 'any_thing_1', - any_thing_2: 'any_thing_2' - }, - compression: { - minBytes: 1024 - }, - debug: { - request: ['implementation'] - }, - host: 'localhost', - listener: null, - load: { sampleInterval: 0 }, - mime: mimeOptions, - plugins: plugin, - port: 8000, - router: { - isCaseSensitive: true, - stripTrailingSlash: false - }, - routes: routeOptions, - state: { - strictHeader: true, - ignoreErrors: false, - isSecure: true, - isHttpOnly: true, - isSameSite: 'Strict', - encoding: 'none' - }, - tls: null -}; - -const server = new Server(options); -server.start(); - -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); -}); diff --git a/types/hapi/test/server/server-path.ts b/types/hapi/test/server/server-path.ts deleted file mode 100644 index 7578a9ba2f..0000000000 --- a/types/hapi/test/server/server-path.ts +++ /dev/null @@ -1,30 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverpathrelativeto -import {Plugin, Server, ServerRegisterOptions, ServerRoute} from "hapi"; - -const server = new Server({ - port: 8000, -}); - -const serverRouteOption:ServerRoute = { - path: '/file', - method: 'GET', - handler: { - file: './test.html' - } -} - -const plugin:Plugin = { - name: 'example', - register: (server:Server, options:ServerRegisterOptions) => { - // Assuming the Inert plugin was registered previously - server.path(__dirname + '../static'); - server.route(serverRouteOption); - } -}; - -server.start(); -server.register(plugin); - -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); -}); diff --git a/types/hapi/test/server/server-plugins.ts b/types/hapi/test/server/server-plugins.ts deleted file mode 100644 index c38f240067..0000000000 --- a/types/hapi/test/server/server-plugins.ts +++ /dev/null @@ -1,20 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverplugins -import {Plugin, Server, ServerRegisterOptions} from "hapi"; - -const plugin:Plugin = { - name: 'example', - register: (server:Server, options:ServerRegisterOptions) => { - - server.expose('key', 'value'); - server.plugins.example.other = 'other'; - - console.log(server.plugins.example.key); // 'value' - console.log(server.plugins.example.other); // 'other' - } -}; - -const server = new Server({ - port: 8000, -}); -server.start(); -server.register(plugin); diff --git a/types/hapi/test/server/server-settings.ts b/types/hapi/test/server/server-settings.ts deleted file mode 100644 index ec30cdc606..0000000000 --- a/types/hapi/test/server/server-settings.ts +++ /dev/null @@ -1,12 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serversettings -import {Server} from "hapi"; - -const server = new Server({ - port: 8000, - app: { - key: 'value' - } -}); -server.start(); - -console.log(server.settings.app); // { key: 'value' } diff --git a/types/hapi/test/server/server-start.ts b/types/hapi/test/server/server-start.ts deleted file mode 100644 index 228b9ca6a2..0000000000 --- a/types/hapi/test/server/server-start.ts +++ /dev/null @@ -1,11 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstart -import {Server} from "hapi"; - -const server = new Server({ - port: 8000, -}); -server.start(); - -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); -}); diff --git a/types/hapi/test/server/server-state.ts b/types/hapi/test/server/server-state.ts deleted file mode 100644 index 7a6c118c4d..0000000000 --- a/types/hapi/test/server/server-state.ts +++ /dev/null @@ -1,28 +0,0 @@ -// from https://hapijs.com/tutorials/cookies?lang=en_US -import {Request, ResponseToolkit, Server, ServerOptions, ServerRoute, ServerStateCookieOptions} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; - -const serverRoute: ServerRoute = { - path: '/say-hello', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return h.response('Hello').state('data', { firstVisit: false }); - } -} - -const server = new Server(options); -server.route(serverRoute); - -const stateOption: ServerStateCookieOptions = { - ttl: 24 * 60 * 60 * 1000, // One day - isSecure: false, - isHttpOnly: false, - encoding: 'base64json', -} -server.state('data', stateOption); - -server.start(); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/test/server/server-stop.ts b/types/hapi/test/server/server-stop.ts deleted file mode 100644 index c07649ff65..0000000000 --- a/types/hapi/test/server/server-stop.ts +++ /dev/null @@ -1,17 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-await-serverstopoptions -import {Server} from "hapi"; - -const server = new Server({ - port: 8000, -}); - -server.start(); -server.events.on('start', () => { - console.log('Server started at: ' + server.info.uri); -}); -server.events.on('stop', () => { - console.log('Server stoped.'); -}); -setTimeout(() => { - server.stop({ timeout: 10 * 1000 }); -}, 5 * 1000); diff --git a/types/hapi/test/server/server-table.ts b/types/hapi/test/server/server-table.ts deleted file mode 100644 index 75d63ac724..0000000000 --- a/types/hapi/test/server/server-table.ts +++ /dev/null @@ -1,22 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost -import {Request, ResponseToolkit, Server, ServerOptions} from "hapi"; - -const options: ServerOptions = { - port: 8000, -}; - -const server = new Server(options); -server.app.key = 'value2'; - -server.route({ - path: '/', - method: 'GET', - handler: (request: Request, h: ResponseToolkit) => { - return h.response("Hello World"); - } -}); - -server.start(); -const table = server.table(); -console.log(table); -console.log('Server started at: ' + server.info.uri); diff --git a/types/hapi/test/server/server-version.ts b/types/hapi/test/server/server-version.ts deleted file mode 100644 index ecca8ba5ba..0000000000 --- a/types/hapi/test/server/server-version.ts +++ /dev/null @@ -1,9 +0,0 @@ -// https://github.com/hapijs/hapi/blob/master/API.md#-serverversion -import {Server} from "hapi"; - -const server = new Server({ - port: 8000, -}); - -server.start(); -console.log(server.version); // 17.x.x diff --git a/types/hapi/v16/test/server/settings.ts b/types/hapi/test/server/settings.ts similarity index 84% rename from types/hapi/v16/test/server/settings.ts rename to types/hapi/test/server/settings.ts index f250c8e8fd..c2ec9ce3ed 100644 --- a/types/hapi/v16/test/server/settings.ts +++ b/types/hapi/test/server/settings.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serversettings -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server({ app: { key: 'value' diff --git a/types/hapi/v16/test/server/start.ts b/types/hapi/test/server/start.ts similarity index 76% rename from types/hapi/v16/test/server/start.ts rename to types/hapi/test/server/start.ts index a9408a57aa..a15bb79740 100644 --- a/types/hapi/v16/test/server/start.ts +++ b/types/hapi/test/server/start.ts @@ -1,8 +1,8 @@ // From https://hapijs.com/api/16.1.1#serverstartcallback -import * as Hapi from '../../'; -import * as Hoek from '../../../../hoek'; +import * as Hapi from 'hapi'; +import * as Hoek from 'hoek'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/state.ts b/types/hapi/test/server/state.ts similarity index 95% rename from types/hapi/v16/test/server/state.ts rename to types/hapi/test/server/state.ts index 19c10cfae3..2035343a17 100644 --- a/types/hapi/v16/test/server/state.ts +++ b/types/hapi/test/server/state.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverstatename-options -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/stop.ts b/types/hapi/test/server/stop.ts similarity index 87% rename from types/hapi/v16/test/server/stop.ts rename to types/hapi/test/server/stop.ts index ca14a70dfa..ddfd07aa8f 100644 --- a/types/hapi/v16/test/server/stop.ts +++ b/types/hapi/test/server/stop.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#serverstopoptions-callback -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80 }); diff --git a/types/hapi/v16/test/server/table.ts b/types/hapi/test/server/table.ts similarity index 89% rename from types/hapi/v16/test/server/table.ts rename to types/hapi/test/server/table.ts index c1410f95db..abe0707c76 100644 --- a/types/hapi/v16/test/server/table.ts +++ b/types/hapi/test/server/table.ts @@ -1,7 +1,7 @@ // From https://hapijs.com/api/16.1.1#servertablehost -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.connection({ port: 80, host: 'example.com' }); server.route({ method: 'GET', path: '/example', handler: function (request, reply) { return reply(); } }); diff --git a/types/hapi/v16/test/server/version.ts b/types/hapi/test/server/version.ts similarity index 77% rename from types/hapi/v16/test/server/version.ts rename to types/hapi/test/server/version.ts index 2ee1f57841..064e87e3cd 100644 --- a/types/hapi/v16/test/server/version.ts +++ b/types/hapi/test/server/version.ts @@ -1,6 +1,6 @@ // From http://hapijs.com/api#serversettings -import * as Hapi from '../../'; +import * as Hapi from 'hapi'; const server = new Hapi.Server(); server.version === '8.0.0' diff --git a/types/hapi/tsconfig.json b/types/hapi/tsconfig.json index 2358b83959..2a3f7dbd5d 100644 --- a/types/hapi/tsconfig.json +++ b/types/hapi/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": false, "baseUrl": "../", "typeRoots": [ @@ -18,51 +18,80 @@ }, "files": [ "index.d.ts", - "test/request/catch-all.ts", + "test/connection/table.ts", + "test/continuation/errors.ts", + "test/getting-started/01-creating-a-server.ts", + "test/getting-started/02-adding-routes.ts", + "test/getting-started/03-serving-static-content.ts", + "test/getting-started/04-using-plugins.ts", + "test/path/catch-all.ts", + "test/path/parameters.ts", + "test/plugins/options.ts", + "test/reply/continue.ts", + "test/reply/entity.ts", + "test/reply/redirect.ts", + "test/reply/reply.ts", + "test/reply/state_cookie.ts", "test/request/event-types.ts", + "test/request/generate-response.ts", "test/request/get-log.ts", - "test/request/parameters.ts", + "test/request/log.ts", "test/request/query.ts", - "test/response/continue.ts", + "test/request/set-method.ts", + "test/request/set-url.ts", + "test/request/tail.ts", + "test/response/error-representation.ts", "test/response/error.ts", - "test/response/redirect.ts", - "test/response/response.ts", - "test/response/response-events.ts", - "test/route/adding-routes.ts", + "test/response/events.ts", + "test/response/flow-control.ts", + "test/route/additional-options.ts", + "test/route/auth.ts", "test/route/config.ts", "test/route/handler.ts", - "test/route/route-options.ts", - "test/route/route-options-pre.ts", - "test/server/server-app.ts", - "test/server/server-auth-api.ts", - "test/server/server-auth-default.ts", - "test/server/server-auth-test.ts", - "test/server/server-bind.ts", - "test/server/server-cache.ts", - "test/server/server-cache-provision.ts", - "test/server/server-decoder.ts", - "test/server/server-decorations.ts", - "test/server/server-encoder.ts", - "test/server/server-events.ts", - "test/server/server-events-once.ts", - "test/server/server-expose.ts", - "test/server/server-info.ts", - "test/server/server-inject.ts", - "test/server/server-listener.ts", - "test/server/server-load.ts", - "test/server/server-lookup.ts", - "test/server/server-match.ts", - "test/server/server-method.ts", - "test/server/server-methods.ts", - "test/server/server-mime.ts", - "test/server/server-options.ts", - "test/server/server-path.ts", - "test/server/server-plugins.ts", - "test/server/server-settings.ts", - "test/server/server-start.ts", - "test/server/server-state.ts", - "test/server/server-stop.ts", - "test/server/server-table.ts", - "test/server/server-version.ts" + "test/route/plugins.ts", + "test/route/prerequisites.ts", + "test/route/public-interface.ts", + "test/route/validate.ts", + "test/server/app.ts", + "test/server/auth.ts", + "test/server/bind.ts", + "test/server/cache.ts", + "test/server/connection-options.ts", + "test/server/connections.ts", + "test/server/decoder.ts", + "test/server/decorate.ts", + "test/server/dependency.ts", + "test/server/emit.ts", + "test/server/encoder.ts", + "test/server/event.ts", + "test/server/expose.ts", + "test/server/ext.ts", + "test/server/handler.ts", + "test/server/info.ts", + "test/server/initialize.ts", + "test/server/inject.ts", + "test/server/listener.ts", + "test/server/load.ts", + "test/server/log.ts", + "test/server/lookup.ts", + "test/server/match.ts", + "test/server/method.ts", + "test/server/methods.ts", + "test/server/mime.ts", + "test/server/new.ts", + "test/server/on.ts", + "test/server/once.ts", + "test/server/path.ts", + "test/server/plugins.ts", + "test/server/realm.ts", + "test/server/register.ts", + "test/server/route.ts", + "test/server/select.ts", + "test/server/settings.ts", + "test/server/start.ts", + "test/server/state.ts", + "test/server/stop.ts", + "test/server/table.ts", + "test/server/version.ts" ] -} +} \ No newline at end of file diff --git a/types/hapi/v16/index.d.ts b/types/hapi/v16/index.d.ts deleted file mode 100644 index ee22f1dea7..0000000000 --- a/types/hapi/v16/index.d.ts +++ /dev/null @@ -1,2723 +0,0 @@ -// Type definitions for hapi 16.1 -// Project: https://github.com/hapijs/hapi -// Definitions by: Jason Swearingen , AJP -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + WARNING: BACKWARDS INCOMPATIBLE + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + * - * - * Removal of IPromise replaced with Promise - * Removal of IReplyStrict<> - * Removal of IReply replaced with different interfaces like: - * ReplyWithContinue - * ReplyNoContinue, etc. - * Renaming of all interfaces to remove preceding I in preparation of dtslint - */ - -/// - -import Events = require("events"); -import stream = require("stream"); -import http = require("http"); -import https = require("https"); -import url = require("url"); -import zlib = require("zlib"); -import domain = require("domain"); - -import * as Boom from 'boom'; -import { - ValidationOptions as JoiValidationOptions, - SchemaMap as JoiSchemaMap, - Schema as JoiSchema, -} from 'joi'; -// TODO check JoiValidationObject is correct for "a Joi validation object" -type JoiValidationObject = JoiSchema | JoiSchemaMap | (JoiSchema | JoiSchemaMap)[]; - -import * as Catbox from 'catbox'; -import { MimosOptions } from 'mimos'; -import Podium = require('podium'); -import * as Shot from 'shot'; - -export interface Dictionary { - [key: string]: T; -} - -/** - * Server - * The Server object is the main application container. The server manages all incoming connections along with all the facilities provided by the framework. A server can contain more than one connection (e.g. listen to port 80 and 8080). - * [See docs](https://hapijs.com/api/16.1.1#server) - * [See docs](https://hapijs.com/api/16.1.1#server-properties) - * [See docs](https://hapijs.com/api/16.1.1#server-events) - */ -export class Server extends Podium { - /** - * Creates a new Server object - */ - constructor(options?: ServerOptions); - - /** - * Provides a safe place to store server-specific run-time application data without potential conflicts with the framework internals. The data can be accessed whenever the server is accessible. Initialized with an empty object. - * [See docs](https://hapijs.com/api/16.1.1#serverapp) - */ - app?: any; - /** - * An array containing the server's connections. When the server object is returned from server.select(), the connections array only includes the connections matching the selection criteria. - * [See docs](https://hapijs.com/api/16.1.1#serverconnections) - */ - connections: ServerConnection[]; - /** - * When the server contains exactly one connection, info is an object containing information about the sole connection - * When the server contains more than one connection, each server.connections array member provides its own connection.info. - * [See docs](https://hapijs.com/api/16.1.1#serverinfo) - */ - info: ServerConnectionInfo | null; - /** - * An object containing the process load metrics (when load.sampleInterval is enabled): - * [See docs](https://hapijs.com/api/16.1.1#serverload) - */ - load: { - /** event loop delay milliseconds. */ - eventLoopDelay: number; - /** V8 heap usage. */ - heapUsed: number; - /** RSS memory usage. */ - rss: number; - }; - /** - * When the server contains exactly one connection, listener is the node HTTP server object of the sole connection. - * When the server contains more than one connection, each server.connections array member provides its own connection.listener. - * [See docs](https://hapijs.com/api/16.1.1#serverlistener) - */ - listener: ServerListener | null; - /** - * An object providing access to the server methods cs://hapijs.com/api/16.1.1#servermethodname-method-options} where each server method name is an object property. - * [See docs](https://hapijs.com/api/16.1.1#servermethods) - */ - methods: Dictionary; - /** - * Provides access to the server MIME database used for setting content-type information. The object must not be modified directly but only through the mime server setting. - * [See docs](https://hapijs.com/api/16.1.1#servermime) - */ - readonly mime: {path(path: string): {type: string}}; - /** - * An object containing the values exposed by each plugin registered where each key is a plugin name and the values are the exposed properties by each plugin using server.expose(). Plugins may set the value of the server.plugins[name] object directly or via the server.expose() method. - * [See docs](https://hapijs.com/api/16.1.1#serverplugins) - */ - plugins: PluginsStates; - /** - * The realm object contains server-wide or plugin-specific state that can be shared across various methods. For example, when calling server.bind(), the active realm settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). Realms are a limited version of a sandbox where plugins can maintain state used by the framework when adding routes, extensions, and other properties. - * [See docs](https://hapijs.com/api/16.1.1#serverrealm) - */ - readonly realm: ServerRealm; - /** - * When the server contains exactly one connection, registrations is an object where each key is a registered plugin name - * When the server contains more than one connection, each server.connections array member provides its own connection.registrations. - * TODO check and offer PR to update Hapi docs: Assuming readonly. - * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) - */ - readonly registrations: ServerRegisteredPlugins; - /** - * The root server object containing all the connections and the root server methods (e.g. start(), stop(), connection()). - * TODO, check and offer PR to update Hapi docs: Marked as optional as presumably root server does not reference itself. - * [See docs](https://hapijs.com/api/16.1.1#serverroot) - */ - root?: Server; - /** - * The server configuration object after defaults applied. - * [See docs](https://hapijs.com/api/16.1.1#serversettings) - */ - settings: ServerOptions; - /** - * The hapi module version number. - * [See docs](https://hapijs.com/api/16.1.1#serverversion) - */ - version: string; - - /** - * [See docs](https://hapijs.com/api/16.1.1#serverauthapi) - * [See docs](https://hapijs.com/api/16.1.1#serverauthdefaultoptions) - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) - * [See docs](https://hapijs.com/api/16.1.1#serverauthstrategyname-scheme-mode-options) - * [See docs](https://hapijs.com/api/16.1.1#serverauthteststrategy-request-next) - */ - auth: ServerAuth; - - /** - * Sets a global context used as the default bind object when adding a route or an extension - * When setting context inside a plugin, the context is applied only to methods set up by the plugin. Note that the context applies only to routes and extensions added after it has been set. Ignored if the method being bound is an arrow function. - * @param context the object used to bind this in handler and extension methods. - * [See docs](https://hapijs.com/api/16.1.1#serverbindcontext) - */ - bind(context: any): void; - /** - * [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) - * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) - */ - cache: ServerCacheMethod; - /** - * Adds an incoming server connection - * Returns a server object with the new connections selected. - * Must be called before any other server method that modifies connections is called for it to apply to the new connection (e.g. server.state()) - * Note that the options object is deeply cloned (with the exception of listener which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on. - * - * [See docs](https://hapijs.com/api/16.1.1#serverconnectionoptions) for various advantage topics covering usage and caveats around use of the function in plugin register(), connectionless plugins calling connection(), etc. - * @param connection a connection configuration object or array of objects - */ - connection(options?: ServerConnectionOptions[]): Server; - connection(options?: ServerConnectionOptions): Server; - // connection: (options: ServerConnectionOptions[] | ServerConnectionOptions) => Server; - /** - * Registers a custom content decoding compressor to extend the built-in support for 'gzip' and 'deflate' - * [See docs](https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder) - * @param encoding the decoder name string. - * @param decoder a function using the signature function(options) where options are the encoding specific options configured in the route payload.compression configuration option, and the return value is an object compatible with the output of node's zlib.createGunzip(). - */ - decoder(encoding: string, decoder: ((options: CompressionDecoderSettings) => zlib.Gunzip)): void; - /** - * Extends various framework interfaces with custom methods - * Note that decorations apply to the entire server and all its connections regardless of current selection. - * [See docs](https://hapijs.com/api/16.1.1#serverdecoratetype-property-method-options) - * - * NOTE: it's not possible to type the result of this action. - * It's advised that in a custom definition file, you extend the ReplyNoContinue - * and ReplyWithContinue functions. See Inert `.file` for an example. - * Or if it is not part of a library / plugin then you use a namespace within - * your code to type the request, server and or reply. See - * [tests/server/decorate.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/hapi/tests/server/decorate.ts) - * for examples. - * @param type the interface being decorated. Supported types: - * * 'request' - adds methods to the Request object. - * * 'reply' - adds methods to the reply interface. - * * 'server' - adds methods to the Server object. - * @param property the object decoration key name. - * @param method the extension function or other value. - * @param options if the type is 'request', supports the following optional settings: - * * apply - if true, the method function is invoked using the signature function(request) where request is the current request object and the returned value is assigned as the decoration. - */ - decorate(type: 'request' | 'reply' | 'server', property: string, method: Function): void; - decorate(type: 'request', property: string, method: Function, options?: {apply: false}): void; - decorate(type: 'request', property: string, method: (request: Request) => Function, options: {apply: true}): void; - /** - * The server.decorate('server', ...) method can modify this prototype/interface. - * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts - * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) - */ - // [index: string]: any; - /** - * Used within a plugin to declare a required dependency on other plugins - * The after method is identical to setting a server extension point on 'onPreStart'. Connectionless plugins (those with attributes.connections set to false) can only depend on other connectionless plugins (server initialization will fail even of the dependency is loaded but is not connectionless). - * Dependencies can also be set via the register attributes property (does not support setting after). - * [See docs](https://hapijs.com/api/16.1.1#serverdependencydependencies-after) - * @param dependencies a single string or array of plugin name strings which must be registered in order for this plugin to operate. Plugins listed must be registered before the server is initialized or started. Does not provide version dependency which should be implemented using npm peer dependencies. - * @param after an optional function called after all the specified dependencies have been registered and before the server starts. The function is only called if the server is initialized or started. If a circular dependency is detected, an exception is thrown (e.g. two plugins each has an after function to be called after the other). The function signature is function(server, next) - */ - dependency(dependencies: string | string[], after?: AfterDependencyLoadCallback): void; - /** - * Emits a custom application event update to all the subscribed listeners - * Note that events must be registered before they can be emitted or subscribed to by calling server.event(events). This is done to detect event name misspelling and invalid event activities. - * [See docs](https://hapijs.com/api/16.1.1#serveremitcriteria-data-callback) - * @param criteria the event update criteria which if an object can have the following optional keys (unless noted otherwise): - * * name - the event name string (required). - * * channel - the channel name string. - * * tags - a tag string or array of tag strings. - * @param data the value emitted to the subscribers. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. - * @param callback an optional callback method invoked when all subscribers have been notified using the signature function(). The callback is called only after all the listeners have been notified, including any event updates emitted earlier (the order of event updates are guaranteed to be in the order they were emitted). - */ - emit(criteria: string | {name: string, channel?: string, tags?: string | string[]}, data: any, callback?: () => void): void; - /** - * Registers a custom content encoding compressor to extend the built-in support for 'gzip' and 'deflate' - * [See docs](https://hapijs.com/api/16.1.1#serverencoderencoding-encoder) - * @param encoding the encoder name string. - * @param encoder a function using the signature function(options) where options are the encoding specific options configured in the route compression configuration option, and the return value is an object compatible with the output of node's zlib.createGzip(). - */ - encoder(encoding: string, encoder: ((options: CompressionEncoderSettings) => zlib.Gzip)): void; - /** - * Register custom application events - * [See docs](https://hapijs.com/api/16.1.1#servereventevents) - * @param events see ApplicationEvent - */ - event(events: ApplicationEvent[]): void; - event(events: ApplicationEvent): void; - /** - * Used within a plugin to expose a property via server.plugins[name] - * [See docs](https://hapijs.com/api/16.1.1#serverexposekey-value) - * @param key the key assigned (server.plugins[name][key]). - * @param value the value assigned. - */ - expose(key: string, value: any): void; - /** - * Merges an object into to the existing content of server.plugins[name] - * Note that all properties of obj are deeply cloned into server.plugins[name], so you should avoid using this method for exposing large objects that may be expensive to clone or singleton objects such as database client objects. Instead favor the server.expose(key, value) form, which only copies a reference to value. - * [See docs](https://hapijs.com/api/16.1.1#serverexposeobj) - * @param obj the object merged into the exposed properties container. - */ - expose(obj: Object): void; - /** - * Registers an extension function in one of the available extension points - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * @param events see @ServerExtConfigurationObject - */ - ext(events: ServerStartExtConfigurationObject): void; - ext(events: ServerStartExtConfigurationObject[]): void; - ext(events: ServerRequestExtConfigurationObjectWithRequest): void; - ext(events: ServerRequestExtConfigurationObjectWithRequest[]): void; - /** - * Registers a single extension event using the same properties as used in server.ext(events), but passed as arguments. - * [See docs](https://hapijs.com/api/16.1.1#serverextevent-method-options) - * @param event the extension point event name. - * @param method a function or an array of functions to be executed at a specified point during request processing. - * @param options - */ - ext(event: ServerStartExtPoints, method: ServerExtFunction[], options?: ServerExtOptions): void; - ext(event: ServerStartExtPoints, method: ServerExtFunction, options?: ServerExtOptions): void; - ext(event: ServerRequestExtPoints, method: ServerExtRequestHandler[], options?: ServerExtOptions): void; - ext(event: ServerRequestExtPoints, method: ServerExtRequestHandler, options?: ServerExtOptions): void; - /** - * Registers a new handler type to be used in routes - * The method function can have a defaults object or function property. If the property is set to an object, that object is used as the default route config for routes using this handler. If the property is set to a function, the function uses the signature function(method) and returns the route default configuration. - * [See docs](https://hapijs.com/api/16.1.1#serverhandlername-method) - * @param name string name for the handler being registered. Cannot override any previously registered type. - * @param method the function used to generate the route handler using the signature function(route, options) where: - * * route - the route public interface object. - * * options - the configuration object provided in the handler config. - */ - handler(name: string, method: MakeRouteHandler): void; - /** - * Initializes the server (starts the caches, finalizes plugin registration) but does not start listening on the connection ports - * Note that if the method fails and the callback includes an error, the server is considered to be in an undefined state and should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and other event listeners will get confused by repeated attempts to start the server or make assumptions about the healthy state of the environment. It is recommended to assert that no error has been returned after calling initialize() to abort the process when the server fails to start properly. If you must try to resume after an error, call server.stop() first to reset the server state. - * [See docs](https://hapijs.com/api/16.1.1#serverinitializecallback) - * @param callback the callback method when server initialization is completed or failed with the signature function(err) - */ - initialize(callback: (err: Error) => void): void; - initialize(): Promise; - /** - * When the server contains exactly one connection, injects a request into the sole connection simulating an incoming HTTP request without making an actual socket connection. Injection is useful for testing purposes as well as for invoking routing logic internally without the overhead or limitations of the network stack. Utilizes the shot module for performing injections, with some additional options and response properties - * If no callback is provided, a Promise object is returned. - * When the server contains more than one connection, each server.connections array member provides its own connection.inject(). - * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) - * @param options can be assigned a string with the requested URI, or an object - * @param callback the callback function with signature function(res) - */ - inject(options: string | InjectedRequestOptions, callback: (res: InjectedResponseObject) => void): void; - inject(options: string | InjectedRequestOptions, ): Promise; - /** - * Logs server events that cannot be associated with a specific request. When called the server emits a 'log' event which can be used by other listeners or plugins to record the information or output to the console. - * [See docs](https://hapijs.com/api/16.1.1#serverlogtags-data-timestamp) - * @param tags a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. Any logs generated by the server internally include the 'hapi' tag along with event-specific information. - * @param data an optional message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. If no listeners match the event, the data function is not invoked. - * @param timestamp an optional timestamp expressed in milliseconds. Defaults to Date.now() (now). - */ - log(tags: string | string[], data?: string | Object | Function, timestamp?: number): void; - /** - * When the server contains exactly one connection, looks up a route configuration. - * When the server contains more than one connection, each server.connections array member provides its own connection.lookup() method. - * [See docs](https://hapijs.com/api/16.1.1#serverlookupid) - * @param id the route identifier as set in the route options. - * @return the route public interface object if found, otherwise null. - */ - lookup(id: string): RoutePublicInterface | null; - /** - * When the server contains exactly one connection, looks up a route configuration - * When the server contains more than one connection, each server.connections array member provides its own connection.match() method. - * [See docs](https://hapijs.com/api/16.1.1#servermatchmethod-path-host) - * @param method the HTTP method (e.g. 'GET', 'POST'). TODO check if it allows HEAD - * @param path the requested path (must begin with '/'). - * @param host optional hostname (to match against routes with vhost). - * @return the route public interface object if found, otherwise null. - */ - match(method: HTTP_METHODS, path: string, host?: string): RoutePublicInterface | null; - /** - * Registers a server method. Server methods are functions registered with the server and used throughout the application as a common utility. Their advantage is in the ability to configure them to use the built-in cache and share across multiple request handlers without having to create a common module. - * [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) - * @param name a unique method name used to invoke the method via server.methods[name]. Supports using nested names such as utils.users.get which will automatically create the missing path under server.methods and can be accessed for the previous example via server.methods.utils.users.get. When configured with caching enabled, server.methods[name].cache will be an object see ServerMethodNameCacheObject - * @param method the method function - * @param options optional configuration - */ - method(name: string, method: ServerMethod, options?: ServerMethodOptions): void; - /** - * Registers a server method function as described in server.method() using a configuration object - * [See docs](https://hapijs.com/api/16.1.1#servermethodmethods) - */ - method(methods: ServerMethodConfigurationObject[]): void; - method(methods: ServerMethodConfigurationObject): void; - /** - * Subscribe a handler to an event - * [See docs](https://hapijs.com/api/16.1.1#serveroncriteria-listener) - * @param criteria the subscription criteria which can be an event name string which can be any of the built-in server events or a custom application event registered with server.event(events). - * Or an see ServerEventCriteria. - * If 'start' - emitted when the server is started using server.start(). - * If 'stop' - emitted when the server is stopped using server.stop(). - * @param listener - */ - on(criteria: 'start' | 'stop' | string | ServerEventCriteria, listener: Function): void; - /** - * The 'log' event includes the event object and a tags object (where each tag is a key with the value true) - * [See docs](https://hapijs.com/api/16.1.1#server-events) - */ - on(criteria: 'log', listener: (event: ServerEventObject, tags: Podium.Tags) => void): void; - /** - * The 'request' and 'request-internal' events include the request object, the event object, and a tags object (where each tag is a key with the value true) - * [See docs](https://hapijs.com/api/16.1.1#server-events) - * TODO submit issue to TypeScript. Using 'request' | 'request-internal' removes the type - * interference when using code like: `server.on('request', (request, event, tags) => {...}` - * Same for 'response' | 'tail'. - */ - on(criteria: 'request', listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void): void; - on(criteria: 'request-internal', listener: (request: Request, event: ServerEventObject, tags: Podium.Tags) => void): void; - /** - * The 'request-error' event includes the request object and the causing error err object - * [See docs](https://hapijs.com/api/16.1.1#server-events) - */ - on(criteria: 'request-error', listener: (request: Request, err: Error) => void): void; - /** - * The 'response' and 'tail' events include the request object - * [See docs](https://hapijs.com/api/16.1.1#server-events) - * See 'request' and 'request-internal' - */ - on(criteria: 'response', listener: (request: Request) => void): void; - on(criteria: 'tail', listener: (request: Request) => void): void; - /** - * The 'route' event includes the route public interface, the connection, and the server object used to add the route (e.g. the result of a plugin select operation) - * [See docs](https://hapijs.com/api/16.1.1#server-events) - */ - on(criteria: 'route', listener: (route: RoutePublicInterface, connection: ServerConnection, server: Server) => void): void; - /** - * Same as calling server.on() with the count option set to 1. - * TODO type this to copy the server.on specific types for 'route', 'tail', etc. - * [See docs](https://hapijs.com/api/16.1.1#serveroncecriteria-listener) - * @param criteria - * @param listener - */ - once(criteria: string | ServerEventCriteria, listener: Function): void; - /** - * Sets the path prefix used to locate static resources (files and view templates) when relative paths are used - * Note that setting a path within a plugin only applies to resources accessed by plugin methods. If no path is set, the connection files.relativeTo configuration is used. The path only applies to routes added after it has been set. - * [See docs](https://hapijs.com/api/16.1.1#serverpathrelativeto) - * @param relativeTo the path prefix added to any relative file path starting with '.'. - */ - path(relativeTo: string): void; - /** - * Registers a plugin - * If no callback is provided, a Promise object is returned. - * Note that plugin registration are recorded on each of the available connections. When plugins express a dependency on other plugins, both have to be loaded into the same connections for the dependency requirement to be fulfilled. It is recommended that plugin registration happen after all the server connections are created via server.connection(). - * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) - * @param plugins - * @param options - * @param callback with signature function(err) where err an error returned from the registration function. Note that exceptions thrown by the registration function are not handled by the framework. - * A note on typings. Common use case is: - * register(Plugin, (err) => {// do more stuff}) - * so these typings save passing empty `options` object or having to - * explicity type the Error in the Callback e.g.: - * register(Plugin, {}, (err) => {// do more stuff}) or - * register(Plugin, (err: Error) => {// do more stuff}) - */ - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, callback: (err: Error | null) => void): void; - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>): Promise; - register(plugins: PluginFunction | PluginRegistrationObject, callback: (err: Error | null) => void): void; - register(plugins: PluginFunction | PluginRegistrationObject): Promise; - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, options: PluginRegistrationOptions, callback: (err: Error | null) => void): void; - register(plugins: Array<(PluginFunction | PluginRegistrationObject)>, options: PluginRegistrationOptions): Promise; - register(plugins: PluginFunction | PluginRegistrationObject, options: PluginRegistrationOptions, callback: (err: Error | null) => void): void; - register(plugins: PluginFunction | PluginRegistrationObject, options: PluginRegistrationOptions): Promise; - /** - * Adds a connection route - * [See docs](https://hapijs.com/api/16.1.1#serverrouteoptions) - * @param options a route configuration object [See docs](https://hapijs.com/api/16.1.1#route-configuration) or an array of configuration objects. - */ - route(options: RouteConfiguration[]): void; - route(options: RouteConfiguration): void; - /** - * Selects a subset of the server's connections - * Returns a server object with connections set to the requested subset. Selecting again on a selection operates as a logic AND statement between the individual selections. - * [See docs](https://hapijs.com/api/16.1.1#serverselectlabels) - * @param labels a single string or array of strings of labels used as a logical OR statement to select all the connections with matching labels in their configuration. - */ - select(labels: string | string[]): Server; - /** - * Starts the server connections by listening for incoming requests on the configured port of each listener (unless the connection was configured with autoListen set to false) - * If no callback is provided, a Promise object is returned. - * Note that if the method fails and the callback includes an error, the server is considered to be in an undefined state and should be shut down. In most cases it would be impossible to fully recover as the various plugins, caches, and other event listeners will get confused by repeated attempts to start the server or make assumptions about the healthy state of the environment. It is recommended to assert that no error has been returned after calling start() to abort the process when the server fails to start properly. If you must try to resume after a start error, call server.stop() first to reset the server state. - * If a started server is started again, the second call to start() will only start new connections added after the initial start() was called. No events will be emitted and no extension points invoked. - * [See docs](https://hapijs.com/api/16.1.1#serverstartcallback) - * @param callback the callback method when server startup is completed or failed with the signature function(err) where: - * * err - any startup error condition. - */ - start(callback: (err?: Error) => void): void; - start(): Promise; - /** - * HTTP state management [See docs](https://tools.ietf.org/html/rfc6265) uses client cookies to persist a state across multiple requests. Registers a cookie definitions - * [See docs](https://hapijs.com/api/16.1.1#serverstatename-options) - * @param name the cookie name string. - * @param options optional cookie settings - */ - state(name: string, options?: ServerStateCookieConfiguationObject): void; - /** - * Stops the server's connections by refusing to accept any new connections or requests (existing connections will continue until closed or timeout) - * If no callback is provided, a Promise object is returned. - * [See docs](https://hapijs.com/api/16.1.1#serverstopoptions-callback) - * @param options options object with: - * * timeout - overrides the timeout in millisecond before forcefully terminating a connection. Defaults to 5000 (5 seconds). - * @param callback optional callback method which is called once all the connections have ended and it is safe to exit the process with signature function(err) where: - * * err - any termination error condition. - */ - stop(options: {timeout: number} | null, callback: (err?: Error) => void): void; - stop(options?: {timeout: number}): Promise; - /** - * Returns a copy of the routing table - * Note that if the server has not been started and multiple connections use port 0, the table items will override each other and will produce an incomplete result. - * When calling connection.table() directly on each connection, the return value is the same as the array table item value of an individual connection - * [See docs](https://hapijs.com/api/16.1.1#servertablehost) - * @param host optional host to filter routes matching a specific virtual host. Defaults to all virtual hosts. - */ - table(host?: string): RoutingTableEntry[]; -} - -export interface PluginSpecificConfiguration {} - -/** - * Server Options - * Note that the options object is deeply cloned and cannot contain any values that are unsafe to perform deep copy on. - * [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) - */ -export interface ServerOptions { - /** app - application-specific configuration which can later be accessed via server.settings.app. Note the difference between server.settings.app which is used to store static configuration values and server.app which is meant for storing run-time state. Defaults to {}. */ - app?: any; - /** - * cache - sets up server-side caching. Every server includes a default cache for storing application state. By default, a simple memory-based cache is created which has limited capacity and capabilities. hapi uses catbox for its cache which includes support for common storage solutions (e.g. Redis, MongoDB, Memcached, Riak, among others). Caching is only utilized if methods and plugins explicitly store their state in the cache. The server cache configuration only defines the storage container itself. cache can be assigned: - * * a prototype function (usually obtained by calling require() on a catbox strategy such as require('catbox-redis')). A new catbox client will be created internally using this function. - * * a CatboxServerOptionsCacheConfiguration configuration object - * * an array of the above object for configuring multiple cache instances, each with a unique name. When an array of objects is provided, multiple cache connections are established and each array item (except one) must include a name. - */ - cache?: Catbox.EnginePrototype | CatboxServerOptionsCacheConfiguration | CatboxServerOptionsCacheConfiguration[]; - /** sets the default connections configuration which can be overridden by each connection */ - connections?: ConnectionConfigurationServerDefaults; - /** determines which logged events are sent to the console (this should only be used for development and does not affect which events are actually logged internally and recorded). Set to false to disable all console logging, or to an object with: */ - debug?: false | { - /** a string array of server log tags to be displayed via console.error() when the events are logged via server.log() as well as internally generated server logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. */ - log?: string[] | false; - /** a string array of request log tags to be displayed via console.error() when the events are logged via request.log() as well as internally generated request logs. For example, to display all errors, set the option to ['error']. To turn off all console debug messages set it to false. Defaults to uncaught errors thrown in external code (these errors are handled automatically and result in an Internal Server Error response) or runtime errors due to developer error. */ - request?: string[] | false; - }; - /** process load monitoring */ - load?: { - /** the frequency of sampling in milliseconds. Defaults to 0 (no sampling). */ - sampleInterval?: number; - }; - /** options passed to the mimos module (https://github.com/hapijs/mimos) when generating the mime database used by the server and accessed via server.mime. */ - mime?: MimosOptions; - /** plugin-specific configuration which can later be accessed via server.settings.plugins. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between server.settings.plugins which is used to store static configuration values and server.plugins which is meant for storing run-time state. Defaults to {}. */ - plugins?: PluginSpecificConfiguration; - /** if false, will not use node domains to protect against exceptions thrown in handlers and other external code. Defaults to true. */ - useDomains?: boolean; -} - -/** - * The server event object - * [See docs](https://hapijs.com/api/16.1.1#server-events) - */ -export interface ServerEventObject { - /** the event timestamp. */ - timestamp: number; - /** if the event relates to a request, the request id. */ - request: string; - /** if the event relates to a server, the server.info.uri. */ - server: string; - /** an array of tags (e.g. ['error', 'http']). */ - tags: string[]; - /** optional event-specific information. */ - data: any; - /** true if the event was generated internally by the framework. */ - internal: boolean; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serveroncriteria-listener) - */ -export interface ServerEventCriteria { - /** the event name string (required). */ - name: string; - /** if true, the listener method receives an additional callback argument which must be called when the method completes. No other event will be emitted until the callback methods is called. The method signature is function(). If block is set to a positive integer, the value is used to set a timeout after which any pending events will be emitted, ignoring the eventual call to callback. Defaults to false (non blocking). */ - block?: boolean; - /** a string or array of strings specifying the event channels to subscribe to. If the event registration specified a list of allowed channels, the channels array must match the allowed channels. If channels are specified, event updates without any channel designation will not be included in the subscription. Defaults to no channels filter. */ - channels?: string | string[]; - /** if true, the data object passed to server.emit() is cloned before it is passed to the listener method. Defaults to the event registration option (which defaults to false). */ - clone?: boolean; - /** a positive integer indicating the number of times the listener can be called after which the subscription is automatically removed. A count of 1 is the same as calling server.once(). Defaults to no limit. */ - count?: number; - /** - * the event tags (if present) to subscribe to - * If the object is given: - * * tags - a tag string or array of tag strings. - * * all - if true, all tags must be present for the event update to match the subscription. Defaults to false (at least one matching tag). - */ - filter?: string | string[] | {tags: string | string[], all?: boolean}; - /** if true, and the data object passed to server.emit() is an array, the listener method is called with each array element passed as a separate argument. This should only be used when the emitted data structure is known and predictable. Defaults to the event registration option (which defaults to false). */ - spread?: boolean; - /** if true and the criteria object passed to server.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end (but before the callback argument if block is set). Defaults to the event registration option (which defaults to false). */ - tags?: boolean; -} - -/** - * Server methods, user configured - * Related to [See docs](https://hapijs.com/api/16.1.1#servermethods) - * Related to [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) - */ -export interface ServerMethod { - /** the method must return a value (result, Error, or a promise) or throw an Error. */ - (...args: any[]): any | Error | Promise; - /** Not possible to improve this typing due to this unresolvable issue: https://github.com/Microsoft/TypeScript/issues/15190 */ - (...args: (any | ServerMethodNext)[]): void; - /** When configured with caching enabled, server.methods[name].cache will be an object see ServerMethodNameCacheObject */ - cache?: ServerMethodNameCacheObject; -} - -/** - * Related to [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) - * @param err error response if the method failed. - * @param result the return value. - * @param ttl 0 if result is valid but cannot be cached. Defaults to cache policy. - */ -export interface ServerMethodNext { - (err: Error | null, result: any, ttl?: number): void; -} - -/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) */ -export interface ServerMethodNameCacheObject { - /** - * function that can be used to clear the cache for a given key. - * @param ...args any number of string, number or boolean. If other types then generateKey function must be specified. - * @param callback last argument is a callback. - * Not possible to improve this typing due to this unresolvable issue: https://github.com/Microsoft/TypeScript/issues/15190 - */ - drop(...args: (any | Function)[]): void; - /** an object with cache statistics, see stats documentation for catbox. */ - stats: Catbox.CacheStatisticsObject; -} - -/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) */ -export interface ServerMethodOptions { - /** a context object passed back to the method function (via this) when called. Defaults to active context (set via server.bind() when the method is registered. Ignored if the method is an arrow function. */ - bind?: any; - /** the same cache configuration used in server.cache(). The generateTimeout option is required. */ - cache?: CatboxServerCacheConfiguration; - /** - * if false, expects the method to be a synchronous function. Note that using a synchronous function with caching will convert the method interface to require a callback as an additional argument with the signature function(err, result, cached, report) since the cache interface cannot return values synchronously. Defaults to true. - * TODO: understand and type "an additional argument with the signature function(err, result, cached, report)" if appropriate. - */ - callback?: boolean; - /** a function used to generate a unique key (for caching) from the arguments passed to the method function (the callback argument is not passed as input). The server will automatically generate a unique key if the function's arguments are all of types 'string', 'number', or 'boolean'. However if the method uses other types of arguments, a key generation function must be provided which takes the same arguments as the function and returns a unique string (or null if no key can be generated). */ - generateKey?(args: any[]): string | null; -} - -/** For context [See docs](https://hapijs.com/api/16.1.1#servermethodmethods) */ -export interface ServerMethodConfigurationObject { - name: string; - method: ServerMethod; - options: ServerMethodOptions; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Caching with Catbox + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * TODO confirm this is the same as CatboxServerCacheConfiguration - * - * ** - * Server instantiation options configuration for Catbox cache - * TODO: check it extends Catbox.PolicyOptions and this is what "other options passed to the catbox strategy used." means. - * For context [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) under: options > cache > a configuration object - * ** - * export interface CatboxServerOptionsCacheConfiguration extends Catbox.IPolicyOptions { - * // a prototype function or catbox engine object. - * engine: Catbox.EnginePrototypeOrObject; - * // an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. - * name?: string; - * // if true, allows multiple cache users to share the same segment (e.g. multiple methods using the same cache storage container). Default to false. - * shared?: boolean; - * } - */ -export type CatboxServerOptionsCacheConfiguration = CatboxServerCacheConfiguration; - -/** - * Server cache method configuration for Catbox cache - * Used for "Provisions a cache segment within the server cache facility" - * For context [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) - * Also used in [See docs](https://hapijs.com/api/16.1.1#servermethodname-method-options) > options.cache - */ -export interface CatboxServerCacheConfiguration extends Catbox.PolicyOptions { - /** the cache name configured in server.cache. Defaults to the default cache. */ - cache?: string; - /** string segment name, used to isolate cached items within the cache partition. When called within a plugin, defaults to '!name' where 'name' is the plugin name. When called within a server method, defaults to '#name' where 'name' is the server method name. Required when called outside of a plugin. */ - segment?: string; - /** if true, allows multiple cache provisions to share the same segment. Default to false. */ - shared?: boolean; - /** - * a prototype function or catbox engine object. - * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) example code includes use of `engine` option. But server.cache.provision of `options` says "same as the server cache configuration options.". - * TODO confirm once PR to hapi docs accepted / rejected. - */ - engine?: Catbox.EnginePrototypeOrObject; - /** - * an identifier used later when provisioning or configuring caching for server methods or plugins. Each cache name must be unique. A single item may omit the name option which defines the default cache. If every cache includes a name, a default memory cache is provisioned as well. - * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) example code includes use of `name` option. But server.cache.provision of `options` says "same as the server cache configuration options.". - */ - name?: string; - /** - * Additional options to be passed to the Catbox strategy - */ - [s: string]: any; -} - -/** - * Additional notes - * payload - In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided. - * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) - */ -export interface InjectedRequestOptions extends Shot.RequestOptions { - /** an optional credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials. */ - credentials?: any; - /** an optional artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts. */ - artifacts?: any; - /** sets the initial value of request.app. */ - app?: any; - /** sets the initial value of request.plugins. */ - plugins?: PluginsStates; - /** allows access to routes with config.isInternal set to true. Defaults to false. */ - allowInternals?: boolean; -} - -/** - * the response object from server.inject - * [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) - */ -export interface InjectedResponseObject extends Shot.ResponseObject { - /** the raw handler response (e.g. when not a stream or a view) before it is serialized for transmission. If not available, the value is set to payload. Useful for inspection and reuse of the internal objects returned (instead of parsing the response string). */ - result: Object | string; - /** the request object. */ - request: InjectedRequestOptions; -} - -/** - * For context [See docs](https://hapijs.com/api/16.1.1#new-serveroptions) under: options > connections - */ -export interface ConnectionConfigurationServerDefaults { - /** application-specific connection configuration which can be accessed via connection.settings.app. Provides a safe place to store application configuration without potential conflicts with the framework internals. Should not be used to configure plugins which should use plugins[name]. Note the difference between connection.settings.app which is used to store configuration values and connection.app which is meant for storing run-time state. */ - app?: any; - /** if false, response content encoding is disabled. Defaults to true */ - compression?: boolean; - /** connection load limits configuration where: */ - load?: { - /** maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ - maxHeapUsedBytes?: number; - /** maximum process RSS size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ - maxRssBytes?: number; - /** maximum event loop delay duration in milliseconds over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */ - maxEventLoopDelay?: number; - }; - /** plugin-specific configuration which can later be accessed via connection.settings.plugins. Provides a place to store and pass connection-specific plugin configuration. plugins is an object where each key is a plugin name and the value is the configuration. Note the difference between connection.settings.plugins which is used to store configuration values and connection.plugins which is meant for storing run-time state. */ - plugins?: PluginSpecificConfiguration; - /** controls how incoming request URIs are matched against the routing table: */ - router?: { - /** determines whether the paths '/example' and '/EXAMPLE' are considered different resources. Defaults to true. */ - isCaseSensitive?: boolean; - /** removes trailing slashes on incoming paths. Defaults to false. */ - stripTrailingSlash?: boolean; - }; - /** a route options object used to set the default configuration for every route. */ - routes?: RouteAdditionalConfigurationOptions; - /** sets the default configuration for every state (cookie) set explicitly via server.state() or implicitly (without definition) using the [state configuration object](https://hapijs.com/api/16.1.1#serverstatename-options). */ - state?: ServerStateCookieConfiguationObject; -} - -/** - * a connection configuration object or array of objects with the following optional keys. - * Any connections configuration server defaults can be included to override and customize the individual connection. - * [See docs](https://hapijs.com/api/16.1.1#serverconnectionoptions) - */ -export interface ServerConnectionOptions extends ConnectionConfigurationServerDefaults { - /** host - the public hostname or IP address. Used only to set server.info.host and server.info.uri. If not configured, defaults to the operating system hostname and if not available, to 'localhost'. */ - host?: string; - /** address - sets the host name or IP address the connection will listen on. If not configured, defaults to host if present, otherwise to all available network interfaces (i.e. '0.0.0.0'). Set to 127.0.0.1 or localhost to restrict connection to only those coming from the same machine. */ - address?: string; - /** port - the TCP port the connection will listen to. Defaults to an ephemeral port (0) which uses an available port when the server is started (and assigned to server.info.port). If port is a string containing a '/' character, it is used as a UNIX domain socket path and if it starts with '\.\pipe' as a Windows named pipe. */ - port?: string | number; - /** uri - the full public URI without the path (e.g. 'http://example.com:8080'). If present, used as the connection info.uri otherwise constructed from the connection settings. */ - uri?: string; - /** listener - optional node.js HTTP (or HTTPS) http.Server object or any compatible object. If the listener needs to be manually started, set autoListen to false. If the listener uses TLS, set tls to true. */ - listener?: http.Server; - /** autoListen - indicates that the connection.listener will be started manually outside the framework. Cannot be specified with a port setting. Defaults to true. */ - autoListen?: boolean; - /** labels - a string or string array of labels used to server.select() specific connections matching the specified labels. Defaults to an empty array [] (no labels). */ - labels?: string | string[]; - /** tls - used to create an HTTPS connection. The tls object is passed unchanged as options to the node.js HTTPS server as described in the node.js HTTPS [documentation](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener}) . Set to true when passing a listener object that has been configured to use TLS directly. */ - tls?: true | https.RequestOptions; -} - -/** - * For context see RouteAdditionalConfigurationOptions > compression - * For context [See docs](https://hapijs.com/api/16.1.1#serverencoderencoding-encoder) - */ -export type CompressionEncoderSettings = any; - -/** - * For context see RouteAdditionalConfigurationOptions > payload > compression - * For context [See docs](https://hapijs.com/api/16.1.1#serverdecoderencoding-decoder) - */ -export type CompressionDecoderSettings = any; - -/** - * an optional function called after all the specified dependencies have been registered and before the server starts. The function is only called if the server is initialized or started. If a circular dependency is detected, an exception is thrown (e.g. two plugins each has an after function to be called after the other). The function signature is function(server, next) where: - * [See docs](https://hapijs.com/api/16.1.1#serverdependencydependencies-after) - * Also see Server.dependency - * @param server the server the dependency() method was called on. - * @param next the callback function the method must call to return control over to the application and complete the registration process. The function signature is function(err) where: - * * err - internal error condition, which is returned back via the server.initialize() or server.start() callback. - */ -export interface AfterDependencyLoadCallback { - (server: Server, next: (err?: Error) => void): void; -} - -/** For context see RouteAdditionalConfigurationOptions > auth */ -export interface AuthOptions { - /** - * the authentication mode. Defaults to 'required' if a server authentication strategy is configured, otherwise defaults to no authentication. Available values: - * * 'required' - authentication is required. - * * 'optional' - authentication is optional (must be valid if present). - * * 'try' - same as 'optional' but allows for invalid authentication. - */ - mode?: 'required' | 'optional' | 'try'; - /** a string array of strategy names in order they should be attempted. If only one strategy is used, strategy can be used instead with the single string value. Defaults to the default authentication strategy which is available only when a single strategy is configured. */ - strategies?: string[]; - strategy?: string; - /** - * if set, the payload (in requests other than 'GET' and 'HEAD') is authenticated after it is processed. Requires a strategy with payload authentication support (e.g. Hawk). Cannot be set to a value other than 'required' when the scheme sets the options.payload to true. Available values: - * * false - no payload authentication. This is the default value. - * * 'required' - payload authentication required. This is the default value when the scheme sets options.payload to true. - * * 'optional' - payload authentication performed only when the client includes payload authentication information (e.g. hash attribute in Hawk). - */ - payload?: false | 'required' | 'optional'; - /** specifying the route access rules. */ - access?: RouteAuthAccessConfiguationObject | RouteAuthAccessConfiguationObject[]; - /** (undocumented) Convenience way of setting access.scope, will over write all values in `access` */ - scope?: false | string | string[]; - /** (undocumented) Convenience way of setting access.entity, will over write all values in `access` */ - entity?: 'any' | 'user' | 'app'; -} - -/** - * Each rule is evaluated against an incoming request and access is granted if at least one rule matches. Each rule object must include at least one of: - * For context see RouteAdditionalConfigurationOptions > auth > an object > access - */ -export interface RouteAuthAccessConfiguationObject { - /** the application scope required to access the route. Value can be a scope string or an array of scope strings. The authenticated credentials object scope property must contain at least one of the scopes defined to access the route. If a scope string begins with a + character, that scope is required. If a scope string begins with a ! character, that scope is forbidden. For example, the scope ['!a', '+b', 'c', 'd'] means the incoming request credentials' scope must not include 'a', must include 'b', and must include one of 'c' or 'd'. You may also access properties on the request object (query and params) to populate a dynamic scope by using {} characters around the property name, such as 'user-{params.id}'. Defaults to false (no scope requirements). */ - scope?: false | string | string[]; - /** - * the required authenticated entity type. If set, must match the entity value of the authentication credentials. Available values: - * * any - the authentication can be on behalf of a user or application. This is the default value. - * * user - the authentication must be on behalf of a user which is identified by the presence of a user attribute in the credentials object returned by the authentication strategy. - * * app - the authentication must be on behalf of an application which is identified by the lack of presence of a user attribute in the credentials object returned by the authentication strategy. - */ - entity?: 'any' | 'user' | 'app'; -} - -/** - * For context see RouteAdditionalConfigurationOptions > cache - */ -export type RouteCacheOptions = { - /** - * determines the privacy flag included in client-side caching using the 'Cache-Control' header. Values are: - * * 'default' - no privacy flag. This is the default setting. - * * 'public' - mark the response as suitable for public caching. - * * 'private' - mark the response as suitable only for private caching. - */ - privacy?: 'default' | 'public' | 'private'; - /** an array of HTTP response status codes (e.g. 200) which are allowed to include a valid caching directive. Defaults to [200]. */ - statuses?: number[]; - /** a string with the value of the 'Cache-Control' header when caching is disabled. Defaults to 'no-cache'. */ - otherwise?: string; -} & ({ - /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ - expiresIn?: number; - /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ - expiresAt?: undefined; -} | { - /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ - expiresIn?: undefined; - /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ - expiresAt?: string; -} | { - /** relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */ - expiresIn?: undefined; - /** time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Cannot be used together with expiresIn. */ - expiresAt?: undefined; -}); - -/** - * For context see RouteAdditionalConfigurationOptions > cors - */ -export interface CorsConfigurationObject { - /** a strings array of allowed origin servers ('Access-Control-Allow-Origin'). The array can contain any combination of fully qualified origins along with origin strings containing a wildcard '*' character, or a single '*' origin string. Defaults to any origin ['*']. */ - origin?: string[] | '*'; - /** number of seconds the browser should cache the CORS response ('Access-Control-Max-Age'). The greater the value, the longer it will take before the browser checks for changes in policy. Defaults to 86400 (one day). */ - maxAge?: number; - /** a strings array of allowed headers ('Access-Control-Allow-Headers'). Defaults to ['Accept', 'Authorization', 'Content-Type', 'If-None-Match'] */ - headers?: string[]; - /** a strings array of additional headers to headers. Use this to keep the default headers in place. */ - additionalHeaders?: string[]; - /** a strings array of exposed headers ('Access-Control-Expose-Headers'). Defaults to ['WWW-Authenticate', 'Server-Authorization']. */ - exposedHeaders?: string[]; - /** a strings array of additional headers to exposedHeaders. Use this to keep the default headers in place. */ - additionalExposedHeaders?: string[]; - /** if true, allows user credentials to be sent ('Access-Control-Allow-Credentials'). Defaults to false. */ - credentials?: boolean; -} - -/** - * An object describing the extension function used whilst registering the extension function in one of the available extension points - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * For context see RouteAdditionalConfigurationOptions > ext - */ -export interface ServerStartExtConfigurationObject { - /** the extension point event name. */ - type: ServerStartExtPoints; - /** - * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler - */ - method: ServerExtFunction | ServerExtFunction[]; - options?: ServerExtOptions; -} - -/** - * An object describing the extension function used whilst registering the extension function in one of the available extension points - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * For context see RouteAdditionalConfigurationOptions > ext - */ -export interface ServerRequestExtConfigurationObject { - /** the extension point event name. */ - type: ServerRequestExtPointsBase; - /** - * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler - */ - method: ServerExtRequestHandler | ServerExtRequestHandler[] - options?: ServerExtOptions; -} - -/** - * An object describing the extension function used whilst registering the extension function in one of the available extension points - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * For context see RouteAdditionalConfigurationOptions > ext - */ -export interface ServerRequestExtConfigurationObjectWithRequest { - /** the extension point event name. */ - type: ServerRequestExtPoints; - /** - * a function or an array of functions to be executed at a specified point during request processing. The required extension function signature is see ServerExtFunction or see ServerExtRequestHandler - */ - method: ServerExtRequestHandler | ServerExtRequestHandler[]; - options?: ServerExtOptions; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#route-configuration) > ext - */ -export type RouteExtConfigurationObject = ServerStartExtConfigurationObject | ServerRequestExtConfigurationObject; - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > method - */ -export type ServerExtMethod = ServerExtFunction | ServerExtRequestHandler; - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > options - */ -export interface ServerExtOptions { - /** before - a string or array of strings of plugin names this method must execute before (on the same event). Otherwise, extension methods are executed in the order added. */ - before: string | string[]; - /** after - a string or array of strings of plugin names this method must execute after (on the same event). Otherwise, extension methods are executed in the order added. */ - after: string | string[]; - /** bind - a context object passed back to the provided method (via this) when called. Ignored if the method is an arrow function. */ - bind: any; - /** sandbox - if set to 'plugin' when adding a request extension points the extension is only added to routes defined by the current plugin. Not allowed when configuring route-level extensions, or when adding server extensions. Defaults to 'connection' which applies to any route added to the connection the extension is added to. */ - sandbox?: 'connection' | 'plugin'; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) > events > type - * * 'onPreStart' - called before the connection listeners are started. - * * 'onPostStart' - called after the connection listeners are started. - * * 'onPreStop' - called before the connection listeners are stopped. - * * 'onPostStop' - called after the connection listeners are stopped. - */ -export type ServerStartExtPoints = 'onPreStart' | 'onPostStart' | 'onPreStop' | 'onPostStop'; -/** - * [See docs](https://hapijs.com/api/16.1.1#request-lifecycle) - * * The available extension points include the request extension points as well as the following server extension points: - */ -export type ServerRequestExtPointsBase = 'onPreResponse' | 'onPreAuth' | 'onPostAuth' | 'onPreHandler' | 'onPostHandler' | 'onPreResponse'; - -export type ServerRequestExtPoints = ServerRequestExtPointsBase | 'onRequest'; - -/** - * Server extension function registered an one of the server extension points - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * For context see ServerExtConfigurationObject - * @param server - the server object. - * @param next - the continuation method with signature function(err). - * @param this - the object provided via options.bind or the current active context set with server.bind(). - */ -export interface ServerExtFunction { - (server: Server, next: ContinuationFunction): void; -} - -/** - * For context see RouteAdditionalConfigurationOptions > payload - */ -export interface RoutePayloadConfigurationObject { - /** - * the type of payload representation requested. The value must be one of: - * * 'data' - the incoming payload is read fully into memory. If parse is true, the payload is parsed (JSON, form-decoded, multipart) based on the 'Content-Type' header. If parse is false, the raw Buffer is returned. This is the default value except when a proxy handler is used. - * * 'stream' - the incoming payload is made available via a Stream.Readable interface. If the payload is 'multipart/form-data' and parse is true, fields values are presented as text while files are provided as streams. File streams from a 'multipart/form-data' upload will also have a property hapi containing filename and headers properties. - * * 'file' - the incoming payload is written to temporary file in the directory specified by the server's payload.uploads settings. If the payload is 'multipart/form-data' and parse is true, fields values are presented as text while files are saved. Note that it is the sole responsibility of the application to clean up the files generated by the framework. This can be done by keeping track of which files are used (e.g. using the request.app object), and listening to the server 'response' event to perform any needed cleanup. - */ - output?: PayLoadOutputOption; - /** - * can be true, false, or gunzip; determines if the incoming payload is processed or presented raw. true and gunzip includes gunzipping when the appropriate 'Content-Encoding' is specified on the received request. If parsing is enabled and the 'Content-Type' is known (for the whole payload as well as parts), the payload is converted into an object when possible. If the format is unknown, a Bad Request (400) error response is sent. Defaults to true, except when a proxy handler is used. The supported mime types are: - * * 'application/json' - * * 'application/x-www-form-urlencoded' - * * 'application/octet-stream' - * * 'text/*' - * * 'multipart/form-data' - */ - parse?: 'gunzip' | boolean; - /** - * overrides payload processing for multipart requests. Value can be one of: - * * false - disables multipart processing. - * * object with the following required options: - * * output - same as the payload.output option with an additional value option: - * * annotated - wraps each multipart part in an object with the following keys: // TODO type this? - * * headers - the part headers. - * * filename - the part file name. - * * payload - the processed part payload. - */ - multipart?: false | { - output: PayLoadOutputOption | 'annotated'; - }; - /** a string or an array of strings with the allowed mime types for the endpoint. Defaults to any of the supported mime types listed above. Note that allowing other mime types not listed will not enable them to be parsed, and that if parsing mode is 'parse', the request will result in an error response. */ - allow?: string | string[]; - /** a mime type string overriding the 'Content-Type' header value received. Defaults to no override. */ - override?: string; - /** limits the size of incoming payloads to the specified byte count. Allowing very large payloads may cause the server to run out of memory. Defaults to 1048576 (1MB). */ - maxBytes?: number; - /** payload reception timeout in milliseconds. Sets the maximum time allowed for the client to transmit the request payload (body) before giving up and responding with a Request Timeout (408) error response. Set to false to disable. Defaults to 10000 (10 seconds). */ - timeout?: number | false; - /** the directory used for writing file uploads. Defaults to os.tmpdir(). */ - uploads?: string; - /** - * determines how to handle payload parsing errors. Allowed values are: - * * 'error' - return a Bad Request (400) error response. This is the default value. - * * 'log' - report the error but continue processing the request. - * * 'ignore' - take no action and continue processing the request. - */ - failAction?: 'error' | 'log' | 'ignore'; - /** the default 'Content-Type' HTTP header value is not present. Defaults to 'application/json'. */ - defaultContentType?: string; - /** an object where each key is a content-encoding name and each value is an object with the desired decoder settings. Note that encoder settings are set in the root option compression. */ - compression?: Dictionary; -} - -export type PayLoadOutputOption = 'data' | 'stream' | 'file'; - -/** - * events must be one of: - * * an event name string. - * * an event options object see ApplicationEventOptionsObject - * * a podium [See docs](https://github.com/hapijs/podium) emitter object. - * For context [See docs](https://hapijs.com/api/16.1.1#servereventevents) > events parameter - */ -export type ApplicationEvent = string | ApplicationEventOptionsObject | Podium; - -/** - * an event options object - * For context see ApplicationEvent - * For context [See docs](https://hapijs.com/api/16.1.1#servereventevents) > events parameter - */ -export interface ApplicationEventOptionsObject { - /** the event name string (required). */ - name: string; - /** a string or array of strings specifying the event channels available. Defaults to no channel restrictions (event updates can specify a channel or not). */ - channels?: string | string[]; - /** if true, the data object passed to server.emit() is cloned before it is passed to the listeners (unless an override specified by each listener). Defaults to false (data is passed as-is). */ - clone?: boolean; - /** if true, the data object passed to server.emit() must be an array and the listener method is called with each array element passed as a separate argument (unless an override specified by each listener). This should only be used when the emitted data structure is known and predictable. Defaults to false (data is emitted as a single argument regardless of its type). */ - spread?: boolean; - /** if true and the criteria object passed to server.emit() includes tags, the tags are mapped to an object (where each tag string is the key and the value is true) which is appended to the arguments list at the end (but before the callback argument if block is set). A configuration override can be set by each listener. Defaults to false. */ - tags?: boolean; - /** if true, the same event name can be registered multiple times where the second registration is ignored. Note that if the registration config is changed between registrations, only the first configuration is used. Defaults to false (a duplicate registration will throw an error). */ - shared?: boolean; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Route + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Route configuration - * The route configuration object - * - * [See docs](https://hapijs.com/api/16.1.1#route-configuration) - * - * TODO typings check that the following refers to RouteAdditionalConfigurationOptions "Note that the options object is deeply cloned (with the exception of bind which is shallowly copied) and cannot contain any values that are unsafe to perform deep copy on." - */ -export interface RouteConfiguration { - /** the absolute path used to match incoming requests (must begin with '/'). Incoming requests are compared to the configured paths based on the connection router configuration option. The path can include named parameters enclosed in {} which will be matched against literal values in the request as described in Path parameters. */ - path: string; - /** the HTTP method. Typically one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', or 'OPTIONS'. Any HTTP method is allowed, except for 'HEAD'. Use '*' to match against any HTTP method (only when an exact match was not found, and any match with a specific method will be given a higher priority over a wildcard match). Can be assigned an array of methods which has the same result as adding the same route with different methods manually. */ - method: HTTP_METHODS_PARTIAL | '*' | (HTTP_METHODS_PARTIAL | '*')[]; - /** an optional domain string or an array of domain strings for limiting the route to only requests with a matching host header field. Matching is done against the hostname part of the header only (excluding the port). Defaults to all hosts. */ - vhost?: string; - /** the function called to generate the response after successful authentication and validation. The handler function is described in Route handler. If set to a string, the value is parsed the same way a prerequisite server method string shortcut is processed. Alternatively, handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler. */ - handler?: string | RouteHandler | RouteHandlerPlugins; - /** additional route options. The config value can be an object or a function that returns an object using the signature function(server) where server is the server the route is being added to and this is bound to the current realm's bind option. */ - config?: RouteAdditionalConfigurationOptions | ((server: Server) => RouteAdditionalConfigurationOptions); -} - -/** - * Route options - * Each route can be customize to change the default behavior of the request lifecycle using the following options: - * [See docs](https://hapijs.com/api/16.1.1#route-options) - */ -export interface RouteAdditionalConfigurationOptions { - /** application specific configuration.Should not be used by plugins which should use plugins[name] instead. */ - app?: any; - /** - * Authentication configuration. Value can be: - * * false to disable authentication if a default strategy is set. - * * a string with the name of an authentication strategy registered with server.auth.strategy(). - * * an object - */ - auth?: false | string | AuthOptions; - /** an object passed back to the provided handler (via this) when called. Ignored if the method is an arrow function. */ - bind?: any; - /** - * Route cache options - * if the route method is 'GET', the route can be configured to include caching directives in the response. The default Cache-Control: no-cache header can be disabled by setting cache to false. Caching can be customized using an object - * TODO check: the default is to have 'Cache-Control: no-cache', but on first reading is a contridiction as you can disabled cache and disabled no-cache by setting RouteCacheOptions to false? - */ - cache?: boolean | RouteCacheOptions; - /** an object where each key is a content-encoding name and each value is an object with the desired encoder settings. Note that decoder settings are set in payload.compression. */ - compression?: Dictionary; - /** the Cross-Origin Resource Sharing protocol allows browsers to make cross-origin API calls. CORS is required by web applications running inside a browser which are loaded from a different domain than the API server. CORS headers are disabled by default (false). To enable, set cors to true, or to an object */ - cors?: boolean | CorsConfigurationObject; - /** defined a route-level request extension points by setting the option to an object with a key for each of the desired extension points ('onRequest' is not allowed), and the value is the same as the [server.ext(events)](https://hapijs.com/api/16.1.1#serverextevents) event argument. */ - ext?: RouteExtConfigurationObject | RouteExtConfigurationObject[]; - /** defines the behavior for accessing files: */ - files?: { - /** determines the folder relative paths are resolved against. */ - relativeTo: string; - }; - /** an alternative location for the route.handler option. */ - handler?: string | RouteHandler; - /** an optional unique identifier used to look up the route using server.lookup(). Cannot be assigned to routes with an array of methods. */ - id?: string; - /** if true, the route cannot be accessed through the HTTP connection but only through the server.inject() interface with the allowInternals option set to true. Used for internal routes that should not be accessible to the outside world. Defaults to false. */ - isInternal?: boolean; - /** optional arguments passed to JSON.stringify() when converting an object or error response to a string payload. Supports the following: */ - json?: Json.StringifyArguments & { - /** string suffix added after conversion to JSON string. Defaults to no suffix. */ - suffix?: string; - }; - /** enables JSONP support by setting the value to the query parameter name containing the function name used to wrap the response payload. For example, if the value is 'callback', a request comes in with 'callback=me', and the JSON response is '{ "a":"b" }', the payload will be 'me({ "a":"b" });'. Does not work with stream responses. Headers content-type and x-content-type-options are set to text/javascript and nosniff respectively, and will override those headers even if explicitly set by response.type() */ - jsonp?: string; - /** if true, request level logging is enabled (accessible via request.getLog()). */ - log?: boolean; - /** - * determines how the request payload is processed - * [See docs](https://hapijs.com/api/16.1.1#route-options) - */ - payload?: RoutePayloadConfigurationObject; - /** plugin-specific configuration. plugins is an object where each key is a plugin name and the value is the plugin configuration. */ - plugins?: PluginSpecificConfiguration; - /** an array with [route prerequisites](https://hapijs.com/api/16.1.1#route-prerequisites) methods which are executed in serial or in parallel before the handler is called. */ - pre?: RoutePrerequisitesArray; - /** processing rules for the outgoing response */ - response?: RouteResponseConfigurationObject; - /** sets common security headers (disabled by default). To enable set security to true or to an object with the following options: See RouteSecurityConfigurationObject */ - security?: boolean | RouteSecurityConfigurationObject; - /** HTTP state management (cookies) allows the server to store information on the client which is sent back to the server with every request (as defined in RFC 6265). state supports the following options: */ - state?: { - /** determines if incoming 'Cookie' headers are parsed and stored in the request.state object. Defaults to true. */ - parse?: boolean; - /** - * determines how to handle cookie parsing errors. Allowed values are: - * * 'error' - return a Bad Request (400) error response. This is the default value. - * * 'log' - report the error but continue processing the request. - * * 'ignore' - take no action. - */ - failAction: 'error' | 'log' | 'ignore'; - }; - /** request input validation rules for various request components. When using a Joi validation object, the values of the other inputs (i.e. headers, query, params, payload, and auth) are made available under the validation context (accessible in rules as Joi.ref('$query.key')). Note that validation is performed in order (i.e. headers, params, query, payload) and if type casting is used (converting a string to number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. If the validation rules for headers, params, query, and payload are defined at both the routes defaults level and an individual route, the individual route settings override the routes defaults (the rules are not merged). The validate object supports: */ - validate?: RouteValidationConfigurationObject; - /** define timeouts for processing durations: */ - timeout?: { - /** response timeout in milliseconds. Sets the maximum time allowed for the server to respond to an incoming client request before giving up and responding with a Service Unavailable (503) error response. Disabled by default (false). */ - server?: boolean | number; - /** by default, node sockets automatically timeout after 2 minutes. Use this option to override this behavior. Defaults to undefined which leaves the node default unchanged. Set to false to disable socket timeouts. */ - socket?: boolean | number; - }; - - /** - * TODO decide on moving these to an extended interface of RouteAdditionalConfigurationOptions - */ - /** - * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - * route description used for generating documentation - */ - description?: string; - /** - * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - * route notes used for generating documentation - */ - notes?: string | string[]; - /** - * ONLY WHEN ADDING NEW ROUTES (not when setting defaults). - * route tags used for generating documentation - */ - tags?: string[]; -} - -/** - * Route public interface - * When route information is returned or made available as a property, it is an object with the following: - * [See docs](https://hapijs.com/api/16.1.1#route-public-interface) - */ -export interface RoutePublicInterface { - /** the route HTTP method. */ - method: string; - /** the route path. */ - path: string; - /** the route vhost option if configured. */ - vhost?: string | string[]; - /** the [active realm] [See docs](https://hapijs.com/api/16.1.1#serverrealm) associated with the route.*/ - realm: ServerRealm; - /** the [route options] [See docs](https://hapijs.com/api/16.1.1#route-options) object with all defaults applied. */ - settings: RouteAdditionalConfigurationOptions; - /** the route internal normalized string representing the normalized path. */ - fingerprint: string; - /** route authentication utilities: */ - auth: { - /** authenticates the passed request argument against the route's authentication access configuration. Returns true if the request would have passed the route's access requirements. Note that the route's authentication mode and strategies are ignored. The only match is made between the request.auth.credentials scope and entity information and the route access configuration. Also, if the route uses dynamic scopes, the scopes are constructed against the request.query and request.params which may or may not match between the route and the request's route. If this method is called using a request that has not been authenticated (yet or at all), it will return false if the route requires any authentication. */ - access(request: Request): boolean; - }; -} - -export type RouteHandlerConfig = any; - -/** - * For context [See docs](https://hapijs.com/api/16.1.1#serverhandlername-method) - * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/handler.js#L103) - * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/route.js#L56-L60) - * TODO check the type of `RouteHandlerConfig` is correct for `defaults`. - */ -export interface MakeRouteHandler { - (route: RoutePublicInterface, options: RouteHandlerConfig): RouteHandler; - defaults?: RouteHandlerConfig | ((method: HTTP_METHODS_PARTIAL_lowercase) => RouteHandlerConfig); -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#servertablehost) > return value - */ -export interface RoutingTableEntry { - /** the connection.info the connection the table was generated for. */ - info: ServerConnectionInfo; - /** the connection labels. */ - labels: string[]; - /** an array of routes where each route contains: */ - table: Route[]; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#servertablehost) > return value - * For source [See source](https://github.com/hapijs/hapi/blob/v16.1.1/lib/route.js#L71) - */ -export interface Route { - /** - * the route config with defaults applied. - * TODO check type of RouteConfiguration here is correct - */ - settings: RouteAdditionalConfigurationOptions; - /** - * the HTTP method in lower case. - * TODO, check if it can contain 'head' or not. - */ - method: HTTP_METHODS_PARTIAL_lowercase; - /** the route path. */ - path: string; - - params: string[]; - - connection: ServerConnection; - - fingerprint: string; - - plugin?: any; - - public: RoutePublicInterface; - - server: Server; -} - -/** - * Route Prerequisites - * It is often necessary to perform prerequisite actions before the handler is called (e.g. load required reference data from a database). The route pre option allows defining such pre-handler methods. The methods are called in order. If the pre array contains another array, those methods are called in parallel. pre can be assigned a mixed array of: - * * arrays containing the elements listed below, which are executed in parallel. - * * objects see RoutePrerequisiteObjects - * * functions - same as including an object with a single method key. - * * strings - special short-hand notation for registered server methods using the format 'name(args)' (e.g. 'user(params.id)') where: - * * 'name' - the method name. The name is also used as the default value of assign. - * * 'args' - the method arguments (excluding next) where each argument is a property of the request object - * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) - * For context see RouteAdditionalConfigurationOptions > pre - * - * TODO follow up on "server methods" in "special short-hand notation for registered server methods" at https://hapijs.com/api/16.1.1#servermethodname-method-options - * TODO follow up on "request object" in "each argument is a property of the request object" at https://hapijs.com/api/16.1.1#request-object - */ -export type RoutePrerequisitesArray = RoutePrerequisitesPart[] | (RoutePrerequisitesPart[] | RoutePrerequisitesPart)[]; -export type RoutePrerequisitesPart = RoutePrerequisiteObjects | RoutePrerequisiteRequestHandler | string; - -/** - * see RoutePrerequisites > objects - */ -export interface RoutePrerequisiteObjects { - /** the function to call (or short-hand method string as described below [see RoutePrerequisitesArray]). the function signature is identical to a route handler as described in Route handler. */ - method: RoutePrerequisiteRequestHandler | string; - /** key name to assign the result of the function to within request.pre. */ - assign: string; - /* - * determines how to handle errors returned by the method. Allowed values are: - * * 'error' - returns the error response back to the client. This is the default value. - * * 'log' - logs the error but continues processing the request. If assign is used, the error will be assigned. - * * 'ignore' - takes no special action. If assign is used, the error will be assigned. - */ - failAction?: 'error' | 'log' | 'ignore'; -} - -/** - * For context see RouteAdditionalConfigurationOptions > response - */ -export interface RouteResponseConfigurationObject { - /** the default HTTP status code when the payload is empty. Value can be 200 or 204. Note that a 200 status code is converted to a 204 only at the time or response transmission (the response status code will remain 200 throughout the request lifecycle unless manually set). Defaults to 200. */ - emptyStatusCode?: number; - /** - * defines what to do when a response fails payload validation. Options are: - * * 'error' - return an Internal Server Error (500) error response. This is the default value. - * * 'log' - log the error but send the response. - * * a custom error handler function with the signature function(request, reply, source, error) where: - * * 'request' - the request object. - * * 'reply' - the continuation reply interface. - * * 'error' - the error returned from the validation schema. - * TODO update type of source once PR to hapi is concluded. - */ - failAction?: 'error' | 'log' | ((request: Request, reply: ReplyWithContinue, source: string, error: Boom.BoomError) => void); - /** if true, applies the validation rule changes to the response payload. Defaults to false. */ - modify?: boolean; - /** - * options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is available [here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback) ). - * If a custom validation function (see `schema` or `status` below) is defined then `options` can an arbitrary object that will be passed to this function as the second parameter. - * Defaults to no options. - */ - options?: ValidationOptions; - /** if false, payload range support is disabled. Defaults to true. */ - ranges?: boolean; - /** the percent of response payloads validated (0 - 100). Set to 0 to disable all validation. Defaults to 100 (all response payloads). */ - sample?: number; - /** the default response payload validation rules (for all non-error responses) */ - schema?: RouteResponseConfigurationScheme; - /** HTTP status-code-specific payload validation rules. The status key is set to an object where each key is a 3 digit HTTP status code and the value has the same definition as schema. If a response status code is not present in the status object, the schema definition is used, except for errors which are not validated by default. */ - status?: Dictionary>; -} - -/** - * the default response payload validation rules (for all non-error responses) expressed as one of: - * * true - any payload allowed (no validation performed). This is the default. - * * false - no payload allowed. - * * a Joi validation object. This will receive the request's headers, params, query, payload, and auth credentials and isAuthenticated flags as context. - * * a validation function - * - * TODO check JoiValidationObject is correct for "a Joi validation object" - * - * For context see RouteAdditionalConfigurationOptions > response > schema - * and - * For context see RouteAdditionalConfigurationOptions > response > status - */ -export type RouteResponseConfigurationScheme = boolean | JoiValidationObject | ValidationFunctionForRouteResponse; - -/** - * see RouteResponseConfigurationScheme - * - * a validation function using the signature function(value, options, next) where: - * * value - the value of the response passed to `reply(value)` in the handler. - * * options - the server validation options, merged with an object containing the request's headers, params, payload, and auth credentials object and `isAuthenticated` flag. - * * next([err, [value]]) - the callback function called when validation is completed. `value` will be used as the response value when `err` is falsy, when `value` is not `undefined`, and when `route.settings.response.modify` is `true`. If the response is already a `Boom` error it will be set as its `message` value. - */ -export interface ValidationFunctionForRouteResponse { - (value: any, options: RouteResponseValidationContext & ValidationOptions, next: ContinuationValueFunction): void; -} - -/** - * A context for route input validation via a Joi schema or validation function. - * - * This object is merged with the route response options and passed into the validation function. - * - * See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L217 - */ -export interface RouteResponseValidationContext { - context: { - /** The request headers */ - headers: Dictionary; - /** The request path parameters */ - params: any; - /** The request query parameters */ - query: any; - /** The request payload parameters */ - payload: any; - - /** Partial request authentication information */ - auth: { - /** true if the request has been successfully authenticated, otherwise false. */ - isAuthenticated: boolean; - /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ - credentials: AuthenticatedCredentials; - }; - } -} - -/** - * For context see RouteAdditionalConfigurationOptions > security - */ -export interface RouteSecurityConfigurationObject { - /** controls the 'Strict-Transport-Security' header. If set to true the header will be set to max-age=15768000, if specified as a number the maxAge parameter will be set to that number. Defaults to true. You may also specify an object with the following fields: */ - hsts?: boolean | number | { - /** the max-age portion of the header, as a number. Default is 15768000. */ - maxAge?: number; - /** a boolean specifying whether to add the includeSubDomains flag to the header. */ - includeSubdomains?: boolean; - /** a boolean specifying whether to add the 'preload' flag (used to submit domains inclusion in Chrome's HTTP Strict Transport Security (HSTS) preload list) to the header. */ - preload?: boolean; - }; - /** controls the 'X-Frame-Options' header. When set to true the header will be set to DENY, you may also specify a string value of 'deny' or 'sameorigin'. Defaults to true. To use the 'allow-from' rule, you must set this to an object with the following fields: */ - xframe?: true | 'deny' | 'sameorigin' | { - /** may also be 'deny' or 'sameorigin' but set directly as a string for xframe */ - rule: 'allow-from'; - /** when rule is 'allow-from' this is used to form the rest of the header, otherwise this field is ignored. If rule is 'allow-from' but source is unset, the rule will be automatically changed to 'sameorigin'. */ - source: string; - }; - /** boolean that controls the 'X-XSS-PROTECTION' header for IE. Defaults to true which sets the header to equal '1; mode=block'. NOTE: This setting can create a security vulnerability in versions of IE below 8, as well as unpatched versions of IE8. See [here](https://hackademix.net/2009/11/21/ies-xss-filter-creates-xss-vulnerabilities/) and [here](https://technet.microsoft.com/library/security/ms10-002) for more information. If you actively support old versions of IE, it may be wise to explicitly set this flag to false. [Kept typing non optional to force this security related documentation to be read.] */ - xss: boolean; - /** boolean controlling the 'X-Download-Options' header for IE, preventing downloads from executing in your context. Defaults to true setting the header to 'noopen'. */ - noOpen?: boolean; - /** boolean controlling the 'X-Content-Type-Options' header. Defaults to true setting the header to its only and default option, 'nosniff' */ - noSniff?: boolean; -} - -/** - * request input validation rules for various request components. When using a Joi validation object, the values of the other inputs (i.e. headers, query, params, payload, and auth) are made available under the validation context (accessible in rules as Joi.ref('$query.key')). Note that validation is performed in order (i.e. headers, params, query, payload) and if type casting is used (converting a string to number), the value of inputs not yet validated will reflect the raw, unvalidated and unmodified values. If the validation rules for headers, params, query, and payload are defined at both the routes defaults level and an individual route, the individual route settings override the routes defaults (the rules are not merged). The validate object supports: - * For context see RouteAdditionalConfigurationOptions > validate - * TODO check JoiValidationObject is correct for "a Joi validation object" - */ -export interface RouteValidationConfigurationObject { - /** - * validation rules for incoming request headers (note that all header field names must be in lowercase to match the headers normalized by node). Values allowed: - * * true - any headers allowed (no validation performed). This is the default. - * * false - no headers allowed (this will cause all valid HTTP requests to fail). - * * a Joi validation object. - * * a validation function using the signature function(value, options, next) where: - * * value - the object containing the request headers. - * * options - the server validation options. - * * next(err, value) - the callback function called when validation is completed. `value` will be used as the `headers` value when `err` is falsy. If `next` is called with `undefined` or no arguments then the original value of `value` will be used. - */ - headers?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; - /** - * validation rules for incoming request path parameters, after matching the path against the route and extracting any parameters then stored in request.params. Values allowed: - * Same as `headers`, see above. - */ - params?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; - /** - * validation rules for an incoming request URI query component (the key-value part of the URI between '?' and '#'). The query is parsed into its individual key-value pairs and stored in request.query prior to validation. Values allowed: - * Same as `headers`, see above. - */ - query?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; - /** - * validation rules for an incoming request payload (request body). Values allowed: - * Same as `headers`, see above, with the addition that: - * * a Joi validation object. Note that empty payloads are represented by a null value. If a validation schema is provided and empty payload are supported, it must be explicitly defined by setting the payload value to a joi schema with null allowed (e.g. Joi.object({ /* keys here * / }).allow(null)). - */ - payload?: boolean | JoiValidationObject | ValidationFunctionForRouteInput; - /** an optional object with error fields copied into every validation error response. */ - errorFields?: any; - /** - * determines how to handle invalid requests. Allowed values are: - * * 'error' - return a Bad Request (400) error response. This is the default value. - * * 'log' - log the error but continue processing the request. - * * 'ignore' - take no action. - * * a custom error handler function with the signature function(request, reply, source, error) see RouteFailFunction - */ - failAction?: 'error' | 'log' | 'ignore' | RouteFailFunction; - /** - * options to pass to Joi. Useful to set global options such as stripUnknown or abortEarly (the complete list is [available here](https://github.com/hapijs/joi/blob/master/API.md#validatevalue-schema-options-callback)). - * If a custom validation function (see `headers`, `params`, `query`, or `payload` above) is defined then `options` can an arbitrary object that will be passed to this function as the second parameter. - * Defaults to no options. - */ - options?: ValidationOptions; -} - -/** - * a validation function using the signature function(value, options, next) where: - * For context see RouteAdditionalConfigurationOptions > validate (RouteValidationConfigurationObject) - * - * Also see ValidationFunctionForRouteResponse - * @param value - the object containing the request headers, query, path params or payload. - * @param options - the server validation options. - * @param next([err, [value]]) - the callback function called when validation is completed. - */ -export interface ValidationFunctionForRouteInput { - (value: any, options: RouteInputValidationContext & ValidationOptions, next: ContinuationValueFunction): void; -} - -/** - * A context for route input validation via a Joi schema or validation function. - * - * This object is merged with the route validation options and passed into the validation function. - * - * See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L122 - */ -export interface RouteInputValidationContext { - context: { - // These are only set when *not* validating the respective source (e.g. params, query and payload are set when validating headers): - // See https://github.com/hapijs/hapi/blob/v16.1.1/lib/validation.js#L132 - headers?: Dictionary; - params?: any; - query?: any; - payload?: any; - - /** The request authentication information */ - auth: RequestAuthenticationInformation; - } -} - -/** - * a custom error handler function with the signature 'function(request, reply, source, error)` - * @param request - the request object. - * @param reply - the continuation reply interface. - * @param source - the source of the invalid field (e.g. 'headers', 'params', 'query', 'payload'). - * @param error - the error object prepared for the client response (including the validation function error under error.data). - */ -export interface RouteFailFunction { - (request: Request, reply: ReplyWithContinue, source: string, error: any): void; -} - -/** - * optional cookie settings - * [See docs](https://hapijs.com/api/16.1.1#serverstatename-options) - * Related to see ConnectionConfigurationServerDefaults - */ -export interface ServerStateCookieConfiguationObject { - /** time-to-live in milliseconds. Defaults to null (session time-life - cookies are deleted when the browser is closed). */ - ttl?: number | null; - /** sets the 'Secure' flag. Defaults to true. */ - isSecure?: boolean; - /** sets the 'HttpOnly' flag. Defaults to true. */ - isHttpOnly?: boolean; - /** - * sets the 'SameSite' flag where the value must be one of: - * * false - no flag. - * * 'Strict' - sets the value to 'Strict' (this is the default value). - * * 'Lax' - sets the value to 'Lax'. - */ - isSameSite?: false | 'Strict' | 'Lax'; - /** the path scope. Defaults to null (no path). */ - path?: string | null; - /** the domain scope. Defaults to null (no domain). */ - domain?: string | null; - /** - * if present and the cookie was not received from the client or explicitly set by the route handler, the cookie is automatically added to the response with the provided value. The value can be a function with signature function(request, next) where: - * * request - the request object. - * * next - the continuation function using the function(err, value) signature. - */ - autoValue?(request: Request, next: ContinuationValueFunction): void; - /** - * encoding performs on the provided value before serialization. Options are: - * * 'none' - no encoding. When used, the cookie value must be a string. This is the default value. - * * 'base64' - string value is encoded using Base64. - * * 'base64json' - object value is JSON-stringified then encoded using Base64. - * * 'form' - object value is encoded using the x-www-form-urlencoded method. - * * 'iron' - Encrypts and sign the value using iron. - */ - encoding?: 'none' | 'base64' | 'base64json' | 'form' | 'iron'; - /** - * an object used to calculate an HMAC for cookie integrity validation. This does not provide privacy, only a mean to verify that the cookie value was generated by the server. Redundant when 'iron' encoding is used. Options are: - * * integrity - algorithm options. Defaults to require('iron').defaults.integrity. - * * password - password used for HMAC key generation (must be at least 32 characters long). - */ - sign?: { - integrity?: any; // TODO make iron definitions and getting typing from iron - password: string; - }; - /** password used for 'iron' encoding (must be at least 32 characters long). */ - password?: string; - /** options for 'iron' encoding. Defaults to require('iron').defaults. */ - iron?: any; // TODO make iron definitions and getting typing from iron - /** if true, errors are ignored and treated as missing cookies. */ - ignoreErrors?: boolean; - /** if true, automatically instruct the client to remove invalid cookies. Defaults to false. */ - clearInvalid?: boolean; - /** if false, allows any cookie value including values in violation of RFC 6265. Defaults to true. */ - strictHeader?: boolean; - /** used by proxy plugins (e.g. h2o2). */ - passThrough?: any; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverconnections) - */ -export interface ServerConnection { - /** settings - the connection configuration object passed to server.connection() after applying the server defaults. */ - settings: ServerConnectionOptions; - /** server - the connection's Server object. */ - server: Server; - /** type - set to 'tcp' is the connection is listening on a TCP port, otherwise to 'socket'(a UNIX domain socket or a Windows named pipe). */ - type: 'tcp' | 'socket'; - /** - * registrations - * Described [See docs](https://hapijs.com/api/16.1.1#serverregistrations) "When the server contains more than one connection, each server.connections array member provides its own connection.registrations." - */ - registrations: ServerRegisteredPlugins; - /** states - TODO contribute docs to hapi if they want, and then update type here */ - states: any; - /** auth - TODO contribute docs to hapi if they want, and then update type here */ - auth: any; - /** - * plugins - * TODO contribute docs to hapi if they want. Assuming similar to `registrations`, `listener`, `info`, etc - */ - plugins: PluginsStates; - /** - * app - * TODO contribute docs to hapi if they want. Assuming similar to `registrations`, `listener`, `info`, etc - */ - app: any; - /** Described in server.listener [See docs](https://hapijs.com/api/16.1.1#serverlistener) */ - listener: ServerListener; - /** Described in server.info [See docs](https://hapijs.com/api/16.1.1#serverinfo) */ - info: ServerConnectionInfo; - /** Described in server.inject [See docs](https://hapijs.com/api/16.1.1#serverinjectoptions-callback) */ - inject(options: string | InjectedRequestOptions, callback: (res: InjectedResponseObject) => void): void; - inject(options: string | InjectedRequestOptions, ): Promise; - /** Mentioned but not documented under server.connections [See docs](https://hapijs.com/api/16.1.1#serverconnections) */ - table(host?: string): Route[]; - /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#serverlookupid) */ - lookup(id: string): RoutePublicInterface | null; - /** Described in server.table [See docs](https://hapijs.com/api/16.1.1#servermatchmethod-path-host) */ - match(method: HTTP_METHODS, path: string, host?: string): RoutePublicInterface | null; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverinfo) - */ -export interface ServerConnectionInfo { - /** a unique connection identifier (using the format '{hostname}:{pid}:{now base36}'). */ - id: string; - /** the connection creation timestamp. */ - created: number; - /** the connection start timestamp (0 when stopped). */ - started: number; - /** - * the connection port based on the following rules: - * * the configured port value before the server has been started. - * * the actual port assigned when no port is configured or set to 0 after the server has been started. - * TODO check this type. What happens when socket is a UNIX domain socket or Windows named pipe? - */ - port: number | string; - /** the host name the connection was configured to. Defaults to the operating system hostname when available, otherwise 'localhost'. */ - host: string; - /** the active IP address the connection was bound to after starting. Set to undefined until the server has been started or when using a non TCP port (e.g. UNIX domain socket). */ - address: undefined | string; - /** the protocol used. 'socket' when UNIX domain socket or Windows named pipe. */ - protocol: 'http' | 'https' | 'socket'; - /** a string representing the connection (e.g. 'http://example.com:8080' or 'socket:/unix/domain/socket/path'). Contains the uri setting if provided, otherwise constructed from the available settings. If no port is available or set to 0, the uri will not include a port component. */ - uri: string; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverlistener) - */ -export type ServerListener = http.Server; - -/** - * server.realm - * The realm object contains server-wide or plugin-specific state that can be shared across various methods. For example, when calling server.bind(), the active realm settings.bind property is set which is then used by routes and extensions added at the same level (server root or plugin). Realms are a limited version of a sandbox where plugins can maintain state used by the framework when adding routes, extensions, and other properties. - * [See docs](https://hapijs.com/api/16.1.1#serverrealm) - */ -export interface ServerRealm { - /** when the server object is provided as an argument to the plugin register() method, modifiers provides the registration preferences passed the server.register() method and includes: */ - modifiers: { - /** routes preferences: */ - route: { - /** the route path prefix used by any calls to server.route() from the server. Note that if a prefix is used and the route path is set to '/', the resulting path will not include the trailing slash. */ - prefix: string; - /** the route virtual host settings used by any calls to server.route() from the server. */ - vhost: string; - } - }; - /** the active plugin name (empty string if at the server root). */ - plugin: string; - /** the plugin options object passed at registration. */ - pluginOptions: any; // OptionsPassedToPlugin; - /** plugin-specific state to be shared only among activities sharing the same active state. plugins is an object where each key is a plugin name and the value is the plugin state. */ - plugins: PluginsStates; - /** settings overrides (from RouteAdditionalConfigurationOptions) */ - settings: { - files: { - relativeTo: string; - }; - bind: any; - }; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) - */ -export interface ServerRegisteredPlugins { - [pluginName: string]: ServerRegisteredPlugin; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverregistrations) - */ -export interface ServerRegisteredPlugin { - /** the plugin version. */ - version: string; - /** the plugin name. */ - name: string; - /** - * options used to register the plugin. - * TODO update with outcome of: https://github.com/hapijs/hapi/pull/3479 - */ - options: any; // OptionsPassedToPlugin; - /** plugin registration attributes. */ - attributes: PluginAttributes; -} - -export interface ServerAuth { - /** - * server.auth.api - * An object where each key is a strategy name and the value is the exposed strategy API. Available on when the authentication scheme exposes an API by returning an api key in the object returned from its implementation function. - * When the server contains more than one connection, each server.connections array member provides its own connection.auth.api object. - * [See docs](https://hapijs.com/api/16.1.1#serverauthapi) - */ - api: Dictionary; - /** - * server.auth.default - * Sets a default strategy which is applied to every route - * The default does not apply when the route config specifies auth as false, or has an authentication strategy configured (contains the strategy or strategies authentication settings). Otherwise, the route authentication config is applied to the defaults. - * Note that if the route has authentication config, the default only applies at the time of adding the route, not at runtime. This means that calling default() after adding a route with some authentication config will have no impact on the routes added prior. However, the default will apply to routes added before default() is called if those routes lack any authentication config. - * The default auth strategy configuration can be accessed via connection.auth.settings.default. To obtain the active authentication configuration of a route, use connection.auth.lookup(request.route). - * [See docs](https://hapijs.com/api/16.1.1#serverauthdefaultoptions) - */ - default(options: string | AuthOptions): void; - /** - * server.auth.scheme - * Registers an authentication scheme - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) - * @param name the scheme name. - * @param scheme the method implementing the scheme with signature function(server, options) see ServerAuthScheme - */ - scheme(name: string, scheme: ServerAuthScheme): void; - /** - * Registers an authentication strategy - * [See docs](https://hapijs.com/api/16.1.1#serverauthstrategyname-scheme-mode-options) - * @param name the strategy name. - * @param scheme the scheme name (must be previously registered using server.auth.scheme()). - * @param mode if set to true (which is the same as 'required') or to a valid authentication mode ('required', 'optional', 'try'), the scheme is automatically assigned as the default strategy for any route without an auth config. Can only be assigned to a single server strategy. Defaults to false (no default settings). - * @param options scheme options based on the scheme requirements. - */ - strategy(name: string, scheme: string, options?: any): void; - strategy(name: string, scheme: string, mode: boolean | 'required' | 'optional' | 'try', options?: any): void; - /** - * Tests a request against an authentication strategy - * Note that the test() method does not take into account the route authentication configuration. It also does not perform payload authentication. It is limited to the basic strategy authentication execution. It does not include verifying scope, entity, or other route properties. - * [See docs](https://hapijs.com/api/16.1.1#serverauthteststrategy-request-next) - * @param strategy - the strategy name registered with server.auth.strategy(). - * @param request - the request object. - * @param next - the callback function with signature function(err, credentials) where: - * * err - the error if authentication failed. - * * credentials - the authentication credentials object if authentication was successful. - */ - test(strategy: string, request: Request, next: (err: Error | null, credentials: AuthenticatedCredentials) => void): void; -} - -export type Strategy = any; -export type SchemeSettings = any; - -/** - * the method implementing the scheme with signature function(server, options) where: - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) - * @param server a reference to the server object the scheme is added to. - * @param options optional scheme settings used to instantiate a strategy. - */ -export interface ServerAuthScheme { - (server: Server, options: SchemeSettings): SchemeMethodResult; -} - -/** - * The scheme method must return an object with the following - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) - */ -export interface SchemeMethodResult { - /** optional object which is exposed via the server.auth.api object. */ - api?: Strategy; - /** - * required function called on each incoming request configured with the authentication scheme - * When the scheme authenticate() method implementation calls reply() with an error condition, the specifics of the error affect whether additional authentication strategies will be attempted (if configured for the route). If the err passed to the reply() method includes a message, no additional strategies will be attempted. If the err does not include a message but does include the scheme name (e.g. Boom.unauthorized(null, 'Custom')), additional strategies will be attempted in the order of preference (defined in the route configuration). If authentication fails the scheme names will be present in the 'WWW-Authenticate' header. - * @param request the request object. - * @param reply the reply interface the authentication method must call when done authenticating the request - */ - authenticate(request: Request, reply: ReplySchemeAuth): void; - /** - * optional function called to authenticate the request payload - * When the scheme payload() method returns an error with a message, it means payload validation failed due to bad payload. If the error has no message but includes a scheme name (e.g. Boom.unauthorized(null, 'Custom')), authentication may still be successful if the route auth.payload configuration is set to 'optional'. - * @param request the request object. - * @param reply is called if authentication failed - */ - payload?(request: Request, reply: ReplySchemeAuthOfPayload): void; - /** - * optional function called to decorate the response with authentication headers before the response headers or payload is written where: - * @param request the request object. - * @param reply is called if an error occured - */ - response?(request: Request, reply: ReplySchemeAuthDecorateResponse): void; - /** an optional object with the following keys: */ - options?: { - /** if true, requires payload validation as part of the scheme and forbids routes from disabling payload auth validation. Defaults to false. */ - payload?: boolean; - }; -} - -export interface ServerCacheMethod { - /** - * Provisions a cache segment within the server cache facility - * [See docs](https://hapijs.com/api/16.1.1#servercacheoptions) - */ - (options: CatboxServerCacheConfiguration): Catbox.Policy; - /** - * Provisions a server cache as described in server.cache - * If no callback is provided, a Promise object is returned. - * Note that if the server has been initialized or started, the cache will be automatically started to match the state of any other provisioned server cache. - * [See docs](https://hapijs.com/api/16.1.1#servercacheprovisionoptions-callback) - * @param options same as the server cache configuration options. - * @param callback the callback method when cache provisioning is completed or failed with the signature function(err) where: - * * err - any cache startup error condition. - */ - provision(options: CatboxServerCacheConfiguration): Promise; - provision(options: CatboxServerCacheConfiguration, callback: (err?: Error) => void): void; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Request + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Request object - * The request object is created internally for each incoming request. It is different from the node.js request object received from the HTTP server callback (which is available in request.raw.req). The request object methods and properties change throughout the request lifecycle. - * [See docs](https://hapijs.com/api/16.1.1#request-object) - * [See docs](https://hapijs.com/api/16.1.1#request-properties) - */ -export class Request extends Podium { - /** application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. */ - app: any; - /** authentication information */ - auth: RequestAuthenticationInformation; - /** the connection the request was received by. */ - connection: ServerConnection; - /** the node domain object used to protect against exceptions thrown in extensions, handlers and route prerequisites. Can be used to manually bind callback functions otherwise bound to other domains. Set to null when the server useDomains options is false. */ - domain: domain.Domain | null; - /** the raw request headers (references request.raw.headers). */ - headers: Dictionary; - /** a unique request identifier (using the format '{now}:{connection.info.id}:{5 digits counter}').*/ - id: string; - /** request information */ - info: { - /** the request preferred encoding. */ - acceptEncoding: string; - /** if CORS is enabled for the route, contains the following: */ - cors: { - /** - * true if the request 'Origin' header matches the configured CORS restrictions. Set to false if no 'Origin' header is found or if it does not match. Note that this is only available after the 'onRequest' extension point as CORS is configured per-route and no routing decisions are made at that point in the request lifecycle. - * Note: marking as optional as "... this is only available after ..." - */ - isOriginMatch?: boolean; - }; - /** content of the HTTP 'Host' header (e.g. 'example.com:8080'). */ - host: string; - /** the hostname part of the 'Host' header (e.g. 'example.com'). */ - hostname: string; - /** request reception timestamp. */ - received: number; - /** content of the HTTP 'Referrer' (or 'Referer') header. */ - referrer: string; - /** remote client IP address. */ - remoteAddress: string; - /** - * remote client port. - * Set to string in casethey're requesting from a UNIX domain socket. - * TODO, what type does Hapi return, should this be number | string? - */ - remotePort: string; - /** request response timestamp (0 is not responded yet). */ - responded: number; - }; - /** the request method in lower case (e.g. 'get', 'post'). */ - method: string; - /** the parsed content-type header. Only available when payload parsing enabled and no payload error occurred. */ - mime: string; - /** an object containing the values of params, query, and payload before any validation modifications made. Only set when input validation is performed. */ - orig: { - params: any; - query: any; - payload: any; - }; - /** an object where each key is a path parameter name with matching value as described in Path parameters [See docs](https://hapijs.com/api/16.1.1#path-parameters). */ - params: Dictionary; - /** an array containing all the path params values in the order they appeared in the path. */ - paramsArray: string[]; - /** the request URI's pathname [See docs](https://nodejs.org/api/url.html#url_urlobject_pathname) component. */ - path: string; - /** - * the request payload based on the route payload.output and payload.parse settings. - * TODO check this typing and add references / links. - */ - payload: stream.Readable | Buffer | any; - /** plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. */ - plugins: PluginsStates; - /** an object where each key is the name assigned by a route prerequisites function. The values are the raw values provided to the continuation function as argument. For the wrapped response object, use responses. */ - pre: Object; - /** the response object when set. The object can be modified but must not be assigned another object. To replace the response with another from within an extension point, use reply(response) to override with a different response. Contains null when no response has been set (e.g. when a request terminates prematurely when the client disconnects). */ - response: Response | null; - /** same as pre but represented as the response object created by the pre method. */ - preResponses: Object; - /** - * by default the object outputted from [node's URL parse()](https://nodejs.org/docs/latest/api/url.html#url_urlobject_query) method. - * Might also be set indirectly via [request.setUrl](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/17354#requestseturlurl-striptrailingslash) in which case it may be - * a string (if url is set to an object with the query attribute as an unparsed string). - */ - query: any; - /** an object containing the Node HTTP server objects. **Direct interaction with these raw objects is not recommended.** */ - raw: { - req: http.IncomingMessage; // Or http.ClientRequest http://www.apetuts.com/tutorial/node-js-http-client-request-class/ ? - res: http.ServerResponse; - }; - /** - * the route public interface. - * Optional due to "request.route is not yet populated at this point." [See docs](https://hapijs.com/api/16.1.1#request-lifecycle) - */ - route?: RoutePublicInterface; - /** the server object. */ - server: Server; - /** an object containing parsed HTTP state information (cookies) where each key is the cookie name and value is the matching cookie content after processing using any registered cookie definition. */ - state: Dictionary; - /** the parsed request URI */ - url: url.Url; - - /** - * request.setUrl(url, [stripTrailingSlash]) - * Available only in 'onRequest' extension methods. - * Changes the request URI before the router begins processing the request - * [See docs](https://hapijs.com/api/16.1.1#requestseturlurl-striptrailingslash) - * @param url the new request URI. If url is a string, it is parsed with node's URL parse() method. url can also be set to an object compatible with node's URL parse() method output. - * @param stripTrailingSlash if true, strip the trailing slash from the path. Defaults to false. - */ - setUrl(url: string | url.Url, stripTrailingSlash?: boolean): void; - /** - * request.setMethod(method) - * Available only in 'onRequest' extension methods. - * Changes the request method before the router begins processing the request - * [See docs](https://hapijs.com/api/16.1.1#requestsetmethodmethod) - * @param method is the request HTTP method (e.g. 'GET'). - */ - setMethod(method: HTTP_METHODS): void; - /** - * request.generateResponse(source, [options]) - * Always available. - * Returns a response which you can pass into the reply interface where: - * [See docs](https://hapijs.com/api/16.1.1#requestgenerateresponsesource-options) - * @param source the object to set as the source of the reply interface. TODO, submit a PR to clarify this doc, from the source code it's clear that "the object to set" refers to something of type `ReplyValue` i.e. that can be null, string, number, object, Stream, Promise, or Buffer. - * @param options options for the method, optional. Not documented yet, perhaps not very important. - */ - generateResponse(source?: ReplyValue, options?: {marshal?: any; prepare?: any; close?: any; variety?: any}): Response; - /** - * request.log(tags, [data, [timestamp]]) - * Always available. - * Logs request-specific events. When called, the server emits a 'request' event which can be used by other listeners or plugins. - * Any logs generated by the server internally will be emitted only on the 'request-internal' channel and will include the event.internal flag set to true. - * [See docs](https://hapijs.com/api/16.1.1#requestlogtags-data-timestamp) - * @param tags a string or an array of strings (e.g. ['error', 'database', 'read']) used to identify the event. Tags are used instead of log levels and provide a much more expressive mechanism for describing and filtering events. - * @param data an optional message string or object with the application data being logged. If data is a function, the function signature is function() and it called once to generate (return value) the actual data emitted to the listeners. - * @param timestamp an optional timestamp expressed in milliseconds. Defaults to Date.now() (now). - */ - log(tags: string | string[], data?: string | Object | (() => string | Object), timestamp?: number): void; - /** - * request.getLog([tags], [internal]) - * Always available. - * Returns an array containing the events matching any of the tags specified (logical OR) - * Note that this methods requires the route log configuration set to true. - * [See docs](https://hapijs.com/api/16.1.1#requestgetlogtags-internal) - * @param tags is a single tag string or array of tag strings. If no tags specified, returns all events. - * @param internal filters the events to only those with a matching event.internal value. If true, only internal logs are included. If false, only user event are included. Defaults to all events (undefined). - */ - getLog(tags?: string | string[], internal?: boolean): string[]; - getLog(internal?: boolean): string[]; - /** - * request.tail([name]) - * Available until immediately after the 'response' event is emitted. - * Adds a request tail which has to complete before the request lifecycle is complete. - * Returns a tail function which must be called when the tail activity is completed. - * Tails are actions performed throughout the request lifecycle, but which may end after a response is sent back to the client. For example, a request may trigger a database update which should not delay sending back a response. However, it is still desirable to associate the activity with the request when logging it (or an error associated with it). - * When all tails completed, the server emits a 'tail' event. - * [See docs](https://hapijs.com/api/16.1.1#requesttailname) - * @param name an optional tail name used for logging purposes. - */ - tail(name?: string): (() => void); - /** - * The server.decorate('request', ...) method can modify this prototype/interface. - * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts - * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) - */ - // [index: string]: any; -} - -export interface RequestAuthenticationInformation { - /** true if the request has been successfully authenticated, otherwise false. */ - isAuthenticated: boolean; - /** the credential object received during the authentication process. The presence of an object does not mean successful authentication. */ - credentials: any; - /** an artifact object received from the authentication strategy and used in authentication-related actions. */ - artifacts: any; - /** the route authentication mode. */ - mode: string; - /** the authentication error is failed and mode set to 'try'. */ - error: Error; -} - -export type HTTP_METHODS_PARTIAL_lowercase = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options'; -export type HTTP_METHODS_PARTIAL = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | HTTP_METHODS_PARTIAL_lowercase; -export type HTTP_METHODS = 'HEAD' | 'head' | HTTP_METHODS_PARTIAL; - -/** - * Request events - * The request object supports the following events: - * * 'peek' - emitted for each chunk of payload data read from the client connection. The event method signature is function(chunk, encoding). - * * 'finish' - emitted when the request payload finished reading. The event method signature is function (). - * * 'disconnect' - emitted when a request errors or aborts unexpectedly. - * [See docs](https://hapijs.com/api/16.1.1#request-events) - */ -export type RequestEventTypes = 'peek' | 'finish' | 'disconnect'; - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Handler functions + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Extending RouteConfiguration.handler - * - * The hapi documentation allows for the RouteConfiguration.handler type to have - * `{[pluginName: string]: pluginOptions}` - * "handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler" - * This can be provided by extending the hapi module definition as follows, - * see h2o2 for example: - * - * declare module 'hapi' { - * interface RouteHandlerPlugins { - * proxy?: ... - */ -export interface RouteHandlerPlugins { -} -/** - * The route handler function uses the signature function(request, reply) (NOTE: do not use a fat arrow style function for route handlers as they do not allow context binding and will cause problems when used in conjunction with server.bind) where: - * * request - is the incoming request object (this is not the node.js request object). - * * reply - the reply interface the handler must call to set a response and return control back to the framework. - * [See docs](https://hapijs.com/api/16.1.1#route-handler) - * Same function signature used by request extension point used in server.ext(event), see ServerExtConfigurationObject.method - */ -export interface RouteHandler { - (request: Request, reply: ReplyNoContinue): void; - // (request: Request, reply: StrictReply): void; -} - -/** - * "the function to call, the function signature is identical to a route handler as described in Route handler." - * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) Route prerequisites - */ -export type RoutePrerequisiteRequestHandler = RouteHandler; - -/** - * request extension points: function(request, reply) where - * this - the object provided via options.bind or the current active context set with server.bind(). - * [See docs](https://hapijs.com/api/16.1.1#serverextevents) - * @param request the request object. - * @param reply the reply interface which is used to return control back to the framework. To continue normal execution of the request lifecycle, reply.continue() must be called. If the extension type is 'onPostHandler' or 'onPreResponse', a single argument passed to reply.continue() will override the current set response (including all headers) but will not stop the request lifecycle execution. To abort processing and return a response to the client, call reply(value) where value is an error or any other valid response. - */ -export interface ServerExtRequestHandler { - (request: Request, reply: ReplyWithContinue): void; -} - -/** - * Used by various extensions to handle a request and - * synchronously return a result of some form. - * - * Left in for backwards compatibility of typings but according to the - * [DefinitelyTyped Readme under common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes) - * it talks about not using generic types unless the type was used in typing one - * or more of the function arguments. Using it to type the return was suggested - * to be the same as a type assertion. - */ -export interface RequestHandler { - (request: Request): T; -} - -/** - * Used by server extension points - * err can be `Boom` error or Error that will be wrapped as a `Boom` error - * For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/reply.js#L109-L118) - * For source [See code](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65) - */ -export interface ContinuationFunction { - (err?: Boom.BoomError): void; -} -/** - * For source [See docs](https://github.com/hapijs/hapi/blob/v16.1.1/lib/response.js#L60-L65) - * TODO Can value be typed with a useful generic? - */ -export interface ContinuationValueFunction { - (err: Boom.BoomError): void; - (err: null | undefined, value: any): void; - (): void; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Reply functions + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Typings listed explicitly here [See docs](https://hapijs.com/api/16.1.1#replyerr-result) - * Typings also described in part here [See docs](https://hapijs.com/api/16.1.1#response-object) - */ -export type ReplyValue = _ReplyValue | Promise<_ReplyValue>; -export type _ReplyValue = null | undefined | string | number | boolean | Buffer | Error | stream.Stream | Object; // | array; - -/** - * Reply interface - * reply([err], [result]) - * Concludes the handler activity by setting a response and returning control over to the framework - * When reply() is called with an error or result response, that value is used as the response sent to the client. When reply() is called within a prerequisite, the value is saved for future use and is not used as the response. In all other places except for the handler, calling reply() will be considered an error and will abort the request lifecycle, jumping directly to the 'onPreResponse' event. - * To return control to the framework within an extension or other places other than the handler, without setting a response, the method reply.continue() must be called. Except when used within an authentication strategy, or in an 'onPostHandler' or 'onPreResponse' extension, the reply.continue() must not be passed any argument or an exception is thrown. - * [See docs](https://hapijs.com/api/16.1.1#reply-interface) - * [See docs](https://hapijs.com/api/16.1.1#replyerr-result) - * - * NOTE: modules should extend this interface to expose reply.Nnn methods - */ -export interface Base_Reply { - (err?: ReplyValue): Response; - (err: null, result?: ReplyValue): Response; - /** the active realm associated with the route. */ - realm: ServerRealm; - /** the request object */ - request: Request; - - /** - * reply.entity(options) - * Sets the response 'ETag' and 'Last-Modified' headers and checks for any conditional request headers to decide if the response is going to qualify for an HTTP 304 (Not Modified). If the entity values match the request conditions, reply.entity() returns control back to the framework with a 304 response. Otherwise, it sets the provided entity headers and returns null. - * Returns a response object if the reply is unmodified or null if the response has changed. If null is returned, the developer must call reply() to continue execution. If the response is not null, the developer must not call reply(). - * [See docs](https://hapijs.com/api/16.1.1#replyentityoptions) - * @param options a required configuration object with: - * * etag - the ETag string. Required if modified is not present. Defaults to no header. - * * modified - the Last-Modified header value. Required if etag is not present. Defaults to no header. - * * vary - same as the response.etag() option. Defaults to true. - */ - entity(options: {etag?: string, modified?: string, vary?: boolean}): Response | null; - /** - * reply.close([options]) - * Concludes the handler activity by returning control over to the router and informing the router that a response has already been sent back directly via request.raw.res and that no further response action is needed. Supports the following optional options: - * The response flow control rules do not apply. - * [See docs](https://hapijs.com/api/16.1.1#replycloseoptions) - * @param options options object: - * * end - if false, the router will not call request.raw.res.end()) to ensure the response was ended. Defaults to true. - */ - close(options?: {end?: boolean}): void; - /** - * reply.redirect(uri) - * Redirects the client to the specified uri. Same as calling reply().redirect(uri). - * The response flow control rules apply. - * Sets an HTTP redirection response (302) and decorates the response with additional methods for - * changing to a permanent or non-rewritable redirect is also available see response object redirect for more information. - * [See docs](https://hapijs.com/api/16.1.1#replyredirecturi) - * @param uri an absolute or relative URI used to redirect the client to another resource. - */ - redirect(uri: string): ResponseRedirect; - /** - * reply.response(result) - * Shorthand for calling `reply(null, result)`, replies with the response set to `result`. - * [See docs](https://hapijs.com/api/16.1.1#replyresponseresult) - * TODO likely to change. Await approval of pull request to Hapi docs. - */ - response(result: ReplyValue): Response; - /** - * Sets a cookie on the response - * [See docs](https://hapijs.com/api/16.1.1#reply) - * TODO likely to change. Await approval of pull request to Hapi docs. - */ - state(name: string, value: any, options?: any): void; - /** - * Clears a cookie on the response - * [See docs](https://hapijs.com/api/16.1.1#reply) - * TODO likely to change. Await approval of pull request to Hapi docs. - */ - unstate(name: string, options?: any): void; - /** - * The server.decorate('reply', ...) method can modify this prototype/interface. - * Have disabled these typings as there is a better alternative, see example in: tests/server/decorate.ts - * [And discussion here](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/14517#issuecomment-298891630) - */ - // [index: string]: any; -} -/** - * reply.continue([result]) - * Returns control back to the framework without ending the request lifecycle - * [See docs](https://hapijs.com/api/16.1.1#replycontinueresult) - * [See docs](https://hapijs.com/api/16.1.1#replyerr-result) "With the exception of the handler function, all other methods provide the reply.continue() method which instructs the framework to continue processing the request without setting a response." - * @param result if called in the handler, prerequisites, or extension points other than the 'onPreHandler' and 'onPreResponse', the result argument is not allowed and will throw an exception if present. If called within an authentication strategy, it sets the authenticated credentials. If called by the 'onPreHandler' or 'onPreResponse' extensions, the result argument overrides the current response including all headers, and returns control back to the framework to continue processing any remaining extensions. - */ -export interface Continue_Reply { - continue(result?: ReplyValue): Response | undefined; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > authenticate. - * Also [See docs](https://hapijs.com/api/16.1.1#replyerr-result). - * TODO check it has Base_Reply methods and properties - */ -export interface ReplySchemeAuth extends Base_Reply { - /** - * This function is called if authentication failed. - * TODO, check type the `response` parameter. In https://hapijs.com/api/16.1.1#replyerr-result it is referred to as "null" but this seems to be for a third scenario where it is "used to return both an error and credentials in the authentication methods" then "reply() must be called with three arguments function(err, null, data)" - * @param err any authentication error. - * @param response any authentication response action such as redirection. Ignored if err is present, otherwise required. - * @param result an object containing: - * * credentials the authenticated credentials. - * * artifacts optional authentication artifacts. - */ - (err: Error | null, response: AnyAuthenticationResponseAction | null, result: AuthenticationResult): void; - /** - * is called if authentication succeeded - * @param result same object as result above. - */ - continue(result: AuthenticationResult): void; -} -/** - * Typing as any as it's not yet clear what type this argument takes. - * "any authentication response action such as redirection" is it equivalent to - * `ReplyValue` ? - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) - * TODO research hapi source and type this. - */ -export type AnyAuthenticationResponseAction = any; -/** [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) */ -export interface AuthenticationResult { - credentials?: AuthenticatedCredentials; - artifacts?: any; -} -export interface AuthenticatedCredentials { - // Disabled to allow typing within a project - // [index: string]: any; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > payload - * TODO check it has Base_Reply methods and properties - */ -export interface ReplySchemeAuthOfPayload extends Base_Reply { - /** - * function called to authenticate the request payload where: - * @param err any authentication error. - * @param response any authentication response action such as redirection. Ignored if err is present, otherwise required. - */ - (err: Error | null, response: AnyAuthenticationResponseAction): void; - /** is called if payload authentication succeeded */ - continue(): void; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#serverauthschemename-scheme) > response - * TODO check it has Base_Reply methods and properties - */ -export interface ReplySchemeAuthDecorateResponse extends Base_Reply { - /** - * is called if an error occurred - * @param err any authentication error. - * @param response any authentication response to send instead of the current response. Ignored if err is present, otherwise required. - */ - (err?: Error, response?: ReplyValue): void; - /** is called if the operation succeeded. */ - continue(): void; -} - -export interface ReplyWithContinue extends Continue_Reply, Base_Reply {} - -export interface ReplyNoContinue extends Base_Reply {} - -// TODO assess use and usefulness of StrictReply - -// Concludes the handler activity by setting a response and returning control over to the framework where: -// erran optional error response. -// result an optional response payload. -// Since an request can only have one response regardless if it is an error or success, the reply() method can only result in a single response value. This means that passing both an err and result will only use the err. There is no requirement for either err or result to be (or not) an Error object. The framework will simply use the first argument if present, otherwise the second. The method supports two arguments to be compatible with the common callback pattern of error first. -// FLOW CONTROL: -// When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() -/** - * - */ -// export interface Reply { // extends ReplyMethods { -// (err: Error, -// result?: string | number | boolean | Buffer | stream.Stream | Promise | T, -// /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ -// credentialData?: any): BoomError; -// /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ -// (result: string | number | boolean | Buffer | stream.Stream | Promise | T): Response; -// } - -/** Concludes the handler activity by setting a response and returning control over to the framework where: - erran optional error response. - result an optional response payload. - Since an request can only have one response regardless if it is an error or success, the reply() method can only result in a single response value. This means that passing both an err and result will only use the err. There is no requirement for either err or result to be (or not) an Error object. The framework will simply use the first argument if present, otherwise the second. The method supports two arguments to be compatible with the common callback pattern of error first. - FLOW CONTROL: - When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() */ -// export interface StrictReply extends ReplyMethods { -// (err: Error, -// result?: Promise | T, -// /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ -// credentialData?: any): BoomError; -// /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ -// (result: Promise | T): Response; -// } - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Response + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Response object - * [See docs](https://hapijs.com/api/16.1.1#response-object) - * - * TODO, check extending from Podium is correct. Extending because of "The response object supports the following events" [See docs](https://hapijs.com/api/16.1.1#response-events) - * * 'peek' - emitted for each chunk of data written back to the client connection. The event method signature is function(chunk, encoding). - * * 'finish' - emitted when the response finished writing but before the client response connection is ended. The event method signature is function (). - */ -export interface Response extends Podium { - /** the HTTP response status code. Defaults to 200 (except for errors). */ - statusCode: number; - /** an object containing the response headers where each key is a header field name. Note that this is an incomplete list of headers to be included with the response. Additional headers will be added once the response is prepared for transmission. */ - headers: Dictionary; - /** the value provided using the reply interface. */ - source: ReplyValue; - /** - * a string indicating the type of source with available values: - * * 'plain' - a plain response such as string, number, null, or simple object (e.g. not a Stream, Buffer, or view). - * * 'buffer' - a Buffer. - * * 'stream' - a Stream. - * * 'promise' - a Promise object. - */ - variety: 'plain' | 'buffer' | 'stream' | 'promise'; - /** application-specific state. Provides a safe place to store application data without potential conflicts with the framework. Should not be used by plugins which should use plugins[name]. */ - app: any; - /** plugin-specific state. Provides a place to store and pass request-level plugin data. The plugins is an object where each key is a plugin name and the value is the state. */ - plugins: PluginsStates; - /** response handling flags: */ - settings: { - /** the 'Content-Type' HTTP header 'charset' property. Defaults to 'utf-8'. */ - charset: string; - /** the string encoding scheme used to serial data into the HTTP payload when source is a string or marshals into a string. Defaults to 'utf8'. */ - encoding: string; - /** if true and source is a Stream, copies the statusCode and headers of the stream to the outbound response. Defaults to true. */ - passThrough: boolean; - /** options used for source value requiring stringification. Defaults to no replacer and no space padding. */ - stringify: Json.StringifyArguments; - /** if set, overrides the route cache expiration milliseconds value set in the route config. Defaults to no override. */ - ttl: number | null; - /** if true, a suffix will be automatically added to the 'ETag' header at transmission time (separated by a '-' character) when the HTTP 'Vary' header is present. */ - varyEtag: boolean; - }; - - /** - * The following attribute is present in one or more of the examples - * TODO update once Hapi docs describes explicitly - */ - isBoom?: boolean; - /** - * The following attribute is present in one or more of the examples - * TODO update once Hapi docs describes explicitly - */ - isMissing?: boolean; - /** - * The following attribute is present in one or more of the examples - * TODO update once Hapi docs describes explicitly - */ - output?: Boom.Output; - - /** - * sets the HTTP 'Content-Length' header (to avoid chunked transfer encoding) - * @param length the header value. Must match the actual payload size. - */ - bytes(length: number): Response; - /** - * sets the 'Content-Type' HTTP header 'charset' property - * @param charset the charset property value. - */ - charset(charset: string): Response; - /** - * sets the HTTP status code - * @param statusCode the HTTP status code (e.g. 200). - */ - code(statusCode: number): Response; - /** - * sets the HTTP status message - * @param httpMessage the HTTP status message (e.g. 'Ok' for status code 200). - */ - message(httpMessage: string): Response; - /** - * sets the HTTP status code to Created (201) and the HTTP 'Location' header - * @param uri an absolute or relative URI used as the 'Location' header value. - */ - created(uri: string): Response; - /** - * sets the string encoding scheme used to serial data into the HTTP payload - * @param encoding the encoding property value (see node Buffer encoding [See docs](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings)). - * * 'ascii' - for 7-bit ASCII data only. This encoding is fast and will strip the high bit if set. - * * 'utf8' - Multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8. - * * 'utf16le' - 2 or 4 bytes, little-endian encoded Unicode characters. Surrogate pairs (U+10000 to U+10FFFF) are supported. - * * 'ucs2' - Alias of 'utf16le'. - * * 'base64' - Base64 encoding. When creating a Buffer from a string, this encoding will also correctly accept "URL and Filename Safe Alphabet" as specified in RFC4648, Section 5. - * * 'latin1' - A way of encoding the Buffer into a one-byte encoded string (as defined by the IANA in RFC1345, page 63, to be the Latin-1 supplement block and C0/C1 control codes). - * * 'binary' - Alias for 'latin1'. - * * 'hex' - Encode each byte as two hexadecimal characters. - */ - encoding(encoding: 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'binary' | 'hex'): Response; - /** - * sets the representation entity tag - * @param tag the entity tag string without the double-quote. - * @param options options object - * * weak - if true, the tag will be prefixed with the 'W/' weak signifier. Weak tags will fail to match identical tags for the purpose of determining 304 response status. Defaults to false. - * * vary - if true and content encoding is set or applied to the response (e.g 'gzip' or 'deflate'), the encoding name will be automatically added to the tag at transmission time (separated by a '-' character). Ignored when weak is true. Defaults to true. - */ - etag(tag: string, options?: {weak: boolean, vary: boolean}): Response; - /** - * sets an HTTP header - * @param name the header name. - * @param value the header value. - */ - header(name: string, value: string, options?: ResponseHeaderOptionsObject): Response; - /** - * sets the HTTP 'Location' header - * @param uri an absolute or relative URI used as the 'Location' header value. - */ - location(uri: string): Response; - /** - * sets an HTTP redirection response (302) and decorates the response with additional methods listed below, - * @param uri an absolute or relative URI used to redirect the client to another resource. - */ - redirect(uri: string): Response; - /** - * sets the JSON.stringify() replacer argument - * @param method the replacer function or array. Defaults to none. - */ - replacer(method: Json.StringifyReplacer): Response; - /** - * sets the JSON.stringify() space argument - * @param count the number of spaces to indent nested object keys. Defaults to no indentation. - */ - spaces(count: Json.StringifySpace): Response; - /** - * sets an HTTP cookie - * @param name the cookie name. - * @param value the cookie value. If no encoding is defined, must be a string. - * @param options optional configuration. If the state was previously registered with the server using server.state(), the specified keys in options override those same keys in the server definition (but not others). - */ - state(name: string, value: string | Object | any[], options?: ServerStateCookieConfiguationObject): Response; - /** - * sets a string suffix when the response is process via JSON.stringify(). - */ - suffix(suffix: string): Response; - /** - * overrides the default route cache expiration rule for this response instance - * @param msec the time-to-live value in milliseconds. - */ - ttl(msec: number): Response; - /** - * sets the HTTP 'Content-Type' header - * @param mimeType is the mime type. Should only be used to override the built-in default for each response type. - */ - type(mimeType: string): Response; - /** - * clears the HTTP cookie by setting an expired value - * @param name the cookie name. - * @param options optional configuration for expiring cookie. If the state was previously registered with the server using server.state(), the specified keys in options override those same keys in the server definition (but not others). - */ - unstate(name: string, options?: ServerStateCookieConfiguationObject): Response; - /** - * adds the provided header to the list of inputs affected the response generation via the HTTP 'Vary' header - * @param header the HTTP request header name. - */ - vary(header: string): Response; - - /** - * Flow control - hold() - * When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: - * puts the response on hold until response.send() is called. Available only after reply() is called and until response.hold() is invoked once. - * [See docs](https://hapijs.com/api/16.1.1#flow-control) - */ - hold(): Response; - /** - * Flow control - send() - * When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: - * immediately resume the response. Available only after response.hold() is called and until response.send() is invoked once. - * [See docs](https://hapijs.com/api/16.1.1#flow-control) - */ - send(): Response; - - /** - * Mentioned here: "Note that prerequisites do not follow the same rules of the normal reply interface. In all other cases, calling reply() with or without a value will use the result as the response sent back to the client. In a prerequisite method, calling reply() will assign the returned value to the provided assign key. If the returned value is an error, the failAction setting determines the behavior. To force the return value as the response and skip any other prerequisites and the handler, use the reply().takeover() method." - * TODO prepare documentation PR and submit to hapi. - * [See docs](https://hapijs.com/api/16.1.1#route-prerequisites) - */ - takeover(): Response; -} - -/** - * Response Object Redirect Methods - * When using the redirect() method, the response object provides these additional methods: - * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) - */ -export interface ResponseRedirect extends Response { - /** - * temporary - * sets the status code to 302 or 307 (based on the rewritable() setting) where: - * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) - * @param isTemporary if false, sets status to permanent. Defaults to true. - */ - temporary(isTemporary: boolean): Response; - /** - * permanent - * sets the status code to 301 or 308 (based on the rewritable() setting) where: - * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) - * @param isPermanent if false, sets status to temporary. Defaults to true. - */ - permanent(isPermanent: boolean): Response; - /** - * rewritable - * sets the status code to 301/302 for rewritable (allows changing the request method from 'POST' to 'GET') or 307/308 for non-rewritable (does not allow changing the request method from 'POST' to 'GET'). Exact code based on the temporary() or permanent() setting. Arguments: - * [See docs](https://hapijs.com/api/16.1.1#response-object-redirect-methods) - * @param isRewritable if false, sets to non-rewritable. Defaults to true. - */ - rewritable(isRewritable: boolean): Response; -} - -/** - * [See docs](https://hapijs.com/api/16.1.1#response-object) under "response object provides the following methods" > header > options - */ -export interface ResponseHeaderOptionsObject { - /** if true, the value is appended to any existing header value using separator. Defaults to false. */ - append?: boolean; - /** string used as separator when appending to an existing value. Defaults to ','. */ - separator?: string; - /** if false, the header value is not set if an existing value present. Defaults to true. */ - override?: boolean; - /** if false, the header value is not modified if the provided value is already included. Does not apply when append is false or if the name is 'set-cookie'. Defaults to true. */ - duplicate?: boolean; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + Plugins and register + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// TODO: move to separate file http://stackoverflow.com/questions/43276921 - -/** - * Plugins - * Plugins provide a way to organize the application code by splitting the server logic into smaller components. Each plugin can manipulate the server and its connections through the standard server interface, but with the added ability to sandbox certain properties. - * [See docs](https://hapijs.com/api/16.1.1#plugins) - * @param server the server object the plugin is being registered to. - * @param options an options object passed to the plugin during registration. - * @param next a callback method the function must call to return control back to the framework to complete the registration process with signature function(err) - */ -export interface PluginFunction { - (server: Server, options: OptionsPassedToPlugin, next: (err?: Error) => void): void; - /** - * Note attributes is NOT optional but this type is easier to use. - */ - attributes?: PluginAttributes; -} - -/** - * see Plugin - * [See docs](https://hapijs.com/api/16.1.1#plugins) - */ -export interface PluginAttributes { - /** - * required plugin name string. The name is used as a unique key. Published plugins should use the same name as the name field in the 'package.json' file. Names must be unique within each application. - * NOTE: marked as optional as `pkg` can be used instead. - */ - name?: string; - /** optional plugin version. The version is only used informatively to enable other plugins to find out the versions loaded. The version should be the same as the one specified in the plugin's 'package.json' file. */ - version?: string; - /** Alternatively, the name and version can be included via the pkg attribute containing the 'package.json' file for the module which already has the name and version included */ - pkg?: any; - /** if true, allows the plugin to be registered multiple times with the same server. Defaults to false. */ - multiple?: boolean; - /** optional string or array of string indicating a plugin dependency. Same as setting dependencies via server.dependency(). */ - dependencies?: string | string[]; - /** if false, does not allow the plugin to call server APIs that modify the connections such as adding a route or configuring state. This flag allows the plugin to be registered before connections are added and to pass dependency requirements. When set to 'conditional', the mode is based on the presence of selected connections (if the server has connections, it is the same as true, but if no connections are available, it is the same as false). Defaults to true. */ - connections?: boolean | 'conditional'; - /** if true, will only register the plugin once per connection (or once per server for a connectionless plugin). If set, overrides the once option passed to server.register(). Defaults to undefined (registration will be based on the server.register() option once). */ - once?: boolean; -} - -/** - * Plugins State - * Related [See docs](https://hapijs.com/api/16.1.1#serverplugins) - * Related [See docs](https://hapijs.com/api/16.1.1#serverrealm) - */ -export interface PluginsStates { - [pluginName: string]: any; -} - -/** - * once, select, routes - optional plugin-specific registration options as defined see PluginRegistrationOptions - * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) - */ -export interface PluginRegistrationObject extends PluginRegistrationOptions { - /** the plugin registration function. */ - register: PluginFunction; - /** optional options passed to the registration function when called. */ - options?: OptionsPassedToPlugin; -} - -/** - * registration options (different from the options passed to the registration function): - * * once - if true, the registration is skipped for any connection already registered with. Cannot be used with plugin options. If the plugin does not have a connections attribute set to false and the registration selection is empty, registration will be skipped as no connections are available to register once. Defaults to false. - * * routes - modifiers applied to each route added by the plugin: - * * prefix - string added as prefix to any route path (must begin with '/'). If a plugin registers a child plugin the prefix is passed on to the child or is added in front of the child-specific prefix. - * * vhost - virtual host string (or array of strings) applied to every route. The outer-most vhost overrides the any nested configuration. - * * select - a string or array of string labels used to pre-select connections for plugin registration. - * [See docs](https://hapijs.com/api/16.1.1#serverregisterplugins-options-callback) - */ -export interface PluginRegistrationOptions { - once?: boolean; - routes?: {prefix?: string, vhost?: string | string[]}; - select?: string | string[]; -} - -/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + + - + + - + JSON + - + + - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */ -// This was in a seperate file and perhaps should move to some of the lib typings? -// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/16065#issuecomment-299443673 -// -// json/json-tests.ts -// -// import * as JSON from './index'; -// -// var a: JSON.StringifyReplacer = function(key, value) { -// if (key === "do not include") { -// return undefined; -// } -// return value; -// }; -// - -export namespace Json { - /** - * @see {@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter} - */ - export type StringifyReplacer = ((key: string, value: any) => any) | (string | number)[] | undefined; - - /** - * Any value greater than 10 is truncated. - */ - export type StringifySpace = number | string; - - export interface StringifyArguments { - /** the replacer function or array. Defaults to no action. */ - replacer?: StringifyReplacer; - /** number of spaces to indent nested object keys. Defaults to no indentation. */ - space?: StringifySpace; - } -} diff --git a/types/hapi/v16/test/request/event-types.ts b/types/hapi/v16/test/request/event-types.ts deleted file mode 100644 index d9ee4dab33..0000000000 --- a/types/hapi/v16/test/request/event-types.ts +++ /dev/null @@ -1,30 +0,0 @@ - -// From https://hapijs.com/api/16.1.1#requestsetmethodmethod - -import * as Hapi from '../../'; -const Crypto = require('crypto'); -const server = new Hapi.Server(); -server.connection({ port: 80 }); - -const onRequest: Hapi.ServerExtRequestHandler = function (request, reply) { - - const hash = Crypto.createHash('sha1'); - request.on('peek', (chunk) => { - - hash.update(chunk); - }); - - request.once('finish', () => { - - console.log(hash.digest('hex')); - }); - - request.once('disconnect', () => { - - console.error('request aborted'); - }); - - return reply.continue(); -}; - -server.ext('onRequest', onRequest); diff --git a/types/hapi/v16/test/request/get-log.ts b/types/hapi/v16/test/request/get-log.ts deleted file mode 100644 index 53568ba734..0000000000 --- a/types/hapi/v16/test/request/get-log.ts +++ /dev/null @@ -1,12 +0,0 @@ - -// From https://hapijs.com/api/16.1.1#requestgetlogtags-internal - -import * as Hapi from '../../'; - -var request: Hapi.Request = {}; - -request.getLog(); -request.getLog('error'); -request.getLog(['error', 'auth']); -request.getLog(['error'], true); -request.getLog(false); diff --git a/types/hapi/v16/test/request/query.ts b/types/hapi/v16/test/request/query.ts deleted file mode 100644 index 1aa801b69d..0000000000 --- a/types/hapi/v16/test/request/query.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Added test in addition to docs, for request.query - -import * as Hapi from '../../'; - -interface GetThingQuery { - name: string; -} - -const handler: Hapi.RouteHandler = function (request, reply) { - - const query = request.query as GetThingQuery; - - return reply(`You asked for ${query.name}`); -}; diff --git a/types/hapi/v16/test/response/error.ts b/types/hapi/v16/test/response/error.ts deleted file mode 100644 index f426de66e0..0000000000 --- a/types/hapi/v16/test/response/error.ts +++ /dev/null @@ -1,25 +0,0 @@ - -// From https://hapijs.com/api/16.1.1#error-response - -import * as Hapi from '../../'; -const Boom = require('../../../../boom'); - -const server = new Hapi.Server(); - -server.route({ - method: 'GET', - path: '/badRequest', - handler: function (request, reply) { - - return reply(Boom.badRequest('Unsupported parameter')); - } -}); - -server.route({ - method: 'GET', - path: '/internal', - handler: function (request, reply) { - - return reply(new Error('unexpect error')); - } -}); diff --git a/types/hapi/v16/test/route/config.ts b/types/hapi/v16/test/route/config.ts deleted file mode 100644 index 680ee4c043..0000000000 --- a/types/hapi/v16/test/route/config.ts +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - -import * as Hapi from '../../'; - -// different methods -var routeConfig: Hapi.RouteConfiguration = { - path: '/signin', - method: 'PUT', - vhost: 'site.coms', -}; -var routeConfig: Hapi.RouteConfiguration = { - path: '/signin', - method: '*' -}; -var routeConfig: Hapi.RouteConfiguration = { - path: '/signin', - method: ['OPTIONS', '*'] -}; - -// different handlers -var routeConfig: Hapi.RouteConfiguration = { - path: '/signin', - method: 'PUT', - handler: 'some registered handler' -}; -var routeConfig: Hapi.RouteConfiguration = { - path: '/signin', - method: 'PUT', - handler: function (request, reply) { - return reply('ok'); - } -}; - -const server = new Hapi.Server(); -server.route(routeConfig); - -// Handler in config -const user: Hapi.RouteAdditionalConfigurationOptions = { - cache: { expiresIn: 5000 }, - handler: function (request, reply) { - - return reply({ name: 'John' }); - } -}; - -server.route({method: 'GET', path: '/user', config: user }); diff --git a/types/hapi/v16/test/route/handler.ts b/types/hapi/v16/test/route/handler.ts deleted file mode 100644 index 401bf35eab..0000000000 --- a/types/hapi/v16/test/route/handler.ts +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -import * as Hapi from '../../'; - -var handler: Hapi.RouteHandler = function(request, reply) { - reply('success'); -} -var strictHandler: Hapi.RouteHandler = function(request, reply) { - reply(123); -} diff --git a/types/hapi/v16/tsconfig.json b/types/hapi/v16/tsconfig.json deleted file mode 100644 index f77f7d4abe..0000000000 --- a/types/hapi/v16/tsconfig.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": false, - "baseUrl": "../../", - "typeRoots": [ - "../../" - ], - "types": [], - "paths": { - "hapi": [ - "hapi/v16" - ] - }, - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "test/connection/table.ts", - "test/continuation/errors.ts", - "test/getting-started/01-creating-a-server.ts", - "test/getting-started/02-adding-routes.ts", - "test/getting-started/03-serving-static-content.ts", - "test/getting-started/04-using-plugins.ts", - "test/path/catch-all.ts", - "test/path/parameters.ts", - "test/plugins/options.ts", - "test/reply/continue.ts", - "test/reply/entity.ts", - "test/reply/redirect.ts", - "test/reply/reply.ts", - "test/reply/state_cookie.ts", - "test/request/event-types.ts", - "test/request/generate-response.ts", - "test/request/get-log.ts", - "test/request/log.ts", - "test/request/query.ts", - "test/request/set-method.ts", - "test/request/set-url.ts", - "test/request/tail.ts", - "test/response/error-representation.ts", - "test/response/error.ts", - "test/response/events.ts", - "test/response/flow-control.ts", - "test/route/additional-options.ts", - "test/route/auth.ts", - "test/route/config.ts", - "test/route/handler.ts", - "test/route/plugins.ts", - "test/route/prerequisites.ts", - "test/route/public-interface.ts", - "test/route/validate.ts", - "test/server/app.ts", - "test/server/auth.ts", - "test/server/bind.ts", - "test/server/cache.ts", - "test/server/connection-options.ts", - "test/server/connections.ts", - "test/server/decoder.ts", - "test/server/decorate.ts", - "test/server/dependency.ts", - "test/server/emit.ts", - "test/server/encoder.ts", - "test/server/event.ts", - "test/server/expose.ts", - "test/server/ext.ts", - "test/server/handler.ts", - "test/server/info.ts", - "test/server/initialize.ts", - "test/server/inject.ts", - "test/server/listener.ts", - "test/server/load.ts", - "test/server/log.ts", - "test/server/lookup.ts", - "test/server/match.ts", - "test/server/method.ts", - "test/server/methods.ts", - "test/server/mime.ts", - "test/server/new.ts", - "test/server/on.ts", - "test/server/once.ts", - "test/server/path.ts", - "test/server/plugins.ts", - "test/server/realm.ts", - "test/server/register.ts", - "test/server/route.ts", - "test/server/select.ts", - "test/server/settings.ts", - "test/server/start.ts", - "test/server/state.ts", - "test/server/stop.ts", - "test/server/table.ts", - "test/server/version.ts" - ] -} diff --git a/types/hapi/v16/tslint.json b/types/hapi/v16/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/hapi/v16/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From cf0576d62762c71a217cdac66177f71eaf954e49 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 21 Dec 2017 07:23:52 -0800 Subject: [PATCH 287/298] chunked-dc: Provides its own types (#22397) --- notNeededPackages.json | 6 ++++ types/chunked-dc/chunked-dc-tests.ts | 19 ---------- types/chunked-dc/index.d.ts | 53 ---------------------------- types/chunked-dc/tsconfig.json | 24 ------------- types/chunked-dc/tslint.json | 1 - 5 files changed, 6 insertions(+), 97 deletions(-) delete mode 100644 types/chunked-dc/chunked-dc-tests.ts delete mode 100644 types/chunked-dc/index.d.ts delete mode 100644 types/chunked-dc/tsconfig.json delete mode 100644 types/chunked-dc/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 921fd414ce..2cb9f876d1 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -150,6 +150,12 @@ "sourceRepoURL": "https://github.com/mapbox/cheap-ruler", "asOfVersion": "2.5.0" }, + { + "libraryName": "chunked-dc", + "typingsPackageName": "chunked-dc", + "sourceRepoURL": "https://github.com/saltyrtc/chunked-dc-js", + "asOfVersion": "0.2.2" + }, { "libraryName": "commander", "typingsPackageName": "commander", diff --git a/types/chunked-dc/chunked-dc-tests.ts b/types/chunked-dc/chunked-dc-tests.ts deleted file mode 100644 index 1bedf11c5a..0000000000 --- a/types/chunked-dc/chunked-dc-tests.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Chunker - -let chunker = new Chunker(1337, Uint8Array.of(1, 2, 3), 2); -for (const chunk of chunker) { - // Do smoething with chunk -} -while (chunker.hasNext) { - const chunk = chunker.next().value; -} - -// Unchunker - -let unchunker = new Unchunker(); -unchunker.onMessage = (message: Uint8Array, context: any[]) => { - // Do something with the received message -}; -let chunk = Uint8Array.of(1, 2).buffer; -unchunker.add(chunk); -unchunker.gc(1024); diff --git a/types/chunked-dc/index.d.ts b/types/chunked-dc/index.d.ts deleted file mode 100644 index 5e57953621..0000000000 --- a/types/chunked-dc/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -// Type definitions for chunked-dc 0.1 -// Project: https://github.com/saltyrtc/chunked-dc-js -// Definitions by: Danilo Bargen -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -// Interfaces -declare namespace chunkedDc { - /** common.ts */ - - interface CommonStatic { - HEADER_LENGTH: number; - } - - /** chunker.ts */ - - interface Chunker extends IterableIterator { - hasNext: boolean; - next(): IteratorResult; - [Symbol.iterator](): IterableIterator; - } - - interface ChunkerStatic { - new(id: number, message: Uint8Array, chunkSize: number): Chunker; - } - - /** unchunker.ts */ - - type MessageListener = (message: Uint8Array, context?: any) => void; - - interface Unchunker { - onMessage: MessageListener; - add(chunk: ArrayBuffer, context?: any): void; - gc(maxAge: number): number; - } - - interface UnchunkerStatic { - new(): Unchunker; - } - - /** main.ts */ - - interface Standalone { - Chunker: ChunkerStatic; - Unchunker: UnchunkerStatic; - } -} - -// Entry point for the packed ES5 version: -declare var chunkedDc: chunkedDc.Standalone; - -// Entry point for the ES2015 version: -declare var Chunker: chunkedDc.ChunkerStatic; -declare var Unchunker: chunkedDc.UnchunkerStatic; diff --git a/types/chunked-dc/tsconfig.json b/types/chunked-dc/tsconfig.json deleted file mode 100644 index 28dc51c3c3..0000000000 --- a/types/chunked-dc/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "chunked-dc-tests.ts" - ] -} \ No newline at end of file diff --git a/types/chunked-dc/tslint.json b/types/chunked-dc/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/chunked-dc/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } From 34823aacc829de2c61561f62ca182c68ddb5ecfe Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 21 Dec 2017 07:26:49 -0800 Subject: [PATCH 288/298] plottable: Provides its own types (#22384) --- notNeededPackages.json | 6 + types/plottable/index.d.ts | 4121 ---------------------------- types/plottable/plottable-tests.ts | 51 - types/plottable/tsconfig.json | 29 - types/plottable/tslint.json | 79 - 5 files changed, 6 insertions(+), 4280 deletions(-) delete mode 100644 types/plottable/index.d.ts delete mode 100644 types/plottable/plottable-tests.ts delete mode 100644 types/plottable/tsconfig.json delete mode 100644 types/plottable/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 2cb9f876d1..4c7d2fab7d 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -588,6 +588,12 @@ "sourceRepoURL": "https://github.com/PeculiarVentures/pkcs11js", "asOfVersion": "1.0.4" }, + { + "libraryName": "plottable", + "typingsPackageName": "plottable", + "sourceRepoURL": "http://plottablejs.org/", + "asOfVersion": "3.7.0" + }, { "libraryName": "poly2tri.js", "typingsPackageName": "poly2tri", diff --git a/types/plottable/index.d.ts b/types/plottable/index.d.ts deleted file mode 100644 index ee52e5fc4d..0000000000 --- a/types/plottable/index.d.ts +++ /dev/null @@ -1,4121 +0,0 @@ -// Type definitions for Plottable v1.4.0 -// Project: http://plottablejs.org/ -// Definitions by: Plottable Team -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -import * as d3 from "d3"; - -declare global { - namespace Plottable { - namespace Utils { - namespace Math { - /** - * Checks if x is between a and b. - * - * @param {number} x The value to test if in range - * @param {number} a The beginning of the (inclusive) range - * @param {number} b The ending of the (inclusive) range - * @return {boolean} Whether x is in [a, b] - */ - function inRange(x: number, a: number, b: number): boolean; - /** - * Clamps x to the range [min, max]. - * - * @param {number} x The value to be clamped. - * @param {number} min The minimum value. - * @param {number} max The maximum value. - * @return {number} A clamped value in the range [min, max]. - */ - function clamp(x: number, min: number, max: number): number; - /** - * Applies the accessor, if provided, to each element of `array` and returns the maximum value. - * If no maximum value can be computed, returns defaultValue. - */ - function max(array: C[], defaultValue: C): C; - function max(array: T[], accessor: (t?: T, i?: number) => C, defaultValue: C): C; - /** - * Applies the accessor, if provided, to each element of `array` and returns the minimum value. - * If no minimum value can be computed, returns defaultValue. - */ - function min(array: C[], defaultValue: C): C; - function min(array: T[], accessor: (t?: T, i?: number) => C, defaultValue: C): C; - /** - * Returns true **only** if x is NaN - */ - function isNaN(n: any): boolean; - /** - * Returns true if the argument is a number, which is not NaN - * Numbers represented as strings do not pass this function - */ - function isValidNumber(n: any): boolean; - /** - * Generates an array of consecutive, strictly increasing numbers - * in the range [start, stop) separeted by step - */ - function range(start: number, stop: number, step?: number): number[]; - /** - * Returns the square of the distance between two points - * - * @param {Point} p1 - * @param {Point} p2 - * @return {number} dist(p1, p2)^2 - */ - function distanceSquared(p1: Point, p2: Point): number; - } - } - } - - - namespace Plottable { - namespace Utils { - /** - * Shim for ES6 map. - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map - */ - class Map { - constructor(); - set(key: K, value: V): Map; - get(key: K): V; - has(key: K): boolean; - forEach(callbackFn: (value: V, key: K, map: Map) => void, thisArg?: any): void; - delete(key: K): boolean; - } - } - } - - - namespace Plottable { - namespace Utils { - /** - * Shim for ES6 set. - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set - */ - class Set { - size: number; - constructor(); - add(value: T): Set; - delete(value: T): boolean; - has(value: T): boolean; - forEach(callback: (value: T, value2: T, set: Set) => void, thisArg?: any): void; - } - } - } - - namespace Plottable { - namespace Utils { - namespace DOM { - /** - * Gets the bounding box of an element. - * @param {d3.Selection} element - * @returns {SVGRed} The bounding box. - */ - function elementBBox(element: d3.Selection): SVGRect; - /** - * Screen refresh rate which is assumed to be 60fps - */ - var SCREEN_REFRESH_RATE_MILLISECONDS: number; - /** - * Polyfill for `window.requestAnimationFrame`. - * If the function exists, then we use the function directly. - * Otherwise, we set a timeout on `SCREEN_REFRESH_RATE_MILLISECONDS` and then perform the function. - * - * @param {() => void} callback The callback to call in the next animation frame - */ - function requestAnimationFramePolyfill(callback: () => void): void; - /** - * Calculates the width of the element. - * The width includes the padding and the border on the element's left and right sides. - * - * @param {Element} element The element to query - * @returns {number} The width of the element. - */ - function elementWidth(element: Element): number; - /** - * Calculates the height of the element. - * The height includes the padding the and the border on the element's top and bottom sides. - * - * @param {Element} element The element to query - * @returns {number} The height of the element - */ - function elementHeight(element: Element): number; - /** - * Retrieves the number array representing the translation for the selection - * - * @param {d3.Selection} selection The selection to query - * @returns {[number, number]} The number array representing the translation - */ - function translate(selection: d3.Selection): [number, number]; - /** - * Translates the given selection by the input x / y pixel amounts. - * - * @param {d3.Selection} selection The selection to translate - * @param {number} x The amount to translate in the x direction - * @param {number} y The amount to translate in the y direction - * @returns {d3.Selection} The input selection - */ - function translate(selection: d3.Selection, x: number, y: number): d3.Selection; - /** - * Checks if the first ClientRect overlaps the second. - * - * @param {ClientRect} clientRectA The first ClientRect - * @param {ClientRect} clientRectB The second ClientRect - * @returns {boolean} If the ClientRects overlap each other. - */ - function clientRectsOverlap(clientRectA: ClientRect, clientRectB: ClientRect): boolean; - /** - * Returns true if and only if innerClientRect is inside outerClientRect. - * - * @param {ClientRect} innerClientRect The first ClientRect - * @param {ClientRect} outerClientRect The second ClientRect - * @returns {boolean} If and only if the innerClientRect is inside outerClientRect. - */ - function clientRectInside(innerClientRect: ClientRect, outerClientRect: ClientRect): boolean; - /** - * Retrieves the bounding svg of the input element - * - * @param {SVGElement} element The element to query - * @returns {SVGElement} The bounding svg - */ - function boundingSVG(element: SVGElement): SVGElement; - /** - * Generates a ClipPath ID that is unique for this instance of Plottable - */ - function generateUniqueClipPathId(): string; - /** - * Returns true if the supplied coordinates or Ranges intersect or are contained by bbox. - * - * @param {number | Range} xValOrRange The x coordinate or Range to test - * @param {number | Range} yValOrRange The y coordinate or Range to test - * @param {SVGRect} bbox The bbox - * @param {number} tolerance Amount by which to expand bbox, in each dimension, before - * testing intersection - * - * @returns {boolean} True if the supplied coordinates or Ranges intersect or are - * contained by bbox, false otherwise. - */ - function intersectsBBox(xValOrRange: number | Range, yValOrRange: number | Range, bbox: SVGRect, tolerance?: number): boolean; - } - } - } - - - namespace Plottable { - namespace Utils { - namespace Color { - /** - * Return contrast ratio between two colors - * Based on implementation from chroma.js by Gregor Aisch (gka) (licensed under BSD) - * chroma.js may be found here: https://github.com/gka/chroma.js - * License may be found here: https://github.com/gka/chroma.js/blob/master/LICENSE - * see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef - */ - function contrast(a: string, b: string): number; - /** - * Returns a brighter copy of this color. Each channel is multiplied by 0.7 ^ -factor. - * Channel values are capped at the maximum value of 255, and the minimum value of 30. - */ - function lightenColor(color: string, factor: number): string; - /** - * Gets the Hex Code of the color resulting by applying the className CSS class to the - * colorTester selection. Returns null if the tester is transparent. - * - * @param {d3.Selection} colorTester The d3 selection to apply the CSS class to - * @param {string} className The name of the class to be applied - * @return {string} The hex code of the computed color - */ - function colorTest(colorTester: d3.Selection, className: string): string; - } - } - } - - - namespace Plottable { - namespace Utils { - namespace Array { - /** - * Takes two arrays of numbers and adds them together - * - * @param {number[]} aList The first array of numbers - * @param {number[]} bList The second array of numbers - * @return {number[]} An array of numbers where x[i] = aList[i] + bList[i] - */ - function add(aList: number[], bList: number[]): number[]; - /** - * Take an array of values, and return the unique values. - * Will work iff ∀ a, b, a.toString() == b.toString() => a == b; will break on Object inputs - * - * @param {T[]} values The values to find uniqueness for - * @return {T[]} The unique values - */ - function uniq(arr: T[]): T[]; - /** - * @param {T[][]} a The 2D array that will have its elements joined together. - * @return {T[]} Every array in a, concatenated together in the order they appear. - */ - function flatten(a: T[][]): T[]; - /** - * Creates an array of length `count`, filled with value or (if value is a function), value() - * - * @param {T | ((index?: number) => T)} value The value to fill the array with or a value generator (called with index as arg) - * @param {number} count The length of the array to generate - * @return {any[]} - */ - function createFilledArray(value: T | ((index?: number) => T), count: number): T[]; - } - } - } - - - namespace Plottable { - namespace Utils { - /** - * A set of callbacks which can be all invoked at once. - * Each callback exists at most once in the set (based on reference equality). - * All callbacks should have the same signature. - */ - class CallbackSet extends Set { - callCallbacks(...args: any[]): CallbackSet; - } - } - } - - - namespace Plottable { - namespace Utils { - namespace Stacking { - type StackedDatum = { - value: number; - offset: number; - }; - type StackingResult = Utils.Map>; - /** - * Computes the StackingResult (value and offset) for each data point in each Dataset. - * - * @param {Dataset[]} datasets The Datasets to be stacked on top of each other in the order of stacking - * @param {Accessor} keyAccessor Accessor for the key of the data - * @param {Accessor} valueAccessor Accessor for the value of the data - * @return {StackingResult} value and offset for each datapoint in each Dataset - */ - function stack(datasets: Dataset[], keyAccessor: Accessor, valueAccessor: Accessor): StackingResult; - /** - * Computes the total extent over all data points in all Datasets, taking stacking into consideration. - * - * @param {StackingResult} stackingResult The value and offset information for each datapoint in each dataset - * @oaram {Accessor} keyAccessor Accessor for the key of the data existent in the stackingResult - * @param {Accessor} filter A filter for data to be considered when computing the total extent - * @return {[number, number]} The total extent - */ - function stackedExtent(stackingResult: StackingResult, keyAccessor: Accessor, filter: Accessor): number[]; - /** - * Normalizes a key used for stacking - * - * @param {any} key The key to be normalized - * @return {string} The stringified key - */ - function normalizeKey(key: any): string; - } - } - } - - - namespace Plottable { - namespace Utils { - namespace Window { - /** - * Print a warning message to the console, if it is available. - * - * @param {string} The warnings to print - */ - function warn(warning: string): void; - /** - * Is like setTimeout, but activates synchronously if time=0 - * We special case 0 because of an observed issue where calling setTimeout causes visible flickering. - * We believe this is because when requestAnimationFrame calls into the paint function, as soon as that function finishes - * evaluating, the results are painted to the screen. As a result, if we want something to occur immediately but call setTimeout - * with time=0, then it is pushed to the call stack and rendered in the next frame, so the component that was rendered via - * setTimeout appears out-of-sync with the rest of the plot. - */ - function setTimeout(f: Function, time: number, ...args: any[]): number; - /** - * Sends a deprecation warning to the console. The warning includes the name of the deprecated method, - * version number of the deprecation, and an optional message. - * - * To be used in the first line of a deprecated method. - * - * @param {string} callingMethod The name of the method being deprecated - * @param {string} version The version when the tagged method became obsolete - * @param {string?} message Optional message to be shown with the warning - */ - function deprecated(callingMethod: string, version: string, message?: string): void; - } - } - } - - - namespace Plottable { - namespace Utils { - class ClientToSVGTranslator { - /** - * Returns the ClientToSVGTranslator for the containing elem. - * If one already exists on that , it will be returned; otherwise, a new one will be created. - */ - static getTranslator(elem: SVGElement): ClientToSVGTranslator; - constructor(svg: SVGElement); - /** - * Computes the position relative to the in svg-coordinate-space. - */ - computePosition(clientX: number, clientY: number): Point; - /** - * Checks whether event happened inside element. - */ - insideSVG(e: Event): boolean; - } - } - } - - - namespace Plottable { - namespace Configs { - /** - * Specifies if Plottable should show warnings. - */ - var SHOW_WARNINGS: boolean; - } - } - - - namespace Plottable { - var version: string; - } - - - namespace Plottable { - type DatasetCallback = (dataset: Dataset) => void; - class Dataset { - /** - * A Dataset contains an array of data and some metadata. - * Changes to the data or metadata will cause anything subscribed to the Dataset to update. - * - * @constructor - * @param {any[]} [data=[]] The data for this Dataset. - * @param {any} [metadata={}] An object containing additional information. - */ - constructor(data?: any[], metadata?: any); - /** - * Adds a callback to be called when the Dataset updates. - * - * @param {DatasetCallback} callback. - * @returns {Dataset} The calling Dataset. - */ - onUpdate(callback: DatasetCallback): Dataset; - /** - * Removes a callback that would be called when the Dataset updates. - * - * @param {DatasetCallback} callback - * @returns {Dataset} The calling Dataset. - */ - offUpdate(callback: DatasetCallback): Dataset; - /** - * Gets the data. - * - * @returns {any[]} - */ - data(): any[]; - /** - * Sets the data. - * - * @param {any[]} data - * @returns {Dataset} The calling Dataset. - */ - data(data: any[]): Dataset; - /** - * Gets the metadata. - * - * @returns {any} - */ - metadata(): any; - /** - * Sets the metadata. - * - * @param {any} metadata - * @returns {Dataset} The calling Dataset. - */ - metadata(metadata: any): Dataset; - } - } - - - namespace Plottable { - namespace RenderPolicies { - /** - * A policy for rendering Components. - */ - interface RenderPolicy { - render(): any; - } - /** - * Renders Components immediately after they are enqueued. - * Useful for debugging, horrible for performance. - */ - class Immediate implements RenderPolicy { - render(): void; - } - /** - * The default way to render, which only tries to render every frame - * (usually, 1/60th of a second). - */ - class AnimationFrame implements RenderPolicy { - render(): void; - } - /** - * Renders with `setTimeout()`. - * Generally an inferior way to render compared to `requestAnimationFrame`, - * but useful for browsers that don't suppoort `requestAnimationFrame`. - */ - class Timeout implements RenderPolicy { - render(): void; - } - } - } - - - namespace Plottable { - /** - * The RenderController is responsible for enqueueing and synchronizing - * layout and render calls for Components. - * - * Layout and render calls occur inside an animation callback - * (window.requestAnimationFrame if available). - * - * RenderController.flush() immediately lays out and renders all Components currently enqueued. - * - * To always have immediate rendering (useful for debugging), call - * ```typescript - * Plottable.RenderController.setRenderPolicy( - * new Plottable.RenderPolicies.Immediate() - * ); - * ``` - */ - namespace RenderController { - namespace Policy { - var IMMEDIATE: string; - var ANIMATION_FRAME: string; - var TIMEOUT: string; - } - function renderPolicy(): RenderPolicies.RenderPolicy; - function renderPolicy(renderPolicy: string): void; - /** - * Enqueues the Component for rendering. - * - * @param {Component} component - */ - function registerToRender(component: Component): void; - /** - * Enqueues the Component for layout and rendering. - * - * @param {Component} component - */ - function registerToComputeLayout(component: Component): void; - /** - * Renders all Components waiting to be rendered immediately - * instead of waiting until the next frame. - * - * Useful to call when debugging. - */ - function flush(): void; - } - } - - namespace Plottable { - /** - * Accesses a specific datum property. - */ - interface Accessor { - (datum: any, index: number, dataset: Dataset): T; - } - /** - * Retrieves a scaled datum property. - * Essentially passes the result of an Accessor through a Scale. - */ - type Projector = (datum: any, index: number, dataset: Dataset) => any; - /** - * A mapping from attributes ("x", "fill", etc.) to the functions that get - * that information out of the data. - */ - type AttributeToProjector = { - [attr: string]: Projector; - }; - /** - * A function that generates attribute values from the datum and index. - * Essentially a Projector with a particular Dataset rolled in. - */ - type AppliedProjector = (datum: any, index: number) => any; - /** - * A mapping from attributes to the AppliedProjectors used to generate them. - */ - type AttributeToAppliedProjector = { - [attr: string]: AppliedProjector; - }; - /** - * Space request used during layout negotiation. - * - * @member {number} minWidth The minimum acceptable width given the offered space. - * @member {number} minHeight the minimum acceptable height given the offered space. - */ - type SpaceRequest = { - minWidth: number; - minHeight: number; - }; - /** - * Min and max values for a particular property. - */ - type Range = { - min: number; - max: number; - }; - /** - * A location in pixel-space. - */ - type Point = { - x: number; - y: number; - }; - /** - * The corners of a box. - */ - type Bounds = { - topLeft: Point; - bottomRight: Point; - }; - /** - * An object representing a data-backed visual entity inside a Component. - */ - interface Entity { - datum: any; - position: Point; - selection: d3.Selection; - component: C; - } - } - - - namespace Plottable { - type Formatter = (d: any) => string; - /** - * This field is deprecated and will be removed in v2.0.0. - * - * The number of milliseconds between midnight one day and the next is - * not a fixed quantity. - * - * Use date.setDate(date.getDate() + number_of_days) instead. - * - */ - var MILLISECONDS_IN_ONE_DAY: number; - namespace Formatters { - /** - * Creates a formatter for currency values. - * - * @param {number} [precision] The number of decimal places to show (default 2). - * @param {string} [symbol] The currency symbol to use (default "$"). - * @param {boolean} [prefix] Whether to prepend or append the currency symbol (default true). - * @param {boolean} [onlyShowUnchanged] Whether to return a value if value changes after formatting (default true). - * - * @returns {Formatter} A formatter for currency values. - */ - function currency(precision?: number, symbol?: string, prefix?: boolean): (d: any) => string; - /** - * Creates a formatter that displays exactly [precision] decimal places. - * - * @param {number} [precision] The number of decimal places to show (default 3). - * @param {boolean} [onlyShowUnchanged] Whether to return a value if value changes after formatting (default true). - * - * @returns {Formatter} A formatter that displays exactly [precision] decimal places. - */ - function fixed(precision?: number): (d: any) => string; - /** - * Creates a formatter that formats numbers to show no more than - * [precision] decimal places. All other values are stringified. - * - * @param {number} [precision] The number of decimal places to show (default 3). - * @param {boolean} [onlyShowUnchanged] Whether to return a value if value changes after formatting (default true). - * - * @returns {Formatter} A formatter for general values. - */ - function general(precision?: number): (d: any) => string; - /** - * Creates a formatter that stringifies its input. - * - * @returns {Formatter} A formatter that stringifies its input. - */ - function identity(): (d: any) => string; - /** - * Creates a formatter for percentage values. - * Multiplies the input by 100 and appends "%". - * - * @param {number} [precision] The number of decimal places to show (default 0). - * @param {boolean} [onlyShowUnchanged] Whether to return a value if value changes after formatting (default true). - * - * @returns {Formatter} A formatter for percentage values. - */ - function percentage(precision?: number): (d: any) => string; - /** - * Creates a formatter for values that displays [precision] significant figures - * and puts SI notation. - * - * @param {number} [precision] The number of significant figures to show (default 3). - * - * @returns {Formatter} A formatter for SI values. - */ - function siSuffix(precision?: number): (d: any) => string; - /** - * Creates a multi time formatter that displays dates. - * - * @returns {Formatter} A formatter for time/date values. - */ - function multiTime(): (d: any) => string; - /** - * Creates a time formatter that displays time/date using given specifier. - * - * List of directives can be found on: https://github.com/mbostock/d3/wiki/Time-Formatting#format - * - * @param {string} [specifier] The specifier for the formatter. - * - * @returns {Formatter} A formatter for time/date values. - */ - function time(specifier: string): Formatter; - /** - * Creates a formatter for relative dates. - * - * @param {number} baseValue The start date (as epoch time) used in computing relative dates (default 0) - * @param {number} increment The unit used in calculating relative date values (default MILLISECONDS_IN_ONE_DAY) - * @param {string} label The label to append to the formatted string (default "") - * - * @returns {Formatter} A formatter for time/date values. - */ - function relativeDate(baseValue?: number, increment?: number, label?: string): (d: any) => string; - } - } - - - namespace Plottable { - /** - * A SymbolFactory is a function that takes in a symbolSize which is the edge length of the render area - * and returns a string representing the 'd' attribute of the resultant 'path' element - */ - type SymbolFactory = (symbolSize: number) => string; - namespace SymbolFactories { - function circle(): SymbolFactory; - function square(): SymbolFactory; - function cross(): SymbolFactory; - function diamond(): SymbolFactory; - function triangleUp(): SymbolFactory; - function triangleDown(): SymbolFactory; - } - } - - - namespace Plottable { - interface ScaleCallback> { - (scale: S): any; - } - namespace Scales { - /** - * A function that supplies domain values to be included into a Scale. - * - * @param {Scale} scale - * @returns {D[]} An array of values that should be included in the Scale. - */ - interface IncludedValuesProvider { - (scale: Scale): D[]; - } - /** - * A function that supplies padding exception values for the Scale. - * If one end of the domain is set to an excepted value as a result of autoDomain()-ing, - * that end of the domain will not be padded. - * - * @param {QuantitativeScale} scale - * @returns {D[]} An array of values that should not be padded. - */ - interface PaddingExceptionsProvider { - (scale: QuantitativeScale): D[]; - } - } - class Scale { - /** - * A Scale is a function (in the mathematical sense) that maps values from a domain to a range. - * - * @constructor - */ - constructor(); - /** - * Given an array of potential domain values, computes the extent of those values. - * - * @param {D[]} values - * @returns {D[]} The extent of the input values. - */ - extentOfValues(values: D[]): D[]; - protected _getAllIncludedValues(): D[]; - protected _getExtent(): D[]; - /** - * Adds a callback to be called when the Scale updates. - * - * @param {ScaleCallback} callback. - * @returns {Scale} The calling Scale. - */ - onUpdate(callback: ScaleCallback>): Scale; - /** - * Removes a callback that would be called when the Scale updates. - * - * @param {ScaleCallback} callback. - * @returns {Scale} The calling Scale. - */ - offUpdate(callback: ScaleCallback>): Scale; - protected _dispatchUpdate(): void; - /** - * Sets the Scale's domain so that it spans the Extents of all its ExtentsProviders. - * - * @returns {Scale} The calling Scale. - */ - autoDomain(): Scale; - protected _autoDomainIfAutomaticMode(): void; - /** - * Computes the range value corresponding to a given domain value. - * - * @param {D} value - * @returns {R} The range value corresponding to the supplied domain value. - */ - scale(value: D): R; - /** - * Gets the domain. - * - * @returns {D[]} The current domain. - */ - domain(): D[]; - /** - * Sets the domain. - * - * @param {D[]} values - * @returns {Scale} The calling Scale. - */ - domain(values: D[]): Scale; - protected _getDomain(): void; - protected _setDomain(values: D[]): void; - protected _setBackingScaleDomain(values: D[]): void; - /** - * Gets the range. - * - * @returns {R[]} The current range. - */ - range(): R[]; - /** - * Sets the range. - * - * @param {R[]} values - * @returns {Scale} The calling Scale. - */ - range(values: R[]): Scale; - protected _getRange(): void; - protected _setRange(values: R[]): void; - /** - * Adds an IncludedValuesProvider to the Scale. - * - * @param {Scales.IncludedValuesProvider} provider - * @returns {Scale} The calling Scale. - */ - addIncludedValuesProvider(provider: Scales.IncludedValuesProvider): Scale; - /** - * Removes the IncludedValuesProvider from the Scale. - * - * @param {Scales.IncludedValuesProvider} provider - * @returns {Scale} The calling Scale. - */ - removeIncludedValuesProvider(provider: Scales.IncludedValuesProvider): Scale; - } - } - - - namespace Plottable { - class QuantitativeScale extends Scale { - protected static _DEFAULT_NUM_TICKS: number; - /** - * A QuantitativeScale is a Scale that maps number-like values to numbers. - * It is invertible and continuous. - * - * @constructor - */ - constructor(); - autoDomain(): QuantitativeScale; - protected _autoDomainIfAutomaticMode(): void; - protected _getExtent(): D[]; - /** - * Adds a padding exception provider. - * If one end of the domain is set to an excepted value as a result of autoDomain()-ing, - * that end of the domain will not be padded. - * - * @param {Scales.PaddingExceptionProvider} provider The provider function. - * @returns {QuantitativeScale} The calling QuantitativeScale. - */ - addPaddingExceptionsProvider(provider: Scales.PaddingExceptionsProvider): QuantitativeScale; - /** - * Removes the padding exception provider. - * - * @param {Scales.PaddingExceptionProvider} provider The provider function. - * @returns {QuantitativeScale} The calling QuantitativeScale. - */ - removePaddingExceptionsProvider(provider: Scales.PaddingExceptionsProvider): QuantitativeScale; - /** - * Gets the padding proportion. - */ - padProportion(): number; - /** - * Sets the padding porportion. - * When autoDomain()-ing, the computed domain will be expanded by this proportion, - * then rounded to human-readable values. - * - * @param {number} padProportion The padding proportion. Passing 0 disables padding. - * @returns {QuantitativeScale} The calling QuantitativeScale. - */ - padProportion(padProportion: number): QuantitativeScale; - protected _expandSingleValueDomain(singleValueDomain: D[]): D[]; - /** - * Computes the domain value corresponding to a supplied range value. - * - * @param {number} value: A value from the Scale's range. - * @returns {D} The domain value corresponding to the supplied range value. - */ - invert(value: number): D; - domain(): D[]; - domain(values: D[]): QuantitativeScale; - /** - * Gets the lower end of the domain. - * - * @return {D} - */ - domainMin(): D; - /** - * Sets the lower end of the domain. - * - * @return {QuantitativeScale} The calling QuantitativeScale. - */ - domainMin(domainMin: D): QuantitativeScale; - /** - * Gets the upper end of the domain. - * - * @return {D} - */ - domainMax(): D; - /** - * Sets the upper end of the domain. - * - * @return {QuantitativeScale} The calling QuantitativeScale. - */ - domainMax(domainMax: D): QuantitativeScale; - extentOfValues(values: D[]): D[]; - protected _setDomain(values: D[]): void; - /** - * Gets the array of tick values generated by the default algorithm. - */ - defaultTicks(): D[]; - /** - * Gets an array of tick values spanning the domain. - * - * @returns {D[]} - */ - ticks(): D[]; - /** - * Given a domain, expands its domain onto "nice" values, e.g. whole - * numbers. - */ - protected _niceDomain(domain: D[], count?: number): D[]; - protected _defaultExtent(): D[]; - /** - * Gets the TickGenerator. - */ - tickGenerator(): Scales.TickGenerators.TickGenerator; - /** - * Sets the TickGenerator - * - * @param {TickGenerator} generator - * @return {QuantitativeScale} The calling QuantitativeScale. - */ - tickGenerator(generator: Scales.TickGenerators.TickGenerator): QuantitativeScale; - } - } - - - namespace Plottable { - namespace Scales { - class Linear extends QuantitativeScale { - /** - * @constructor - */ - constructor(); - protected _defaultExtent(): number[]; - protected _expandSingleValueDomain(singleValueDomain: number[]): number[]; - scale(value: number): number; - protected _getDomain(): number[]; - protected _setBackingScaleDomain(values: number[]): void; - protected _getRange(): number[]; - protected _setRange(values: number[]): void; - invert(value: number): number; - defaultTicks(): number[]; - protected _niceDomain(domain: number[], count?: number): number[]; - } - } - } - - - namespace Plottable { - namespace Scales { - class ModifiedLog extends QuantitativeScale { - /** - * A ModifiedLog Scale acts as a regular log scale for large numbers. - * As it approaches 0, it gradually becomes linear. - * Consequently, a ModifiedLog Scale can process 0 and negative numbers. - * - * @constructor - * @param {number} [base=10] - * The base of the log. Must be > 1. - * - * For x <= base, scale(x) = log(x). - * - * For 0 < x < base, scale(x) will become more and more - * linear as it approaches 0. - * - * At x == 0, scale(x) == 0. - * - * For negative values, scale(-x) = -scale(x). - */ - constructor(base?: number); - scale(x: number): number; - invert(x: number): number; - protected _getDomain(): number[]; - protected _setDomain(values: number[]): void; - protected _setBackingScaleDomain(values: number[]): void; - ticks(): number[]; - protected _niceDomain(domain: number[], count?: number): number[]; - protected _defaultExtent(): number[]; - protected _expandSingleValueDomain(singleValueDomain: number[]): number[]; - protected _getRange(): number[]; - protected _setRange(values: number[]): void; - defaultTicks(): number[]; - } - } - } - - - namespace Plottable { - namespace Scales { - class Category extends Scale { - /** - * A Category Scale maps strings to numbers. - * - * @constructor - */ - constructor(); - extentOfValues(values: string[]): string[]; - protected _getExtent(): string[]; - domain(): string[]; - domain(values: string[]): Category; - protected _setDomain(values: string[]): void; - range(): [number, number]; - range(values: [number, number]): Category; - /** - * Returns the width of the range band. - * - * @returns {number} The range band width - */ - rangeBand(): number; - /** - * Returns the step width of the scale. - * - * The step width is the pixel distance between adjacent values in the domain. - * - * @returns {number} - */ - stepWidth(): number; - /** - * Gets the inner padding. - * - * The inner padding is defined as the padding in between bands on the scale, - * expressed as a multiple of the rangeBand(). - * - * @returns {number} - */ - innerPadding(): number; - /** - * Sets the inner padding. - * - * The inner padding is defined as the padding in between bands on the scale, - * expressed as a multiple of the rangeBand(). - * - * @returns {Category} The calling Category Scale. - */ - innerPadding(innerPadding: number): Category; - /** - * Gets the outer padding. - * - * The outer padding is the padding in between the outer bands and the edges of the range, - * expressed as a multiple of the rangeBand(). - * - * @returns {number} - */ - outerPadding(): number; - /** - * Sets the outer padding. - * - * The outer padding is the padding in between the outer bands and the edges of the range, - * expressed as a multiple of the rangeBand(). - * - * @returns {Category} The calling Category Scale. - */ - outerPadding(outerPadding: number): Category; - scale(value: string): number; - protected _getDomain(): string[]; - protected _setBackingScaleDomain(values: string[]): void; - protected _getRange(): number[]; - protected _setRange(values: number[]): void; - } - } - } - - - namespace Plottable { - namespace Scales { - class Color extends Scale { - /** - * A Color Scale maps string values to color hex values expressed as a string. - * - * @constructor - * @param {string} [scaleType] One of "Category10"/"Category20"/"Category20b"/"Category20c". - * (see https://github.com/mbostock/d3/wiki/Ordinal-Scales#categorical-colors) - * If not supplied, reads the colors defined using CSS -- see plottable.css. - */ - constructor(scaleType?: string); - extentOfValues(values: string[]): string[]; - protected _getExtent(): string[]; - static invalidateColorCache(): void; - /** - * Returns the color-string corresponding to a given string. - * If there are not enough colors in the range(), a lightened version of an existing color will be used. - * - * @param {string} value - * @returns {string} - */ - scale(value: string): string; - protected _getDomain(): string[]; - protected _setBackingScaleDomain(values: string[]): void; - protected _getRange(): string[]; - protected _setRange(values: string[]): void; - } - } - } - - - namespace Plottable { - namespace Scales { - class Time extends QuantitativeScale { - /** - * A Time Scale maps Date objects to numbers. - * - * @constructor - */ - constructor(); - /** - * Returns an array of ticks values separated by the specified interval. - * - * @param {string} interval A string specifying the interval unit. - * @param {number?} [step] The number of multiples of the interval between consecutive ticks. - * @return {Date[]} - */ - tickInterval(interval: string, step?: number): Date[]; - protected _setDomain(values: Date[]): void; - protected _defaultExtent(): Date[]; - protected _expandSingleValueDomain(singleValueDomain: Date[]): Date[]; - scale(value: Date): number; - protected _getDomain(): Date[]; - protected _setBackingScaleDomain(values: Date[]): void; - protected _getRange(): number[]; - protected _setRange(values: number[]): void; - invert(value: number): Date; - defaultTicks(): Date[]; - protected _niceDomain(domain: Date[]): Date[]; - /** - * Transforms the Plottable TimeInterval string into a d3 time interval equivalent. - * If the provided TimeInterval is incorrect, the default is d3.time.year - */ - static timeIntervalToD3Time(timeInterval: string): d3.time.Interval; - } - } - } - - - namespace Plottable { - namespace Scales { - class InterpolatedColor extends Scale { - static REDS: string[]; - static BLUES: string[]; - static POSNEG: string[]; - /** - * An InterpolatedColor Scale maps numbers to color hex values, expressed as strings. - * - * @param {string} [scaleType="linear"] One of "linear"/"log"/"sqrt"/"pow". - */ - constructor(scaleType?: string); - extentOfValues(values: number[]): number[]; - autoDomain(): InterpolatedColor; - scale(value: number): string; - protected _getDomain(): number[]; - protected _setBackingScaleDomain(values: number[]): void; - protected _getRange(): string[]; - protected _setRange(range: string[]): void; - } - } - } - - - namespace Plottable { - namespace Scales { - namespace TickGenerators { - /** - * Generates an array of tick values for the specified scale. - * - * @param {QuantitativeScale} scale - * @returns {D[]} - */ - interface TickGenerator { - (scale: Plottable.QuantitativeScale): D[]; - } - /** - * Creates a TickGenerator using the specified interval. - * - * Generates ticks at multiples of the interval while also including the domain boundaries. - * - * @param {number} interval - * @returns {TickGenerator} - */ - function intervalTickGenerator(interval: number): TickGenerator; - /** - * Creates a TickGenerator returns only integer tick values. - * - * @returns {TickGenerator} - */ - function integerTickGenerator(): TickGenerator; - } - } - } - - - namespace Plottable { - namespace Drawers { - /** - * A step for the drawer to draw. - * - * Specifies how AttributeToProjector needs to be animated. - */ - type DrawStep = { - attrToProjector: AttributeToProjector; - animator: Animator; - }; - /** - * A DrawStep that carries an AttributeToAppliedProjector map. - */ - type AppliedDrawStep = { - attrToAppliedProjector: AttributeToAppliedProjector; - animator: Animator; - }; - } - class Drawer { - protected _svgElementName: string; - protected _className: string; - /** - * A Drawer draws svg elements based on the input Dataset. - * - * @constructor - * @param {Dataset} dataset The dataset associated with this Drawer - */ - constructor(dataset: Dataset); - /** - * Retrieves the renderArea selection for the Drawer. - */ - renderArea(): d3.Selection; - /** - * Sets the renderArea selection for the Drawer. - * - * @param {d3.Selection} Selection containing the to render to. - * @returns {Drawer} The calling Drawer. - */ - renderArea(area: d3.Selection): Drawer; - /** - * Removes the Drawer and its renderArea - */ - remove(): void; - protected _applyDefaultAttributes(selection: d3.Selection): void; - /** - * Calculates the total time it takes to use the input drawSteps to draw the input data - * - * @param {any[]} data The data that would have been drawn - * @param {Drawers.DrawStep[]} drawSteps The DrawSteps to use - * @returns {number} The total time it takes to draw - */ - totalDrawTime(data: any[], drawSteps: Drawers.DrawStep[]): number; - /** - * Draws the data into the renderArea using the spefic steps and metadata - * - * @param{any[]} data The data to be drawn - * @param{DrawStep[]} drawSteps The list of steps, which needs to be drawn - */ - draw(data: any[], drawSteps: Drawers.DrawStep[]): Drawer; - selection(): d3.Selection; - /** - * Returns the CSS selector for this Drawer's visual elements. - */ - selector(): string; - /** - * Returns the D3 selection corresponding to the datum with the specified index. - */ - selectionForIndex(index: number): d3.Selection; - } - } - - - namespace Plottable { - namespace Drawers { - class Line extends Drawer { - constructor(dataset: Dataset); - protected _applyDefaultAttributes(selection: d3.Selection): void; - selectionForIndex(index: number): d3.Selection; - } - } - } - - - namespace Plottable { - namespace Drawers { - class Area extends Drawer { - constructor(dataset: Dataset); - protected _applyDefaultAttributes(selection: d3.Selection): void; - selectionForIndex(index: number): d3.Selection; - } - } - } - - - namespace Plottable { - namespace Drawers { - class Rectangle extends Drawer { - constructor(dataset: Dataset); - } - } - } - - - namespace Plottable { - namespace Drawers { - class Arc extends Drawer { - constructor(dataset: Dataset); - } - } - } - - - namespace Plottable { - namespace Drawers { - class Symbol extends Drawer { - constructor(dataset: Dataset); - } - } - } - - - namespace Plottable { - namespace Drawers { - class Segment extends Drawer { - constructor(dataset: Dataset); - } - } - } - - - namespace Plottable { - type ComponentCallback = (component: Component) => void; - namespace Components { - class Alignment { - static TOP: string; - static BOTTOM: string; - static LEFT: string; - static RIGHT: string; - static CENTER: string; - } - } - class Component { - protected _boundingBox: d3.Selection; - protected _clipPathEnabled: boolean; - protected _isSetup: boolean; - protected _isAnchored: boolean; - constructor(); - /** - * Attaches the Component as a child of a given d3 Selection. - * - * @param {d3.Selection} selection. - * @returns {Component} The calling Component. - */ - anchor(selection: d3.Selection): Component; - /** - * Adds a callback to be called on anchoring the Component to the DOM. - * If the Component is already anchored, the callback is called immediately. - * - * @param {ComponentCallback} callback - * @return {Component} - */ - onAnchor(callback: ComponentCallback): Component; - /** - * Removes a callback that would be called on anchoring the Component to the DOM. - * The callback is identified by reference equality. - * - * @param {ComponentCallback} callback - * @return {Component} - */ - offAnchor(callback: ComponentCallback): Component; - /** - * Creates additional elements as necessary for the Component to function. - * Called during anchor() if the Component's element has not been created yet. - * Override in subclasses to provide additional functionality. - */ - protected _setup(): void; - /** - * Given available space in pixels, returns the minimum width and height this Component will need. - * - * @param {number} availableWidth - * @param {number} availableHeight - * @returns {SpaceRequest} - */ - requestedSpace(availableWidth: number, availableHeight: number): SpaceRequest; - /** - * Computes and sets the size, position, and alignment of the Component from the specified values. - * If no parameters are supplied and the Component is a root node, - * they are inferred from the size of the Component's element. - * - * @param {Point} [origin] Origin of the space offered to the Component. - * @param {number} [availableWidth] Available width in pixels. - * @param {number} [availableHeight] Available height in pixels. - * @returns {Component} The calling Component. - */ - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Component; - protected _sizeFromOffer(availableWidth: number, availableHeight: number): { - width: number; - height: number; - }; - /** - * Queues the Component for rendering. - * - * @returns {Component} The calling Component. - */ - render(): Component; - /** - * Renders the Component without waiting for the next frame. - */ - renderImmediately(): Component; - /** - * Causes the Component to re-layout and render. - * - * This function should be called when a CSS change has occured that could - * influence the layout of the Component, such as changing the font size. - * - * @returns {Component} The calling Component. - */ - redraw(): Component; - /** - * Renders the Component to a given . - * - * @param {String|d3.Selection} element A selector-string for the , or a d3 selection containing an . - * @returns {Component} The calling Component. - */ - renderTo(element: String | d3.Selection): Component; - /** - * Gets the x alignment of the Component. - */ - xAlignment(): string; - /** - * Sets the x alignment of the Component. - * - * @param {string} xAlignment The x alignment of the Component ("left"/"center"/"right"). - * @returns {Component} The calling Component. - */ - xAlignment(xAlignment: string): Component; - /** - * Gets the y alignment of the Component. - */ - yAlignment(): string; - /** - * Sets the y alignment of the Component. - * - * @param {string} yAlignment The y alignment of the Component ("top"/"center"/"bottom"). - * @returns {Component} The calling Component. - */ - yAlignment(yAlignment: string): Component; - /** - * Checks if the Component has a given CSS class. - * - * @param {string} cssClass The CSS class to check for. - */ - hasClass(cssClass: string): boolean; - /** - * Adds a given CSS class to the Component. - * - * @param {string} cssClass The CSS class to add. - * @returns {Component} The calling Component. - */ - addClass(cssClass: string): Component; - /** - * Removes a given CSS class from the Component. - * - * @param {string} cssClass The CSS class to remove. - * @returns {Component} The calling Component. - */ - removeClass(cssClass: string): Component; - /** - * Checks if the Component has a fixed width or if it grows to fill available space. - * Returns false by default on the base Component class. - */ - fixedWidth(): boolean; - /** - * Checks if the Component has a fixed height or if it grows to fill available space. - * Returns false by default on the base Component class. - */ - fixedHeight(): boolean; - /** - * Detaches a Component from the DOM. The Component can be reused. - * - * This should only be used if you plan on reusing the calling Component. Otherwise, use destroy(). - * - * @returns The calling Component. - */ - detach(): Component; - /** - * Adds a callback to be called when the Component is detach()-ed. - * - * @param {ComponentCallback} callback - * @return {Component} The calling Component. - */ - onDetach(callback: ComponentCallback): Component; - /** - * Removes a callback to be called when the Component is detach()-ed. - * The callback is identified by reference equality. - * - * @param {ComponentCallback} callback - * @return {Component} The calling Component. - */ - offDetach(callback: ComponentCallback): Component; - /** - * Gets the parent ComponentContainer for this Component. - */ - parent(): ComponentContainer; - /** - * Sets the parent ComponentContainer for this Component. - * An error will be thrown if the parent does not contain this Component. - * Adding a Component to a ComponentContainer should be done - * using the appropriate method on the ComponentContainer. - */ - parent(parent: ComponentContainer): Component; - /** - * Removes a Component from the DOM and disconnects all listeners. - */ - destroy(): void; - /** - * Gets the width of the Component in pixels. - */ - width(): number; - /** - * Gets the height of the Component in pixels. - */ - height(): number; - /** - * Gets the origin of the Component relative to its parent. - * - * @return {Point} - */ - origin(): Point; - /** - * Gets the origin of the Component relative to the root . - * - * @return {Point} - */ - originToSVG(): Point; - /** - * Gets the Selection containing the in front of the visual elements of the Component. - * - * Will return undefined if the Component has not been anchored. - * - * @return {d3.Selection} - */ - foreground(): d3.Selection; - /** - * Gets a Selection containing a that holds the visual elements of the Component. - * - * Will return undefined if the Component has not been anchored. - * - * @return {d3.Selection} content selection for the Component - */ - content(): d3.Selection; - /** - * Gets the Selection containing the behind the visual elements of the Component. - * - * Will return undefined if the Component has not been anchored. - * - * @return {d3.Selection} background selection for the Component - */ - background(): d3.Selection; - } - } - - - namespace Plottable { - class ComponentContainer extends Component { - constructor(); - anchor(selection: d3.Selection): ComponentContainer; - render(): ComponentContainer; - /** - * Checks whether the specified Component is in the ComponentContainer. - */ - has(component: Component): boolean; - protected _adoptAndAnchor(component: Component): void; - /** - * Removes the specified Component from the ComponentContainer. - */ - remove(component: Component): ComponentContainer; - /** - * Carry out the actual removal of a Component. - * Implementation dependent on the type of container. - * - * @return {boolean} true if the Component was successfully removed, false otherwise. - */ - protected _remove(component: Component): boolean; - /** - * Invokes a callback on each Component in the ComponentContainer. - */ - protected _forEach(callback: (component: Component) => void): void; - /** - * Destroys the ComponentContainer and all Components within it. - */ - destroy(): void; - } - } - - - namespace Plottable { - namespace Components { - class Group extends ComponentContainer { - /** - * Constructs a Group. - * - * A Group contains Components that will be rendered on top of each other. - * Components added later will be rendered above Components already in the Group. - * - * @constructor - * @param {Component[]} [components=[]] Components to be added to the Group. - */ - constructor(components?: Component[]); - protected _forEach(callback: (component: Component) => any): void; - /** - * Checks whether the specified Component is in the Group. - */ - has(component: Component): boolean; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Group; - protected _sizeFromOffer(availableWidth: number, availableHeight: number): { - width: number; - height: number; - }; - fixedWidth(): boolean; - fixedHeight(): boolean; - /** - * @return {Component[]} The Components in this Group. - */ - components(): Component[]; - /** - * Adds a Component to this Group. - * The added Component will be rendered above Components already in the Group. - */ - append(component: Component): Group; - protected _remove(component: Component): boolean; - } - } - } - - - namespace Plottable { - class Axis extends Component { - /** - * The css class applied to each end tick mark (the line on the end tick). - */ - static END_TICK_MARK_CLASS: string; - /** - * The css class applied to each tick mark (the line on the tick). - */ - static TICK_MARK_CLASS: string; - /** - * The css class applied to each tick label (the text associated with the tick). - */ - static TICK_LABEL_CLASS: string; - protected _tickMarkContainer: d3.Selection; - protected _tickLabelContainer: d3.Selection; - protected _baseline: d3.Selection; - protected _scale: Scale; - protected _computedWidth: number; - protected _computedHeight: number; - /** - * Constructs an Axis. - * An Axis is a visual representation of a Scale. - * - * @constructor - * @param {Scale} scale - * @param {string} orientation One of "top"/"bottom"/"left"/"right". - */ - constructor(scale: Scale, orientation: string); - destroy(): void; - protected _isHorizontal(): boolean; - protected _computeWidth(): number; - protected _computeHeight(): number; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - fixedHeight(): boolean; - fixedWidth(): boolean; - protected _rescale(): void; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Axis; - protected _setup(): void; - protected _getTickValues(): D[]; - renderImmediately(): Axis; - protected _generateBaselineAttrHash(): { - [key: string]: number; - }; - protected _generateTickMarkAttrHash(isEndTickMark?: boolean): { - [key: string]: number | ((d: any) => number); - }; - redraw(): Component; - protected _setDefaultAlignment(): void; - /** - * Gets the Formatter on the Axis. Tick values are passed through the - * Formatter before being displayed. - */ - formatter(): Formatter; - /** - * Sets the Formatter on the Axis. Tick values are passed through the - * Formatter before being displayed. - * - * @param {Formatter} formatter - * @returns {Axis} The calling Axis. - */ - formatter(formatter: Formatter): Axis; - /** - * @deprecated As of release 1.3, replaced by innerTickLength() - * - * Gets the tick mark length in pixels. - */ - tickLength(): number; - /** - * Sets the tick mark length in pixels. - * - * @param {number} length - * @returns {Axis} The calling Axis. - */ - tickLength(length: number): Axis; - /** - * Gets the tick mark length in pixels. - */ - innerTickLength(): number; - /** - * Sets the tick mark length in pixels. - * - * @param {number} length - * @returns {Axis} The calling Axis. - */ - innerTickLength(length: number): Axis; - /** - * Gets the end tick mark length in pixels. - */ - endTickLength(): number; - /** - * Sets the end tick mark length in pixels. - * - * @param {number} length - * @returns {Axis} The calling Axis. - */ - endTickLength(length: number): Axis; - protected _maxLabelTickLength(): number; - /** - * Gets the padding between each tick mark and its associated label in pixels. - */ - tickLabelPadding(): number; - /** - * Sets the padding between each tick mark and its associated label in pixels. - * - * @param {number} padding - * @returns {Axis} The calling Axis. - */ - tickLabelPadding(padding: number): Axis; - /** - * Gets the margin in pixels. - * The margin is the amount of space between the tick labels and the outer edge of the Axis. - */ - margin(): number; - /** - * Sets the margin in pixels. - * The margin is the amount of space between the tick labels and the outer edge of the Axis. - * - * @param {number} size - * @returns {Axis} The calling Axis. - */ - margin(size: number): Axis; - /** - * Gets the orientation of the Axis. - */ - orientation(): string; - /** - * Sets the orientation of the Axis. - * - * @param {number} orientation One of "top"/"bottom"/"left"/"right". - * @returns {Axis} The calling Axis. - */ - orientation(orientation: string): Axis; - /** - * Gets whether the Axis shows the end tick labels. - */ - showEndTickLabels(): boolean; - /** - * Sets whether the Axis shows the end tick labels. - * - * @param {boolean} show - * @returns {Axis} The calling Axis. - */ - showEndTickLabels(show: boolean): Axis; - } - } - - - namespace Plottable { - namespace TimeInterval { - var second: string; - var minute: string; - var hour: string; - var day: string; - var week: string; - var month: string; - var year: string; - } - namespace Axes { - /** - * Defines a configuration for a Time Axis tier. - * For details on how ticks are generated see: https://github.com/mbostock/d3/wiki/Time-Scales#ticks - * interval - A time unit associated with this configuration (seconds, minutes, hours, etc). - * step - number of intervals between each tick. - * formatter - formatter used to format tick labels. - */ - type TimeAxisTierConfiguration = { - interval: string; - step: number; - formatter: Formatter; - }; - /** - * An array of linked TimeAxisTierConfigurations. - * Each configuration will be shown on a different tier. - * Currently, up to two tiers are supported. - */ - type TimeAxisConfiguration = TimeAxisTierConfiguration[]; - class Time extends Axis { - /** - * The CSS class applied to each Time Axis tier - */ - static TIME_AXIS_TIER_CLASS: string; - /** - * Constructs a Time Axis. - * - * A Time Axis is a visual representation of a Time Scale. - * - * @constructor - * @param {Scales.Time} scale - * @param {string} orientation One of "top"/"bottom". - */ - constructor(scale: Scales.Time, orientation: string); - /** - * Gets the label positions for each tier. - */ - tierLabelPositions(): string[]; - /** - * Sets the label positions for each tier. - * - * @param {string[]} newPositions The positions for each tier. "bottom" and "center" are the only supported values. - * @returns {Axes.Time} The calling Time Axis. - */ - tierLabelPositions(newPositions: string[]): Time; - /** - * Gets the possible TimeAxisConfigurations. - */ - axisConfigurations(): TimeAxisConfiguration[]; - /** - * Sets the possible TimeAxisConfigurations. - * The Time Axis will choose the most precise configuration that will display in the available space. - * - * @param {TimeAxisConfiguration[]} configurations - * @returns {Axes.Time} The calling Time Axis. - */ - axisConfigurations(configurations: TimeAxisConfiguration[]): Time; - orientation(): string; - orientation(orientation: string): Time; - protected _computeHeight(): number; - protected _sizeFromOffer(availableWidth: number, availableHeight: number): { - width: number; - height: number; - }; - protected _setup(): void; - protected _getTickValues(): any[]; - renderImmediately(): Time; - } - } - } - - - namespace Plottable { - namespace Axes { - class Numeric extends Axis { - /** - * Constructs a Numeric Axis. - * - * A Numeric Axis is a visual representation of a QuantitativeScale. - * - * @constructor - * @param {QuantitativeScale} scale - * @param {string} orientation One of "top"/"bottom"/"left"/"right". - */ - constructor(scale: QuantitativeScale, orientation: string); - protected _setup(): void; - protected _computeWidth(): number; - protected _computeHeight(): number; - protected _getTickValues(): number[]; - protected _rescale(): void; - renderImmediately(): Numeric; - /** - * Gets the tick label position relative to the tick marks. - * - * @returns {string} The current tick label position. - */ - tickLabelPosition(): string; - /** - * Sets the tick label position relative to the tick marks. - * - * @param {string} position "top"/"center"/"bottom" for a vertical Numeric Axis, - * "left"/"center"/"right" for a horizontal Numeric Axis. - * @returns {Numeric} The calling Numeric Axis. - */ - tickLabelPosition(position: string): Numeric; - } - } - } - - - namespace Plottable { - namespace Axes { - class Category extends Axis { - /** - * Constructs a Category Axis. - * - * A Category Axis is a visual representation of a Category Scale. - * - * @constructor - * @param {Scales.Category} scale - * @param {string} [orientation="bottom"] One of "top"/"bottom"/"left"/"right". - */ - constructor(scale: Scales.Category, orientation: string); - protected _setup(): void; - protected _rescale(): Component; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - protected _getTickValues(): string[]; - /** - * Gets the tick label angle in degrees. - */ - tickLabelAngle(): number; - /** - * Sets the tick label angle in degrees. - * Right now only -90/0/90 are supported. 0 is horizontal. - * - * @param {number} angle - * @returns {Category} The calling Category Axis. - */ - tickLabelAngle(angle: number): Category; - renderImmediately(): Category; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Axis; - } - } - } - - - namespace Plottable { - namespace Components { - class Label extends Component { - /** - * A Label is a Component that displays a single line of text. - * - * @constructor - * @param {string} [displayText=""] The text of the Label. - * @param {number} [angle=0] The angle of the Label in degrees (-90/0/90). 0 is horizontal. - */ - constructor(displayText?: string, angle?: number); - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - protected _setup(): void; - /** - * Gets the Label's text. - */ - text(): string; - /** - * Sets the Label's text. - * - * @param {string} displayText - * @returns {Label} The calling Label. - */ - text(displayText: string): Label; - /** - * Gets the angle of the Label in degrees. - */ - angle(): number; - /** - * Sets the angle of the Label in degrees. - * - * @param {number} angle One of -90/0/90. 0 is horizontal. - * @returns {Label} The calling Label. - */ - angle(angle: number): Label; - /** - * Gets the amount of padding around the Label in pixels. - */ - padding(): number; - /** - * Sets the amount of padding around the Label in pixels. - * - * @param {number} padAmount - * @returns {Label} The calling Label. - */ - padding(padAmount: number): Label; - fixedWidth(): boolean; - fixedHeight(): boolean; - renderImmediately(): Label; - } - class TitleLabel extends Label { - static TITLE_LABEL_CLASS: string; - /** - * @constructor - * @param {string} [text] - * @param {number} [angle] One of -90/0/90. 0 is horizontal. - */ - constructor(text?: string, angle?: number); - } - class AxisLabel extends Label { - static AXIS_LABEL_CLASS: string; - /** - * @constructor - * @param {string} [text] - * @param {number} [angle] One of -90/0/90. 0 is horizontal. - */ - constructor(text?: string, angle?: number); - } - } - } - - - namespace Plottable { - namespace Components { - class Legend extends Component { - /** - * The css class applied to each legend row - */ - static LEGEND_ROW_CLASS: string; - /** - * The css class applied to each legend entry - */ - static LEGEND_ENTRY_CLASS: string; - /** - * The css class applied to each legend symbol - */ - static LEGEND_SYMBOL_CLASS: string; - /** - * The Legend consists of a series of entries, each with a color and label taken from the Color Scale. - * - * @constructor - * @param {Scale.Color} scale - */ - constructor(colorScale: Scales.Color); - protected _setup(): void; - /** - * Gets the maximum number of entries per row. - * - * @returns {number} - */ - maxEntriesPerRow(): number; - /** - * Sets the maximum number of entries perrow. - * - * @param {number} maxEntriesPerRow - * @returns {Legend} The calling Legend. - */ - maxEntriesPerRow(maxEntriesPerRow: number): Legend; - /** - * Gets the current comparator for the Legend's entries. - * - * @returns {(a: string, b: string) => number} - */ - comparator(): (a: string, b: string) => number; - /** - * Sets a new comparator for the Legend's entries. - * The comparator is used to set the display order of the entries. - * - * @param {(a: string, b: string) => number} comparator - * @returns {Legend} The calling Legend. - */ - comparator(comparator: (a: string, b: string) => number): Legend; - /** - * Gets the Color Scale. - * - * @returns {Scales.Color} - */ - colorScale(): Scales.Color; - /** - * Sets the Color Scale. - * - * @param {Scales.Color} scale - * @returns {Legend} The calling Legend. - */ - colorScale(colorScale: Scales.Color): Legend; - destroy(): void; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - /** - * Gets the Entities (representing Legend entries) at a particular point. - * Returns an empty array if no Entities are present at that location. - * - * @param {Point} p - * @returns {Entity[]} - */ - entitiesAt(p: Point): Entity[]; - renderImmediately(): Legend; - /** - * Gets the function determining the symbols of the Legend. - * - * @returns {(datum: any, index: number) => symbolFactory} - */ - symbol(): (datum: any, index: number) => SymbolFactory; - /** - * Sets the function determining the symbols of the Legend. - * - * @param {(datum: any, index: number) => SymbolFactory} symbol - * @returns {Legend} The calling Legend - */ - symbol(symbol: (datum: any, index: number) => SymbolFactory): Legend; - fixedWidth(): boolean; - fixedHeight(): boolean; - } - } - } - - - namespace Plottable { - namespace Components { - class InterpolatedColorLegend extends Component { - /** - * The css class applied to the legend labels. - */ - static LEGEND_LABEL_CLASS: string; - /** - * Creates an InterpolatedColorLegend. - * - * The InterpolatedColorLegend consists of a sequence of swatches that show the - * associated InterpolatedColor Scale sampled at various points. - * Two labels show the maximum and minimum values of the InterpolatedColor Scale. - * - * @constructor - * @param {Scales.InterpolatedColor} interpolatedColorScale - */ - constructor(interpolatedColorScale: Scales.InterpolatedColor); - destroy(): void; - /** - * Gets the Formatter for the labels. - */ - formatter(): Formatter; - /** - * Sets the Formatter for the labels. - * - * @param {Formatter} formatter - * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. - */ - formatter(formatter: Formatter): InterpolatedColorLegend; - /** - * Gets the orientation. - */ - orientation(): string; - /** - * Sets the orientation. - * - * @param {string} orientation One of "horizontal"/"left"/"right". - * @returns {InterpolatedColorLegend} The calling InterpolatedColorLegend. - */ - orientation(orientation: string): InterpolatedColorLegend; - fixedWidth(): boolean; - fixedHeight(): boolean; - protected _setup(): void; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - renderImmediately(): InterpolatedColorLegend; - } - } - } - - - namespace Plottable { - namespace Components { - class Gridlines extends Component { - /** - * @constructor - * @param {QuantitativeScale} xScale The scale to base the x gridlines on. Pass null if no gridlines are desired. - * @param {QuantitativeScale} yScale The scale to base the y gridlines on. Pass null if no gridlines are desired. - */ - constructor(xScale: QuantitativeScale, yScale: QuantitativeScale); - destroy(): Gridlines; - protected _setup(): void; - renderImmediately(): Gridlines; - } - } - } - - - namespace Plottable { - namespace Components { - class Table extends ComponentContainer { - /** - * A Table combines Components in the form of a grid. A - * common case is combining a y-axis, x-axis, and the plotted data via - * ```typescript - * new Table([[yAxis, plot], - * [null, xAxis]]); - * ``` - * - * @constructor - * @param {Component[][]} [rows=[]] A 2-D array of Components to be added to the Table. - * null can be used if a cell is empty. - */ - constructor(rows?: Component[][]); - protected _forEach(callback: (component: Component) => any): void; - /** - * Checks whether the specified Component is in the Table. - */ - has(component: Component): boolean; - /** - * Adds a Component in the specified row and column position. - * - * For example, instead of calling `new Table([[a, b], [null, c]])`, you - * could call - * ```typescript - * var table = new Table(); - * table.add(a, 0, 0); - * table.add(b, 0, 1); - * table.add(c, 1, 1); - * ``` - * - * @param {Component} component The Component to be added. - * @param {number} row - * @param {number} col - * @returns {Table} The calling Table. - */ - add(component: Component, row: number, col: number): Table; - protected _remove(component: Component): boolean; - requestedSpace(offeredWidth: number, offeredHeight: number): SpaceRequest; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Table; - /** - * Gets the padding above and below each row in pixels. - */ - rowPadding(): number; - /** - * Sets the padding above and below each row in pixels. - * - * @param {number} rowPadding - * @returns {Table} The calling Table. - */ - rowPadding(rowPadding: number): Table; - /** - * Gets the padding to the left and right of each column in pixels. - */ - columnPadding(): number; - /** - * Sets the padding to the left and right of each column in pixels. - * - * @param {number} columnPadding - * @returns {Table} The calling Table. - */ - columnPadding(columnPadding: number): Table; - /** - * Gets the weight of the specified row. - * - * @param {number} index - */ - rowWeight(index: number): number; - /** - * Sets the weight of the specified row. - * Space is allocated to rows based on their weight. Rows with higher weights receive proportionally more space. - * - * A common case would be to have one row take up 2/3rds of the space, - * and the other row take up 1/3rd. - * - * Example: - * - * ```JavaScript - * plot = new Plottable.Component.Table([ - * [row1], - * [row2] - * ]); - * - * // assign twice as much space to the first row - * plot - * .rowWeight(0, 2) - * .rowWeight(1, 1) - * ``` - * - * @param {number} index - * @param {number} weight - * @returns {Table} The calling Table. - */ - rowWeight(index: number, weight: number): Table; - /** - * Gets the weight of the specified column. - * - * @param {number} index - */ - columnWeight(index: number): number; - /** - * Sets the weight of the specified column. - * Space is allocated to columns based on their weight. Columns with higher weights receive proportionally more space. - * - * Please see `rowWeight` docs for an example. - * - * @param {number} index - * @param {number} weight - * @returns {Table} The calling Table. - */ - columnWeight(index: number, weight: number): Table; - fixedWidth(): boolean; - fixedHeight(): boolean; - } - } - } - - - namespace Plottable { - namespace Components { - class SelectionBoxLayer extends Component { - protected _box: d3.Selection; - constructor(); - protected _setup(): void; - protected _sizeFromOffer(availableWidth: number, availableHeight: number): { - width: number; - height: number; - }; - /** - * Gets the Bounds of the box. - */ - bounds(): Bounds; - /** - * Sets the Bounds of the box. - * - * @param {Bounds} newBounds - * @return {SelectionBoxLayer} The calling SelectionBoxLayer. - */ - bounds(newBounds: Bounds): SelectionBoxLayer; - protected _setBounds(newBounds: Bounds): void; - renderImmediately(): SelectionBoxLayer; - /** - * Gets whether the box is being shown. - */ - boxVisible(): boolean; - /** - * Shows or hides the selection box. - * - * @param {boolean} show Whether or not to show the box. - * @return {SelectionBoxLayer} The calling SelectionBoxLayer. - */ - boxVisible(show: boolean): SelectionBoxLayer; - fixedWidth(): boolean; - fixedHeight(): boolean; - } - } - } - - - namespace Plottable { - namespace Plots { - interface PlotEntity extends Entity { - dataset: Dataset; - index: number; - component: Plot; - } - interface AccessorScaleBinding { - accessor: Accessor; - scale?: Scale; - } - namespace Animator { - var MAIN: string; - var RESET: string; - } - } - class Plot extends Component { - protected static _ANIMATION_MAX_DURATION: number; - protected _renderArea: d3.Selection; - protected _renderCallback: ScaleCallback>; - protected _propertyExtents: d3.Map; - protected _propertyBindings: d3.Map>; - /** - * A Plot draws some visualization of the inputted Datasets. - * - * @constructor - */ - constructor(); - anchor(selection: d3.Selection): Plot; - protected _setup(): void; - destroy(): void; - /** - * Adds a Dataset to the Plot. - * - * @param {Dataset} dataset - * @returns {Plot} The calling Plot. - */ - addDataset(dataset: Dataset): Plot; - protected _createNodesForDataset(dataset: Dataset): Drawer; - protected _createDrawer(dataset: Dataset): Drawer; - protected _getAnimator(key: string): Animator; - protected _onDatasetUpdate(): void; - /** - * Gets the AccessorScaleBinding for a particular attribute. - * - * @param {string} attr - */ - attr(attr: string): Plots.AccessorScaleBinding; - /** - * Sets a particular attribute to a constant value or the result of an Accessor. - * - * @param {string} attr - * @param {number|string|Accessor|Accessor} attrValue - * @returns {Plot} The calling Plot. - */ - attr(attr: string, attrValue: number | string | Accessor | Accessor): Plot; - /** - * Sets a particular attribute to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the attribute values when autoDomain()-ing. - * - * @param {string} attr - * @param {A|Accessor} attrValue - * @param {Scale} scale The Scale used to scale the attrValue. - * @returns {Plot} The calling Plot. - */ - attr(attr: string, attrValue: A | Accessor, scale: Scale): Plot; - protected _bindProperty(property: string, value: any, scale: Scale): void; - protected _generateAttrToProjector(): AttributeToProjector; - renderImmediately(): Plot; - /** - * Returns whether the plot will be animated. - */ - animated(): boolean; - /** - * Enables or disables animation. - */ - animated(willAnimate: boolean): Plot; - detach(): Plot; - /** - * Updates the extents associated with each attribute, then autodomains all scales the Plot uses. - */ - protected _updateExtents(): void; - protected _updateExtentsForProperty(property: string): void; - protected _filterForProperty(property: string): Accessor; - /** - * Override in subclass to add special extents, such as included values - */ - protected _extentsForProperty(property: string): any[]; - /** - * Get the Animator associated with the specified Animator key. - * - * @return {Animator} - */ - animator(animatorKey: string): Animator; - /** - * Set the Animator associated with the specified Animator key. - * - * @param {string} animatorKey - * @param {Animator} animator - * @returns {Plot} The calling Plot. - */ - animator(animatorKey: string, animator: Animator): Plot; - /** - * Removes a Dataset from the Plot. - * - * @param {Dataset} dataset - * @returns {Plot} The calling Plot. - */ - removeDataset(dataset: Dataset): Plot; - protected _removeDatasetNodes(dataset: Dataset): void; - datasets(): Dataset[]; - datasets(datasets: Dataset[]): Plot; - protected _getDrawersInOrder(): Drawer[]; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _additionalPaint(time: number): void; - protected _getDataToDraw(): Utils.Map; - /** - * Retrieves Selections of this Plot for the specified Datasets. - * - * @param {Dataset[]} [datasets] The Datasets to retrieve the Selections for. - * If not provided, Selections will be retrieved for all Datasets on the Plot. - * @returns {d3.Selection} - */ - selections(datasets?: Dataset[]): d3.Selection; - /** - * Gets the Entities associated with the specified Datasets. - * - * @param {dataset[]} datasets The Datasets to retrieve the Entities for. - * If not provided, returns defaults to all Datasets on the Plot. - * @return {Plots.PlotEntity[]} - */ - entities(datasets?: Dataset[]): Plots.PlotEntity[]; - /** - * Returns the PlotEntity nearest to the query point by the Euclidian norm, or undefined if no PlotEntity can be found. - * - * @param {Point} queryPoint - * @returns {Plots.PlotEntity} The nearest PlotEntity, or undefined if no PlotEntity can be found. - */ - entityNearest(queryPoint: Point): Plots.PlotEntity; - protected _visibleOnPlot(datum: any, pixelPoint: Point, selection: d3.Selection): boolean; - protected _entityVisibleOnPlot(pixelPoint: Point, datum: any, index: number, dataset: Dataset): boolean; - protected _uninstallScaleForKey(scale: Scale, key: string): void; - protected _installScaleForKey(scale: Scale, key: string): void; - protected _propertyProjectors(): AttributeToProjector; - protected static _scaledAccessor(binding: Plots.AccessorScaleBinding): Accessor; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; - protected _animateOnNextRender(): boolean; - } - } - - - namespace Plottable { - namespace Plots { - class Pie extends Plot { - /** - * @constructor - */ - constructor(); - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): Pie; - addDataset(dataset: Dataset): Pie; - removeDataset(dataset: Dataset): Pie; - protected _onDatasetUpdate(): void; - protected _createDrawer(dataset: Dataset): Drawers.Arc; - entities(datasets?: Dataset[]): PlotEntity[]; - /** - * Gets the AccessorScaleBinding for the sector value. - */ - sectorValue(): AccessorScaleBinding; - /** - * Sets the sector value to a constant number or the result of an Accessor. - * - * @param {number|Accessor} sectorValue - * @returns {Pie} The calling Pie Plot. - */ - sectorValue(sectorValue: number | Accessor): Plots.Pie; - /** - * Sets the sector value to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {S|Accessor} sectorValue - * @param {Scale} scale - * @returns {Pie} The calling Pie Plot. - */ - sectorValue(sectorValue: S | Accessor, scale: Scale): Plots.Pie; - /** - * Gets the AccessorScaleBinding for the inner radius. - */ - innerRadius(): AccessorScaleBinding; - /** - * Sets the inner radius to a constant number or the result of an Accessor. - * - * @param {number|Accessor} innerRadius - * @returns {Pie} The calling Pie Plot. - */ - innerRadius(innerRadius: number | Accessor): Plots.Pie; - /** - * Sets the inner radius to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {R|Accessor} innerRadius - * @param {Scale} scale - * @returns {Pie} The calling Pie Plot. - */ - innerRadius(innerRadius: R | Accessor, scale: Scale): Plots.Pie; - /** - * Gets the AccessorScaleBinding for the outer radius. - */ - outerRadius(): AccessorScaleBinding; - /** - * Sets the outer radius to a constant number or the result of an Accessor. - * - * @param {number|Accessor} outerRadius - * @returns {Pie} The calling Pie Plot. - */ - outerRadius(outerRadius: number | Accessor): Plots.Pie; - /** - * Sets the outer radius to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {R|Accessor} outerRadius - * @param {Scale} scale - * @returns {Pie} The calling Pie Plot. - */ - outerRadius(outerRadius: R | Accessor, scale: Scale): Plots.Pie; - /** - * Get whether slice labels are enabled. - * - * @returns {boolean} Whether slices should display labels or not. - */ - labelsEnabled(): boolean; - /** - * Sets whether labels are enabled. - * - * @param {boolean} labelsEnabled - * @returns {Pie} The calling Pie Plot. - */ - labelsEnabled(enabled: boolean): Pie; - /** - * Gets the Formatter for the labels. - */ - labelFormatter(): Formatter; - /** - * Sets the Formatter for the labels. - * - * @param {Formatter} formatter - * @returns {Pie} The calling Pie Plot. - */ - labelFormatter(formatter: Formatter): Pie; - entitiesAt(queryPoint: Point): PlotEntity[]; - protected _propertyProjectors(): AttributeToProjector; - protected _getDataToDraw(): Utils.Map; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): { - x: number; - y: number; - }; - protected _additionalPaint(time: number): void; - } - } - } - - - namespace Plottable { - class XYPlot extends Plot { - protected static _X_KEY: string; - protected static _Y_KEY: string; - /** - * An XYPlot is a Plot that displays data along two primary directions, X and Y. - * - * @constructor - * @param {Scale} xScale The x scale to use. - * @param {Scale} yScale The y scale to use. - */ - constructor(); - /** - * Returns the whether or not the rendering is deferred for performance boost. - * @return {boolean} The deferred rendering option - */ - deferredRendering(): boolean; - /** - * Sets / unsets the deferred rendering option - * Activating this option improves the performance of plot interaction (pan / zoom) by - * performing lazy renders, only after the interaction has stopped. Because re-rendering - * is no longer performed during the interaction, the zooming might experience a small - * resolution degradation, before the lazy re-render is performed. - * - * This option is intended for cases where performance is an issue. - */ - deferredRendering(deferredRendering: boolean): XYPlot; - /** - * Gets the AccessorScaleBinding for X. - */ - x(): Plots.AccessorScaleBinding; - /** - * Sets X to a constant number or the result of an Accessor. - * - * @param {number|Accessor} x - * @returns {XYPlot} The calling XYPlot. - */ - x(x: number | Accessor): XYPlot; - /** - * Sets X to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {X|Accessor} x - * @param {Scale} xScale - * @returns {XYPlot} The calling XYPlot. - */ - x(x: X | Accessor, xScale: Scale): XYPlot; - /** - * Gets the AccessorScaleBinding for Y. - */ - y(): Plots.AccessorScaleBinding; - /** - * Sets Y to a constant number or the result of an Accessor. - * - * @param {number|Accessor} y - * @returns {XYPlot} The calling XYPlot. - */ - y(y: number | Accessor): XYPlot; - /** - * Sets Y to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {Y|Accessor} y - * @param {Scale} yScale - * @returns {XYPlot} The calling XYPlot. - */ - y(y: Y | Accessor, yScale: Scale): XYPlot; - protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; - protected _uninstallScaleForKey(scale: Scale, key: string): void; - protected _installScaleForKey(scale: Scale, key: string): void; - destroy(): XYPlot; - /** - * Gets the automatic domain adjustment mode for visible points. - */ - autorangeMode(): string; - /** - * Sets the automatic domain adjustment mode for visible points to operate against the X Scale, Y Scale, or neither. - * If "x" or "y" is specified the adjustment is immediately performed. - * - * @param {string} autorangeMode One of "x"/"y"/"none". - * "x" will adjust the x Scale in relation to changes in the y domain. - * "y" will adjust the y Scale in relation to changes in the x domain. - * "none" means neither Scale will change automatically. - * @returns {XYPlot} The calling XYPlot. - */ - autorangeMode(autorangeMode: string): XYPlot; - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XYPlot; - /** - * Adjusts the domains of both X and Y scales to show all data. - * This call does not override the autorange() behavior. - * - * @returns {XYPlot} The calling XYPlot. - */ - showAllData(): XYPlot; - protected _projectorsReady(): boolean; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; - protected _getDataToDraw(): Utils.Map; - } - } - - - namespace Plottable { - namespace Plots { - class Rectangle extends XYPlot { - /** - * A Rectangle Plot displays rectangles based on the data. - * The left and right edges of each rectangle can be set with x() and x2(). - * If only x() is set the Rectangle Plot will attempt to compute the correct left and right edge positions. - * The top and bottom edges of each rectangle can be set with y() and y2(). - * If only y() is set the Rectangle Plot will attempt to compute the correct top and bottom edge positions. - * - * @constructor - * @param {Scale.Scale} xScale - * @param {Scale.Scale} yScale - */ - constructor(); - protected _createDrawer(dataset: Dataset): Drawers.Rectangle; - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _updateExtentsForProperty(property: string): void; - protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; - /** - * Gets the AccessorScaleBinding for X. - */ - x(): AccessorScaleBinding; - /** - * Sets X to a constant number or the result of an Accessor. - * - * @param {number|Accessor} x - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - x(x: number | Accessor): Plots.Rectangle; - /** - * Sets X to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {X|Accessor} x - * @param {Scale} xScale - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - x(x: X | Accessor, xScale: Scale): Plots.Rectangle; - /** - * Gets the AccessorScaleBinding for X2. - */ - x2(): AccessorScaleBinding; - /** - * Sets X2 to a constant number or the result of an Accessor. - * If a Scale has been set for X, it will also be used to scale X2. - * - * @param {number|Accessor|X|Accessor} x2 - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - x2(x2: number | Accessor | X | Accessor): Plots.Rectangle; - /** - * Gets the AccessorScaleBinding for Y. - */ - y(): AccessorScaleBinding; - /** - * Sets Y to a constant number or the result of an Accessor. - * - * @param {number|Accessor} y - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - y(y: number | Accessor): Plots.Rectangle; - /** - * Sets Y to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {Y|Accessor} y - * @param {Scale} yScale - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - y(y: Y | Accessor, yScale: Scale): Plots.Rectangle; - /** - * Gets the AccessorScaleBinding for Y2. - */ - y2(): AccessorScaleBinding; - /** - * Sets Y2 to a constant number or the result of an Accessor. - * If a Scale has been set for Y, it will also be used to scale Y2. - * - * @param {number|Accessor|Y|Accessor} y2 - * @returns {Plots.Rectangle} The calling Rectangle Plot. - */ - y2(y2: number | Accessor | Y | Accessor): Plots.Rectangle; - protected _propertyProjectors(): AttributeToProjector; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): { - x: any; - y: any; - }; - protected _getDataToDraw(): Utils.Map; - } - } - } - - - namespace Plottable { - namespace Plots { - class Scatter extends XYPlot { - /** - * A Scatter Plot draws a symbol at each data point. - * - * @constructor - */ - constructor(); - protected _createDrawer(dataset: Dataset): Drawers.Symbol; - /** - * Gets the AccessorScaleBinding for the size property of the plot. - * The size property corresponds to the area of the symbol. - */ - size(): AccessorScaleBinding; - /** - * Sets the size property to a constant number or the result of an Accessor. - * - * @param {number|Accessor} size - * @returns {Plots.Scatter} The calling Scatter Plot. - */ - size(size: number | Accessor): Plots.Scatter; - /** - * Sets the size property to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {S|Accessor} sectorValue - * @param {Scale} scale - * @returns {Plots.Scatter} The calling Scatter Plot. - */ - size(size: S | Accessor, scale: Scale): Plots.Scatter; - /** - * Gets the AccessorScaleBinding for the symbol property of the plot. - * The symbol property corresponds to how the symbol will be drawn. - */ - symbol(): AccessorScaleBinding; - /** - * Sets the symbol property to an Accessor. - * - * @param {Accessor} symbol - * @returns {Plots.Scatter} The calling Scatter Plot. - */ - symbol(symbol: Accessor): Plots.Scatter; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _visibleOnPlot(datum: any, pixelPoint: Point, selection: d3.Selection): boolean; - protected _entityVisibleOnPlot(pixelPoint: Point, datum: any, index: number, dataset: Dataset): boolean; - protected _propertyProjectors(): AttributeToProjector; - } - } - } - - - namespace Plottable { - namespace Plots { - class Bar extends XYPlot { - static ORIENTATION_VERTICAL: string; - static ORIENTATION_HORIZONTAL: string; - protected _isVertical: boolean; - /** - * A Bar Plot draws bars growing out from a baseline to some value - * - * @constructor - * @param {string} [orientation="vertical"] One of "vertical"/"horizontal". - */ - constructor(orientation?: string); - x(): Plots.AccessorScaleBinding; - x(x: number | Accessor): Bar; - x(x: X | Accessor, xScale: Scale): Bar; - y(): Plots.AccessorScaleBinding; - y(y: number | Accessor): Bar; - y(y: Y | Accessor, yScale: Scale): Bar; - /** - * Gets the orientation of the plot - * - * @return "vertical" | "horizontal" - */ - orientation(): string; - render(): Bar; - protected _createDrawer(dataset: Dataset): Drawers.Rectangle; - protected _setup(): void; - /** - * Gets the baseline value. - * The baseline is the line that the bars are drawn from. - * - * @returns {X|Y} - */ - baselineValue(): X | Y; - /** - * Sets the baseline value. - * The baseline is the line that the bars are drawn from. - * - * @param {X|Y} value - * @returns {Bar} The calling Bar Plot. - */ - baselineValue(value: X | Y): Bar; - addDataset(dataset: Dataset): Bar; - removeDataset(dataset: Dataset): Bar; - /** - * Get whether bar labels are enabled. - * - * @returns {boolean} Whether bars should display labels or not. - */ - labelsEnabled(): boolean; - /** - * Sets whether labels are enabled. - * - * @param {boolean} labelsEnabled - * @returns {Bar} The calling Bar Plot. - */ - labelsEnabled(enabled: boolean): Bar; - /** - * Gets the Formatter for the labels. - */ - labelFormatter(): Formatter; - /** - * Sets the Formatter for the labels. - * - * @param {Formatter} formatter - * @returns {Bar} The calling Bar Plot. - */ - labelFormatter(formatter: Formatter): Bar; - protected _createNodesForDataset(dataset: Dataset): Drawer; - protected _removeDatasetNodes(dataset: Dataset): void; - /** - * Returns the PlotEntity nearest to the query point according to the following algorithm: - * - If the query point is inside a bar, returns the PlotEntity for that bar. - * - Otherwise, gets the nearest PlotEntity by the primary direction (X for vertical, Y for horizontal), - * breaking ties with the secondary direction. - * Returns undefined if no PlotEntity can be found. - * - * @param {Point} queryPoint - * @returns {PlotEntity} The nearest PlotEntity, or undefined if no PlotEntity can be found. - */ - entityNearest(queryPoint: Point): PlotEntity; - protected _visibleOnPlot(datum: any, pixelPoint: Point, selection: d3.Selection): boolean; - protected _entityVisibleOnPlot(pixelPoint: Point, datum: any, index: number, dataset: Dataset): boolean; - /** - * Gets the Entities at a particular Point. - * - * @param {Point} p - * @returns {PlotEntity[]} - */ - entitiesAt(p: Point): PlotEntity[]; - /** - * Gets the Entities that intersect the Bounds. - * - * @param {Bounds} bounds - * @returns {PlotEntity[]} - */ - entitiesIn(bounds: Bounds): PlotEntity[]; - /** - * Gets the Entities that intersect the area defined by the ranges. - * - * @param {Range} xRange - * @param {Range} yRange - * @returns {PlotEntity[]} - */ - entitiesIn(xRange: Range, yRange: Range): PlotEntity[]; - protected _additionalPaint(time: number): void; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - /** - * Computes the barPixelWidth of all the bars in the plot. - * - * If the position scale of the plot is a CategoryScale and in bands mode, then the rangeBands function will be used. - * If the position scale of the plot is a CategoryScale and in points mode, then - * from https://github.com/mbostock/d3/wiki/Ordinal-Scales#ordinal_rangePoints, the max barPixelWidth is step * padding - * If the position scale of the plot is a QuantitativeScale, then _getMinimumDataWidth is scaled to compute the barPixelWidth - */ - protected _getBarPixelWidth(): number; - entities(datasets?: Dataset[]): PlotEntity[]; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): { - x: any; - y: any; - }; - protected _uninstallScaleForKey(scale: Scale, key: string): void; - protected _getDataToDraw(): Utils.Map; - } - } - } - - - namespace Plottable { - namespace Plots { - class Line extends XYPlot { - /** - * A Line Plot draws line segments starting from the first data point to the next. - * - * @constructor - */ - constructor(); - protected _createDrawer(dataset: Dataset): Drawer; - protected _getResetYFunction(): (d: any, i: number, dataset: Dataset) => number; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - /** - * Returns the PlotEntity nearest to the query point by X then by Y, or undefined if no PlotEntity can be found. - * - * @param {Point} queryPoint - * @returns {PlotEntity} The nearest PlotEntity, or undefined if no PlotEntity can be found. - */ - entityNearest(queryPoint: Point): PlotEntity; - protected _propertyProjectors(): AttributeToProjector; - protected _constructLineProjector(xProjector: Projector, yProjector: Projector): (datum: any, index: number, dataset: Dataset) => string; - protected _getDataToDraw(): Utils.Map; - } - } - } - - - namespace Plottable { - namespace Plots { - class Area extends Line { - /** - * An Area Plot draws a filled region (area) between Y and Y0. - * - * @constructor - */ - constructor(); - protected _setup(): void; - y(): Plots.AccessorScaleBinding; - y(y: number | Accessor): Area; - y(y: number | Accessor, yScale: QuantitativeScale): Area; - /** - * Gets the AccessorScaleBinding for Y0. - */ - y0(): Plots.AccessorScaleBinding; - /** - * Sets Y0 to a constant number or the result of an Accessor. - * If a Scale has been set for Y, it will also be used to scale Y0. - * - * @param {number|Accessor} y0 - * @returns {Area} The calling Area Plot. - */ - y0(y0: number | Accessor): Area; - protected _onDatasetUpdate(): void; - addDataset(dataset: Dataset): Area; - protected _removeDatasetNodes(dataset: Dataset): void; - protected _additionalPaint(): void; - protected _createDrawer(dataset: Dataset): Drawers.Area; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _updateYScale(): void; - protected _getResetYFunction(): Accessor; - protected _propertyProjectors(): AttributeToProjector; - selections(datasets?: Dataset[]): d3.Selection; - protected _constructAreaProjector(xProjector: Projector, yProjector: Projector, y0Projector: Projector): (datum: any[], index: number, dataset: Dataset) => string; - } - } - } - - - namespace Plottable { - namespace Plots { - class ClusteredBar extends Bar { - /** - * A ClusteredBar Plot groups bars across Datasets based on the primary value of the bars. - * On a vertical ClusteredBar Plot, the bars with the same X value are grouped. - * On a horizontal ClusteredBar Plot, the bars with the same Y value are grouped. - * - * @constructor - * @param {string} [orientation="vertical"] One of "vertical"/"horizontal". - */ - constructor(orientation?: string); - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - protected _getDataToDraw(): Utils.Map; - } - } - } - - - namespace Plottable { - namespace Plots { - class StackedArea extends Area { - /** - * @constructor - */ - constructor(); - protected _getAnimator(key: string): Animator; - protected _setup(): void; - x(): Plots.AccessorScaleBinding; - x(x: number | Accessor): StackedArea; - x(x: X | Accessor, xScale: Scale): StackedArea; - y(): Plots.AccessorScaleBinding; - y(y: number | Accessor): StackedArea; - y(y: number | Accessor, yScale: QuantitativeScale): StackedArea; - protected _additionalPaint(): void; - protected _updateYScale(): void; - protected _onDatasetUpdate(): StackedArea; - protected _updateExtentsForProperty(property: string): void; - protected _extentsForProperty(attr: string): any[]; - protected _propertyProjectors(): AttributeToProjector; - protected _pixelPoint(datum: any, index: number, dataset: Dataset): Point; - } - } - } - - - namespace Plottable { - namespace Plots { - class StackedBar extends Bar { - /** - * A StackedBar Plot stacks bars across Datasets based on the primary value of the bars. - * On a vertical StackedBar Plot, the bars with the same X value are stacked. - * On a horizontal StackedBar Plot, the bars with the same Y value are stacked. - * - * @constructor - * @param {Scale} xScale - * @param {Scale} yScale - * @param {string} [orientation="vertical"] One of "vertical"/"horizontal". - */ - constructor(orientation?: string); - x(): Plots.AccessorScaleBinding; - x(x: number | Accessor): StackedBar; - x(x: X | Accessor, xScale: Scale): StackedBar; - y(): Plots.AccessorScaleBinding; - y(y: number | Accessor): StackedBar; - y(y: Y | Accessor, yScale: Scale): StackedBar; - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - protected _onDatasetUpdate(): StackedBar; - protected _updateExtentsForProperty(property: string): void; - protected _extentsForProperty(attr: string): any[]; - } - } - } - - - namespace Plottable { - namespace Plots { - class Segment extends XYPlot { - /** - * A Segment Plot displays line segments based on the data. - * - * @constructor - */ - constructor(); - protected _createDrawer(dataset: Dataset): Drawers.Segment; - protected _generateDrawSteps(): Drawers.DrawStep[]; - protected _updateExtentsForProperty(property: string): void; - protected _filterForProperty(property: string): (datum: any, index: number, dataset: Dataset) => boolean; - /** - * Gets the AccessorScaleBinding for X - */ - x(): AccessorScaleBinding; - /** - * Sets X to a constant value or the result of an Accessor. - * - * @param {X|Accessor} x - * @returns {Plots.Segment} The calling Segment Plot. - */ - x(x: number | Accessor): Plots.Segment; - /** - * Sets X to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {X|Accessor} x - * @param {Scale} xScale - * @returns {Plots.Segment} The calling Segment Plot. - */ - x(x: X | Accessor, xScale: Scale): Plots.Segment; - /** - * Gets the AccessorScaleBinding for X2 - */ - x2(): AccessorScaleBinding; - /** - * Sets X2 to a constant number or the result of an Accessor. - * If a Scale has been set for X, it will also be used to scale X2. - * - * @param {number|Accessor|Y|Accessor} y2 - * @returns {Plots.Segment} The calling Segment Plot - */ - x2(x2: number | Accessor | X | Accessor): Plots.Segment; - /** - * Gets the AccessorScaleBinding for Y - */ - y(): AccessorScaleBinding; - /** - * Sets Y to a constant value or the result of an Accessor. - * - * @param {Y|Accessor} y - * @returns {Plots.Segment} The calling Segment Plot. - */ - y(y: number | Accessor): Plots.Segment; - /** - * Sets Y to a scaled constant value or scaled result of an Accessor. - * The provided Scale will account for the values when autoDomain()-ing. - * - * @param {Y|Accessor} y - * @param {Scale} yScale - * @returns {Plots.Segment} The calling Segment Plot. - */ - y(y: Y | Accessor, yScale: Scale): Plots.Segment; - /** - * Gets the AccessorScaleBinding for Y2. - */ - y2(): AccessorScaleBinding; - /** - * Sets Y2 to a constant number or the result of an Accessor. - * If a Scale has been set for Y, it will also be used to scale Y2. - * - * @param {number|Accessor|Y|Accessor} y2 - * @returns {Plots.Segment} The calling Segment Plot. - */ - y2(y2: number | Accessor | Y | Accessor): Plots.Segment; - protected _propertyProjectors(): AttributeToProjector; - } - } - } - - - namespace Plottable { - namespace Plots { - class Waterfall extends Bar { - constructor(); - /** - * Gets whether connectors are enabled. - * - * @returns {boolean} Whether connectors should be shown or not. - */ - connectorsEnabled(): boolean; - /** - * Sets whether connectors are enabled. - * - * @param {boolean} enabled - * @returns {Plots.Waterfall} The calling Waterfall Plot. - */ - connectorsEnabled(enabled: boolean): Waterfall; - /** - * Gets the AccessorScaleBinding for whether a bar represents a total or a delta. - */ - total(): Plots.AccessorScaleBinding; - /** - * Sets total to a constant number or the result of an Accessor - * - * @param {Accessor} - * @returns {Plots.Waterfall} The calling Waterfall Plot. - */ - total(total: Accessor): Waterfall; - protected _additionalPaint(time: number): void; - protected _createNodesForDataset(dataset: Dataset): Drawer; - protected _extentsForProperty(attr: string): any[]; - protected _generateAttrToProjector(): { - [attr: string]: (datum: any, index: number, dataset: Dataset) => any; - }; - protected _onDatasetUpdate(): Waterfall; - } - } - } - - - namespace Plottable { - interface Animator { - /** - * Applies the supplied attributes to a d3.Selection with some animation. - * - * @param {d3.Selection} selection The update selection or transition selection that we wish to animate. - * @param {AttributeToAppliedProjector} attrToAppliedProjector The set of - * AppliedProjectors that we will use to set attributes on the selection. - * @return {any} Animators should return the selection or - * transition object so that plots may chain the transitions between - * animators. - */ - animate(selection: d3.Selection, attrToAppliedProjector: AttributeToAppliedProjector): d3.Selection | d3.Transition; - /** - * Given the number of elements, return the total time the animation requires - * - * @param {number} numberofIterations The number of elements that will be drawn - * @returns {number} - */ - totalTime(numberOfIterations: number): number; - } - } - - - namespace Plottable { - namespace Animators { - /** - * An animator implementation with no animation. The attributes are - * immediately set on the selection. - */ - class Null implements Animator { - totalTime(selection: any): number; - animate(selection: d3.Selection, attrToAppliedProjector: AttributeToAppliedProjector): d3.Selection; - } - } - } - - - namespace Plottable { - namespace Animators { - /** - * An Animator with easing and configurable durations and delays. - */ - class Easing implements Animator { - /** - * Constructs the default animator - * - * @constructor - */ - constructor(); - totalTime(numberOfSteps: number): number; - animate(selection: d3.Selection, attrToAppliedProjector: AttributeToAppliedProjector): d3.Transition; - /** - * Gets the start delay of the animation in milliseconds. - * - * @returns {number} The current start delay. - */ - startDelay(): number; - /** - * Sets the start delay of the animation in milliseconds. - * - * @param {number} startDelay The start delay in milliseconds. - * @returns {Easing} The calling Easing Animator. - */ - startDelay(startDelay: number): Easing; - /** - * Gets the duration of one animation step in milliseconds. - * - * @returns {number} The current duration. - */ - stepDuration(): number; - /** - * Sets the duration of one animation step in milliseconds. - * - * @param {number} stepDuration The duration in milliseconds. - * @returns {Easing} The calling Easing Animator. - */ - stepDuration(stepDuration: number): Easing; - /** - * Gets the maximum start delay between animation steps in milliseconds. - * - * @returns {number} The current maximum iterative delay. - */ - stepDelay(): number; - /** - * Sets the maximum start delay between animation steps in milliseconds. - * - * @param {number} stepDelay The maximum iterative delay in milliseconds. - * @returns {Easing} The calling Easing Animator. - */ - stepDelay(stepDelay: number): Easing; - /** - * Gets the maximum total animation duration constraint in milliseconds. - * - * If the animation time would exceed the specified time, the duration of each step - * and the delay between each step will be reduced until the animation fits within - * the specified time. - * - * @returns {number} The current maximum total animation duration. - */ - maxTotalDuration(): number; - /** - * Sets the maximum total animation duration constraint in miliseconds. - * - * If the animation time would exceed the specified time, the duration of each step - * and the delay between each step will be reduced until the animation fits within - * the specified time. - * - * @param {number} maxTotalDuration The maximum total animation duration in milliseconds. - * @returns {Easing} The calling Easing Animator. - */ - maxTotalDuration(maxTotalDuration: number): Easing; - /** - * Gets the current easing mode of the animation. - * - * @returns {string} the current easing mode. - */ - easingMode(): string; - /** - * Sets the easing mode of the animation. - * - * @param {string} easingMode The desired easing mode. - * @returns {Easing} The calling Easing Animator. - */ - easingMode(easingMode: string): Easing; - } - } - } - - - namespace Plottable { - class Dispatcher { - protected _eventToCallback: { - [eventName: string]: (e: Event) => any; - }; - protected _callbacks: Utils.CallbackSet[]; - protected _setCallback(callbackSet: Utils.CallbackSet, callback: Function): void; - protected _unsetCallback(callbackSet: Utils.CallbackSet, callback: Function): void; - } - } - - - namespace Plottable { - namespace Dispatchers { - type MouseCallback = (p: Point, event: MouseEvent) => void; - class Mouse extends Dispatcher { - /** - * Get a Mouse Dispatcher for the containing elem. - * If one already exists on that , it will be returned; otherwise, a new one will be created. - * - * @param {SVGElement} elem - * @return {Dispatchers.Mouse} - */ - static getDispatcher(elem: SVGElement): Dispatchers.Mouse; - /** - * This constructor not be invoked directly. - * - * @constructor - * @param {SVGElement} svg The root to attach to. - */ - constructor(svg: SVGElement); - /** - * Registers a callback to be called when the mouse position changes. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - onMouseMove(callback: MouseCallback): Dispatchers.Mouse; - /** - * Removes a callback that would be called when the mouse position changes. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - offMouseMove(callback: MouseCallback): Dispatchers.Mouse; - /** - * Registers a callback to be called when a mousedown occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - onMouseDown(callback: MouseCallback): Dispatchers.Mouse; - /** - * Removes a callback that would be called when a mousedown occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - offMouseDown(callback: MouseCallback): Dispatchers.Mouse; - /** - * Registers a callback to be called when a mouseup occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - onMouseUp(callback: MouseCallback): Dispatchers.Mouse; - /** - * Removes a callback that would be called when a mouseup occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - offMouseUp(callback: MouseCallback): Dispatchers.Mouse; - /** - * Registers a callback to be called when a wheel event occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - onWheel(callback: MouseCallback): Dispatchers.Mouse; - /** - * Removes a callback that would be called when a wheel event occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - offWheel(callback: MouseCallback): Dispatchers.Mouse; - /** - * Registers a callback to be called when a dblClick occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - onDblClick(callback: MouseCallback): Dispatchers.Mouse; - /** - * Removes a callback that would be called when a dblClick occurs. - * - * @param {MouseCallback} callback - * @return {Dispatchers.Mouse} The calling Mouse Dispatcher. - */ - offDblClick(callback: MouseCallback): Dispatchers.Mouse; - /** - * Returns the last computed mouse position in coordinate space. - * - * @return {Point} - */ - lastMousePosition(): Point; - } - } - } - - - namespace Plottable { - namespace Dispatchers { - type TouchCallback = (ids: number[], idToPoint: { - [id: number]: Point; - }, event: TouchEvent) => void; - class Touch extends Dispatcher { - /** - * Gets a Touch Dispatcher for the containing elem. - * If one already exists on that , it will be returned; otherwise, a new one will be created. - * - * @param {SVGElement} elem - * @return {Dispatchers.Touch} - */ - static getDispatcher(elem: SVGElement): Dispatchers.Touch; - /** - * This constructor should not be invoked directly. - * - * @constructor - * @param {SVGElement} svg The root to attach to. - */ - constructor(svg: SVGElement); - /** - * Registers a callback to be called when a touch starts. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - onTouchStart(callback: TouchCallback): Dispatchers.Touch; - /** - * Removes a callback that would be called when a touch starts. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - offTouchStart(callback: TouchCallback): Dispatchers.Touch; - /** - * Registers a callback to be called when the touch position changes. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - onTouchMove(callback: TouchCallback): Dispatchers.Touch; - /** - * Removes a callback that would be called when the touch position changes. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - offTouchMove(callback: TouchCallback): Dispatchers.Touch; - /** - * Registers a callback to be called when a touch ends. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - onTouchEnd(callback: TouchCallback): Dispatchers.Touch; - /** - * Removes a callback that would be called when a touch ends. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - offTouchEnd(callback: TouchCallback): Dispatchers.Touch; - /** - * Registers a callback to be called when a touch is cancelled. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - onTouchCancel(callback: TouchCallback): Dispatchers.Touch; - /** - * Removes a callback that would be called when a touch is cancelled. - * - * @param {TouchCallback} callback - * @return {Dispatchers.Touch} The calling Touch Dispatcher. - */ - offTouchCancel(callback: TouchCallback): Dispatchers.Touch; - } - } - } - - - namespace Plottable { - namespace Dispatchers { - type KeyCallback = (keyCode: number, event: KeyboardEvent) => void; - class Key extends Dispatcher { - /** - * Gets a Key Dispatcher. If one already exists it will be returned; - * otherwise, a new one will be created. - * - * @return {Dispatchers.Key} - */ - static getDispatcher(): Dispatchers.Key; - /** - * This constructor should not be invoked directly. - * - * @constructor - */ - constructor(); - /** - * Registers a callback to be called whenever a key is pressed. - * - * @param {KeyCallback} callback - * @return {Dispatchers.Key} The calling Key Dispatcher. - */ - onKeyDown(callback: KeyCallback): Key; - /** - * Removes the callback to be called whenever a key is pressed. - * - * @param {KeyCallback} callback - * @return {Dispatchers.Key} The calling Key Dispatcher. - */ - offKeyDown(callback: KeyCallback): Key; - } - } - } - - - namespace Plottable { - class Interaction { - protected _componentAttachedTo: Component; - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Attaches this Interaction to a Component. - * If the Interaction was already attached to a Component, it first detaches itself from the old Component. - * - * @param {Component} component - * @returns {Interaction} The calling Interaction. - */ - attachTo(component: Component): Interaction; - /** - * Detaches this Interaction from the Component. - * This Interaction can be reused. - * - * @param {Component} component - * @returns {Interaction} The calling Interaction. - */ - detachFrom(component: Component): Interaction; - /** - * Gets whether this Interaction is enabled. - */ - enabled(): boolean; - /** - * Enables or disables this Interaction. - * - * @param {boolean} enabled Whether the Interaction should be enabled. - * @return {Interaction} The calling Interaction. - */ - enabled(enabled: boolean): Interaction; - /** - * Translates an -coordinate-space point to Component-space coordinates. - * - * @param {Point} p A Point in -space coordinates. - * @return {Point} The same location in Component-space coordinates. - */ - protected _translateToComponentSpace(p: Point): Point; - /** - * Checks whether a Component-coordinate-space Point is inside the Component. - * - * @param {Point} p A Point in Compoennt-space coordinates. - * @return {boolean} Whether or not the point is inside the Component. - */ - protected _isInsideComponent(p: Point): boolean; - } - } - - - namespace Plottable { - type ClickCallback = (point: Point) => void; - namespace Interactions { - class Click extends Interaction { - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Adds a callback to be called when the Component is clicked. - * - * @param {ClickCallback} callback - * @return {Interactions.Click} The calling Click Interaction. - */ - onClick(callback: ClickCallback): Click; - /** - * Removes a callback that would be called when the Component is clicked. - * - * @param {ClickCallback} callback - * @return {Interactions.Click} The calling Click Interaction. - */ - offClick(callback: ClickCallback): Click; - } - } - } - - - namespace Plottable { - namespace Interactions { - class DoubleClick extends Interaction { - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Adds a callback to be called when the Component is double-clicked. - * - * @param {ClickCallback} callback - * @return {Interactions.DoubleClick} The calling DoubleClick Interaction. - */ - onDoubleClick(callback: ClickCallback): DoubleClick; - /** - * Removes a callback that would be called when the Component is double-clicked. - * - * @param {ClickCallback} callback - * @return {Interactions.DoubleClick} The calling DoubleClick Interaction. - */ - offDoubleClick(callback: ClickCallback): DoubleClick; - } - } - } - - - namespace Plottable { - type KeyCallback = (keyCode: number) => void; - namespace Interactions { - class Key extends Interaction { - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Adds a callback to be called when the key with the given keyCode is - * pressed and the user is moused over the Component. - * - * @param {number} keyCode - * @param {KeyCallback} callback - * @returns {Interactions.Key} The calling Key Interaction. - */ - onKeyPress(keyCode: number, callback: KeyCallback): Key; - /** - * Removes a callback that would be called when the key with the given keyCode is - * pressed and the user is moused over the Component. - * - * @param {number} keyCode - * @param {KeyCallback} callback - * @returns {Interactions.Key} The calling Key Interaction. - */ - offKeyPress(keyCode: number, callback: KeyCallback): Key; - } - } - } - - - namespace Plottable { - type PointerCallback = (point: Point) => void; - namespace Interactions { - class Pointer extends Interaction { - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Adds a callback to be called when the pointer enters the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - onPointerEnter(callback: PointerCallback): Pointer; - /** - * Removes a callback that would be called when the pointer enters the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - offPointerEnter(callback: PointerCallback): Pointer; - /** - * Adds a callback to be called when the pointer moves within the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - onPointerMove(callback: PointerCallback): Pointer; - /** - * Removes a callback that would be called when the pointer moves within the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - offPointerMove(callback: PointerCallback): Pointer; - /** - * Adds a callback to be called when the pointer exits the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - onPointerExit(callback: PointerCallback): Pointer; - /** - * Removes a callback that would be called when the pointer exits the Component. - * - * @param {PointerCallback} callback - * @return {Interactions.Pointer} The calling Pointer Interaction. - */ - offPointerExit(callback: PointerCallback): Pointer; - } - } - } - - - namespace Plottable { - namespace Interactions { - class PanZoom extends Interaction { - /** - * A PanZoom Interaction updates the domains of an x-scale and/or a y-scale - * in response to the user panning or zooming. - * - * @constructor - * @param {QuantitativeScale} [xScale] The x-scale to update on panning/zooming. - * @param {QuantitativeScale} [yScale] The y-scale to update on panning/zooming. - */ - constructor(xScale?: QuantitativeScale, yScale?: QuantitativeScale); - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Gets the x scales for this PanZoom Interaction. - */ - xScales(): QuantitativeScale[]; - /** - * Sets the x scales for this PanZoom Interaction. - * - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - xScales(xScales: QuantitativeScale[]): Interactions.PanZoom; - /** - * Gets the y scales for this PanZoom Interaction. - */ - yScales(): QuantitativeScale[]; - /** - * Sets the y scales for this PanZoom Interaction. - * - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - yScales(yScales: QuantitativeScale[]): Interactions.PanZoom; - /** - * Adds an x scale to this PanZoom Interaction - * - * @param {QuantitativeScale} An x scale to add - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - addXScale(xScale: QuantitativeScale): PanZoom; - /** - * Removes an x scale from this PanZoom Interaction - * - * @param {QuantitativeScale} An x scale to remove - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - removeXScale(xScale: QuantitativeScale): PanZoom; - /** - * Adds a y scale to this PanZoom Interaction - * - * @param {QuantitativeScale} A y scale to add - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - addYScale(yScale: QuantitativeScale): PanZoom; - /** - * Removes a y scale from this PanZoom Interaction - * - * @param {QuantitativeScale} A y scale to remove - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - removeYScale(yScale: QuantitativeScale): PanZoom; - /** - * Gets the minimum domain extent for the scale, specifying the minimum allowable amount - * between the ends of the domain. - * - * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale - * - * @param {QuantitativeScale} quantitativeScale The scale to query - * @returns {D} The minimum domain extent for the scale. - */ - minDomainExtent(quantitativeScale: QuantitativeScale): D; - /** - * Sets the minimum domain extent for the scale, specifying the minimum allowable amount - * between the ends of the domain. - * - * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale - * - * @param {QuantitativeScale} quantitativeScale The scale to query - * @param {D} minDomainExtent The minimum domain extent for the scale. - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - minDomainExtent(quantitativeScale: QuantitativeScale, minDomainExtent: D): Interactions.PanZoom; - /** - * Gets the maximum domain extent for the scale, specifying the maximum allowable amount - * between the ends of the domain. - * - * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale - * - * @param {QuantitativeScale} quantitativeScale The scale to query - * @returns {D} The maximum domain extent for the scale. - */ - maxDomainExtent(quantitativeScale: QuantitativeScale): D; - /** - * Sets the maximum domain extent for the scale, specifying the maximum allowable amount - * between the ends of the domain. - * - * Note that extents will mainly work on scales that work linearly like Linear Scale and Time Scale - * - * @param {QuantitativeScale} quantitativeScale The scale to query - * @param {D} minDomainExtent The maximum domain extent for the scale. - * @returns {Interactions.PanZoom} The calling PanZoom Interaction. - */ - maxDomainExtent(quantitativeScale: QuantitativeScale, maxDomainExtent: D): Interactions.PanZoom; - } - } - } - - - namespace Plottable { - type DragCallback = (start: Point, end: Point) => void; - namespace Interactions { - class Drag extends Interaction { - protected _anchor(component: Component): void; - protected _unanchor(): void; - /** - * Gets whether the Drag Interaction constrains Points passed to its - * callbacks to lie inside its Component. - * - * If true, when the user drags outside of the Component, the closest Point - * inside the Component will be passed to the callback instead of the actual - * cursor position. - * - * @return {boolean} - */ - constrainedToComponent(): boolean; - /** - * Sets whether the Drag Interaction constrains Points passed to its - * callbacks to lie inside its Component. - * - * If true, when the user drags outside of the Component, the closest Point - * inside the Component will be passed to the callback instead of the actual - * cursor position. - * - * @param {boolean} - * @return {Interactions.Drag} The calling Drag Interaction. - */ - constrainedToComponent(constrainedToComponent: boolean): Drag; - /** - * Adds a callback to be called when dragging starts. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - onDragStart(callback: DragCallback): Drag; - /** - * Removes a callback that would be called when dragging starts. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - offDragStart(callback: DragCallback): Drag; - /** - * Adds a callback to be called during dragging. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - onDrag(callback: DragCallback): Drag; - /** - * Removes a callback that would be called during dragging. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - offDrag(callback: DragCallback): Drag; - /** - * Adds a callback to be called when dragging ends. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - onDragEnd(callback: DragCallback): Drag; - /** - * Removes a callback that would be called when dragging ends. - * - * @param {DragCallback} callback - * @returns {Drag} The calling Drag Interaction. - */ - offDragEnd(callback: DragCallback): Drag; - } - } - } - - - namespace Plottable { - type DragBoxCallback = (bounds: Bounds) => void; - namespace Components { - class DragBoxLayer extends Components.SelectionBoxLayer { - protected _hasCorners: boolean; - /** - * Constructs a DragBoxLayer. - * - * A DragBoxLayer is a SelectionBoxLayer with a built-in Drag Interaction. - * A drag gesture will set the Bounds of the box. - * If resizing is enabled using resizable(true), the edges of box can be repositioned. - * - * @constructor - */ - constructor(); - protected _setup(): void; - renderImmediately(): DragBoxLayer; - /** - * Gets the detection radius of the drag box in pixels. - */ - detectionRadius(): number; - /** - * Sets the detection radius of the drag box in pixels. - * - * @param {number} r - * @return {DragBoxLayer} The calling DragBoxLayer. - */ - detectionRadius(r: number): DragBoxLayer; - /** - * Gets whether or not the drag box is resizable. - */ - resizable(): boolean; - /** - * Sets whether or not the drag box is resizable. - * - * @param {boolean} canResize - * @return {DragBoxLayer} The calling DragBoxLayer. - */ - resizable(canResize: boolean): DragBoxLayer; - protected _setResizableClasses(canResize: boolean): void; - /** - * Sets the callback to be called when dragging starts. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - onDragStart(callback: DragBoxCallback): DragBoxLayer; - /** - * Removes a callback to be called when dragging starts. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - offDragStart(callback: DragBoxCallback): DragBoxLayer; - /** - * Sets a callback to be called during dragging. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - onDrag(callback: DragBoxCallback): DragBoxLayer; - /** - * Removes a callback to be called during dragging. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - offDrag(callback: DragBoxCallback): DragBoxLayer; - /** - * Sets a callback to be called when dragging ends. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - onDragEnd(callback: DragBoxCallback): DragBoxLayer; - /** - * Removes a callback to be called when dragging ends. - * - * @param {DragBoxCallback} callback - * @returns {DragBoxLayer} The calling DragBoxLayer. - */ - offDragEnd(callback: DragBoxCallback): DragBoxLayer; - /** - * Gets the internal Interactions.Drag of the DragBoxLayer. - */ - dragInteraction(): Interactions.Drag; - /** - * Enables or disables the interaction and drag box. - */ - enabled(enabled: boolean): DragBoxLayer; - /** - * Gets the enabled state. - */ - enabled(): boolean; - } - } - } - - - namespace Plottable { - namespace Components { - class XDragBoxLayer extends DragBoxLayer { - /** - * An XDragBoxLayer is a DragBoxLayer whose size can only be set in the X-direction. - * The y-values of the bounds() are always set to 0 and the height() of the XDragBoxLayer. - * - * @constructor - */ - constructor(); - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): XDragBoxLayer; - protected _setBounds(newBounds: Bounds): void; - protected _setResizableClasses(canResize: boolean): void; - } - } - } - - - namespace Plottable { - namespace Components { - class YDragBoxLayer extends DragBoxLayer { - /** - * A YDragBoxLayer is a DragBoxLayer whose size can only be set in the Y-direction. - * The x-values of the bounds() are always set to 0 and the width() of the YDragBoxLayer. - * - * @constructor - */ - constructor(); - computeLayout(origin?: Point, availableWidth?: number, availableHeight?: number): YDragBoxLayer; - protected _setBounds(newBounds: Bounds): void; - protected _setResizableClasses(canResize: boolean): void; - } - } - } -} diff --git a/types/plottable/plottable-tests.ts b/types/plottable/plottable-tests.ts deleted file mode 100644 index 1dbc306eb7..0000000000 --- a/types/plottable/plottable-tests.ts +++ /dev/null @@ -1,51 +0,0 @@ - - -var data = [ - { x: 1, y: 1, x2: 2, y2: 2 }, - { x: 4, y: 4, x2: 3, y2: 3 }, - { x: 2, y: 2, x2: 3, y2: 3 } -]; - -// Create a dataset -var dataset = new Plottable.Dataset(data); - -// Generate a bunch of scales -var linearScale = new Plottable.Scales.Linear(); -var modifiedLogScale = new Plottable.Scales.ModifiedLog(); -var categoryScale = new Plottable.Scales.Category(); -var categorySecondaryScale = new Plottable.Scales.Category(); - -// Generate a bunch of axes -var numericAxis = new Plottable.Axes.Numeric(linearScale, "bottom"); -var numericSecondaryAxis = new Plottable.Axes.Numeric(modifiedLogScale, "left"); -var categoryAxis = new Plottable.Axes.Category(categoryScale, "bottom"); -var categorySecondaryAxis = new Plottable.Axes.Category(categorySecondaryScale, "left"); - -// Scatter plot -var scatter = new Plottable.Plots.Scatter() - .x((d) => d.x, linearScale) - .y((d) => d.y, categoryScale) - .addDataset(dataset); - -// Line plot -var line = new Plottable.Plots.Line() - .x((d) => d.x, linearScale) - .y((d) => d.y, modifiedLogScale) - .addDataset(dataset); - -// Rectangle plot -var rectangle = new Plottable.Plots.Rectangle() - .x((d) => d.x, linearScale) - .y((d) => d.y, modifiedLogScale) - .x2((d) => d.x2) - .y2((d) => d.y2) - .addDataset(dataset); - -// Create a group of plots -var group = new Plottable.Components.Group([line, scatter]); - -// Make a chart -new Plottable.Components.Table([ - [numericSecondaryAxis, group], - [null, numericAxis] -]); \ No newline at end of file diff --git a/types/plottable/tsconfig.json b/types/plottable/tsconfig.json deleted file mode 100644 index 3eb45943e1..0000000000 --- a/types/plottable/tsconfig.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "paths": { - "d3": [ - "d3/v3" - ] - }, - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "plottable-tests.ts" - ] -} \ No newline at end of file diff --git a/types/plottable/tslint.json b/types/plottable/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/plottable/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From 5efc5fd3298f21d5710fe54cafbf565c884731f0 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 21 Dec 2017 07:38:25 -0800 Subject: [PATCH 289/298] jimp: Provides its own types (#22352) --- notNeededPackages.json | 6 ++ types/jimp/index.d.ts | 206 ------------------------------------ types/jimp/jimp-tests.ts | 218 --------------------------------------- types/jimp/tsconfig.json | 23 ----- types/jimp/tslint.json | 1 - 5 files changed, 6 insertions(+), 448 deletions(-) delete mode 100644 types/jimp/index.d.ts delete mode 100644 types/jimp/jimp-tests.ts delete mode 100644 types/jimp/tsconfig.json delete mode 100644 types/jimp/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 4c7d2fab7d..2b18517915 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -360,6 +360,12 @@ "sourceRepoURL": "https://github.com/blakeembrey/is-upper-case", "asOfVersion": "1.1.2" }, + { + "libraryName": "jimp", + "typingsPackageName": "jimp", + "sourceRepoURL": "https://github.com/oliver-moran/jimp#readme", + "asOfVersion": "0.2.28" + }, { "libraryName": "jpush-react-native", "typingsPackageName": "jpush-react-native", diff --git a/types/jimp/index.d.ts b/types/jimp/index.d.ts deleted file mode 100644 index 4c39f58796..0000000000 --- a/types/jimp/index.d.ts +++ /dev/null @@ -1,206 +0,0 @@ -// Type definitions for jimp 0.2 -// Project: https://github.com/oliver-moran/jimp#readme -// Definitions by: Jack Works -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace jimp { - type Callback = (this: JimpImage, err: Error, data: T) => void; - type ResizeMode = string; - type PresetFont = string; - type FileMINE = string; - type AlignMode = number; - type FilterType = number; - - // Used in font info provided by parse-bmfont-ascii - type FontBoolean = 0 | 1; - interface FontChar { - id: number; - x: number; - y: number; - weight: number; - height: number; - xoffset: number; - yoffset: number; - xadvance: number; - page: number; - chnl: number; - } - type Font = { - common: {lineHeight: number, base: number, scaleW: number, scaleH: number, pages: number, packed: number}, - info: { - face: string, - size: number, - bold: FontBoolean, - italic: FontBoolean, - charset: string, - unicode: FontBoolean, - stretchH: number, - smooth: FontBoolean, - aa: number, - padding: [number, number, number, number], - spacing: [number, number] - }, - kernings: any, - pages: JIMP[], - chars: { - [char: number]: FontChar, - [char: string]: FontChar - } - } | PresetFont; - - class JimpImage { - constructor(width: number, height: number, callback?: Callback); - constructor(width: number, height: number, initialColor: number, callback?: Callback); - - /* Get/set meta data */ - hash(n?: number): string; - - getExtension(): string; - getMIME(): FileMINE; - - getPixelColor(x: number, y: number): number; - setPixelColor(hex: number, x: number, y: number): void; - - /* Save */ - write(path: string, callback?: Callback): void; - getBase64(mine: FileMINE, callback?: Callback): void; - getBuffer(mine: FileMINE, callback?: Callback): void; - - /* Parameter */ - quality(n: number): JimpImage; - rgba(is: boolean): JimpImage; - filterType(type: FilterType): JimpImage; - deflateLevel(level: number): JimpImage; - - /* Operation */ - clone(): JimpImage; - print(font: Font, x: number, y: number, text: string, width?: number): JimpImage; - - /* Adv */ - color( - params: Array<{ - apply: 'lighten' | 'brighten' | 'darken' | 'desaturate' | 'saturate' | 'greyscale' | 'spin' | 'hue' | 'tint' | 'shade' | 'red' | 'green' | 'blue', - params: [number] - } | { - apply: 'mix', - params: [string, number] - } | { - apply: 'xor', - params: [string] - }>): JimpImage; - - convolution(matrix: number[][]): JimpImage; - scan(x: number, y: number, width: number, height: number, callback?: (this: JimpImage, x: number, y: number, idx: number) => void): JimpImage; - - /* Low level data */ - bitmap: {data: Buffer, readonly width: number, readonly height: number}; - readonly _originalMime: string; - - /* Resize */ - contain(width: number, height: number, callback?: Callback): JimpImage; - contain(width: number, height: number, alignBitsOrMode?: number | ResizeMode, callback?: Callback): JimpImage; - contain(width: number, height: number, alignBits: number, mode?: ResizeMode, callback?: Callback): JimpImage; - - cover(width: number, height: number, callback?: Callback): JimpImage; - cover(width: number, height: number, alignBitsOrmode?: ResizeMode | number, callback?: Callback): JimpImage; - cover(width: number, height: number, alignBits: number, mode?: ResizeMode, callback?: Callback): JimpImage; - - resize(width: number, height: number, callback?: Callback): JimpImage; - resize(width: number, height: number, mode?: ResizeMode, callback?: Callback): JimpImage; - - scale(factor: any, callback?: Callback): JimpImage; - scale(factor: any, mode?: ResizeMode, callback?: Callback): JimpImage; - - scaleToFit(width: number, height: number, callback?: Callback): JimpImage; - scaleToFit(width: number, height: number, mode?: ResizeMode, callback?: Callback): JimpImage; - - /* Crop */ - autocrop(callback?: Callback): JimpImage; - crop(x: number, y: number, width: number, height: number, callback?: Callback): JimpImage; - - /* Composing */ - blit(scr: string, x: number, y: number, callback?: Callback): JimpImage; - blit(scr: string, x: number, y: number, srcx?: number, srcy?: number, callback?: Callback): JimpImage; - blit(scr: string, x: number, y: number, srcx?: number, srcy?: number, srcw?: number, srch?: number, callback?: Callback): JimpImage; - - composite(scr: string, x: number, y: number, callback?: Callback): JimpImage; - mask(scr: string, x: number, y: number, callback?: Callback): JimpImage; - - /* Flip and rotate */ - flip(horz: any, vert: any, callback?: Callback): JimpImage; - mirror(horz: any, vert: any, callback?: Callback): JimpImage; - rotate(deg: number, callback?: Callback): JimpImage; - rotate(deg: number, mode?: any, callback?: Callback): JimpImage; - - /* Colour */ - brightness(val: number, callback?: Callback): JimpImage; - contrast(val: number, callback?: Callback): JimpImage; - dither565(callback?: Callback): JimpImage; - greyscale(callback?: Callback): JimpImage; - invert(callback?: Callback): JimpImage; - normalize(callback?: Callback): JimpImage; - - /* Alpha channel */ - fade(val: number, callback?: Callback): JimpImage; - opacity(val: number, callback?: Callback): JimpImage; - opaque(callback?: Callback): JimpImage; - background(hex: number, callback?: Callback): JimpImage; - - /* Blurs */ - gaussian(pixel: number, callback?: Callback): JimpImage; - blur(pixel: number, callback?: Callback): JimpImage; - - /* Effects */ - posterize(level: number, callback?: Callback): JimpImage; - sepia(callback?: Callback): JimpImage; - } - class JIMP extends JimpImage { - static read(path: string | Buffer, callback?: Callback): Promise; - static loadFont(path: string | PresetFont, callback?: Callback): Promise; - static rgbaToInt(r: number, g: number, b: number, alpha: number): number; - static intToRGBA(hex: number): {r: number, g: number, b: number, a: number}; - static distance(image: JimpImage, image2: JimpImage): number; - static diff(image1: JimpImage, image2: JimpImage, threshold?: number): {image: JimpImage, percent: number}; - static deflateStrategy(deflate: number): void; - - static readonly RESIZE_NEAREST_NEIGHBOR: ResizeMode; - static readonly RESIZE_BILINEAR: ResizeMode; - static readonly RESIZE_BICUBIC: ResizeMode; - static readonly RESIZE_HERMITE: ResizeMode; - static readonly RESIZE_BEZIER: ResizeMode; - - static readonly FONT_SANS_8_BLACK: PresetFont; - static readonly FONT_SANS_16_BLACK: PresetFont; - static readonly FONT_SANS_32_BLACK: PresetFont; - static readonly FONT_SANS_64_BLACK: PresetFont; - static readonly FONT_SANS_128_BLACK: PresetFont; - - static readonly FONT_SANS_8_WHITE: PresetFont; - static readonly FONT_SANS_16_WHITE: PresetFont; - static readonly FONT_SANS_32_WHITE: PresetFont; - static readonly FONT_SANS_64_WHITE: PresetFont; - static readonly FONT_SANS_128_WHITE: PresetFont; - - static readonly MIME_PNG: FileMINE; - static readonly MIME_JPEG: FileMINE; - static readonly MIME_BMP: FileMINE; - static readonly AUTO: number; - - static readonly HORIZONTAL_ALIGN_LEFT: AlignMode; - static readonly HORIZONTAL_ALIGN_CENTER: AlignMode; - static readonly HORIZONTAL_ALIGN_RIGHT: AlignMode; - static readonly VERTICAL_ALIGN_TOP: AlignMode; - static readonly VERTICAL_ALIGN_MIDDLE: AlignMode; - static readonly VERTICAL_ALIGN_BOTTOM: AlignMode; - - static readonly PNG_FILTER_AUTO: FilterType; - static readonly PNG_FILTER_NONE: FilterType; - static readonly PNG_FILTER_SUB: FilterType; - static readonly PNG_FILTER_UP: FilterType; - static readonly PNG_FILTER_AVERAGE: FilterType; - static readonly PNG_FILTER_PAETH: FilterType; - } -} -export = jimp.JIMP; diff --git a/types/jimp/jimp-tests.ts b/types/jimp/jimp-tests.ts deleted file mode 100644 index 10ee61073e..0000000000 --- a/types/jimp/jimp-tests.ts +++ /dev/null @@ -1,218 +0,0 @@ -import Jimp = require('jimp'); - -// All code below is from node-jimp document -Jimp.read("lenna.png", (err, data) => { - if (err) throw err; - data.resize(256, 256) // resize - .quality(60) // set JPEG quality - .greyscale() // set greyscale - .write("lena-small-bw.jpg"); // save -}); - -Jimp.read("lenna.png").then(lenna => { - lenna.resize(256, 256) // resize - .quality(60) // set JPEG quality - .greyscale() // set greyscale - .write("lena-small-bw.jpg"); // save -}).catch(err => { - console.error(err); -}); - -Jimp.read("./path/to/image.jpg", (err, image) => { - // do stuff with the image (if no exception) -}); - -Jimp.read("./path/to/image.jpg").then(image => { - // do stuff with the image -}).catch(err => { - // handle an exception -}); - -Jimp.read(new Buffer(''), (err, image) => { - // do stuff with the image (if no exception) -}); - -Jimp.read("http://www.example.com/path/to/lenna.jpg", (err, image) => { - // do stuff with the image (if no exception) -}); - -let image = new Jimp(1, 2); -const w = 0; -const h = 0; -const x = 0; -const y = 0; -const f = 0; -const src = ''; -const horz = Jimp.HORIZONTAL_ALIGN_CENTER; -const vert = Jimp.VERTICAL_ALIGN_BOTTOM; -const deg = 90; -const val = 0.5; -const hex = 0xFFFFFFFF; -const r = 0; -const n = 1; -/* Resize */ -image.contain(w, h); // scale the image to the given width and height, some parts of the image may be letter boxed -image.cover(w, h); // scale the image to the given width and height, some parts of the image may be clipped -image.resize(w, h); // resize the image. Jimp.AUTO can be passed as one of the values. -image.scale(f); // scale the image by the factor f -image.scaleToFit(w, h); // scale the image to the largest size that fits inside the given width and height - -// An optional resize mode can be passed with all resize methods. - -/* Crop */ -image.autocrop(); // automatically crop same-color borders from image (if any) -image.crop(x, y, w, h); // crop to the given region - -/* Composing */ -image.blit(src, x, y); - // blit the image with another Jimp image at x, y, optionally cropped. -image.composite(src, x, y); // composites another Jimp image over this image at x, y -image.mask(src, x, y); // masks the image with another Jimp image at x, y using average pixel value - -/* Flip and rotate */ -image.flip(horz, vert); // flip the image horizontally or vertically -image.mirror(horz, vert); // an alias for flip - -// rotate the image clockwise by a number of degrees. -// Optionally, a resize mode can be passed. -// If `false` is passed as the second parameter, -// the image width and height will not be resized. -image.rotate(deg); - -// JPEG images with EXIF orientation data will be automatically re-orientated as appropriate. - -/* Colour */ -image.brightness(val); // adjust the brighness by a value -1 to +1 -image.contrast(val); // adjust the contrast by a value -1 to +1 -image.dither565(); // ordered dithering of the image and reduce color space to 16-bits (RGB565) -image.greyscale(); // remove colour from the image -image.invert(); // invert the image colours -image.normalize(); // normalize the channels in an image - -/* Alpha channel */ -image.fade(f); // an alternative to opacity, fades the image by a factor 0 - 1. 0 will haven no effect. 1 will turn the image -image.opacity(f); // multiply the alpha channel by each pixel by the factor f, 0 - 1 -image.opaque(); // set the alpha channel on every pixel to fully opaque -image.background(hex); // set the default new pixel colour (e.g. 0xFFFFFFFF or 0x00000000) for by some operations (e.g. image.contain and - -/* Blurs */ -image.gaussian(r); // Gaussian blur the image by r pixels (VERY slow) -image.blur(r); // fast blur the image by r pixels - -/* Effects */ -image.posterize(n); // apply a posterization effect with n level -image.sepia(); // apply a sepia wash to the image - -image.clone(); // returns a clone of the image -image.resize(250, 250); // resize the image to 250 x 250 -image.resize(Jimp.AUTO, 250); // resize the height to 250 and scale the width accordingly -image.resize(250, Jimp.AUTO); // resize the width to 250 and scale the height accordingly - -image.resize(250, 250, Jimp.RESIZE_BEZIER); - -image.contain(250, 250, Jimp.HORIZONTAL_ALIGN_LEFT | Jimp.VERTICAL_ALIGN_TOP); - -const path = ''; -const str = ''; -const width = 0; -Jimp.loadFont(path).then(font => { // load font from .fnt file - image.print(font, x, y, str); // print a message on an image - image.print(font, x, y, str, width); // print a message on an image with text wrapped at width -}); - -const cb = (err: Error, data: any) => {}; -Jimp.loadFont(path, cb); // using a callback pattern - -Jimp.loadFont(Jimp.FONT_SANS_32_BLACK).then(font => { - image.print(font, 10, 10, "Hello world!"); -}); - -image.write(path, cb); // Node-style callback will be fired when write is successful - -const file = "new_name." + image.getExtension(); -image.write(file); - -const mime = 'image/png'; -image.getBuffer(mime, cb); // Node-style callback will be fired with result -image.getBase64(mime, cb); // Node-style callback will be fired with result -image.quality(n); // set the quality of saved JPEG, 0 - 100 - -const bool = true; -const number = 0; -image.rgba(bool); // set whether PNGs are saved as RGBA (true, default) or RGB (false) -image.filterType(number); // set the filter type for the saved PNG -image.deflateLevel(number); // set the deflate level for the saved PNG -Jimp.deflateStrategy(number); // set the deflate for the saved PNG (0-3) - -image.color([ - { apply: 'hue', params: [ -90 ] }, - { apply: 'lighten', params: [ 50 ] }, - { apply: 'xor', params: [ '#06D' ] } -]); -image.convolution([ - [-2, -1, 0], - [-1, 1, 1], - [ 0, 1, 2] -]); -image.scan(0, 0, image.bitmap.width, image.bitmap.height, function(x, y, idx) { - // x, y is the position of this pixel on the image - // idx is the position start position of this rgba tuple in the bitmap Buffer - // this is the image - - const red = this.bitmap.data[ idx + 0 ]; - const green = this.bitmap.data[ idx + 1 ]; - const blue = this.bitmap.data[ idx + 2 ]; - const alpha = this.bitmap.data[ idx + 3 ]; - - // rgba values run from 0 - 255 - // e.g. this.bitmap.data[idx] = 0; // removes red from this pixel -}); -image.getPixelColor(x, y); // returns the colour of that pixel e.g. 0xFFFFFFFF -image.setPixelColor(hex, x, y); // sets the colour of that pixel - -const g = 0; -const b = 0; -const a = 0; -Jimp.rgbaToInt(r, g, b, a); // e.g. converts 255, 255, 255, 255 to 0xFFFFFFFF -Jimp.intToRGBA(hex); // e.g. converts 0xFFFFFFFF to {r: 255, g: 255, b: 255, a:255} - -image = new Jimp(256, 256, (err, image) => { - // this image is 256 x 256, every pixel is set to 0x00000000 -}); - -image = new Jimp(256, 256, 0xFF0000FF, (err, image) => { - // this image is 256 x 256, every pixel is set to 0xFF0000FF -}); - -image.hash(); // aHgG4GgoFjA -image.hash(2); // 1010101011010000101010000100101010010000011001001001010011100100 - -const image1 = new Jimp(0, 1); -const image2 = new Jimp(0, 1); -Jimp.distance(image1, image2); // returns a number 0-1, where 0 means the two images are perceived to be identical - -const threshold = 0; -let diff = Jimp.diff(image1, image2, threshold); // threshold ranges 0-1 (default: 0.1) -diff.image; // a Jimp image showing differences -diff.percent; // the proportion of different pixels (0-1), where 0 means the images are pixel identical - -const distance = Jimp.distance(image, image2); // perceived distance -diff = Jimp.diff(image, image2); // pixel difference - -if (distance < 0.15 || diff.percent < 0.15) { - // images match -} else { - // not a match -} - -Jimp.read("lenna.png", function(err, image) { - this.greyscale().scale(0.5).write("lena-half-bw.png"); -}); - -Jimp.read("lenna.png", (err, image) => { - image.greyscale((err, image) => { - image.scale(0.5, (err, image) => { - image.write("lena-half-bw.png"); - }); - }); -}); diff --git a/types/jimp/tsconfig.json b/types/jimp/tsconfig.json deleted file mode 100644 index 03ab32095b..0000000000 --- a/types/jimp/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "jimp-tests.ts" - ] -} \ No newline at end of file diff --git a/types/jimp/tslint.json b/types/jimp/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/jimp/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } From d530396c4a5cce1982eab054ce2a68744b00e83f Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 21 Dec 2017 07:38:43 -0800 Subject: [PATCH 290/298] bowser: Provides its own types (#22381) --- notNeededPackages.json | 6 +++ types/bowser/bowser-tests.ts | 11 ---- types/bowser/index.d.ts | 101 ----------------------------------- types/bowser/tsconfig.json | 24 --------- types/bowser/tslint.json | 7 --- 5 files changed, 6 insertions(+), 143 deletions(-) delete mode 100644 types/bowser/bowser-tests.ts delete mode 100644 types/bowser/index.d.ts delete mode 100644 types/bowser/tsconfig.json delete mode 100644 types/bowser/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 2b18517915..3a8fe0570a 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -120,6 +120,12 @@ "sourceRepoURL": "https://github.com/peterolson/BigInteger.js", "asOfVersion": "0.0.31" }, + { + "libraryName": "Bowser", + "typingsPackageName": "bowser", + "sourceRepoURL": "https://github.com/ded/bowser", + "asOfVersion": "1.1.1" + }, { "libraryName": "Bugsnag Browser", "typingsPackageName": "bugsnag-js", diff --git a/types/bowser/bowser-tests.ts b/types/bowser/bowser-tests.ts deleted file mode 100644 index 6b69a12ca2..0000000000 --- a/types/bowser/bowser-tests.ts +++ /dev/null @@ -1,11 +0,0 @@ -bowser.msedge; // $ExpectType boolean -bowser.test(['msie']); // $ExpectType boolean -bowser.a === bowser.c; -bowser.osversion > 10; -bowser.osversion === '10.1A'; -bowser.compareVersions(['9.0', '10']); - -bowser().android; // $ExpectType boolean -bowser().x; // $ExpectType boolean -bowser.check({msie: "11"}, window.navigator.userAgent); -bowser.isUnsupportedBrowser({msie: "10"}, window.navigator.userAgent); diff --git a/types/bowser/index.d.ts b/types/bowser/index.d.ts deleted file mode 100644 index 7339783c77..0000000000 --- a/types/bowser/index.d.ts +++ /dev/null @@ -1,101 +0,0 @@ -// Type definitions for Bowser 1.x -// Project: https://github.com/ded/bowser -// Definitions by: Paulo Cesar -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare const bowser: bowser.IBowser; -export = bowser; -export as namespace bowser; - -declare namespace bowser { - interface IBowserOS { - mac: boolean; - /** other than Windows Phone */ - windows: boolean; - windowsphone: boolean; - /** other than android, chromeos, webos, tizen, and sailfish */ - linux: boolean; - chromeos: boolean; - android: boolean; - /** also sets one of iphone/ipad/ipod */ - ios: boolean; - blackberry: boolean; - firefoxos: boolean; - /** may also set touchpad */ - webos: boolean; - bada: boolean; - tizen: boolean; - sailfish: boolean; - } - - interface IBowserVersions { - chrome: boolean; - firefox: boolean; - msie: boolean; - msedge: boolean; - safari: boolean; - android: boolean; - ios: boolean; - opera: boolean; - phantom: boolean; - blackberry: boolean; - webos: boolean; - silk: boolean; - bada: boolean; - tizen: boolean; - seamonkey: boolean; - sailfish: boolean; - ucbrowser: boolean; - qupzilla: boolean; - vivaldi: boolean; - sleipnir: boolean; - kMeleon: boolean; - } - - interface IBowserEngines { - /** IE <= 11 */ - msie: boolean; - /** Chrome 0-27, Android <4.4, iOs, BB, etc. */ - webkit: boolean; - /** Chrome >=28, Android >=4.4, Opera, etc. */ - blink: boolean; - /** Firefox, etc. */ - gecko: boolean; - /** IE > 11 */ - msedge: boolean; - /** If a tablet device is detected, the flag tablet is set instead of mobile. */ - tablet: boolean; - /** All detected mobile OSes are additionally flagged mobile, unless it's a tablet */ - mobile: boolean; - } - - interface IBowserGrade { - /** Grade A browser */ - a: boolean; - /** Grade C browser */ - c: boolean; - /** Grade X browser */ - x: boolean; - /** A human readable name for this browser. E.g. 'Chrome', '' */ - name: string; - /** Version number for the browser. E.g. '32.0' */ - version: string | number; - osversion: string | number; - } - - interface IBowserDetection extends IBowserGrade, IBowserEngines, IBowserOS, IBowserVersions { } - - interface IBowserMinVersions { - // { msie: "11", "firefox": "4" } - [index: string]: string; - } - - interface IBowser extends IBowserDetection { - (): IBowserDetection; - test(browserList: string[]): boolean; - _detect(ua: string): IBowser; - compareVersions(versions: string[]): number; - check(minVersions: IBowserMinVersions, strictMode?: boolean | string, ua?: string): boolean; - isUnsupportedBrowser(minVersions: IBowserMinVersions, strictMode?: boolean | string, ua?: string): boolean; - } -} diff --git a/types/bowser/tsconfig.json b/types/bowser/tsconfig.json deleted file mode 100644 index 533b285bb0..0000000000 --- a/types/bowser/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "bowser-tests.ts" - ] -} \ No newline at end of file diff --git a/types/bowser/tslint.json b/types/bowser/tslint.json deleted file mode 100644 index 45f91d386b..0000000000 --- a/types/bowser/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - // TODO - "interface-name": false - } -} From 012e232dea28b23db2c346d252913274c69c6d87 Mon Sep 17 00:00:00 2001 From: "VML\\snau" Date: Thu, 21 Dec 2017 08:56:19 -0800 Subject: [PATCH 291/298] updated the `event` parameter to be optional on the `close` method, just like it is on the `open` method --- types/vanilla-modal/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vanilla-modal/index.d.ts b/types/vanilla-modal/index.d.ts index 90775bf7ee..6c15609ce2 100644 --- a/types/vanilla-modal/index.d.ts +++ b/types/vanilla-modal/index.d.ts @@ -36,7 +36,7 @@ export default class VanillaModal { removeOpenId(): void; open(allMatches: string, e?: Event): void; detectTransition(): boolean; - close(e: Event): void; + close(e?: Event): void; closeModal(e: Event): void; closeModalWithTransition(e: Event): void; captureNode(node: Node): void; From ed3919e476199a20ba9d62d8cb34e816599c0e15 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 21 Dec 2017 09:44:19 -0800 Subject: [PATCH 292/298] keycloak-js: Provides its own types (#22372) --- notNeededPackages.json | 6 + types/keycloak-js/index.d.ts | 463 ------------------------- types/keycloak-js/keycloak-authz.d.ts | 39 --- types/keycloak-js/keycloak-js-tests.ts | 18 - types/keycloak-js/tsconfig.json | 24 -- types/keycloak-js/tslint.json | 9 - 6 files changed, 6 insertions(+), 553 deletions(-) delete mode 100644 types/keycloak-js/index.d.ts delete mode 100644 types/keycloak-js/keycloak-authz.d.ts delete mode 100644 types/keycloak-js/keycloak-js-tests.ts delete mode 100644 types/keycloak-js/tsconfig.json delete mode 100644 types/keycloak-js/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 3a8fe0570a..0f92b3f3ac 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -408,6 +408,12 @@ "sourceRepoURL": "https://github.com/jsplumb/jsPlumb", "asOfVersion": "2.5.7" }, + { + "libraryName": "keycloak-js", + "typingsPackageName": "keycloak-js", + "sourceRepoURL": "https://github.com/keycloak/keycloak", + "asOfVersion": "3.4.1" + }, { "libraryName": "knockout-paging", "typingsPackageName": "knockout-paging", diff --git a/types/keycloak-js/index.d.ts b/types/keycloak-js/index.d.ts deleted file mode 100644 index ee1ef73deb..0000000000 --- a/types/keycloak-js/index.d.ts +++ /dev/null @@ -1,463 +0,0 @@ -// Type definitions for keycloak-js 2.5 -// Project: https://github.com/keycloak/keycloak -// Definitions by: Brett Epps -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export as namespace Keycloak; - -export = Keycloak; - -/** - * Creates a new Keycloak client instance. - * @param config Path to a JSON config file or a plain config object. - */ -declare function Keycloak(config?: string|{}): Keycloak.KeycloakInstance; - -declare namespace Keycloak { - type KeycloakAdapterName = 'cordova'|'default'; - type KeycloakOnLoad = 'login-required'|'check-sso'; - type KeycloakResponseMode = 'query'|'fragment'; - type KeycloakResponseType = 'code'|'id_token token'|'code id_token token'; - type KeycloakFlow = 'standard'|'implicit'|'hybrid'; - - interface KeycloakInitOptions { - /** - * @private Undocumented. - */ - adapter?: KeycloakAdapterName; - - /** - * Specifies an action to do on load. - */ - onLoad?: KeycloakOnLoad; - - /** - * Set an initial value for the token. - */ - token?: string; - - /** - * Set an initial value for the refresh token. - */ - refreshToken?: string; - - /** - * Set an initial value for the id token (only together with `token` or - * `refreshToken`). - */ - idToken?: string; - - /** - * Set an initial value for skew between local time and Keycloak server in - * seconds (only together with `token` or `refreshToken`). - */ - timeSkew?: number; - - /** - * Set to enable/disable monitoring login state. - * @default true - */ - checkLoginIframe?: boolean; - - /** - * Set the interval to check login state (in seconds). - * @default 5 - */ - checkLoginIframeInterval?: boolean; - - /** - * Set the OpenID Connect response mode to send to Keycloak upon login. - * @default fragment After successful authentication Keycloak will redirect - * to JavaScript application with OpenID Connect parameters - * added in URL fragment. This is generally safer and - * recommended over query. - */ - responseMode?: KeycloakResponseMode; - - /** - * Set the OpenID Connect flow. - * @default standard - */ - flow?: KeycloakFlow; - } - - interface KeycloakLoginOptions { - /** - * @private Undocumented. - */ - scope?: string; - - /** - * Specifies the uri to redirect to after login. - */ - redirectUri?: string; - - /** - * By default the login screen is displayed if the user is not logged into - * Keycloak. To only authenticate to the application if the user is already - * logged in and not display the login page if the user is not logged in, set - * this option to `'none'`. To always require re-authentication and ignore - * SSO, set this option to `'login'`. - */ - prompt?: 'none'|'login'; - - /** - * If value is `'register'` then user is redirected to registration page, - * otherwise to login page. - */ - action?: 'register'; - - /** - * Used just if user is already authenticated. Specifies maximum time since - * the authentication of user happened. If user is already authenticated for - * longer time than `'maxAge'`, the SSO is ignored and he will need to - * authenticate again. - */ - maxAge?: number; - - /** - * Used to pre-fill the username/email field on the login form. - */ - loginHint?: string; - - /** - * Used to tell Keycloak which IDP the user wants to authenticate with. - */ - idpHint?: string; - - /** - * Specifies the desired locale for the UI. - */ - locale?: string; - } - - type KeycloakPromiseCallback = (result: T) => void; - - interface KeycloakPromise { - /** - * Function to call if the promised action succeeds. - */ - success(callback: KeycloakPromiseCallback): KeycloakPromise; - - /** - * Function to call if the promised action throws an error. - */ - error(callback: KeycloakPromiseCallback): KeycloakPromise; - } - - interface KeycloakError { - error: string; - error_description: string; - } - - interface KeycloakAdapter { - login(options?: KeycloakLoginOptions): KeycloakPromise; - logout(options?: any): KeycloakPromise; - register(options?: KeycloakLoginOptions): KeycloakPromise; - accountManagement(): KeycloakPromise; - redirectUri(options: { redirectUri: string; }, encodeHash: boolean): string; - } - - interface KeycloakProfile { - id?: string; - username?: string; - email?: string; - firstName?: string; - lastName?: string; - enabled?: boolean; - emailVerified?: boolean; - totp?: boolean; - createdTimestamp?: number; - } - - // export interface KeycloakUserInfo {} - - /** - * A client for the Keycloak authentication server. - * @see {@link https://keycloak.gitbooks.io/securing-client-applications-guide/content/topics/oidc/javascript-adapter.html|Keycloak JS adapter documentation} - */ - interface KeycloakInstance { - /** - * Is true if the user is authenticated, false otherwise. - */ - authenticated?: boolean; - - /** - * The user id. - */ - subject?: string; - - /** - * Response mode passed in init (default value is `'fragment'`). - */ - responseMode?: KeycloakResponseMode; - - /** - * Response type sent to Keycloak with login requests. This is determined - * based on the flow value used during initialization, but can be overridden - * by setting this value. - */ - responseType?: KeycloakResponseType; - - /** - * Flow passed in init. - */ - flow?: KeycloakFlow; - - /** - * The realm roles associated with the token. - */ - realmAccess?: { roles: string[] }; - - /** - * The resource roles associated with the token. - */ - resourceAccess?: string[]; - - /** - * The base64 encoded token that can be sent in the Authorization header in - * requests to services. - */ - token?: string; - - /** - * The parsed token as a JavaScript object. - */ - tokenParsed?: { - exp?: number; - iat?: number; - nonce?: string; - sub?: string; - session_state?: string; - realm_access?: { roles: string[] }; - resource_access?: string[]; - }; - - /** - * The base64 encoded refresh token that can be used to retrieve a new token. - */ - refreshToken?: string; - - /** - * The parsed refresh token as a JavaScript object. - */ - refreshTokenParsed?: { nonce?: string }; - - /** - * The base64 encoded ID token. - */ - idToken?: string; - - /** - * The parsed id token as a JavaScript object. - */ - idTokenParsed?: { nonce?: string }; - - /** - * The estimated time difference between the browser time and the Keycloak - * server in seconds. This value is just an estimation, but is accurate - * enough when determining if a token is expired or not. - */ - timeSkew?: number; - - /** - * @private Undocumented. - */ - loginRequired?: boolean; - - /** - * @private Undocumented. - */ - authServerUrl?: string; - - /** - * @private Undocumented. - */ - realm?: string; - - /** - * @private Undocumented. - */ - clientId?: string; - - /** - * @private Undocumented. - */ - clientSecret?: string; - - /** - * @private Undocumented. - */ - redirectUri?: string; - - /** - * @private Undocumented. - */ - sessionId?: string; - - /** - * @private Undocumented. - */ - profile?: KeycloakProfile; - - /** - * @private Undocumented. - */ - userInfo?: {}; // KeycloakUserInfo; - - /** - * Called when the adapter is initialized. - */ - onReady?(authenticated?: boolean): void; - - /** - * Called when a user is successfully authenticated. - */ - onAuthSuccess?(): void; - - /** - * Called if there was an error during authentication. - */ - onAuthError?(errorData: KeycloakError): void; - - /** - * Called when the token is refreshed. - */ - onAuthRefreshSuccess?(): void; - - /** - * Called if there was an error while trying to refresh the token. - */ - onAuthRefreshError?(): void; - - /** - * Called if the user is logged out (will only be called if the session - * status iframe is enabled, or in Cordova mode). - */ - onAuthLogout?(): void; - - /** - * Called when the access token is expired. If a refresh token is available - * the token can be refreshed with Keycloak#updateToken, or in cases where - * it's not (ie. with implicit flow) you can redirect to login screen to - * obtain a new access token. - */ - onTokenExpired?(): void; - - /** - * Called to initialize the adapter. - * @param initOptions Initialization options. - * @returns A promise to set functions to be invoked on success or error. - */ - init(initOptions: KeycloakInitOptions): KeycloakPromise; - - /** - * Redirects to login form. - * @param options Login options. - */ - login(options?: KeycloakLoginOptions): KeycloakPromise; - - /** - * Redirects to logout. - * @param options Logout options. - * @param options.redirectUri Specifies the uri to redirect to after logout. - */ - logout(options?: any): KeycloakPromise; - - /** - * Redirects to registration form. - * @param options Supports same options as Keycloak#login but `action` is - * set to `'register'`. - */ - register(options?: any): KeycloakPromise; - - /** - * Redirects to the Account Management Console. - */ - accountManagement(): KeycloakPromise; - - /** - * Returns the URL to login form. - * @param options Supports same options as Keycloak#login. - */ - createLoginUrl(options?: KeycloakLoginOptions): string; - - /** - * Returns the URL to logout the user. - * @param options Logout options. - * @param options.redirectUri Specifies the uri to redirect to after logout. - */ - createLogoutUrl(options?: any): string; - - /** - * Returns the URL to registration page. - * @param options Supports same options as Keycloak#createLoginUrl but - * `action` is set to `'register'`. - */ - createRegisterUrl(options?: KeycloakLoginOptions): string; - - /** - * Returns the URL to the Account Management Console. - */ - createAccountUrl(): string; - - /** - * Returns true if the token has less than `minValidity` seconds left before - * it expires. - * @param minValidity If not specified, `0` is used. - */ - isTokenExpired(minValidity?: number): boolean; - - /** - * If the token expires within `minValidity` seconds, the token is refreshed. - * If the session status iframe is enabled, the session status is also - * checked. - * @returns A promise to set functions that can be invoked if the token is - * still valid, or if the token is no longer valid. - * @example - * ```js - * keycloak.updateToken(5).success(function(refreshed) { - * if (refreshed) { - * alert('Token was successfully refreshed'); - * } else { - * alert('Token is still valid'); - * } - * }).error(function() { - * alert('Failed to refresh the token, or the session has expired'); - * }); - */ - updateToken(minValidity: number): KeycloakPromise; - - /** - * Clears authentication state, including tokens. This can be useful if - * the application has detected the session was expired, for example if - * updating token fails. Invoking this results in Keycloak#onAuthLogout - * callback listener being invoked. - */ - clearToken(): void; - - /** - * Returns true if the token has the given realm role. - * @param role A realm role name. - */ - hasRealmRole(role: string): boolean; - - /** - * Returns true if the token has the given role for the resource. - * @param role A role name. - * @param resource If not specified, `clientId` is used. - */ - hasResourceRole(role: string, resource?: string): boolean; - - /** - * Loads the user's profile. - * @returns A promise to set functions to be invoked on success or error. - */ - loadUserProfile(): KeycloakPromise; - - /** - * @private Undocumented. - */ - loadUserInfo(): KeycloakPromise<{}, void>; - } -} diff --git a/types/keycloak-js/keycloak-authz.d.ts b/types/keycloak-js/keycloak-authz.d.ts deleted file mode 100644 index 0ee42180b4..0000000000 --- a/types/keycloak-js/keycloak-authz.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -import * as Keycloak from '.'; - -export as namespace KeycloakAuthorization; - -export = KeycloakAuthorization; - -/** - * Creates a new Keycloak client instance. - * @param config Path to a JSON config file or a plain config object. - */ -declare function KeycloakAuthorization(keycloak: Keycloak.KeycloakInstance): KeycloakAuthorization.KeycloakAuthorizationInstance; - -declare namespace KeycloakAuthorization { - interface KeycloakAuthorizationPromise { - then(onGrant: (rpt: string) => void, onDeny: () => void, onError: () => void): void; - } - - interface KeycloakAuthorizationInstance { - rpt: any; - config: { rpt_endpoint: string }; - - init(): void; - - /** - * This method enables client applications to better integrate with resource servers protected by a Keycloak - * policy enforcer. - * - * In this case, the resource server will respond with a 401 status code and a WWW-Authenticate header holding the - * necessary information to ask a Keycloak server for authorization data using both UMA and Entitlement protocol, - * depending on how the policy enforcer at the resource server was configured. - */ - authorize(wwwAuthenticateHeader: string): KeycloakAuthorizationPromise; - - /** - * Obtains all entitlements from a Keycloak server based on a given resourceServerId. - */ - entitlement(resourceServerId: string, entitlementRequest: {}): KeycloakAuthorizationPromise; - } -} diff --git a/types/keycloak-js/keycloak-js-tests.ts b/types/keycloak-js/keycloak-js-tests.ts deleted file mode 100644 index f0c78392b7..0000000000 --- a/types/keycloak-js/keycloak-js-tests.ts +++ /dev/null @@ -1,18 +0,0 @@ -import * as Keycloak from 'keycloak-js'; -import { - KeycloakInstance, - KeycloakError, - KeycloakFlow, - KeycloakInitOptions, - KeycloakLoginOptions, - KeycloakProfile, - KeycloakPromise, - KeycloakResponseMode, - KeycloakResponseType -} from 'keycloak-js'; - -import * as KeycloakAuthorization from 'keycloak-js/keycloak-authz'; -import { KeycloakAuthorizationPromise } from 'keycloak-js/keycloak-authz'; - -const keycloak = Keycloak(); -const keycloakAuthz = KeycloakAuthorization(keycloak); diff --git a/types/keycloak-js/tsconfig.json b/types/keycloak-js/tsconfig.json deleted file mode 100644 index 7c2834a781..0000000000 --- a/types/keycloak-js/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "keycloak-authz.d.ts", - "keycloak-js-tests.ts" - ] -} \ No newline at end of file diff --git a/types/keycloak-js/tslint.json b/types/keycloak-js/tslint.json deleted file mode 100644 index fe920e78bc..0000000000 --- a/types/keycloak-js/tslint.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - // TODOs - "no-duplicate-imports": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false - } -} From 11b5878146b7771c4081bfc40614c344316f1f81 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 21 Dec 2017 10:22:55 -0800 Subject: [PATCH 293/298] http-status-codes: Provides its own types (#22426) --- notNeededPackages.json | 6 + .../http-status-codes-tests.ts | 107 ------------------ types/http-status-codes/index.d.ts | 60 ---------- types/http-status-codes/tsconfig.json | 23 ---- types/http-status-codes/tslint.json | 79 ------------- 5 files changed, 6 insertions(+), 269 deletions(-) delete mode 100644 types/http-status-codes/http-status-codes-tests.ts delete mode 100644 types/http-status-codes/index.d.ts delete mode 100644 types/http-status-codes/tsconfig.json delete mode 100644 types/http-status-codes/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 0f92b3f3ac..921f7a96b3 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -306,6 +306,12 @@ "sourceRepoURL": "https://github.com/ivogabe/gulp-typescript", "asOfVersion": "2.13.0" }, + { + "libraryName": "http-status-codes", + "typingsPackageName": "http-status-codes", + "sourceRepoURL": "https://github.com/prettymuchbryce/node-http-status", + "asOfVersion": "1.2.0" + }, { "libraryName": "Facebook's Immutable", "typingsPackageName": "immutable", diff --git a/types/http-status-codes/http-status-codes-tests.ts b/types/http-status-codes/http-status-codes-tests.ts deleted file mode 100644 index 8f0e3aae2c..0000000000 --- a/types/http-status-codes/http-status-codes-tests.ts +++ /dev/null @@ -1,107 +0,0 @@ -import HttpStatusCodes = require("http-status-codes"); - -var ACCEPTED = HttpStatusCodes.ACCEPTED; -var BAD_GATEWAY = HttpStatusCodes.BAD_GATEWAY; -var BAD_REQUEST = HttpStatusCodes.BAD_REQUEST; -var CONFLICT = HttpStatusCodes.CONFLICT; -var CONTINUE = HttpStatusCodes.CONTINUE; -var CREATED = HttpStatusCodes.CREATED; -var EXPECTATION_FAILED = HttpStatusCodes.EXPECTATION_FAILED; -var FAILED_DEPENDENCY = HttpStatusCodes.FAILED_DEPENDENCY ; -var FORBIDDEN = HttpStatusCodes.FORBIDDEN; -var GATEWAY_TIMEOUT = HttpStatusCodes.GATEWAY_TIMEOUT; -var GONE = HttpStatusCodes.GONE; -var HTTP_VERSION_NOT_SUPPORTED = HttpStatusCodes.HTTP_VERSION_NOT_SUPPORTED; -var INSUFFICIENT_SPACE_ON_RESOURCE = HttpStatusCodes.INSUFFICIENT_SPACE_ON_RESOURCE; -var INSUFFICIENT_STORAGE = HttpStatusCodes.INSUFFICIENT_STORAGE; -var INTERNAL_SERVER_ERROR = HttpStatusCodes.INTERNAL_SERVER_ERROR; -var LENGTH_REQUIRED = HttpStatusCodes.LENGTH_REQUIRED; -var LOCKED = HttpStatusCodes.LOCKED; -var METHOD_FAILURE = HttpStatusCodes.METHOD_FAILURE; -var METHOD_NOT_ALLOWED = HttpStatusCodes.METHOD_NOT_ALLOWED; -var MOVED_PERMANENTLY = HttpStatusCodes.MOVED_PERMANENTLY; -var MOVED_TEMPORARILY = HttpStatusCodes.MOVED_TEMPORARILY; -var MULTI_STATUS = HttpStatusCodes.MULTI_STATUS; -var MULTIPLE_CHOICES = HttpStatusCodes.MULTIPLE_CHOICES; -var NETWORK_AUTHENTICATION_REQUIRED = HttpStatusCodes.NETWORK_AUTHENTICATION_REQUIRED; -var NO_CONTENT = HttpStatusCodes.NO_CONTENT; -var NON_AUTHORITATIVE_INFORMATION = HttpStatusCodes.NON_AUTHORITATIVE_INFORMATION; -var NOT_ACCEPTABLE = HttpStatusCodes.NOT_ACCEPTABLE; -var NOT_FOUND = HttpStatusCodes.NOT_FOUND; -var NOT_IMPLEMENTED = HttpStatusCodes.NOT_IMPLEMENTED; -var NOT_MODIFIED = HttpStatusCodes.NOT_MODIFIED; -var OK = HttpStatusCodes.OK; -var PARTIAL_CONTENT = HttpStatusCodes.PARTIAL_CONTENT; -var PAYMENT_REQUIRED = HttpStatusCodes.PAYMENT_REQUIRED; -var PRECONDITION_FAILED = HttpStatusCodes.PRECONDITION_FAILED; -var PRECONDITION_REQUIRED = HttpStatusCodes.PRECONDITION_REQUIRED; -var PROCESSING = HttpStatusCodes.PROCESSING; -var PROXY_AUTHENTICATION_REQUIRED = HttpStatusCodes.PROXY_AUTHENTICATION_REQUIRED; -var REQUEST_HEADER_FIELDS_TOO_LARGE = HttpStatusCodes.REQUEST_HEADER_FIELDS_TOO_LARGE; -var REQUEST_TIMEOUT = HttpStatusCodes.REQUEST_TIMEOUT; -var REQUEST_TOO_LONG = HttpStatusCodes.REQUEST_TOO_LONG; -var REQUEST_URI_TOO_LONG = HttpStatusCodes.REQUEST_URI_TOO_LONG; -var REQUESTED_RANGE_NOT_SATISFIABLE = HttpStatusCodes.REQUESTED_RANGE_NOT_SATISFIABLE; -var RESET_CONTENT = HttpStatusCodes.RESET_CONTENT; -var SEE_OTHER = HttpStatusCodes.SEE_OTHER; -var SERVICE_UNAVAILABLE = HttpStatusCodes.SERVICE_UNAVAILABLE; -var SWITCHING_PROTOCOLS = HttpStatusCodes.SWITCHING_PROTOCOLS; -var TEMPORARY_REDIRECT = HttpStatusCodes.TEMPORARY_REDIRECT; -var TOO_MANY_REQUESTS = HttpStatusCodes.TOO_MANY_REQUESTS; -var UNAUTHORIZED = HttpStatusCodes.UNAUTHORIZED; -var UNPROCESSABLE_ENTITY = HttpStatusCodes.UNPROCESSABLE_ENTITY; -var UNSUPPORTED_MEDIA_TYPE = HttpStatusCodes.UNSUPPORTED_MEDIA_TYPE; -var USE_PROXY = HttpStatusCodes.USE_PROXY; - -var ACCEPTED_Text = HttpStatusCodes.getStatusText(202); -var BAD_GATEWAY_Text = HttpStatusCodes.getStatusText(502); -var BAD_REQUEST_Text = HttpStatusCodes.getStatusText(400); -var CONFLICT_Text = HttpStatusCodes.getStatusText(409); -var CONTINUE_Text = HttpStatusCodes.getStatusText(100); -var CREATED_Text = HttpStatusCodes.getStatusText(201); -var EXPECTATION_FAILED_Text = HttpStatusCodes.getStatusText(417); -var FAILED_DEPENDENCY_Text = HttpStatusCodes.getStatusText(424); -var FORBIDDEN_Text = HttpStatusCodes.getStatusText(403); -var GATEWAY_TIMEOUT_Text = HttpStatusCodes.getStatusText(504); -var GONE_Text = HttpStatusCodes.getStatusText(410); -var HTTP_VERSION_NOT_SUPPORTED_Text = HttpStatusCodes.getStatusText(505); -var INSUFFICIENT_SPACE_ON_RESOURCE_Text = HttpStatusCodes.getStatusText(419); -var INSUFFICIENT_STORAGE_Text = HttpStatusCodes.getStatusText(507); -var INTERNAL_SERVER_ERROR_Text = HttpStatusCodes.getStatusText(500); -var LENGTH_REQUIRED_Text = HttpStatusCodes.getStatusText(411); -var LOCKED_Text = HttpStatusCodes.getStatusText(423); -var METHOD_FAILURE_Text = HttpStatusCodes.getStatusText(420); -var METHOD_NOT_ALLOWED_Text = HttpStatusCodes.getStatusText(405); -var MOVED_PERMANENTLY_Text = HttpStatusCodes.getStatusText(301); -var MOVED_TEMPORARILY_Text = HttpStatusCodes.getStatusText(302); -var MULTI_STATUS_Text = HttpStatusCodes.getStatusText(207); -var MULTIPLE_CHOICES_Text = HttpStatusCodes.getStatusText(300); -var NETWORK_AUTHENTICATION_REQUIRED_Text = HttpStatusCodes.getStatusText(511); -var NO_CONTENT_Text = HttpStatusCodes.getStatusText(204); -var NON_AUTHORITATIVE_INFORMATION_Text = HttpStatusCodes.getStatusText(203); -var NOT_ACCEPTABLE_Text = HttpStatusCodes.getStatusText(406); -var NOT_FOUND_Text = HttpStatusCodes.getStatusText(404); -var NOT_IMPLEMENTED_Text = HttpStatusCodes.getStatusText(501); -var NOT_MODIFIED_Text = HttpStatusCodes.getStatusText(304); -var OK_Text = HttpStatusCodes.getStatusText(200); -var PARTIAL_CONTENT_Text = HttpStatusCodes.getStatusText(206); -var PAYMENT_REQUIRED_Text = HttpStatusCodes.getStatusText(402); -var PRECONDITION_FAILED_Text = HttpStatusCodes.getStatusText(412); -var PRECONDITION_REQUIRED_Text = HttpStatusCodes.getStatusText(428); -var PROCESSING_Text = HttpStatusCodes.getStatusText(102); -var PROXY_AUTHENTICATION_REQUIRED_Text = HttpStatusCodes.getStatusText(407); -var REQUEST_HEADER_FIELDS_TOO_LARGE_Text = HttpStatusCodes.getStatusText(431); -var REQUEST_TIMEOUT_Text = HttpStatusCodes.getStatusText(408); -var REQUEST_TOO_LONG_Text = HttpStatusCodes.getStatusText(413); -var REQUEST_URI_TOO_LONG_Text = HttpStatusCodes.getStatusText(414); -var REQUESTED_RANGE_NOT_SATISFIABLE_Text = HttpStatusCodes.getStatusText(416); -var RESET_CONTENT_Text = HttpStatusCodes.getStatusText(205); -var SEE_OTHER_Text = HttpStatusCodes.getStatusText(303); -var SERVICE_UNAVAILABLE_Text = HttpStatusCodes.getStatusText(503); -var SWITCHING_PROTOCOLS_Text = HttpStatusCodes.getStatusText(101); -var TEMPORARY_REDIRECT_Text = HttpStatusCodes.getStatusText(307); -var TOO_MANY_REQUESTS_Text = HttpStatusCodes.getStatusText(429); -var UNAUTHORIZED_Text = HttpStatusCodes.getStatusText(401); -var UNPROCESSABLE_ENTITY_Text = HttpStatusCodes.getStatusText(422); -var UNSUPPORTED_MEDIA_TYPE_Text = HttpStatusCodes.getStatusText(415); -var USE_PROXY_Text = HttpStatusCodes.getStatusText(305); \ No newline at end of file diff --git a/types/http-status-codes/index.d.ts b/types/http-status-codes/index.d.ts deleted file mode 100644 index 082ce9b767..0000000000 --- a/types/http-status-codes/index.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -// Type definitions for Node.JS package http-status-codes v1.0.5 -// Project: https://github.com/prettymuchbryce/node-http-status -// Definitions by: Josh McCullough -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - - -export declare var ACCEPTED: number; -export declare var BAD_GATEWAY: number; -export declare var BAD_REQUEST: number; -export declare var CONFLICT: number; -export declare var CONTINUE: number; -export declare var CREATED: number; -export declare var EXPECTATION_FAILED: number; -export declare var FAILED_DEPENDENCY: number; -export declare var FORBIDDEN: number; -export declare var GATEWAY_TIMEOUT: number; -export declare var GONE: number; -export declare var HTTP_VERSION_NOT_SUPPORTED: number; -export declare var INSUFFICIENT_SPACE_ON_RESOURCE: number; -export declare var INSUFFICIENT_STORAGE: number; -export declare var INTERNAL_SERVER_ERROR: number; -export declare var LENGTH_REQUIRED: number; -export declare var LOCKED: number; -export declare var METHOD_FAILURE: number; -export declare var METHOD_NOT_ALLOWED: number; -export declare var MOVED_PERMANENTLY: number; -export declare var MOVED_TEMPORARILY: number; -export declare var MULTI_STATUS: number; -export declare var MULTIPLE_CHOICES: number; -export declare var NETWORK_AUTHENTICATION_REQUIRED: number; -export declare var NO_CONTENT: number; -export declare var NON_AUTHORITATIVE_INFORMATION: number; -export declare var NOT_ACCEPTABLE: number; -export declare var NOT_FOUND: number; -export declare var NOT_IMPLEMENTED: number; -export declare var NOT_MODIFIED: number; -export declare var OK: number; -export declare var PARTIAL_CONTENT: number; -export declare var PAYMENT_REQUIRED: number; -export declare var PRECONDITION_FAILED: number; -export declare var PRECONDITION_REQUIRED: number; -export declare var PROCESSING: number; -export declare var PROXY_AUTHENTICATION_REQUIRED: number; -export declare var REQUEST_HEADER_FIELDS_TOO_LARGE: number; -export declare var REQUEST_TIMEOUT: number; -export declare var REQUEST_TOO_LONG: number; -export declare var REQUEST_URI_TOO_LONG: number; -export declare var REQUESTED_RANGE_NOT_SATISFIABLE: number; -export declare var RESET_CONTENT: number; -export declare var SEE_OTHER: number; -export declare var SERVICE_UNAVAILABLE: number; -export declare var SWITCHING_PROTOCOLS: number; -export declare var TEMPORARY_REDIRECT: number; -export declare var TOO_MANY_REQUESTS: number; -export declare var UNAUTHORIZED: number; -export declare var UNPROCESSABLE_ENTITY: number; -export declare var UNSUPPORTED_MEDIA_TYPE: number; -export declare var USE_PROXY: number; - -export declare function getStatusText(statusCode: number): string; diff --git a/types/http-status-codes/tsconfig.json b/types/http-status-codes/tsconfig.json deleted file mode 100644 index c6e7cecee8..0000000000 --- a/types/http-status-codes/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "http-status-codes-tests.ts" - ] -} \ No newline at end of file diff --git a/types/http-status-codes/tslint.json b/types/http-status-codes/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/http-status-codes/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From f3e0c3d36fa99b727ef34688291094c7e4adb4ad Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 21 Dec 2017 11:14:40 -0800 Subject: [PATCH 294/298] iconv-lite: Provides its own types (#22428) --- notNeededPackages.json | 6 +++ types/iconv-lite/iconv-lite-tests.ts | 52 ------------------ types/iconv-lite/index.d.ts | 32 ----------- types/iconv-lite/tsconfig.json | 23 -------- types/iconv-lite/tslint.json | 79 ---------------------------- 5 files changed, 6 insertions(+), 186 deletions(-) delete mode 100644 types/iconv-lite/iconv-lite-tests.ts delete mode 100644 types/iconv-lite/index.d.ts delete mode 100644 types/iconv-lite/tsconfig.json delete mode 100644 types/iconv-lite/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 921f7a96b3..76ba44852f 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -312,6 +312,12 @@ "sourceRepoURL": "https://github.com/prettymuchbryce/node-http-status", "asOfVersion": "1.2.0" }, + { + "libraryName": "iconv-lite", + "typingsPackageName": "iconv-lite", + "sourceRepoURL": "https://github.com/ashtuchkin/iconv-lite", + "asOfVersion": "0.4.14" + }, { "libraryName": "Facebook's Immutable", "typingsPackageName": "immutable", diff --git a/types/iconv-lite/iconv-lite-tests.ts b/types/iconv-lite/iconv-lite-tests.ts deleted file mode 100644 index f89e84e195..0000000000 --- a/types/iconv-lite/iconv-lite-tests.ts +++ /dev/null @@ -1,52 +0,0 @@ -// Code examples from iconv-lite README - -import * as iconv from "iconv-lite"; - -import * as assert from "assert"; -import * as fs from "fs"; -import * as http from "http"; - -// Basic API -(() => { - // Convert from an encoded buffer to js string. - const str: string = iconv.decode(new Buffer([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251'); - - // Convert from js string to an encoded buffer. - const buf: Buffer = iconv.encode("Sample input string", 'win1251'); - - // Check if encoding is supported - const exists: boolean = iconv.encodingExists("us-ascii"); -})(); - -// Streaming API -(() => { - // Decode stream (from binary stream to js strings) - http.createServer(function(req, res) { - var converterStream = iconv.decodeStream('win1251'); - req.pipe(converterStream); - - converterStream.on('data', function(str: string) { - console.log(str); // Do something with decoded strings, chunk-by-chunk. - }); - }); - - // Convert encoding streaming example - fs.createReadStream('file-in-win1251.txt') - .pipe(iconv.decodeStream('win1251')) - .pipe(iconv.encodeStream('ucs2')) - .pipe(fs.createWriteStream('file-in-ucs2.txt')); - - // Sugar: all encode/decode streams have .collect(cb) method to accumulate data. - http.createServer(function(req, res) { - req.pipe(iconv.decodeStream('win1251')).collect(function(err, body) { - assert(typeof body == 'string'); - console.log(body); // full request body string - }); - }); -})(); - -// Extend Node.js own encodings -(() => { - iconv.extendNodeEncodings(); - iconv.undoExtendNodeEncodings(); -})(); diff --git a/types/iconv-lite/index.d.ts b/types/iconv-lite/index.d.ts deleted file mode 100644 index 4c0f1ecf11..0000000000 --- a/types/iconv-lite/index.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Type definitions for iconv-lite -// Project: https://github.com/ashtuchkin/iconv-lite -// Definitions by: Martin Poelstra -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -import stream = require("stream"); - -export interface Options { - stripBOM: boolean; - addBOM: boolean; - defaultEncoding: string; -} - -export function decode(buffer: Buffer, encoding: string, options?: Options): string; -export function encode(source: string, encoding: string, options?: Options): Buffer; -export function encodingExists(encoding: string): boolean; - -export class DecodeStream extends stream.Transform { - collect(cb: (err: Error, decoded: string) => any): DecodeStream; -} - -export class EncodeStream extends stream.Transform { - collect(cb: (err: Error, decoded: Buffer) => any): EncodeStream; -} - -export function decodeStream(encoding: string, options?: Options): DecodeStream; -export function encodeStream(encoding: string, options?: Options): EncodeStream; - -export function extendNodeEncodings(): void; -export function undoExtendNodeEncodings(): void; diff --git a/types/iconv-lite/tsconfig.json b/types/iconv-lite/tsconfig.json deleted file mode 100644 index 27ea4716bf..0000000000 --- a/types/iconv-lite/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "iconv-lite-tests.ts" - ] -} \ No newline at end of file diff --git a/types/iconv-lite/tslint.json b/types/iconv-lite/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/iconv-lite/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} From b19ec6c9649c5bbfffa10e760f5b4d8643f33679 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 21 Dec 2017 16:04:59 -0800 Subject: [PATCH 295/298] zetapush-js: Provides its own types (#22430) --- notNeededPackages.json | 6 + types/zetapush-js/index.d.ts | 187 ------------------------- types/zetapush-js/tsconfig.json | 23 --- types/zetapush-js/tslint.json | 1 - types/zetapush-js/zetapush-js-tests.ts | 23 --- 5 files changed, 6 insertions(+), 234 deletions(-) delete mode 100644 types/zetapush-js/index.d.ts delete mode 100644 types/zetapush-js/tsconfig.json delete mode 100644 types/zetapush-js/tslint.json delete mode 100644 types/zetapush-js/zetapush-js-tests.ts diff --git a/notNeededPackages.json b/notNeededPackages.json index 76ba44852f..80e3cb27ba 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -972,6 +972,12 @@ "sourceRepoURL": "github.com/node-xmpp/node-xmpp/", "asOfVersion": "1.2.0" }, + { + "libraryName": "zetapush-js", + "typingsPackageName": "zetapush-js", + "sourceRepoURL": "https://github.com/zetapush/zetapush-js", + "asOfVersion": "3.1.2" + }, { "libraryName": "Zone.js", "typingsPackageName": "zone.js", diff --git a/types/zetapush-js/index.d.ts b/types/zetapush-js/index.d.ts deleted file mode 100644 index b6d8d1d9e3..0000000000 --- a/types/zetapush-js/index.d.ts +++ /dev/null @@ -1,187 +0,0 @@ -// Type definitions for zetapush-js 3.1 -// Project: https://github.com/zetapush/zetapush-js -// Definitions by: ghoullier -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export interface HandshakeFields { - ext: any; -} - -export interface AbstractHandshakeOptions { - authType: string; - sandboxId: string; - deploymentId: string; -} - -export interface CredentialsHandshakeOptions { - authType: string; - deploymentId: string; - login: string; - password: string; -} - -export interface TokenHandshakeOptions { - authType: string; - deploymentId: string; - token: string; -} - -export interface AbstractHandshake { - authType: string; - authVersion: string; - sandboxId: string; - deploymentId: string; - getHandshakeFields(client: Client): HandshakeFields; -} - -export interface CredentialsAuthData { - login: string; - password: string; -} - -export interface CredentialsHandshake extends AbstractHandshake { - login: string; - password: string; - authData: CredentialsAuthData; -} - -export interface TokenAuthData { - token: string; -} - -export interface TokenHandshake extends AbstractHandshake { - token: string; - authData: TokenAuthData; -} - -export type AuthenticationCallback = () => AbstractHandshake; - -export type AsyncMacroServicePublisher = (method: string, parameters: any, hardFail?: boolean, debug?: number) => Promise; - -export type MacroServicePublisher = (method: string, parameters: any, hardFail?: boolean, debug?: number) => void; - -export type ServicePublisher = (method: string, parameters: any) => void; - -export interface Options { - apiUrl?: string; - sandboxId: string; - forceHttps?: boolean; - resource?: string; - transports?: any[]; -} - -export interface ClientOptions extends Options { - authentication(): AbstractHandshake; -} - -export interface WeakClientOptions extends Options { - deploymentId?: string; -} - -export interface Services { - Macro: AsyncMacroService; - Messaging: Service; -} - -export interface Service { - DEFAULT_DEPLOYMENT_ID: string; - $publish: ServicePublisher; -} - -export interface AsyncMacroService { - DEFAULT_DEPLOYMENT_ID: string; - $publish: AsyncMacroServicePublisher; -} - -export interface MacroService { - DEFAULT_DEPLOYMENT_ID: string; - $publish: MacroServicePublisher; -} - -export interface ServiceDeclaration { - Type: Service; - deploymentId?: string; -} - -export interface Token { - token: string; -} - -export interface Credentials { - login: string; - password: string; -} - -export interface ClientHelper { - authentication: AuthenticationCallback; - servers: Promise; - getUniqRequestId(): string; -} - -export type ConnectionStatusHandler = number; - -export namespace Authentication { - function delegating({ token }: TokenAuthData): TokenHandshake; - function simple({ login, password }: CredentialsAuthData): CredentialsHandshake; - function weak({ token }: TokenAuthData): TokenHandshake; -} - -export interface ConnectionStatusListener { - onConnectionBroken(): void; - onConnectionClosed(): void; - onConnectionEstablished(): void; - onConnectionToServerFail(failure: any): void; - onConnectionWillClose(): void; - onFailedHandshake(failure: any): void; - onMessageLost(): void; - onNoServerUrlAvailable(): void; - onSuccessfulHandshake(authentication: any): void; -} - -export class Client { - helper: ClientHelper; - constructor(options: ClientOptions); - addConnectionStatusListener(listener: ConnectionStatusListener): ConnectionStatusHandler; - connect(): void; - createService(declaration: ServiceDeclaration): Service; - createAsyncMacroService(declaration: ServiceDeclaration): AsyncMacroService; - disconnect(): void; - isConnected(): boolean; - getSandboxId(): string; - getResource(): string; - getUserId(): string; - removeConnectionStatusListener(listener: ConnectionStatusHandler): void; - setAuthentication(authentication: AuthenticationCallback): void; - setLogLevel(level: string): void; - setResource(resource: string): void; - unsubscribe(service: Service): void; - // - onConnectionBroken(handler: () => void): void; - onConnectionClosed(handler: () => void): void; - onConnectionEstablished(handler: () => void): void; - onConnectionToServerFail(handler: (failure: any) => void): void; - onConnectionWillClose(handler: () => void): void; - onFailedHandshake(handler: (failure: any) => void): void; - onMessageLost(handler: () => void): void; - onNoServerUrlAvailable(handler: () => void): void; - onSuccessfulHandshake(handler: (authentication: any) => void): void; -} - -export class SmartClient extends Client { - getCredentials(): any; - getSession(): any; - hasCredentials(): boolean; - isStronglyAuthenticated(session?: any): boolean; - isWeaklyAuthenticated(session?: any): boolean; - setCredentials(credentials: any): void; -} -export class WeakClient extends Client { - constructor(options: WeakClientOptions); - getToken(): Token; -} - -export const services: Services; - -export const VERSION: string; - -export as namespace ZetaPush; diff --git a/types/zetapush-js/tsconfig.json b/types/zetapush-js/tsconfig.json deleted file mode 100644 index 3ce2c2d301..0000000000 --- a/types/zetapush-js/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "zetapush-js-tests.ts" - ] -} \ No newline at end of file diff --git a/types/zetapush-js/tslint.json b/types/zetapush-js/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/zetapush-js/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } diff --git a/types/zetapush-js/zetapush-js-tests.ts b/types/zetapush-js/zetapush-js-tests.ts deleted file mode 100644 index 46eb822680..0000000000 --- a/types/zetapush-js/zetapush-js-tests.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Authentication, Client, WeakClient } from 'zetapush-js'; - -const weak = new WeakClient({ - sandboxId: '' -}); - -weak.onConnectionEstablished(() => { - // onConnectionEstablished; -}); -weak.connect(); - -const client = new Client({ - apiUrl: '', - sandboxId: '', - authentication: () => Authentication.simple({ - login: 'login', - password: 'password' - }) -}); -client.onConnectionEstablished(() => { - // onConnectionEstablished; -}); -client.connect(); From b30b11a7359f6dd1ddf572b7565545b26192a1d2 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 21 Dec 2017 18:20:02 -0800 Subject: [PATCH 296/298] fecha: Provides its own types (#22429) --- notNeededPackages.json | 6 ++ types/fecha/fecha-tests.ts | 124 ------------------------------------- types/fecha/index.d.ts | 52 ---------------- types/fecha/tsconfig.json | 23 ------- types/fecha/tslint.json | 1 - 5 files changed, 6 insertions(+), 200 deletions(-) delete mode 100644 types/fecha/fecha-tests.ts delete mode 100644 types/fecha/index.d.ts delete mode 100644 types/fecha/tsconfig.json delete mode 100644 types/fecha/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 80e3cb27ba..d42bb163dc 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -270,6 +270,12 @@ "sourceRepoURL": "https://www.npmjs.com/package/fast-simplex-noise", "asOfVersion": "3.0.0" }, + { + "libraryName": "fecha", + "typingsPackageName": "fecha", + "sourceRepoURL": "https://github.com/taylorhakes/fecha", + "asOfVersion": "2.3.1" + }, { "libraryName": "FineUploader", "typingsPackageName": "fine-uploader", diff --git a/types/fecha/fecha-tests.ts b/types/fecha/fecha-tests.ts deleted file mode 100644 index 0d0ce48638..0000000000 --- a/types/fecha/fecha-tests.ts +++ /dev/null @@ -1,124 +0,0 @@ -import fecha = require('fecha'); - -// test fecha.parse -fecha.parse("February 3rd, 2014", "MMMM Do, YYYY"); -fecha.parse("5/3/98", "shortDate"); - -// test override fecha.i18n -fecha.i18n = { - dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"], - dayNames: [ - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday" - ], - monthNamesShort: [ - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec" - ], - monthNames: [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December" - ], - amPm: ["am", "pm"], - DoFn(D: number) { - return D + "th"; - } -}; - -// just change one default mask -fecha.masks.shortDate = "M/D/YY"; - -// test override fecha.masks with an object. Must implement all keys. -// if you want to implement partially, use -// fecha.masks = Object.assign(fecha.masks, {shortDate: 'M/D/YY'}) for example. -fecha.masks = { - default: "ddd MMM DD YYYY HH:mm:ss", - shortDate: "M/D/YY", - mediumDate: "MMM D, YYYY", - longDate: "MMMM D, YYYY", - fullDate: "dddd, MMMM D, YYYY", - shortTime: "HH:mm", - mediumTime: "HH:mm:ss", - longTime: "HH:mm:ss.SSS" -}; - -// test add custom named mask. -// fecha.masks.myMask = "HH:mm:ss YY/MM/DD"; does not work for now. -fecha.masks['myMask'] = "HH:mm:ss YY/MM/DD"; - -// test fecha.format without i18nSettings, with Date object. -fecha.format(new Date(2014, 5, 6, 14, 10, 45), "myMask"); - -// test fecha.format without i18nSettings with number. -fecha.format(Date.now(), "myMask"); - -// test override i18nSettings with fecha.format -fecha.format(new Date(2014, 5, 6, 14, 10, 45), "myMask", { - dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"], - dayNames: [ - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday" - ], - monthNamesShort: [ - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec" - ], - monthNames: [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December" - ], - amPm: ["am", "pm"], - DoFn(D: number) { - return D + "th"; - } -}); diff --git a/types/fecha/index.d.ts b/types/fecha/index.d.ts deleted file mode 100644 index f68d26a316..0000000000 --- a/types/fecha/index.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -// Type definitions for fecha 2.3 -// Project: https://github.com/taylorhakes/fecha -// Definitions by: Goh Yisheng -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export type Days = [string, string, string, string, string, string, string]; - -export type Months = [ - string, - string, - string, - string, - string, - string, - string, - string, - string, - string, - string, - string -]; - -export interface i18nSettings { - amPm: [string, string]; - dayNames: Days; - dayNamesShort: Days; - monthNames: Months; - monthNamesShort: Months; - DoFn(D: number): string; -} - -export interface Masks { - default: string; - fullDate: string; - longDate: string; - longTime: string; - mediumDate: string; - mediumTime: string; - shortDate: string; - shortTime: string; - [myMask: string]: string; -} - -export let masks: Masks; - -export let i18n: i18nSettings; - -export function format(dateObj: Date | number, mask: string, i18nSettings?: i18nSettings): string; - -export function parse(dateStr: string, format: string, i18nSettings?: i18nSettings): Date; - -export as namespace Fecha; diff --git a/types/fecha/tsconfig.json b/types/fecha/tsconfig.json deleted file mode 100644 index 8582f99228..0000000000 --- a/types/fecha/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "fecha-tests.ts" - ] -} \ No newline at end of file diff --git a/types/fecha/tslint.json b/types/fecha/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/fecha/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } From 2419274a40c0a07525df0e2b8b0423ab38d96b7f Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 21 Dec 2017 19:47:54 -0800 Subject: [PATCH 297/298] docker-file-parser: Provides its own types (#22367) * docker-file-parser: Provides its own types * Fix url --- notNeededPackages.json | 6 +++++ .../docker-file-parser-tests.ts | 25 ------------------- types/docker-file-parser/index.d.ts | 21 ---------------- types/docker-file-parser/tsconfig.json | 23 ----------------- types/docker-file-parser/tslint.json | 1 - 5 files changed, 6 insertions(+), 70 deletions(-) delete mode 100644 types/docker-file-parser/docker-file-parser-tests.ts delete mode 100644 types/docker-file-parser/index.d.ts delete mode 100644 types/docker-file-parser/tsconfig.json delete mode 100644 types/docker-file-parser/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index d42bb163dc..8250bf4b0f 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -198,6 +198,12 @@ "sourceRepoURL": "https://github.com/dfahlander/Dexie.js", "asOfVersion": "1.3.1" }, + { + "libraryName": "docker-file-parser", + "typingsPackageName": "docker-file-parser", + "sourceRepoURL": "https://github.com/joyent/docker-file-parser", + "asOfVersion": "1.0.3" + }, { "libraryName": "dot-case", "typingsPackageName": "dot-case", diff --git a/types/docker-file-parser/docker-file-parser-tests.ts b/types/docker-file-parser/docker-file-parser-tests.ts deleted file mode 100644 index 21cd715f47..0000000000 --- a/types/docker-file-parser/docker-file-parser-tests.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { parse, CommandEntry, ParseOptions } from 'docker-file-parser'; - -const file = ` -FROM node:8 - -ADD . /opt/ -WORKDIR /opt - -RUN npm install --production - -EXPOSE 8080 -VOLUME /opt/scripts - -CMD ["npm", "start"] -`; - -const options: ParseOptions = { - includeComments: false -}; - -const result: CommandEntry[] = parse(file, options); -const line1Name = result[0].name; -const line1Number = result[0].lineno; -const line1Args = result[0].args; -const line1Raw = result[0].raw; diff --git a/types/docker-file-parser/index.d.ts b/types/docker-file-parser/index.d.ts deleted file mode 100644 index 5263ef3353..0000000000 --- a/types/docker-file-parser/index.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Type definitions for docker-file-parser 1.0 -// Project: https://github.com/joyent/docker-file-parse -// Definitions by: Yash Kulshrestha -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export interface CommandEntry { - name: string; - args: string[]; - lineno: number; - raw: string; - error?: string; -} - -export interface ParseOptions { - includeComments: boolean; -} - -export function parse( - contents: string, - options?: ParseOptions -): CommandEntry[]; diff --git a/types/docker-file-parser/tsconfig.json b/types/docker-file-parser/tsconfig.json deleted file mode 100644 index 7c529341c4..0000000000 --- a/types/docker-file-parser/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "strictFunctionTypes": true - }, - "files": [ - "index.d.ts", - "docker-file-parser-tests.ts" - ] -} diff --git a/types/docker-file-parser/tslint.json b/types/docker-file-parser/tslint.json deleted file mode 100644 index 3db14f85ea..0000000000 --- a/types/docker-file-parser/tslint.json +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "dtslint/dt.json" } From d449675b98048c12371e70ae71269907f3f03ffb Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 22 Dec 2017 15:54:02 -0800 Subject: [PATCH 298/298] timezonecomplete: Provides its own types (#22364) --- notNeededPackages.json | 6 + types/timezonecomplete/index.d.ts | 1519 ----------------- .../timezonecomplete-tests.ts | 234 --- types/timezonecomplete/tsconfig.json | 23 - types/timezonecomplete/tslint.json | 79 - 5 files changed, 6 insertions(+), 1855 deletions(-) delete mode 100644 types/timezonecomplete/index.d.ts delete mode 100644 types/timezonecomplete/timezonecomplete-tests.ts delete mode 100644 types/timezonecomplete/tsconfig.json delete mode 100644 types/timezonecomplete/tslint.json diff --git a/notNeededPackages.json b/notNeededPackages.json index 8250bf4b0f..cfcdb8861a 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -882,6 +882,12 @@ "sourceRepoURL": "http://gcanti.github.io/tcomb/guide/index.html", "asOfVersion": "2.6.0" }, + { + "libraryName": "timezonecomplete", + "typingsPackageName": "timezonecomplete", + "sourceRepoURL": "https://github.com/SpiritIT/timezonecomplete", + "asOfVersion": "5.5.0" + }, { "libraryName": "title-case", "typingsPackageName": "title-case", diff --git a/types/timezonecomplete/index.d.ts b/types/timezonecomplete/index.d.ts deleted file mode 100644 index 0f8f94d420..0000000000 --- a/types/timezonecomplete/index.d.ts +++ /dev/null @@ -1,1519 +0,0 @@ -// Type definitions for timezonecomplete 1.15.0 -// Project: https://github.com/SpiritIT/timezonecomplete -// Definitions by: Rogier Schouten -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare module 'timezonecomplete' { - import basics = require("__timezonecomplete/basics"); - export import TimeUnit = basics.TimeUnit; - export import WeekDay = basics.WeekDay; - export import timeUnitToMilliseconds = basics.timeUnitToMilliseconds; - export import isLeapYear = basics.isLeapYear; - export import daysInMonth = basics.daysInMonth; - export import daysInYear = basics.daysInYear; - export import firstWeekDayOfMonth = basics.firstWeekDayOfMonth; - export import lastWeekDayOfMonth = basics.lastWeekDayOfMonth; - export import weekDayOnOrAfter = basics.weekDayOnOrAfter; - export import weekDayOnOrBefore = basics.weekDayOnOrBefore; - export import weekNumber = basics.weekNumber; - export import weekOfMonth = basics.weekOfMonth; - export import dayOfYear = basics.dayOfYear; - export import secondOfDay = basics.secondOfDay; - export import timeUnitToString = basics.timeUnitToString; - export import stringToTimeUnit = basics.stringToTimeUnit; - import datetime = require("__timezonecomplete/datetime"); - export import DateTime = datetime.DateTime; - export import now = datetime.now; - export import nowLocal = datetime.nowLocal; - export import nowUtc = datetime.nowUtc; - import duration = require("__timezonecomplete/duration"); - export import Duration = duration.Duration; - export import years = duration.years; - export import months = duration.months; - export import days = duration.days; - export import hours = duration.hours; - export import minutes = duration.minutes; - export import seconds = duration.seconds; - export import milliseconds = duration.milliseconds; - import javascript = require("__timezonecomplete/javascript"); - export import DateFunctions = javascript.DateFunctions; - import period = require("__timezonecomplete/period"); - export import Period = period.Period; - export import PeriodDst = period.PeriodDst; - export import periodDstToString = period.periodDstToString; - import timesource = require("__timezonecomplete/timesource"); - export import TimeSource = timesource.TimeSource; - export import RealTimeSource = timesource.RealTimeSource; - import timezone = require("__timezonecomplete/timezone"); - export import NormalizeOption = timezone.NormalizeOption; - export import TimeZoneKind = timezone.TimeZoneKind; - export import TimeZone = timezone.TimeZone; - export import local = timezone.local; - export import utc = timezone.utc; - export import zone = timezone.zone; - import globals = require("__timezonecomplete/globals"); - export import min = globals.min; - export import max = globals.max; -} - -declare module '__timezonecomplete/basics' { - import javascript = require("__timezonecomplete/javascript"); - import DateFunctions = javascript.DateFunctions; - /** - * Day-of-week. Note the enum values correspond to JavaScript day-of-week: - * Sunday = 0, Monday = 1 etc - */ - export enum WeekDay { - Sunday = 0, - Monday = 1, - Tuesday = 2, - Wednesday = 3, - Thursday = 4, - Friday = 5, - Saturday = 6, - } - /** - * Time units - */ - export enum TimeUnit { - Millisecond = 0, - Second = 1, - Minute = 2, - Hour = 3, - Day = 4, - Week = 5, - Month = 6, - Year = 7, - /** - * End-of-enum marker, do not use - */ - MAX = 8, - } - /** - * Approximate number of milliseconds for a time unit. - * A day is assumed to have 24 hours, a month is assumed to equal 30 days - * and a year is set to 360 days (because 12 months of 30 days). - * - * @param unit Time unit e.g. TimeUnit.Month - * @returns The number of milliseconds. - */ - export function timeUnitToMilliseconds(unit: TimeUnit): number; - /** - * Time unit to lowercase string. If amount is specified, then the string is put in plural form - * if necessary. - * @param unit The unit - * @param amount If this is unequal to -1 and 1, then the result is pluralized - */ - export function timeUnitToString(unit: TimeUnit, amount?: number): string; - export function stringToTimeUnit(s: string): TimeUnit; - /** - * @return True iff the given year is a leap year. - */ - export function isLeapYear(year: number): boolean; - /** - * The days in a given year - */ - export function daysInYear(year: number): number; - /** - * @param year The full year - * @param month The month 1-12 - * @return The number of days in the given month - */ - export function daysInMonth(year: number, month: number): number; - /** - * Returns the day of the year of the given date [0..365]. January first is 0. - * - * @param year The year e.g. 1986 - * @param month Month 1-12 - * @param day Day of month 1-31 - */ - export function dayOfYear(year: number, month: number, day: number): number; - /** - * Returns the last instance of the given weekday in the given month - * - * @param year The year - * @param month the month 1-12 - * @param weekDay the desired week day - * - * @return the last occurrence of the week day in the month - */ - export function lastWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number; - /** - * Returns the first instance of the given weekday in the given month - * - * @param year The year - * @param month the month 1-12 - * @param weekDay the desired week day - * - * @return the first occurrence of the week day in the month - */ - export function firstWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number; - /** - * Returns the day-of-month that is on the given weekday and which is >= the given day. - * Throws if the month has no such day. - */ - export function weekDayOnOrAfter(year: number, month: number, day: number, weekDay: WeekDay): number; - /** - * Returns the day-of-month that is on the given weekday and which is <= the given day. - * Throws if the month has no such day. - */ - export function weekDayOnOrBefore(year: number, month: number, day: number, weekDay: WeekDay): number; - /** - * The week of this month. There is no official standard for this, - * but we assume the same rules for the weekNumber (i.e. - * week 1 is the week that has the 4th day of the month in it) - * - * @param year The year - * @param month The month [1-12] - * @param day The day [1-31] - * @return Week number [1-5] - */ - export function weekOfMonth(year: number, month: number, day: number): number; - /** - * The ISO 8601 week number for the given date. Week 1 is the week - * that has January 4th in it, and it starts on Monday. - * See https://en.wikipedia.org/wiki/ISO_week_date - * - * @param year Year e.g. 1988 - * @param month Month 1-12 - * @param day Day of month 1-31 - * - * @return Week number 1-53 - */ - export function weekNumber(year: number, month: number, day: number): number; - /** - * Convert a unix milli timestamp into a TimeT structure. - * This does NOT take leap seconds into account. - */ - export function unixToTimeNoLeapSecs(unixMillis: number): TimeStruct; - /** - * Convert a year, month, day etc into a unix milli timestamp. - * This does NOT take leap seconds into account. - * - * @param year Year e.g. 1970 - * @param month Month 1-12 - * @param day Day 1-31 - * @param hour Hour 0-23 - * @param minute Minute 0-59 - * @param second Second 0-59 (no leap seconds) - * @param milli Millisecond 0-999 - */ - export function timeToUnixNoLeapSecs(year?: number, month?: number, day?: number, hour?: number, minute?: number, second?: number, milli?: number): number; - /** - * Convert a TimeT structure into a unix milli timestamp. - * This does NOT take leap seconds into account. - */ - export function timeToUnixNoLeapSecs(tm: TimeStruct): number; - /** - * Return the day-of-week. - * This does NOT take leap seconds into account. - */ - export function weekDayNoLeapSecs(unixMillis: number): WeekDay; - /** - * N-th second in the day, counting from 0 - */ - export function secondOfDay(hour: number, minute: number, second: number): number; - /** - * Basic representation of a date and time - */ - export class TimeStruct { - /** - * Year, 1970-... - */ - year: number; - /** - * Month 1-12 - */ - month: number; - /** - * Day of month, 1-31 - */ - day: number; - /** - * Hour 0-23 - */ - hour: number; - /** - * Minute 0-59 - */ - minute: number; - /** - * Seconds, 0-59 - */ - second: number; - /** - * Milliseconds 0-999 - */ - milli: number; - /** - * Create a TimeStruct from a number of unix milliseconds - */ - static fromUnix(unixMillis: number): TimeStruct; - /** - * Create a TimeStruct from a JavaScript date - * - * @param d The date - * @param df Which functions to take (getX() or getUTCX()) - */ - static fromDate(d: Date, df: DateFunctions): TimeStruct; - /** - * Returns a TimeStruct from an ISO 8601 string WITHOUT time zone - */ - static fromString(s: string): TimeStruct; - /** - * Constructor - * - * @param year Year e.g. 1970 - * @param month Month 1-12 - * @param day Day 1-31 - * @param hour Hour 0-23 - * @param minute Minute 0-59 - * @param second Second 0-59 (no leap seconds) - * @param milli Millisecond 0-999 - */ - constructor( - /** - * Year, 1970-... - */ - year?: number, - /** - * Month 1-12 - */ - month?: number, - /** - * Day of month, 1-31 - */ - day?: number, - /** - * Hour 0-23 - */ - hour?: number, - /** - * Minute 0-59 - */ - minute?: number, - /** - * Seconds, 0-59 - */ - second?: number, - /** - * Milliseconds 0-999 - */ - milli?: number); - /** - * Validate a TimeStruct, returns false if invalid. - */ - validate(): boolean; - /** - * The day-of-year 0-365 - */ - yearDay(): number; - /** - * Returns this time as a unix millisecond timestamp - * Does NOT take leap seconds into account. - */ - toUnixNoLeapSecs(): number; - /** - * Deep equals - */ - equals(other: TimeStruct): boolean; - /** - * < operator - */ - lessThan(other: TimeStruct): boolean; - clone(): TimeStruct; - valueOf(): number; - /** - * ISO 8601 string YYYY-MM-DDThh:mm:ss.nnn - */ - toString(): string; - inspect(): string; - } -} - -declare module '__timezonecomplete/datetime' { - import basics = require("__timezonecomplete/basics"); - import WeekDay = basics.WeekDay; - import TimeUnit = basics.TimeUnit; - import duration = require("__timezonecomplete/duration"); - import Duration = duration.Duration; - import javascript = require("__timezonecomplete/javascript"); - import DateFunctions = javascript.DateFunctions; - import timesource = require("__timezonecomplete/timesource"); - import TimeSource = timesource.TimeSource; - import timezone = require("__timezonecomplete/timezone"); - import TimeZone = timezone.TimeZone; - /** - * Current date+time in local time - */ - export function nowLocal(): DateTime; - /** - * Current date+time in UTC time - */ - export function nowUtc(): DateTime; - /** - * Current date+time in the given time zone - * @param timeZone The desired time zone (optional, defaults to UTC). - */ - export function now(timeZone?: TimeZone): DateTime; - /** - * DateTime class which is time zone-aware - * and which can be mocked for testing purposes. - */ - export class DateTime { - /** - * Actual time source in use. Setting this property allows to - * fake time in tests. DateTime.nowLocal() and DateTime.nowUtc() - * use this property for obtaining the current time. - */ - static timeSource: TimeSource; - /** - * Current date+time in local time - */ - static nowLocal(): DateTime; - /** - * Current date+time in UTC time - */ - static nowUtc(): DateTime; - /** - * Current date+time in the given time zone - * @param timeZone The desired time zone (optional, defaults to UTC). - */ - static now(timeZone?: TimeZone): DateTime; - /** - * Create a DateTime from a Lotus 123 / Microsoft Excel date-time value - * i.e. a double representing days since 1-1-1900 where 1900 is incorrectly seen as leap year - */ - static fromExcel(n: number, timeZone?: TimeZone): DateTime; - /** - * Constructor. Creates current time in local timezone. - */ - constructor(); - /** - * Constructor - * Non-existing local times are normalized by rounding up to the next DST offset. - * - * @param isoString String in ISO 8601 format. Instead of ISO time zone, - * it may include a space and then and IANA time zone. - * e.g. "2007-04-05T12:30:40.500" (no time zone, naive date) - * e.g. "2007-04-05T12:30:40.500+01:00" (UTC offset without daylight saving time) - * or "2007-04-05T12:30:40.500Z" (UTC) - * or "2007-04-05T12:30:40.500 Europe/Amsterdam" (IANA time zone, with daylight saving time if applicable) - * @param timeZone if given, the date in the string is assumed to be in this time zone. - * Note that it is NOT CONVERTED to the time zone. Useful - * for strings without a time zone - */ - constructor(isoString: string, timeZone?: TimeZone); - /** - * Constructor. You provide a date, then you say whether to take the - * date.getYear()/getXxx methods or the date.getUTCYear()/date.getUTCXxx methods, - * and then you state which time zone that date is in. - * Non-existing local times are normalized by rounding up to the next DST offset. - * Note that the Date class has bugs and inconsistencies when constructing them with times around - * DST changes. - * - * @param date A date object. - * @param getters Specifies which set of Date getters contains the date in the given time zone: the - * Date.getXxx() methods or the Date.getUTCXxx() methods. - * @param timeZone The time zone that the given date is assumed to be in (may be null for unaware dates) - */ - constructor(date: Date, getFuncs: DateFunctions, timeZone?: TimeZone); - /** - * Constructor. Note that unlike JavaScript dates we require fields to be in normal ranges. - * Use the add(duration) or sub(duration) for arithmetic. - * @param year The full year (e.g. 2014) - * @param month The month [1-12] (note this deviates from JavaScript Date) - * @param day The day of the month [1-31] - * @param hour The hour of the day [0-24) - * @param minute The minute of the hour [0-59] - * @param second The second of the minute [0-59] - * @param millisecond The millisecond of the second [0-999] - * @param timeZone The time zone, or null (for unaware dates) - */ - constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, timeZone?: TimeZone); - /** - * Constructor - * @param unixTimestamp milliseconds since 1970-01-01T00:00:00.000 - * @param timeZone the time zone that the timestamp is assumed to be in (usually UTC). - */ - constructor(unixTimestamp: number, timeZone?: TimeZone); - /** - * @return a copy of this object - */ - clone(): DateTime; - /** - * @return The time zone that the date is in. May be null for unaware dates. - */ - zone(): TimeZone; - /** - * Zone name abbreviation at this time - * @param dstDependent (default true) set to false for a DST-agnostic abbreviation - * @return The abbreviation - */ - zoneAbbreviation(dstDependent?: boolean): string; - /** - * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates. - */ - offset(): number; - /** - * @return The full year e.g. 2014 - */ - year(): number; - /** - * @return The month 1-12 (note this deviates from JavaScript Date) - */ - month(): number; - /** - * @return The day of the month 1-31 - */ - day(): number; - /** - * @return The hour 0-23 - */ - hour(): number; - /** - * @return the minutes 0-59 - */ - minute(): number; - /** - * @return the seconds 0-59 - */ - second(): number; - /** - * @return the milliseconds 0-999 - */ - millisecond(): number; - /** - * @return the day-of-week (the enum values correspond to JavaScript - * week day numbers) - */ - weekDay(): WeekDay; - /** - * Returns the day number within the year: Jan 1st has number 0, - * Jan 2nd has number 1 etc. - * - * @return the day-of-year [0-366] - */ - dayOfYear(): number; - /** - * The ISO 8601 week number. Week 1 is the week - * that has January 4th in it, and it starts on Monday. - * See https://en.wikipedia.org/wiki/ISO_week_date - * - * @return Week number [1-53] - */ - weekNumber(): number; - /** - * The week of this month. There is no official standard for this, - * but we assume the same rules for the weekNumber (i.e. - * week 1 is the week that has the 4th day of the month in it) - * - * @return Week number [1-5] - */ - weekOfMonth(): number; - /** - * Returns the number of seconds that have passed on the current day - * Does not consider leap seconds - * - * @return seconds [0-86399] - */ - secondOfDay(): number; - /** - * @return Milliseconds since 1970-01-01T00:00:00.000Z - */ - unixUtcMillis(): number; - /** - * @return The full year e.g. 2014 - */ - utcYear(): number; - /** - * @return The UTC month 1-12 (note this deviates from JavaScript Date) - */ - utcMonth(): number; - /** - * @return The UTC day of the month 1-31 - */ - utcDay(): number; - /** - * @return The UTC hour 0-23 - */ - utcHour(): number; - /** - * @return The UTC minutes 0-59 - */ - utcMinute(): number; - /** - * @return The UTC seconds 0-59 - */ - utcSecond(): number; - /** - * Returns the UTC day number within the year: Jan 1st has number 0, - * Jan 2nd has number 1 etc. - * - * @return the day-of-year [0-366] - */ - utcDayOfYear(): number; - /** - * @return The UTC milliseconds 0-999 - */ - utcMillisecond(): number; - /** - * @return the UTC day-of-week (the enum values correspond to JavaScript - * week day numbers) - */ - utcWeekDay(): WeekDay; - /** - * The ISO 8601 UTC week number. Week 1 is the week - * that has January 4th in it, and it starts on Monday. - * See https://en.wikipedia.org/wiki/ISO_week_date - * - * @return Week number [1-53] - */ - utcWeekNumber(): number; - /** - * The week of this month. There is no official standard for this, - * but we assume the same rules for the weekNumber (i.e. - * week 1 is the week that has the 4th day of the month in it) - * - * @return Week number [1-5] - */ - utcWeekOfMonth(): number; - /** - * Returns the number of seconds that have passed on the current day - * Does not consider leap seconds - * - * @return seconds [0-86399] - */ - utcSecondOfDay(): number; - /** - * Convert this date to the given time zone (in-place). - * Throws if this date does not have a time zone. - * @return this (for chaining) - */ - convert(zone?: TimeZone): DateTime; - /** - * Returns this date converted to the given time zone. - * Unaware dates can only be converted to unaware dates (clone) - * Converting an unaware date to an aware date throws an exception. Use the constructor - * if you really need to do that. - * - * @param zone The new time zone. This may be null to create unaware date. - * @return The converted date - */ - toZone(zone?: TimeZone): DateTime; - /** - * Convert to JavaScript date with the zone time in the getX() methods. - * Unless the timezone is local, the Date.getUTCX() methods will NOT be correct. - * This is because Date calculates getUTCX() from getX() applying local time zone. - */ - toDate(): Date; - /** - * Add a time duration relative to UTC. - * @return this + duration - */ - add(duration: Duration): DateTime; - /** - * Add an amount of time relative to UTC, as regularly as possible. - * - * Adding e.g. 1 hour will increment the utcHour() field, adding 1 month - * increments the utcMonth() field. - * Adding an amount of units leaves lower units intact. E.g. - * adding a month will leave the day() field untouched if possible. - * - * Note adding Months or Years will clamp the date to the end-of-month if - * the start date was at the end of a month, i.e. contrary to JavaScript - * Date#setUTCMonth() it will not overflow into the next month - * - * In case of DST changes, the utc time fields are still untouched but local - * time fields may shift. - */ - add(amount: number, unit: TimeUnit): DateTime; - /** - * Add an amount of time to the zone time, as regularly as possible. - * - * Adding e.g. 1 hour will increment the hour() field of the zone - * date by one. In case of DST changes, the time fields may additionally - * increase by the DST offset, if a non-existing local time would - * be reached otherwise. - * - * Adding a unit of time will leave lower-unit fields intact, unless the result - * would be a non-existing time. Then an extra DST offset is added. - * - * Note adding Months or Years will clamp the date to the end-of-month if - * the start date was at the end of a month, i.e. contrary to JavaScript - * Date#setUTCMonth() it will not overflow into the next month - */ - addLocal(duration: Duration): DateTime; - addLocal(amount: number, unit: TimeUnit): DateTime; - /** - * Same as add(-1*duration); - */ - sub(duration: Duration): DateTime; - /** - * Same as add(-1*amount, unit); - */ - sub(amount: number, unit: TimeUnit): DateTime; - /** - * Same as addLocal(-1*amount, unit); - */ - subLocal(duration: Duration): DateTime; - subLocal(amount: number, unit: TimeUnit): DateTime; - /** - * Time difference between two DateTimes - * @return this - other - */ - diff(other: DateTime): Duration; - /** - * Chops off the time part, yields the same date at 00:00:00.000 - * @return a new DateTime - */ - startOfDay(): DateTime; - /** - * @return True iff (this < other) - */ - lessThan(other: DateTime): boolean; - /** - * @return True iff (this <= other) - */ - lessEqual(other: DateTime): boolean; - /** - * @return True iff this and other represent the same moment in time in UTC - */ - equals(other: DateTime): boolean; - /** - * @return True iff this and other represent the same time and the same zone - */ - identical(other: DateTime): boolean; - /** - * @return True iff this > other - */ - greaterThan(other: DateTime): boolean; - /** - * @return True iff this >= other - */ - greaterEqual(other: DateTime): boolean; - /** - * @return The minimum of this and other - */ - min(other: DateTime): DateTime; - /** - * @return The maximum of this and other - */ - max(other: DateTime): DateTime; - /** - * Proper ISO 8601 format string with any IANA zone converted to ISO offset - * E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam - */ - toIsoString(): string; - /** - * Return a string representation of the DateTime according to the - * specified format. The format is implemented as the LDML standard - * (http://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns) - * - * @param formatString The format specification (e.g. "dd/MM/yyyy HH:mm:ss") - * @return The string representation of this DateTime - */ - format(formatString: string): string; - /** - * Modified ISO 8601 format string with IANA name if applicable. - * E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam" - */ - toString(): string; - /** - * Used by util.inspect() - */ - inspect(): string; - /** - * The valueOf() method returns the primitive value of the specified object. - */ - valueOf(): any; - /** - * Modified ISO 8601 format string in UTC without time zone info - */ - toUtcString(): string; - } -} - -declare module '__timezonecomplete/duration' { - import basics = require("__timezonecomplete/basics"); - import TimeUnit = basics.TimeUnit; - /** - * Construct a time duration - * @param n Number of years (may be fractional or negative) - * @return A duration of n years - */ - export function years(n: number): Duration; - /** - * Construct a time duration - * @param n Number of months (may be fractional or negative) - * @return A duration of n months - */ - export function months(n: number): Duration; - /** - * Construct a time duration - * @param n Number of days (may be fractional or negative) - * @return A duration of n days - */ - export function days(n: number): Duration; - /** - * Construct a time duration - * @param n Number of hours (may be fractional or negative) - * @return A duration of n hours - */ - export function hours(n: number): Duration; - /** - * Construct a time duration - * @param n Number of minutes (may be fractional or negative) - * @return A duration of n minutes - */ - export function minutes(n: number): Duration; - /** - * Construct a time duration - * @param n Number of seconds (may be fractional or negative) - * @return A duration of n seconds - */ - export function seconds(n: number): Duration; - /** - * Construct a time duration - * @param n Number of milliseconds (may be fractional or negative) - * @return A duration of n milliseconds - */ - export function milliseconds(n: number): Duration; - /** - * Time duration which is represented as an amount and a unit e.g. - * '1 Month' or '166 Seconds'. The unit is preserved through calculations. - * - * It has two sets of getter functions: - * - second(), minute(), hour() etc, singular form: these can be used to create string representations. - * These return a part of your string representation. E.g. for 2500 milliseconds, the millisecond() part would be 500 - * - seconds(), minutes(), hours() etc, plural form: these return the total amount represented in the corresponding unit. - */ - export class Duration { - /** - * Construct a time duration - * @param n Number of years (may be fractional or negative) - * @return A duration of n years - */ - static years(n: number): Duration; - /** - * Construct a time duration - * @param n Number of months (may be fractional or negative) - * @return A duration of n months - */ - static months(n: number): Duration; - /** - * Construct a time duration - * @param n Number of days (may be fractional or negative) - * @return A duration of n days - */ - static days(n: number): Duration; - /** - * Construct a time duration - * @param n Number of hours (may be fractional or negative) - * @return A duration of n hours - */ - static hours(n: number): Duration; - /** - * Construct a time duration - * @param n Number of minutes (may be fractional or negative) - * @return A duration of n minutes - */ - static minutes(n: number): Duration; - /** - * Construct a time duration - * @param n Number of seconds (may be fractional or negative) - * @return A duration of n seconds - */ - static seconds(n: number): Duration; - /** - * Construct a time duration - * @param n Number of milliseconds (may be fractional or negative) - * @return A duration of n milliseconds - */ - static milliseconds(n: number): Duration; - /** - * Construct a time duration of 0 - */ - constructor(); - /** - * Construct a time duration from a string in one of two formats: - * 1) [-]hhhh[:mm[:ss[.nnn]]] e.g. '-01:00:30.501' - * 2) amount and unit e.g. '-1 days' or '1 year'. The unit may be in singular or plural form and is case-insensitive - */ - constructor(input: string); - /** - * Construct a duration from an amount and a time unit. - * @param amount Number of units - * @param unit A time unit i.e. TimeUnit.Second, TimeUnit.Hour etc. Default Millisecond. - */ - constructor(amount: number, unit?: TimeUnit); - /** - * @return another instance of Duration with the same value. - */ - clone(): Duration; - /** - * Returns this duration expressed in different unit (positive or negative, fractional). - * This is precise for Year <-> Month and for time-to-time conversion (i.e. Hour-or-less to Hour-or-less). - * It is approximate for any other conversion - */ - as(unit: TimeUnit): number; - /** - * Convert this duration to a Duration in another unit. You always get a clone even if you specify - * the same unit. - * This is precise for Year <-> Month and for time-to-time conversion (i.e. Hour-or-less to Hour-or-less). - * It is approximate for any other conversion - */ - convert(unit: TimeUnit): Duration; - /** - * The entire duration in milliseconds (negative or positive) - * For Day/Month/Year durations, this is approximate! - */ - milliseconds(): number; - /** - * The millisecond part of the duration (always positive) - * For Day/Month/Year durations, this is approximate! - * @return e.g. 400 for a -01:02:03.400 duration - */ - millisecond(): number; - /** - * The entire duration in seconds (negative or positive, fractional) - * For Day/Month/Year durations, this is approximate! - * @return e.g. 1.5 for a 1500 milliseconds duration - */ - seconds(): number; - /** - * The second part of the duration (always positive) - * For Day/Month/Year durations, this is approximate! - * @return e.g. 3 for a -01:02:03.400 duration - */ - second(): number; - /** - * The entire duration in minutes (negative or positive, fractional) - * For Day/Month/Year durations, this is approximate! - * @return e.g. 1.5 for a 90000 milliseconds duration - */ - minutes(): number; - /** - * The minute part of the duration (always positive) - * For Day/Month/Year durations, this is approximate! - * @return e.g. 2 for a -01:02:03.400 duration - */ - minute(): number; - /** - * The entire duration in hours (negative or positive, fractional) - * For Day/Month/Year durations, this is approximate! - * @return e.g. 1.5 for a 5400000 milliseconds duration - */ - hours(): number; - /** - * The hour part of a duration. This assumes that a day has 24 hours (which is not the case - * during DST changes). - */ - hour(): number; - /** - * DEPRECATED - * The hour part of the duration (always positive). - * Note that this part can exceed 23 hours, because for - * now, we do not have a days() function - * For Day/Month/Year durations, this is approximate! - * @return e.g. 25 for a -25:02:03.400 duration - */ - wholeHours(): number; - /** - * The entire duration in days (negative or positive, fractional) - * This is approximate if this duration is not in days! - */ - days(): number; - /** - * The day part of a duration. This assumes that a month has 30 days. - */ - day(): number; - /** - * The entire duration in days (negative or positive, fractional) - * This is approximate if this duration is not in Months or Years! - */ - months(): number; - /** - * The month part of a duration. - */ - month(): number; - /** - * The entire duration in years (negative or positive, fractional) - * This is approximate if this duration is not in Months or Years! - */ - years(): number; - /** - * Non-fractional positive years - */ - wholeYears(): number; - /** - * Amount of units (positive or negative, fractional) - */ - amount(): number; - /** - * The unit this duration was created with - */ - unit(): TimeUnit; - /** - * Sign - * @return "-" if the duration is negative - */ - sign(): string; - /** - * Approximate if the durations have units that cannot be converted - * @return True iff (this < other) - */ - lessThan(other: Duration): boolean; - /** - * Approximate if the durations have units that cannot be converted - * @return True iff (this <= other) - */ - lessEqual(other: Duration): boolean; - /** - * Similar but not identical - * Approximate if the durations have units that cannot be converted - * @return True iff this and other represent the same time duration - */ - equals(other: Duration): boolean; - /** - * Similar but not identical - * Returns false if we cannot determine whether they are equal in all time zones - * so e.g. 60 minutes equals 1 hour, but 24 hours do NOT equal 1 day - * - * @return True iff this and other represent the same time duration - */ - equalsExact(other: Duration): boolean; - /** - * Same unit and same amount - */ - identical(other: Duration): boolean; - /** - * Approximate if the durations have units that cannot be converted - * @return True iff this > other - */ - greaterThan(other: Duration): boolean; - /** - * Approximate if the durations have units that cannot be converted - * @return True iff this >= other - */ - greaterEqual(other: Duration): boolean; - /** - * Approximate if the durations have units that cannot be converted - * @return The minimum (most negative) of this and other - */ - min(other: Duration): Duration; - /** - * Approximate if the durations have units that cannot be converted - * @return The maximum (most positive) of this and other - */ - max(other: Duration): Duration; - /** - * Approximate if the durations have units that cannot be converted - * Multiply with a fixed number. - * @return a new Duration of (this * value) - */ - multiply(value: number): Duration; - /** - * Approximate if the durations have units that cannot be converted - * Divide by a fixed number. - * @return a new Duration of (this / value) - */ - divide(value: number): Duration; - /** - * Add a duration. - * @return a new Duration of (this + value) with the unit of this duration - */ - add(value: Duration): Duration; - /** - * Subtract a duration. - * @return a new Duration of (this - value) with the unit of this duration - */ - sub(value: Duration): Duration; - /** - * Return the absolute value of the duration i.e. remove the sign. - */ - abs(): Duration; - /** - * DEPRECATED - * String in [-]hhhh:mm:ss.nnn notation. All fields are - * always present except the sign. - */ - toFullString(): string; - /** - * String in [-]hhhh:mm[:ss[.nnn]] notation. - * @param full If true, then all fields are always present except the sign. Otherwise, seconds and milliseconds - * are chopped off if zero - */ - toHmsString(full?: boolean): string; - /** - * String in ISO 8601 notation e.g. 'P1M' for one month or 'PT1M' for one minute - */ - toIsoString(): string; - /** - * String representation with amount and unit e.g. '1.5 years' or '-1 day' - */ - toString(): string; - /** - * Used by util.inspect() - */ - inspect(): string; - /** - * The valueOf() method returns the primitive value of the specified object. - */ - valueOf(): any; - } -} - -declare module '__timezonecomplete/javascript' { - /** - * Indicates how a Date object should be interpreted. - * Either we can take getYear(), getMonth() etc for our field - * values, or we can take getUTCYear(), getUtcMonth() etc to do that. - */ - export enum DateFunctions { - /** - * Use the Date.getFullYear(), Date.getMonth(), ... functions. - */ - Get = 0, - /** - * Use the Date.getUTCFullYear(), Date.getUTCMonth(), ... functions. - */ - GetUTC = 1, - } -} - -declare module '__timezonecomplete/period' { - import basics = require("__timezonecomplete/basics"); - import TimeUnit = basics.TimeUnit; - import duration = require("__timezonecomplete/duration"); - import Duration = duration.Duration; - import datetime = require("__timezonecomplete/datetime"); - import DateTime = datetime.DateTime; - /** - * Specifies how the period should repeat across the day - * during DST changes. - */ - export enum PeriodDst { - /** - * Keep repeating in similar intervals measured in UTC, - * unaffected by Daylight Saving Time. - * E.g. a repetition of one hour will take one real hour - * every time, even in a time zone with DST. - * Leap seconds, leap days and month length - * differences will still make the intervals different. - */ - RegularIntervals = 0, - /** - * Ensure that the time at which the intervals occur stay - * at the same place in the day, local time. So e.g. - * a period of one day, starting at 8:05AM Europe/Amsterdam time - * will always start at 8:05 Europe/Amsterdam. This means that - * in UTC time, some intervals will be 25 hours and some - * 23 hours during DST changes. - * Another example: an hourly interval will be hourly in local time, - * skipping an hour in UTC for a DST backward change. - */ - RegularLocalTime = 1, - /** - * End-of-enum marker - */ - MAX = 2, - } - /** - * Convert a PeriodDst to a string: "regular intervals" or "regular local time" - */ - export function periodDstToString(p: PeriodDst): string; - /** - * Repeating time period: consists of a starting point and - * a time length. This class accounts for leap seconds and leap days. - */ - export class Period { - /** - * Constructor - * LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour, - * then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not. - * This is due to the enormous processing power required by these cases. They are not - * implemented and you will get an assert. - * - * @param start The start of the period. If the period is in Months or Years, and - * the day is 29 or 30 or 31, the results are maximised to end-of-month. - * @param interval The interval of the period - * @param dst Specifies how to handle Daylight Saving Time. Not relevant - * if the time zone of the start datetime does not have DST. - * Defaults to RegularLocalTime. - */ - constructor(start: DateTime, interval: Duration, dst?: PeriodDst); - /** - * Constructor - * LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour, - * then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not. - * This is due to the enormous processing power required by these cases. They are not - * implemented and you will get an assert. - * - * @param start The start of the period. If the period is in Months or Years, and - * the day is 29 or 30 or 31, the results are maximised to end-of-month. - * @param amount The amount of units. - * @param unit The unit. - * @param dst Specifies how to handle Daylight Saving Time. Not relevant - * if the time zone of the start datetime does not have DST. - * Defaults to RegularLocalTime. - */ - constructor(start: DateTime, amount: number, unit: TimeUnit, dst?: PeriodDst); - /** - * The start date - */ - start(): DateTime; - /** - * The interval - */ - interval(): Duration; - /** - * DEPRECATED - * The amount of units of the interval - */ - amount(): number; - /** - * DEPRECATED - * The unit of the interval - */ - unit(): TimeUnit; - /** - * The dst handling mode - */ - dst(): PeriodDst; - /** - * The first occurrence of the period greater than - * the given date. The given date need not be at a period boundary. - * Pre: the fromdate and startdate must either both have timezones or not - * @param fromDate: the date after which to return the next date - * @return the first date matching the period after fromDate, given - * in the same zone as the fromDate. - */ - findFirst(fromDate: DateTime): DateTime; - /** - * Returns the next timestamp in the period. The given timestamp must - * be at a period boundary, otherwise the answer is incorrect. - * This function has MUCH better performance than findFirst. - * Returns the datetime "count" times away from the given datetime. - * @param prev Boundary date. Must have a time zone (any time zone) iff the period start date has one. - * @param count Optional, must be >= 1 and whole. - * @return (prev + count * period), in the same timezone as prev. - */ - findNext(prev: DateTime, count?: number): DateTime; - /** - * Checks whether the given date is on a period boundary - * (expensive!) - */ - isBoundary(occurrence: DateTime): boolean; - /** - * Returns true iff this period has the same effect as the given one. - * i.e. a period of 24 hours is equal to one of 1 day if they have the same UTC start moment - * and same dst. - */ - equals(other: Period): boolean; - /** - * Returns true iff this period was constructed with identical arguments to the other one. - */ - identical(other: Period): boolean; - /** - * Returns an ISO duration string e.g. - * 2014-01-01T12:00:00.000+01:00/P1H - * 2014-01-01T12:00:00.000+01:00/PT1M (one minute) - * 2014-01-01T12:00:00.000+01:00/P1M (one month) - */ - toIsoString(): string; - /** - * A string representation e.g. - * "10 years, starting at 2014-03-01T12:00:00 Europe/Amsterdam, keeping regular intervals". - */ - toString(): string; - /** - * Used by util.inspect() - */ - inspect(): string; - } -} - -declare module '__timezonecomplete/timesource' { - /** - * For testing purposes, we often need to manipulate what the current - * time is. This is an interface for a custom time source object - * so in tests you can use a custom time source. - */ - export interface TimeSource { - /** - * Return the current date+time as a javascript Date object - */ - now(): Date; - } - /** - * Default time source, returns actual time - */ - export class RealTimeSource implements TimeSource { - now(): Date; - } -} - -declare module '__timezonecomplete/timezone' { - import javascript = require("__timezonecomplete/javascript"); - import DateFunctions = javascript.DateFunctions; - /** - * The local time zone for a given date as per OS settings. Note that time zones are cached - * so you don't necessarily get a new object each time. - */ - export function local(): TimeZone; - /** - * Coordinated Universal Time zone. Note that time zones are cached - * so you don't necessarily get a new object each time. - */ - export function utc(): TimeZone; - /** - * @param offset offset w.r.t. UTC in minutes, e.g. 90 for +01:30. Note that time zones are cached - * so you don't necessarily get a new object each time. - * @returns a time zone with the given fixed offset - */ - export function zone(offset: number): TimeZone; - /** - * Time zone for an offset string or an IANA time zone string. Note that time zones are cached - * so you don't necessarily get a new object each time. - * @param s Empty string for no time zone (null is returned), - * "localtime" for local time, - * a TZ database time zone name (e.g. Europe/Amsterdam), - * or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see: - * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones - * @param dst Optional, default true: adhere to Daylight Saving Time if applicable. Note for - * "localtime", timezonecomplete will adhere to the computer settings, the DST flag - * does not have any effect. - */ - export function zone(name: string, dst?: boolean): TimeZone; - /** - * The type of time zone - */ - export enum TimeZoneKind { - /** - * Local time offset as determined by JavaScript Date class. - */ - Local = 0, - /** - * Fixed offset from UTC, without DST. - */ - Offset = 1, - /** - * IANA timezone managed through Olsen TZ database. Includes - * DST if applicable. - */ - Proper = 2, - } - /** - * Option for TimeZone#normalizeLocal() - */ - export enum NormalizeOption { - /** - * Normalize non-existing times by ADDING the DST offset - */ - Up = 0, - /** - * Normalize non-existing times by SUBTRACTING the DST offset - */ - Down = 1, - } - /** - * Time zone. The object is immutable because it is cached: - * requesting a time zone twice yields the very same object. - * Note that we use time zone offsets inverted w.r.t. JavaScript Date.getTimezoneOffset(), - * i.e. offset 90 means +01:30. - * - * Time zones come in three flavors: the local time zone, as calculated by JavaScript Date, - * a fixed offset ("+01:30") without DST, or a IANA timezone ("Europe/Amsterdam") with DST - * applied depending on the time zone rules. - */ - export class TimeZone { - /** - * The local time zone for a given date. Note that - * the time zone varies with the date: amsterdam time for - * 2014-01-01 is +01:00 and amsterdam time for 2014-07-01 is +02:00 - */ - static local(): TimeZone; - /** - * The UTC time zone. - */ - static utc(): TimeZone; - /** - * Time zone with a fixed offset - * @param offset offset w.r.t. UTC in minutes, e.g. 90 for +01:30 - */ - static zone(offset: number): TimeZone; - /** - * Time zone for an offset string or an IANA time zone string. Note that time zones are cached - * so you don't necessarily get a new object each time. - * @param s Empty string for no time zone (null is returned), - * "localtime" for local time, - * a TZ database time zone name (e.g. Europe/Amsterdam), - * or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see: - * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones - * TZ database zone name may be suffixed with " without DST" to indicate no DST should be applied. - * In that case, the dst parameter is ignored. - * @param dst Optional, default true: adhere to Daylight Saving Time if applicable. Note for - * "localtime", timezonecomplete will adhere to the computer settings, the DST flag - * does not have any effect. - */ - static zone(s: string, dst?: boolean): TimeZone; - /** - * Do not use this constructor, use the static - * TimeZone.zone() method instead. - * @param name NORMALIZED name, assumed to be correct - * @param dst Adhere to Daylight Saving Time if applicable, ignored for local time and fixed offsets - */ - constructor(name: string, dst?: boolean); - /** - * The time zone identifier. Can be an offset "-01:30" or an - * IANA time zone name "Europe/Amsterdam", or "localtime" for - * the local time zone. - */ - name(): string; - dst(): boolean; - /** - * The kind of time zone (Local/Offset/Proper) - */ - kind(): TimeZoneKind; - /** - * Equality operator. Maps zero offsets and different names for UTC onto - * each other. Other time zones are not mapped onto each other. - */ - equals(other: TimeZone): boolean; - /** - * Returns true iff the constructor arguments were identical, so UTC !== GMT - */ - identical(other: TimeZone): boolean; - /** - * Is this zone equivalent to UTC? - */ - isUtc(): boolean; - /** - * Does this zone have Daylight Saving Time at all? - */ - hasDst(): boolean; - /** - * Calculate timezone offset from a UTC time. - * - * @param year Full year - * @param month Month 1-12 (note this deviates from JavaScript date) - * @param day Day of month 1-31 - * @param hour Hour 0-23 - * @param minute Minute 0-59 - * @param second Second 0-59 - * @param millisecond Millisecond 0-999 - * - * @return the offset of this time zone with respect to UTC at the given time, in minutes. - */ - offsetForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; - /** - * Calculate timezone offset from a zone-local time (NOT a UTC time). - * @param year local full year - * @param month local month 1-12 (note this deviates from JavaScript date) - * @param day local day of month 1-31 - * @param hour local hour 0-23 - * @param minute local minute 0-59 - * @param second local second 0-59 - * @param millisecond local millisecond 0-999 - * @return the offset of this time zone with respect to UTC at the given time, in minutes. - */ - offsetForZone(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; - /** - * Note: will be removed in version 2.0.0 - * - * Convenience function, takes values from a Javascript Date - * Calls offsetForUtc() with the contents of the date - * - * @param date: the date - * @param funcs: the set of functions to use: get() or getUTC() - */ - offsetForUtcDate(date: Date, funcs: DateFunctions): number; - /** - * Note: will be removed in version 2.0.0 - * - * Convenience function, takes values from a Javascript Date - * Calls offsetForUtc() with the contents of the date - * - * @param date: the date - * @param funcs: the set of functions to use: get() or getUTC() - */ - offsetForZoneDate(date: Date, funcs: DateFunctions): number; - /** - * Zone abbreviation at given UTC timestamp e.g. CEST for Central European Summer Time. - * - * @param year Full year - * @param month Month 1-12 (note this deviates from JavaScript date) - * @param day Day of month 1-31 - * @param hour Hour 0-23 - * @param minute Minute 0-59 - * @param second Second 0-59 - * @param millisecond Millisecond 0-999 - * @param dstDependent (default true) set to false for a DST-agnostic abbreviation - * - * @return "local" for local timezone, the offset for an offset zone, or the abbreviation for a proper zone. - */ - abbreviationForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, dstDependent?: boolean): string; - /** - * Normalizes non-existing local times by adding a forward offset change. - * During a forward standard offset change or DST offset change, some amount of - * local time is skipped. Therefore, this amount of local time does not exist. - * This function adds the amount of forward change to any non-existing time. After all, - * this is probably what the user meant. - * - * @param localUnixMillis Unix timestamp in zone time - * @param opt (optional) Round up or down? Default: up - * - * @returns Unix timestamp in zone time, normalized. - */ - normalizeZoneTime(localUnixMillis: number, opt?: NormalizeOption): number; - /** - * The time zone identifier (normalized). - * Either "localtime", IANA name, or "+hh:mm" offset. - */ - toString(): string; - /** - * Used by util.inspect() - */ - inspect(): string; - /** - * Convert an offset number into an offset string - * @param offset The offset in minutes from UTC e.g. 90 minutes - * @return the offset in ISO notation "+01:30" for +90 minutes - */ - static offsetToString(offset: number): string; - /** - * String to offset conversion. - * @param s Formats: "-01:00", "-0100", "-01", "Z" - * @return offset w.r.t. UTC in minutes - */ - static stringToOffset(s: string): number; - } -} - -declare module '__timezonecomplete/globals' { - import datetime = require("__timezonecomplete/datetime"); - import DateTime = datetime.DateTime; - import duration = require("__timezonecomplete/duration"); - import Duration = duration.Duration; - /** - * Returns the minimum of two DateTimes - */ - export function min(d1: DateTime, d2: DateTime): DateTime; - /** - * Returns the minimum of two Durations - */ - export function min(d1: Duration, d2: Duration): Duration; - /** - * Returns the maximum of two DateTimes - */ - export function max(d1: DateTime, d2: DateTime): DateTime; - /** - * Returns the maximum of two Durations - */ - export function max(d1: Duration, d2: Duration): Duration; - /** - * Returns the absolute value of a Duration - */ - export function abs(d: Duration): Duration; -} diff --git a/types/timezonecomplete/timezonecomplete-tests.ts b/types/timezonecomplete/timezonecomplete-tests.ts deleted file mode 100644 index 8c6d14cad7..0000000000 --- a/types/timezonecomplete/timezonecomplete-tests.ts +++ /dev/null @@ -1,234 +0,0 @@ - - -import tc = require("timezonecomplete"); - -var b: boolean; -var n: number; -var s: string; -var w: tc.WeekDay; - -n = tc.timeUnitToMilliseconds(tc.TimeUnit.Month); -b = tc.isLeapYear(2014); -n = tc.daysInMonth(2014, 10); -n = tc.daysInYear(2014); -n = tc.dayOfYear(2014, 1, 2); -w = tc.firstWeekDayOfMonth(2014, 1, tc.WeekDay.Sunday); -w = tc.lastWeekDayOfMonth(2014, 1, tc.WeekDay.Sunday); -n = tc.weekDayOnOrAfter(2014, 1, 14, tc.WeekDay.Monday); -n = tc.weekDayOnOrBefore(2014, 1, 14, tc.WeekDay.Monday); -n = tc.secondOfDay(13, 59, 59); -n = tc.weekOfMonth(2014, 1, 1); - -s = tc.timeUnitToString(tc.TimeUnit.Second); -var tu: tc.TimeUnit = tc.stringToTimeUnit("bla"); - -// DURATION - -var d: tc.Duration; -var d1: tc.Duration = tc.Duration.hours(24); -var d2: tc.Duration = tc.Duration.minutes(24); -var d3: tc.Duration = tc.Duration.seconds(24); -var d4: tc.Duration = tc.Duration.milliseconds(24); -var d5: tc.Duration = tc.hours(24); -var d6: tc.Duration = tc.minutes(24); -var d7: tc.Duration = tc.seconds(24); -var d8: tc.Duration = tc.milliseconds(24); -var d9: tc.Duration = new tc.Duration(24); -var d10: tc.Duration = new tc.Duration("00:01"); -var d11: tc.Duration = d6.clone(); -var d12: tc.Duration = new tc.Duration(4, tc.TimeUnit.Second); - -n = d7.wholeHours(); -n = d7.hours(); -n = d7.minutes(); -n = d7.minute(); -n = d7.seconds(); -n = d7.second(); -n = d7.milliseconds(); -n = d7.millisecond(); -s = d7.sign(); -b = d7.lessThan(d6); -b = d7.greaterThan(d6); -d = d7.min(d6); -d = d7.max(d6); -d = d7.multiply(3); -d = d7.divide(0.3); -d = d7.add(d6); -d = d7.sub(d6); -s = d7.toString(); - -b = d7.equals(d6); -b = d7.equalsExact(d6); -b = d7.identical(d6); - -// TIMEZONE - -var t: tc.TimeZone; -var k: tc.TimeZoneKind; - -t = tc.TimeZone.local(); -t = tc.TimeZone.utc(); -t = tc.TimeZone.zone(2); -t = tc.TimeZone.zone("+01:00"); -t = tc.local(); -t = tc.utc(); -t = tc.zone(2); -t = tc.zone("+01:00"); -t = tc.zone("Europe/Amsterdam", false); -s = t.name(); -k = t.kind(); -b = t.equals(t); -b = t.isUtc(); -b = t.dst(); -n = t.offsetForUtc(2014, 1, 1, 13, 0, 5, 123); -n = t.offsetForZone(2014, 1, 1, 13, 0, 5, 123); -n = t.offsetForUtcDate(new Date(2014, 1, 1, 13, 0, 5, 123), tc.DateFunctions.Get); -n = t.offsetForZoneDate(new Date(2014, 1, 1, 13, 0, 5, 123), tc.DateFunctions.GetUTC); -s = t.toString(); -s = tc.TimeZone.offsetToString(2); -n = tc.TimeZone.stringToOffset("+00:01"); -b = t.equals(t); -b = t.identical(t); - -// REALTIMESOURCE - -var date: Date = (new tc.RealTimeSource()).now(); - -// DATETIME - -var dt: tc.DateTime; - -var ts: tc.TimeSource = tc.DateTime.timeSource; - -dt = tc.DateTime.nowLocal(); -dt = tc.DateTime.nowUtc(); -dt = tc.DateTime.now(tc.TimeZone.local()); -dt = tc.DateTime.fromExcel(1.5); -dt = tc.nowLocal(); -dt = tc.nowUtc(); -dt = tc.now(tc.TimeZone.local()); -dt = new tc.DateTime(); -dt = new tc.DateTime("2014-01-01T13:05:01.123 UTC"); -dt = new tc.DateTime("2014-01-01T13:05:01.123", tc.TimeZone.utc()); -dt = new tc.DateTime(date, tc.DateFunctions.Get); -dt = new tc.DateTime(date, tc.DateFunctions.Get, tc.TimeZone.utc()); -dt = new tc.DateTime(2014, 1, 1, 13, 5, 1, 123); -dt = new tc.DateTime(2014, 1, 1, 13, 5, 1, 123, tc.TimeZone.utc()); -dt = new tc.DateTime(89949284); -dt = new tc.DateTime(89949284, tc.TimeZone.utc()); -dt = dt.clone(); -t = dt.zone(); -n = dt.offset(); -n = dt.year(); -n = dt.month(); -n = dt.day(); -n = dt.hour(); -n = dt.minute(); -n = dt.second(); -n = dt.weekNumber(); -n = dt.weekOfMonth(); -n = dt.secondOfDay(); -n = dt.dayOfYear(); -n = dt.millisecond(); -n = dt.unixUtcMillis(); -n = dt.utcYear(); -n = dt.utcMonth(); -n = dt.utcDay(); -n = dt.utcHour(); -n = dt.utcMinute(); -n = dt.utcSecond(); -n = dt.utcMillisecond(); -n = dt.utcWeekNumber(); -n = dt.utcWeekOfMonth(); -n = dt.utcSecondOfDay(); -n = dt.utcDayOfYear(); -s = dt.format("%Y-%m-%d"); -dt.convert(tc.TimeZone.local()); -dt = dt.toZone(tc.TimeZone.utc()); -date = dt.toDate(); -dt = dt.add(tc.Duration.seconds(2)); -dt = dt.add(2, tc.TimeUnit.Year); -dt = dt.add(2, tc.TimeUnit.Month); -dt = dt.add(2, tc.TimeUnit.Week); -dt = dt.add(2, tc.TimeUnit.Day); -dt = dt.add(2, tc.TimeUnit.Hour); -dt = dt.add(2, tc.TimeUnit.Minute); -dt = dt.add(2, tc.TimeUnit.Second); -dt = dt.addLocal(2, tc.TimeUnit.Second); -dt = dt.addLocal(tc.minutes(2)); -dt = dt.sub(tc.Duration.seconds(2)); -dt = dt.sub(2, tc.TimeUnit.Year); -dt = dt.sub(2, tc.TimeUnit.Month); -dt = dt.sub(2, tc.TimeUnit.Week); -dt = dt.sub(2, tc.TimeUnit.Day); -dt = dt.sub(2, tc.TimeUnit.Hour); -dt = dt.sub(2, tc.TimeUnit.Minute); -dt = dt.sub(2, tc.TimeUnit.Second); -dt = dt.subLocal(2, tc.TimeUnit.Second); -dt = dt.subLocal(tc.minutes(2)); -d = dt.diff(new tc.DateTime(9289234, tc.TimeZone.local())); -b = dt.lessThan(new tc.DateTime(9289234, tc.TimeZone.local())); -b = dt.lessEqual(new tc.DateTime(9289234, tc.TimeZone.local())); -b = dt.greaterThan(new tc.DateTime(9289234, tc.TimeZone.local())); -b = dt.greaterEqual(new tc.DateTime(9289234, tc.TimeZone.local())); -dt = dt.min(new tc.DateTime(9289234, tc.TimeZone.local())); -dt = dt.max(new tc.DateTime(9289234, tc.TimeZone.local())); -s = dt.toIsoString(); -s = dt.toString(); -s = dt.toUtcString(); -dt = dt.startOfDay(); - -var wd: tc.WeekDay; -wd = dt.weekDay(); -wd = dt.utcWeekDay(); - -// PERIOD - -s = tc.periodDstToString(tc.PeriodDst.RegularIntervals); -s = tc.periodDstToString(tc.PeriodDst.RegularLocalTime); - -var p: tc.Period; - -p = new tc.Period(tc.DateTime.nowLocal(), 1, tc.TimeUnit.Hour, tc.PeriodDst.RegularLocalTime); -p = new tc.Period(tc.DateTime.nowLocal(), tc.hours(1), tc.PeriodDst.RegularLocalTime); -dt = p.start(); -n = p.amount(); -var tu: tc.TimeUnit = p.unit(); -var pd: tc.PeriodDst = p.dst(); -dt = p.findFirst(tc.DateTime.nowLocal()); -dt = p.findNext(dt); -s = p.toIsoString(); -s = p.toString(); -b = p.isBoundary(dt); -b = p.equals(p); -b = p.identical(p); - - -// GLOBALS -d = tc.min(tc.Duration.seconds(2), tc.Duration.seconds(3)); -d = tc.max(tc.Duration.seconds(2), tc.Duration.seconds(3)); - -dt = tc.min(new tc.DateTime(2), new tc.DateTime(3)); -dt = tc.max(new tc.DateTime(2), new tc.DateTime(3)); - - - - - - - - - - - - - - - - - - - - - - diff --git a/types/timezonecomplete/tsconfig.json b/types/timezonecomplete/tsconfig.json deleted file mode 100644 index 57312fb0fe..0000000000 --- a/types/timezonecomplete/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "timezonecomplete-tests.ts" - ] -} \ No newline at end of file diff --git a/types/timezonecomplete/tslint.json b/types/timezonecomplete/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/timezonecomplete/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -}